diff --git a/hardware/arduino/avr/cores/arduino/PluggableUSB.cpp b/hardware/arduino/avr/cores/arduino/PluggableUSB.cpp index e389c3541..b5e94eeb6 100644 --- a/hardware/arduino/avr/cores/arduino/PluggableUSB.cpp +++ b/hardware/arduino/avr/cores/arduino/PluggableUSB.cpp @@ -25,9 +25,6 @@ #define MAX_MODULES 6 -static u8 startIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT; -static u8 firstEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT; - static u8 lastIf = CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT; static u8 lastEp = CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT; @@ -36,18 +33,18 @@ extern u8 _initEndpoints[]; PUSBCallbacks cbs[MAX_MODULES]; u8 modules_count = 0; -int PUSB_GetInterface(u8* interfaceNum) +int8_t PUSB_GetInterface(u8* interfaceNum) { - int ret = 0; + int8_t ret = 0; for (u8 i=0; i= MAX_MODULES) { return 0; diff --git a/hardware/arduino/avr/cores/arduino/PluggableUSB.h b/hardware/arduino/avr/cores/arduino/PluggableUSB.h index 7b3722c99..877a9b00f 100644 --- a/hardware/arduino/avr/cores/arduino/PluggableUSB.h +++ b/hardware/arduino/avr/cores/arduino/PluggableUSB.h @@ -28,9 +28,9 @@ typedef struct { bool (*setup)(Setup& setup, u8 i); - int (*getInterface)(u8* interfaceNum); - int (*getDescriptor)(int t); - int numEndpoints; + int8_t (*getInterface)(u8* interfaceNum); + int8_t (*getDescriptor)(int8_t t); + int8_t numEndpoints; u8 endpointType[6]; } PUSBCallbacks; @@ -40,11 +40,11 @@ typedef struct u8 firstEndpoint; } PUSBReturn; -int PUSB_AddFunction(PUSBCallbacks *cb, u8 *interface); +int8_t PUSB_AddFunction(PUSBCallbacks *cb, u8 *interface); -int PUSB_GetInterface(u8* interfaceNum); +int8_t PUSB_GetInterface(u8* interfaceNum); -int PUSB_GetDescriptor(int t); +int8_t PUSB_GetDescriptor(int8_t t); bool PUSB_Setup(Setup& setup, u8 i); diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp index f49c90e8d..7806108cc 100644 --- a/libraries/HID/HID.cpp +++ b/libraries/HID/HID.cpp @@ -29,6 +29,8 @@ Mouse_ Mouse; Keyboard_ Keyboard; HID_ HID; +static u8 HID_ENDPOINT_INT; + //================================================================================ //================================================================================ @@ -43,10 +45,6 @@ HID_ HID; #define RAWHID_RX_SIZE 64 static u8 HID_INTERFACE; -static u8 HID_FIRST_ENDPOINT; -static u8 HID_ENDPOINT_INT; - -static PUSBCallbacks cb; extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { @@ -144,13 +142,13 @@ u8 _hid_idle = 1; #define WEAK __attribute__ ((weak)) -int WEAK HID_GetInterface(u8* interfaceNum) +int8_t WEAK HID_GetInterface(u8* interfaceNum) { interfaceNum[0] += 1; // uses 1 return USB_SendControl(0,&_hidInterface,sizeof(_hidInterface)); } -int WEAK HID_GetDescriptor(int t) +int8_t WEAK HID_GetDescriptor(int8_t t) { if (HID_REPORT_DESCRIPTOR_TYPE == t) { return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor)); @@ -205,20 +203,16 @@ bool WEAK HID_Setup(Setup& setup, u8 i) } // to be called by begin(), will trigger USB disconnection and reconnection -int HID_Plug(void) +int8_t HID_Plug(void) { - u8 interface; - u8 res; + PUSBCallbacks cb; cb.setup = &HID_Setup; cb.getInterface = &HID_GetInterface; cb.getDescriptor = &HID_GetDescriptor; cb.numEndpoints = 1; cb.endpointType[0] = EP_TYPE_INTERRUPT_IN; - res = PUSB_AddFunction(&cb, &interface); - HID_INTERFACE = interface; - HID_FIRST_ENDPOINT = res; - HID_ENDPOINT_INT = res; + HID_ENDPOINT_INT = PUSB_AddFunction(&cb, &HID_INTERFACE); _hidInterface = { @@ -227,7 +221,7 @@ int HID_Plug(void) D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01) }; - return res; + return HID_ENDPOINT_INT; } HID_::HID_(void) diff --git a/libraries/HID/HID.h b/libraries/HID/HID.h index b43e3f039..70a72135a 100644 --- a/libraries/HID/HID.h +++ b/libraries/HID/HID.h @@ -129,9 +129,9 @@ public: int begin(void); }; -int HID_Plug(void); -int HID_GetInterface(u8* interfaceNum); -int HID_GetDescriptor(int t); +int8_t HID_Plug(void); +int8_t HID_GetInterface(u8* interfaceNum); +int8_t HID_GetDescriptor(int8_t t); bool HID_Setup(Setup& setup, u8 i); void HID_SendReport(uint8_t id, const void* data, int len);