diff --git a/usb/include/usb_cdc.h b/usb/include/usb_cdc.h index 0ac4213..dc79a91 100644 --- a/usb/include/usb_cdc.h +++ b/usb/include/usb_cdc.h @@ -39,7 +39,7 @@ #include #include "usb_config.h" -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(push, 1) #elif __XC8 #else @@ -488,7 +488,7 @@ extern int8_t CDC_SEND_BREAK_CALLBACK(uint8_t interface, uint16_t duration); /** @}*/ -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(pop) #elif __XC8 #else diff --git a/usb/include/usb_ch9.h b/usb/include/usb_ch9.h index 760ae16..0d80b40 100644 --- a/usb/include/usb_ch9.h +++ b/usb/include/usb_ch9.h @@ -38,7 +38,7 @@ #include -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(push, 1) #elif __XC8 #else @@ -273,7 +273,7 @@ struct interface_association_descriptor { /** @endcond */ -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(pop) #elif __XC8 #else diff --git a/usb/include/usb_hid.h b/usb/include/usb_hid.h index bf31edc..42d6f56 100644 --- a/usb/include/usb_hid.h +++ b/usb/include/usb_hid.h @@ -39,7 +39,7 @@ #include #include "usb_config.h" -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(push, 1) #elif __XC8 #else @@ -333,7 +333,7 @@ uint8_t process_hid_setup_request(const struct setup_packet *setup); /** @}*/ -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(pop) #elif __XC8 #else diff --git a/usb/include/usb_microsoft.h b/usb/include/usb_microsoft.h index 36e0848..5dd2d1e 100644 --- a/usb/include/usb_microsoft.h +++ b/usb/include/usb_microsoft.h @@ -38,7 +38,7 @@ #include -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(push, 1) #elif __XC8 #else @@ -171,7 +171,7 @@ uint16_t MICROSOFT_CUSTOM_PROPERTY_DESCRIPTOR_FUNC(uint8_t interface, /* Doxygen end-of-group for microsoft_items */ /** @}*/ -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(pop) #elif __XC8 #else diff --git a/usb/include/usb_msc.h b/usb/include/usb_msc.h index cdd4033..0b9a1be 100644 --- a/usb/include/usb_msc.h +++ b/usb/include/usb_msc.h @@ -39,7 +39,7 @@ #include #include "usb_config.h" -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(push, 1) #elif __XC8 #else @@ -299,7 +299,7 @@ struct scsi_sense_response { /* Additional, vendor-specific sense data goes here. */ }; -#if defined(__XC16__) || defined(__XC32__) +#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) #pragma pack(pop) #elif __XC8 #else diff --git a/usb/src/usb.c b/usb/src/usb.c index ff2be5b..b7242b6 100644 --- a/usb/src/usb.c +++ b/usb/src/usb.c @@ -36,6 +36,8 @@ #include #elif __XC8 #include +#elif defined(__GNUC__) && __mips == 32 + /* You need to have an include in usb_config.h. */ #else #error "Compiler not supported" #endif @@ -116,7 +118,7 @@ STATIC_SIZE_CHECK_EQUAL(sizeof(struct microsoft_extended_compat_header), 16); STATIC_SIZE_CHECK_EQUAL(sizeof(struct microsoft_extended_compat_function), 24); STATIC_SIZE_CHECK_EQUAL(sizeof(struct microsoft_extended_properties_header), 10); STATIC_SIZE_CHECK_EQUAL(sizeof(struct microsoft_extended_property_section_header), 8); -#ifdef __XC32__ +#if defined(__XC32__) || (defined(__GNUC__) && __mips == 32) STATIC_SIZE_CHECK_EQUAL(sizeof(struct buffer_descriptor), 8); #else STATIC_SIZE_CHECK_EQUAL(sizeof(struct buffer_descriptor), 4); @@ -205,7 +207,7 @@ static struct buffer_descriptor bds[NUM_BD] BD_ATTR_TAG; 0x400 and 0x7FF per the datasheet.*/ /* This addr is for the PIC18F4550 */ #pragma udata usb_buffers=0x500 -#elif defined(__XC16__) || defined(__XC32__) +#elif defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32) /* Buffers can go anywhere on PIC24/PIC32 parts which are supported (so far). */ #elif __XC8 @@ -623,7 +625,7 @@ void usb_init(void) SFR_BD_ADDR_REG = w.hb; -#elif __XC32__ +#elif __XC32__ || (defined(__GNUC__) && __mips == 32) union WORD { struct { uint8_t lb; @@ -1692,7 +1694,7 @@ void _ISR __attribute((auto_psv)) _USB1Interrupt() usb_service(); } -#elif __XC32__ +#elif __XC32__ || (defined(__GNUC__) && __mips == 32) /* No parameter for interrupt() means to use IPL=RIPL and to detect whether to use shadow registers or not. This is the safest option, but if a user @@ -1710,4 +1712,4 @@ void __attribute__((vector(_USB_1_VECTOR), interrupt(), nomips16)) _USB1Interrup #else #error Compiler not supported yet #endif -#endif \ No newline at end of file +#endif diff --git a/usb/src/usb_cdc.c b/usb/src/usb_cdc.c index 6a569db..5b3b223 100644 --- a/usb/src/usb_cdc.c +++ b/usb/src/usb_cdc.c @@ -159,7 +159,7 @@ uint8_t process_cdc_setup_request(const struct setup_packet *setup) return -1; usb_send_data_stage((void*)response, - min(len, setup->wLength), + MIN(len, setup->wLength), callback, context); return 0; } @@ -227,7 +227,7 @@ uint8_t process_cdc_setup_request(const struct setup_packet *setup) (uint16_t) data_multiplexed_state << 1; usb_send_data_stage((char*)&transfer_data.comm_feature, - min(setup->wLength, + MIN(setup->wLength, sizeof(transfer_data.comm_feature)), NULL/*callback*/, NULL); return 0; @@ -241,7 +241,7 @@ uint8_t process_cdc_setup_request(const struct setup_packet *setup) transfer_interface = interface; usb_start_receive_ep0_data_stage( (char*)&transfer_data.line_coding, - min(setup->wLength, + MIN(setup->wLength, sizeof(transfer_data.line_coding)), set_line_coding, NULL); return 0; @@ -260,7 +260,7 @@ uint8_t process_cdc_setup_request(const struct setup_packet *setup) return -1; usb_send_data_stage((char*)&transfer_data.line_coding, - min(setup->wLength, + MIN(setup->wLength, sizeof(transfer_data.line_coding)), /*callback*/NULL, NULL); return 0; diff --git a/usb/src/usb_hal.h b/usb/src/usb_hal.h index eb9a42f..c9addc5 100644 --- a/usb/src/usb_hal.h +++ b/usb/src/usb_hal.h @@ -437,7 +437,7 @@ struct buffer_descriptor { #define FAR #define memcpy_from_rom(x,y,z) memcpy(x,y,z) -#elif __XC32__ +#elif __XC32__ || (defined(__GNUC__) && __mips == 32) #define USB_NEEDS_POWER_ON #define USB_NEEDS_SET_BD_ADDR_REG @@ -530,7 +530,7 @@ struct buffer_descriptor { uint32_t BSTALL : 1; uint32_t DTSEN : 1; /* DTS in datasheet */ uint32_t reserved : 2; /* NINC, KEEP */ - uint32_t DTS : 1; /* DATA0/1 in datasheet */ + uint32_t /*DTS*/ : 1; /* DATA0/1 in datasheet */ uint32_t /*UOWN*/ : 1; uint32_t : 8; diff --git a/usb/src/usb_hid.c b/usb/src/usb_hid.c index 5861515..76a4c6c 100644 --- a/usb/src/usb_hid.c +++ b/usb/src/usb_hid.c @@ -91,7 +91,7 @@ uint8_t process_hid_setup_request(const struct setup_packet *setup) if (len < 0) return -1; - usb_send_data_stage((void*) desc, min(len, setup->wLength), NULL, NULL); + usb_send_data_stage((void*) desc, MIN(len, setup->wLength), NULL, NULL); return 0; } @@ -112,7 +112,7 @@ uint8_t process_hid_setup_request(const struct setup_packet *setup) if (len < 0) return -1; - usb_send_data_stage((void*)desc, min(len, setup->wLength), callback, context); + usb_send_data_stage((void*)desc, MIN(len, setup->wLength), callback, context); return 0; } #endif