Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for compiling on vanilla mipsel GCC toolchain #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions usb/include/usb_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <stdint.h>
#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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions usb/include/usb_ch9.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <stdint.h>

#if defined(__XC16__) || defined(__XC32__)
#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32)
#pragma pack(push, 1)
#elif __XC8
#else
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions usb/include/usb_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <stdint.h>
#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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions usb/include/usb_microsoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <stdint.h>

#if defined(__XC16__) || defined(__XC32__)
#if defined(__XC16__) || defined(__XC32__) || (defined(__GNUC__) && __mips == 32)
#pragma pack(push, 1)
#elif __XC8
#else
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions usb/include/usb_msc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <stdint.h>
#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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions usb/src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <delays.h>
#elif __XC8
#include <xc.h>
#elif defined(__GNUC__) && __mips == 32
/* You need to have an include in usb_config.h. */
#else
#error "Compiler not supported"
#endif
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -1710,4 +1712,4 @@ void __attribute__((vector(_USB_1_VECTOR), interrupt(), nomips16)) _USB1Interrup
#else
#error Compiler not supported yet
#endif
#endif
#endif
8 changes: 4 additions & 4 deletions usb/src/usb_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions usb/src/usb_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions usb/src/usb_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
Expand Down