diff --git a/doc/help_mla_usb.jar b/doc/help_mla_usb.jar deleted file mode 100644 index 8325082..0000000 Binary files a/doc/help_mla_usb.jar and /dev/null differ diff --git a/doc/help_mla_usb.pdf b/doc/help_mla_usb.pdf index fa9222e..5767043 100644 Binary files a/doc/help_mla_usb.pdf and b/doc/help_mla_usb.pdf differ diff --git a/inc/usb.h b/inc/usb.h index 3bbb105..e8e9a75 100644 --- a/inc/usb.h +++ b/inc/usb.h @@ -61,7 +61,7 @@ please contact mla_licensing@microchip.com specific version of the library is being used. */ #define USB_MAJOR_VER 2 // Firmware version, major release number. -#define USB_MINOR_VER 13 // Firmware version, minor release number. +#define USB_MINOR_VER 18 // Firmware version, minor release number. #define USB_DOT_VER 0 // Firmware version, dot release number. #endif // _USB_H_ diff --git a/inc/usb_ch9.h b/inc/usb_ch9.h index 8992bd2..78862f5 100644 --- a/inc/usb_ch9.h +++ b/inc/usb_ch9.h @@ -42,7 +42,9 @@ please contact mla_licensing@microchip.com #include #if defined(__XC8) - #define __attribute__(a) + #define PACKED +#else + #define PACKED __attribute__((packed)) #endif // ***************************************************************************** @@ -66,7 +68,7 @@ please contact mla_licensing@microchip.com This struct defines the structure of a USB Device Descriptor. */ -typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR +typedef struct PACKED _USB_DEVICE_DESCRIPTOR { uint8_t bLength; // Length of this descriptor. uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). @@ -90,7 +92,7 @@ typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR This struct defines the structure of a USB Configuration Descriptor. */ -typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR +typedef struct PACKED _USB_CONFIGURATION_DESCRIPTOR { uint8_t bLength; // Length of this descriptor. uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). @@ -113,7 +115,7 @@ typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR This struct defines the structure of a USB Interface Descriptor. */ -typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR +typedef struct PACKED _USB_INTERFACE_DESCRIPTOR { uint8_t bLength; // Length of this descriptor. uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). @@ -132,7 +134,7 @@ typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR This struct defines the structure of a USB Endpoint Descriptor. */ -typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR +typedef struct PACKED _USB_ENDPOINT_DESCRIPTOR { uint8_t bLength; // Length of this descriptor. uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). @@ -197,7 +199,7 @@ This struct defines the structure of a USB OTG Descriptor. Note that this structure may need to be packed, or even accessed as uint8_ts, to properly access the correct fields when used on some device architectures. */ -typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR +typedef struct PACKED _USB_OTG_DESCRIPTOR { uint8_t bLength; // Length of this descriptor. uint8_t bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG). @@ -221,7 +223,7 @@ typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR // array of unicode characters making up the string, must be allocated // immediately following this header with no padding between them. -typedef struct __attribute__ ((packed)) _USB_STRING_DSC +typedef struct PACKED _USB_STRING_DSC { uint8_t bLength; // Size of this descriptor uint8_t bDescriptorType; // Type, USB_DSC_STRING @@ -240,7 +242,7 @@ typedef struct __attribute__ ((packed)) _USB_STRING_DSC // If so, it may need to implement the the device qualifier and other // speed descriptors. -typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR +typedef struct PACKED _USB_DEVICE_QUALIFIER_DESCRIPTOR { uint8_t bLength; // Size of this descriptor uint8_t bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER @@ -263,10 +265,10 @@ typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR // // Note: Refer to the USB 2.0 specification for additional details on the // usage of the setup packet and standard device requests. -typedef union __attribute__ ((packed)) +typedef union PACKED { /** Standard Device Requests ***********************************/ - struct __attribute__ ((packed)) + struct PACKED { uint8_t bmRequestType; //from table 9-2 of USB2.0 spec uint8_t bRequest; //from table 9-2 of USB2.0 spec @@ -274,7 +276,7 @@ typedef union __attribute__ ((packed)) uint16_t wIndex; //from table 9-2 of USB2.0 spec uint16_t wLength; //from table 9-2 of USB2.0 spec }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; @@ -311,7 +313,7 @@ typedef union __attribute__ ((packed)) } byte; } W_Length; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned Recipient:5; //Device,Interface,Endpoint,Other unsigned RequestType:2; //Standard,Class,Vendor,Reserved @@ -324,7 +326,7 @@ typedef union __attribute__ ((packed)) unsigned :8; unsigned :8; }; - struct __attribute__ ((packed)) + struct PACKED { union // offset description { // ------ ------------------------ @@ -337,7 +339,7 @@ typedef union __attribute__ ((packed)) }; }requestInfo; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; @@ -347,7 +349,7 @@ typedef union __attribute__ ((packed)) unsigned :8; unsigned :8; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; @@ -358,7 +360,7 @@ typedef union __attribute__ ((packed)) unsigned :8; unsigned :8; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; @@ -369,7 +371,7 @@ typedef union __attribute__ ((packed)) unsigned :8; unsigned :8; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; @@ -380,7 +382,7 @@ typedef union __attribute__ ((packed)) unsigned :8; unsigned :8; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; @@ -391,7 +393,7 @@ typedef union __attribute__ ((packed)) unsigned :8; unsigned :8; }; - struct __attribute__ ((packed)) + struct PACKED { unsigned :8; unsigned :8; diff --git a/inc/usb_device.h b/inc/usb_device.h index 389e6e2..21cef27 100644 --- a/inc/usb_device.h +++ b/inc/usb_device.h @@ -44,7 +44,11 @@ please contact mla_licensing@microchip.com #include "usb_config.h" #if defined(__XC8) - #define __attribute__(a) + #define PACKED + #define ALIGNED +#else + #define PACKED __attribute__((packed)) + #define ALIGNED __attribute__((aligned)) #endif /** DEFINITIONS ****************************************************/ @@ -1987,9 +1991,9 @@ typedef union // Definition of the PIPE structure // This structure is used to keep track of data that is sent out // of the stack automatically. -typedef struct __attribute__ ((packed)) +typedef struct PACKED { - union __attribute__ ((packed)) + union PACKED { //Various options of pointers that are available to // get the data from @@ -1998,9 +2002,9 @@ typedef struct __attribute__ ((packed)) uint16_t *wRam; const uint16_t *wRom; }pSrc; - union __attribute__ ((packed)) + union PACKED { - struct __attribute__ ((packed)) + struct PACKED { //is this transfer from RAM or const? uint8_t ctrl_trf_mem :1; @@ -2013,23 +2017,23 @@ typedef struct __attribute__ ((packed)) }bits; uint8_t Val; }info; - uint16_t_VAL __attribute__((aligned)) wCount; + uint16_t_VAL ALIGNED wCount; }IN_PIPE; extern USB_VOLATILE IN_PIPE inPipes[]; -typedef struct __attribute__ ((packed)) +typedef struct PACKED { - union __attribute__ ((packed)) + union PACKED { //Various options of pointers that are available to // get the data from uint8_t *bRam; uint16_t *wRam; }pDst; - union __attribute__ ((packed)) + union PACKED { - struct __attribute__ ((packed)) + struct PACKED { uint8_t reserved :7; //is this PIPE currently in use @@ -2049,6 +2053,6 @@ extern USB_VOLATILE uint8_t USBTicksSinceSuspendEnd; /******************************************************************************/ /* DOM-IGNORE-END */ -#include +#include "usb_hal.h" #endif //USB_DEVICE_H diff --git a/inc/usb_device_cdc.h b/inc/usb_device_cdc.h index ff88aa9..71e2067 100644 --- a/inc/usb_device_cdc.h +++ b/inc/usb_device_cdc.h @@ -776,7 +776,7 @@ void putsUSBUSART(char *data); will be transferred to the host. **************************************************************************/ -void putrsUSBUSART(const const char *data); +void putrsUSBUSART(const char *data); /************************************************************************ Function: @@ -835,6 +835,11 @@ void CDCTxService(void); /* Line Coding Structure */ #define LINE_CODING_LENGTH 0x07 +#if defined(__XC8) + #define PACKED +#else + #define PACKED __attribute__((packed)) +#endif typedef union _LINE_CODING { @@ -865,7 +870,7 @@ typedef union _CONTROL_SIGNAL_BITMAP /* Functional Descriptor Structure - See CDC Specification 1.1 for details */ /* Header Functional Descriptor */ -typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC +typedef struct PACKED _USB_CDC_HEADER_FN_DSC { uint8_t bFNLength; uint8_t bDscType; @@ -874,7 +879,7 @@ typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC } USB_CDC_HEADER_FN_DSC; /* Abstract Control Management Functional Descriptor */ -typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC +typedef struct PACKED _USB_CDC_ACM_FN_DSC { uint8_t bFNLength; uint8_t bDscType; @@ -883,7 +888,7 @@ typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC } USB_CDC_ACM_FN_DSC; /* Union Functional Descriptor */ -typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC +typedef struct PACKED _USB_CDC_UNION_FN_DSC { uint8_t bFNLength; uint8_t bDscType; @@ -893,7 +898,7 @@ typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC } USB_CDC_UNION_FN_DSC; /* Call Management Functional Descriptor */ -typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC +typedef struct PACKED _USB_CDC_CALL_MGT_FN_DSC { uint8_t bFNLength; uint8_t bDscType; @@ -902,7 +907,7 @@ typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC uint8_t bDataInterface; } USB_CDC_CALL_MGT_FN_DSC; -typedef union __attribute__((packed)) _CDC_NOTICE +typedef union PACKED _CDC_NOTICE { LINE_CODING GetLineCoding; LINE_CODING SetLineCoding; diff --git a/inc/usb_device_msd.h b/inc/usb_device_msd.h index 01d29f2..5bb22f3 100644 --- a/inc/usb_device_msd.h +++ b/inc/usb_device_msd.h @@ -26,6 +26,12 @@ please contact mla_licensing@microchip.com #include #include "fileio.h" +#if defined(__XC8) +#define PACKED +#else +#define PACKED __attribute__((packed)) +#endif + /** D E F I N I T I O N S ****************************************************/ /* MSD Interface Class Code */ @@ -266,7 +272,7 @@ typedef union typedef union { uint8_t v[2]; - struct __attribute__((__packed__)) + struct PACKED { uint8_t LB; uint8_t HB; @@ -415,12 +421,12 @@ typedef union } USB_MSD_CMD_SPECIFIC_INFO; /* Fixed format if Desc bit of request sense cbw is 0 */ -typedef union __attribute__((packed)){ +typedef union PACKED{ struct { uint8_t _byte[18]; }; - struct __attribute__((packed)){ + struct PACKED{ unsigned ResponseCode:7; // b6-b0 is Response Code Fixed or descriptor format unsigned VALID:1; // Set to 1 to indicate information field is a valid value diff --git a/inc/usb_hal_pic16f1.h b/inc/usb_hal_pic16f1.h index f26406f..0eeb3ae 100644 --- a/inc/usb_hal_pic16f1.h +++ b/inc/usb_hal_pic16f1.h @@ -33,6 +33,7 @@ please contact mla_licensing@microchip.com #include #include "usb_config.h" +#include "fixed_address_memory.h" #ifdef __cplusplus // Provide C++ Compatability extern "C" { @@ -183,7 +184,11 @@ please contact mla_licensing@microchip.com //----- Definitions for BDT address -------------------------------------------- #define BDT_BASE_ADDR 0x2000 +#if(__XC8_VERSION < 2000) #define BDT_BASE_ADDR_TAG @ BDT_BASE_ADDR +#else + #define BDT_BASE_ADDR_TAG __at(BDT_BASE_ADDR) +#endif #define BDT_ENTRY_SIZE 4 #if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG) @@ -200,8 +205,13 @@ please contact mla_licensing@microchip.com #define CTRL_TRF_SETUP_ADDR BDT_BASE_ADDR + (BDT_ENTRY_SIZE * BDT_NUM_ENTRIES) #define CTRL_TRF_DATA_ADDR CTRL_TRF_SETUP_ADDR + USB_EP0_BUFF_SIZE +#if(__XC8_VERSION < 2000) #define CTRL_TRF_SETUP_ADDR_TAG @ CTRL_TRF_SETUP_ADDR #define CTRL_TRF_DATA_ADDR_TAG @ CTRL_TRF_DATA_ADDR +#else + #define CTRL_TRF_SETUP_ADDR_TAG __at(CTRL_TRF_SETUP_ADDR) + #define CTRL_TRF_DATA_ADDR_TAG __at(CTRL_TRF_DATA_ADDR) +#endif //----- Deprecated definitions - will be removed at some point of time---------- //--------- Deprecated in v2.2 diff --git a/inc/usb_hal_pic18.h b/inc/usb_hal_pic18.h index 3235e02..375a66e 100644 --- a/inc/usb_hal_pic18.h +++ b/inc/usb_hal_pic18.h @@ -218,17 +218,28 @@ please contact mla_licensing@microchip.com #define CTRL_TRF_SETUP_ADDRESS (USB_BDT_ADDRESS+(BDT_NUM_ENTRIES*4)) #define CTRL_TRF_DATA_ADDRESS (CTRL_TRF_SETUP_ADDRESS + USB_EP0_BUFF_SIZE) - #define BDT_BASE_ADDR_TAG @USB_BDT_ADDRESS - #define CTRL_TRF_SETUP_ADDR_TAG @CTRL_TRF_SETUP_ADDRESS - #define CTRL_TRF_DATA_ADDR_TAG @CTRL_TRF_DATA_ADDRESS + #if(__XC8_VERSION < 2000) + #define BDT_BASE_ADDR_TAG @USB_BDT_ADDRESS + #define CTRL_TRF_SETUP_ADDR_TAG @CTRL_TRF_SETUP_ADDRESS + #define CTRL_TRF_DATA_ADDR_TAG @CTRL_TRF_DATA_ADDRESS + #else + #define BDT_BASE_ADDR_TAG __at(USB_BDT_ADDRESS) + #define CTRL_TRF_SETUP_ADDR_TAG __at(CTRL_TRF_SETUP_ADDRESS) + #define CTRL_TRF_DATA_ADDR_TAG __at(CTRL_TRF_DATA_ADDRESS) + #endif #if defined(USB_USE_MSD) //MSD application specific USB endpoint buffer placement macros (so they //get linked to a USB module accessible portion of RAM) #define MSD_CBW_ADDRESS (CTRL_TRF_DATA_ADDRESS + USB_EP0_BUFF_SIZE) #define MSD_CSW_ADDRESS (MSD_CBW_ADDRESS + MSD_OUT_EP_SIZE) - #define MSD_CBW_ADDR_TAG @MSD_CBW_ADDRESS - #define MSD_CSW_ADDR_TAG @MSD_CSW_ADDRESS + #if(__XC8_VERSION < 2000) + #define MSD_CBW_ADDR_TAG @MSD_CBW_ADDRESS + #define MSD_CSW_ADDR_TAG @MSD_CSW_ADDRESS + #else + #define MSD_CBW_ADDR_TAG __at(MSD_CBW_ADDRESS) + #define MSD_CSW_ADDR_TAG __at(MSD_CSW_ADDRESS) + #endif #endif #else #define BDT_BASE_ADDR_TAG __attribute__ ((aligned (512))) diff --git a/inc/usb_hal_pic32mm.h b/inc/usb_hal_pic32mm.h index d97542f..76fd830 100644 --- a/inc/usb_hal_pic32mm.h +++ b/inc/usb_hal_pic32mm.h @@ -41,7 +41,7 @@ please contact mla_licensing@microchip.com #if defined(__32MM0256GPM064__) || defined(__32MM0128GPM064__) || defined(__32MM0064GPM064__) || \ defined(__32MM0256GPM048__) || defined(__32MM0128GPM048__) || defined(__32MM0064GPM048__) || \ defined(__32MM0256GPM036__) || defined(__32MM0128GPM036__) || defined(__32MM0064GPM036__) || \ - defined(__32MM0256GPM028__) || defined(__32MM0128GPM028__) || defined(__32MM0064PM028__) + defined(__32MM0256GPM028__) || defined(__32MM0128GPM028__) || defined(__32MM0064GPM028__) #define DEVICE_SPECIFIC_IEC_REGISTER_COUNT 4 //Number of IECx registers implemented in the microcontroller (varies from device to device, make sure this is set correctly for the intended CPU) #define USB_HAL_VBUSTristate() {TRISBbits.TRISB6 = 1;} diff --git a/src/usb_device.c b/src/usb_device.c index 5805ecb..3046c57 100644 --- a/src/usb_device.c +++ b/src/usb_device.c @@ -197,7 +197,11 @@ volatile uint8_t CtrlTrfData[USB_EP0_BUFF_SIZE] CTRL_TRF_DATA_ADDR_TAG; volatile USB_MSD_CSW msd_csw MSD_CSW_ADDR_TAG; //Must be located in USB module accessible RAM #if defined(__18CXX) || defined(__XC8) + #if(__XC8_VERSION < 2000) volatile char msd_buffer[512] @ MSD_BUFFER_ADDRESS; + #else + volatile char msd_buffer[512] __at(MSD_BUFFER_ADDRESS); + #endif #else volatile char msd_buffer[512]; #endif @@ -2157,6 +2161,7 @@ static void USBStdGetStatusHandler(void) /* * [0]: bit0: Halt Status [0] Not Halted [1] Halted */ + if(SetupPkt.EPNum != 0) { BDT_ENTRY *p; @@ -2170,9 +2175,11 @@ static void USBStdGetStatusHandler(void) } if((p->STAT.UOWN == 1) && (p->STAT.BSTALL == 1)) + { CtrlTrfData[0]=0x01; // Set bit0 - break; + } } + break; }//end switch if(inPipes[0].info.bits.busy == 1) @@ -2561,7 +2568,7 @@ static void USBCtrlTrfOutHandler(void) } else { - BothEP0OutUOWNsSet = false; + BothEP0OutUOWNsSet = false; } } } @@ -2761,40 +2768,6 @@ static void USBStdFeatureReqHandler(void) unsigned char* pUEP; #endif - - #ifdef USB_SUPPORT_OTG - //Check for USB On-The-Go (OTG) specific requests - if ((SetupPkt.bFeature == OTG_FEATURE_B_HNP_ENABLE)&& - (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD)) - { - inPipes[0].info.bits.busy = 1; - if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE) - USBOTGEnableHnp(); - else - USBOTGDisableHnp(); - } - - if ((SetupPkt.bFeature == OTG_FEATURE_A_HNP_SUPPORT)&& - (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD)) - { - inPipes[0].info.bits.busy = 1; - if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE) - USBOTGEnableSupportHnp(); - else - USBOTGDisableSupportHnp(); - } - - if ((SetupPkt.bFeature == OTG_FEATURE_A_ALT_HNP_SUPPORT)&& - (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD)) - { - inPipes[0].info.bits.busy = 1; - if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE) - USBOTGEnableAltHnp(); - else - USBOTGDisableAltHnp(); - } - #endif //#ifdef USB_SUPPORT_OTG - //Check if the host sent a valid SET or CLEAR feature (remote wakeup) request. if((SetupPkt.bFeature == USB_FEATURE_DEVICE_REMOTE_WAKEUP)&& (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD)) diff --git a/src/usb_device_cdc.c b/src/usb_device_cdc.c index 45e3b09..7e8dde2 100644 --- a/src/usb_device_cdc.c +++ b/src/usb_device_cdc.c @@ -55,9 +55,10 @@ please contact mla_licensing@microchip.com #define IN_DATA_BUFFER_ADDRESS_TAG #define OUT_DATA_BUFFER_ADDRESS_TAG #define CONTROL_BUFFER_ADDRESS_TAG + #define DRIVER_DATA_ADDRESS_TAG #endif -#if !defined(IN_DATA_BUFFER_ADDRESS_TAG) || !defined(OUT_DATA_BUFFER_ADDRESS_TAG) || !defined(CONTROL_BUFFER_ADDRESS_TAG) +#if !defined(IN_DATA_BUFFER_ADDRESS_TAG) || !defined(OUT_DATA_BUFFER_ADDRESS_TAG) || !defined(CONTROL_BUFFER_ADDRESS_TAG) || !defined(DRIVER_DATA_ADDRESS_TAG) #error "One of the fixed memory address definitions is not defined. Please define the required address tags for the required buffers." #endif @@ -77,7 +78,7 @@ LINE_CODING line_coding; // Buffer to store line coding information CDC_NOTICE cdc_notice; #if defined(USB_CDC_SUPPORT_DSR_REPORTING) - SERIAL_STATE_NOTIFICATION SerialStatePacket; + SERIAL_STATE_NOTIFICATION SerialStatePacket DRIVER_DATA_ADDRESS_TAG; #endif uint8_t cdc_rx_len; // total rx length @@ -723,10 +724,10 @@ void putsUSBUSART(char *data) will be transferred to the host. **************************************************************************/ -void putrsUSBUSART(const const char *data) +void putrsUSBUSART(const char *data) { uint8_t len; - const const char *pData; + const char *pData; /* * User should have checked that cdc_trf_state is in CDC_TX_READY state diff --git a/src/usb_device_hid.c b/src/usb_device_hid.c index 7574599..384a96f 100644 --- a/src/usb_device_hid.c +++ b/src/usb_device_hid.c @@ -45,6 +45,14 @@ please contact mla_licensing@microchip.com #include "usb.h" #include "usb_device_hid.h" +#if defined(__XC8) + #define PACKED + #define ALIGNED +#else + #define PACKED __attribute__((packed)) + #define ALIGNED __attribute__((aligned)) +#endif + // ***************************************************************************** // ***************************************************************************** // Section: File Scope or Global Constants @@ -56,7 +64,7 @@ please contact mla_licensing@microchip.com // Section: File Scope Data Types // ***************************************************************************** // ***************************************************************************** -typedef struct __attribute__((packed)) +typedef struct PACKED { unsigned :8; unsigned :8; @@ -64,7 +72,7 @@ typedef struct __attribute__((packed)) uint8_t duration; } USB_SETUP_SET_IDLE_RATE; -typedef struct __attribute__((packed)) +typedef struct PACKED { unsigned :8; unsigned :8; diff --git a/src/usb_device_local.h b/src/usb_device_local.h index 27fe522..f74ed1d 100644 --- a/src/usb_device_local.h +++ b/src/usb_device_local.h @@ -369,7 +369,7 @@ typedef union #warning "Disabling the suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device." #else - #define USB_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_WAKEUP_FROM_SUSPEND_HANDLER @@ -377,48 +377,48 @@ typedef union #warning "Disabling the wake from suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device." #else - #define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_SOF_HANDLER #define USB_SOF_HANDLER(event,pointer,size) #else - #define USB_SOF_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_SOF_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_TRANSFER_TERMINATED_HANDLER #define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size) #else - #define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_ERROR_HANDLER #define USB_ERROR_HANDLER(event,pointer,size) #else - #define USB_ERROR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_ERROR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_NONSTANDARD_EP0_REQUEST_HANDLER #define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size) #else - #define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_SET_DESCRIPTOR_HANDLER #define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size) #else - #define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_SET_CONFIGURATION_HANDLER #define USB_SET_CONFIGURATION_HANDLER(event,pointer,size) #else - #define USB_SET_CONFIGURATION_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_SET_CONFIGURATION_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif #if defined USB_DISABLE_TRANSFER_COMPLETE_HANDLER #define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size) #else - #define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size) + #define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER((USB_EVENT)event,pointer,size) #endif