diff --git a/demos/device/device_os_none/.cproject b/demos/device/device_os_none/.cproject
index 99f30ff8b..44097999f 100644
--- a/demos/device/device_os_none/.cproject
+++ b/demos/device/device_os_none/.cproject
@@ -30,7 +30,7 @@
-
+
-
+
@@ -62,7 +62,7 @@
-
+
@@ -120,7 +120,7 @@
-
+
-
+
@@ -152,7 +152,7 @@
-
+
@@ -209,7 +209,7 @@
-
+
-
+
@@ -244,7 +244,7 @@
-
+
@@ -303,7 +303,7 @@
-
+
-
+
@@ -335,7 +335,7 @@
-
+
@@ -393,7 +393,7 @@
-
+
-
+
@@ -428,7 +428,7 @@
-
+
@@ -467,83 +467,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<TargetConfig>
-<Properties property_0="" property_3="NXP" property_4="LPC4370" property_count="5" version="1"/>
-<infoList vendor="NXP"><info chip="LPC4370" match_id="0x0" name="LPC4370" resetscript="LPC18LPC43ExternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC4370</name>
-<family>LPC43xx</family>
+<Properties property_0="" property_3="NXP" property_4="LPC1347" property_count="5" version="1"/>
+<infoList vendor="NXP"><info chip="LPC1347" match_id="0x08020543" name="LPC1347" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1347</name>
+<family>LPC13xx (12bit ADC)</family>
<vendor>NXP (formerly Philips)</vendor>
<reset board="None" core="Real" sys="Real"/>
-<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/>
+<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
<memory id="RAM" type="RAM"/>
<memory id="Periph" is_volatile="true" type="Peripheral"/>
-<memoryInstance derived_from="RAM" id="RamLoc128" location="0x10000000" size="0x20000"/>
-<memoryInstance derived_from="RAM" id="RamLoc72" location="0x10080000" size="0x12000"/>
-<memoryInstance derived_from="RAM" id="RamAHB32" location="0x20000000" size="0x8000"/>
-<memoryInstance derived_from="RAM" id="RamAHB16" location="0x20008000" size="0x4000"/>
-<memoryInstance derived_from="RAM" id="RamAHB_ETB16" location="0x2000c000" size="0x4000"/>
-<memoryInstance derived_from="RAM" id="RamM0Sub16" location="0x18000000" size="0x4000"/>
-<memoryInstance derived_from="RAM" id="RamM0Sub2" location="0x18004000" size="0x800"/>
+<memoryInstance derived_from="Flash" id="MFlash64" location="0x0" size="0x10000"/>
+<memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/>
+<memoryInstance derived_from="RAM" id="RamUsb2" location="0x20004000" size="0x800"/>
+<memoryInstance derived_from="RAM" id="RamPeriph2" location="0x20000000" size="0x800"/>
+<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/>
<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/>
<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/>
<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/>
<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/>
-<peripheralInstance derived_from="SCT" id="SCT" location="0x40000000"/>
-<peripheralInstance derived_from="GPDMA" id="GPDMA" location="0x40002000"/>
-<peripheralInstance derived_from="SPIFI" id="SPIFI" location="0x40003000"/>
-<peripheralInstance derived_from="SDMMC" id="SDMMC" location="0x40004000"/>
-<peripheralInstance derived_from="EMC" id="EMC" location="0x40005000"/>
-<peripheralInstance derived_from="USB0" id="USB0" location="0x40006000"/>
-<peripheralInstance derived_from="USB1" id="USB1" location="0x40007000"/>
-<peripheralInstance derived_from="LCD" id="LCD" location="0x40008000"/>
-<peripheralInstance derived_from="EEPROM" id="EEPROM" location="0x4000e000"/>
-<peripheralInstance derived_from="ETHERNET" id="ETHERNET" location="0x40010000"/>
-<peripheralInstance derived_from="ATIMER" id="ATIMER" location="0x40040000"/>
-<peripheralInstance derived_from="REGFILE" id="REGFILE" location="0x40041000"/>
-<peripheralInstance derived_from="PMC" id="PMC" location="0x40042000"/>
-<peripheralInstance derived_from="CREG" id="CREG" location="0x40043000"/>
-<peripheralInstance derived_from="EVENTROUTER" id="EVENTROUTER" location="0x40044000"/>
-<peripheralInstance derived_from="RTC" id="RTC" location="0x40046000"/>
-<peripheralInstance derived_from="CGU" id="CGU" location="0x40050000"/>
-<peripheralInstance derived_from="CCU1" id="CCU1" location="0x40051000"/>
-<peripheralInstance derived_from="CCU2" id="CCU2" location="0x40052000"/>
-<peripheralInstance derived_from="RGU" id="RGU" location="0x40053000"/>
-<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40080000"/>
-<peripheralInstance derived_from="USART0" id="USART0" location="0x40081000"/>
-<peripheralInstance derived_from="USART2" id="USART2" location="0x400c1000"/>
-<peripheralInstance derived_from="USART3" id="USART3" location="0x400c2000"/>
-<peripheralInstance derived_from="UART1" id="UART1" location="0x40082000"/>
-<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40083000"/>
-<peripheralInstance derived_from="SSP1" id="SSP1" location="0x400c5000"/>
-<peripheralInstance derived_from="TIMER0" id="TIMER0" location="0x40084000"/>
-<peripheralInstance derived_from="TIMER1" id="TIMER1" location="0x40085000"/>
-<peripheralInstance derived_from="TIMER2" id="TIMER2" location="0x400c3000"/>
-<peripheralInstance derived_from="TIMER3" id="TIMER3" location="0x400c4000"/>
-<peripheralInstance derived_from="SCU" id="SCU" location="0x40086000"/>
-<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x40087000"/>
-<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x40088000"/>
-<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40089000"/>
-<peripheralInstance derived_from="MCPWM" id="MCPWM" location="0x400a0000"/>
-<peripheralInstance derived_from="I2C0" id="I2C0" location="0x400a1000"/>
-<peripheralInstance derived_from="I2C1" id="I2C1" location="0x400e0000"/>
-<peripheralInstance derived_from="I2S0" id="I2S0" location="0x400a2000"/>
-<peripheralInstance derived_from="I2S1" id="I2S1" location="0x400a3000"/>
-<peripheralInstance derived_from="C-CAN1" id="C-CAN1" location="0x400a4000"/>
-<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x400c0000"/>
-<peripheralInstance derived_from="QEI" id="QEI" location="0x400c6000"/>
-<peripheralInstance derived_from="GIMA" id="GIMA" location="0x400c7000"/>
-<peripheralInstance derived_from="DAC" id="DAC" location="0x400e1000"/>
-<peripheralInstance derived_from="C-CAN0" id="C-CAN0" location="0x400e2000"/>
-<peripheralInstance derived_from="ADC0" id="ADC0" location="0x400e3000"/>
-<peripheralInstance derived_from="ADC1" id="ADC1" location="0x400e4000"/>
-<peripheralInstance derived_from="ADCHS" id="ADCHS" location="0x400f0000"/>
-<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x400f4000"/>
-<peripheralInstance derived_from="SPI" id="SPI" location="0x40100000"/>
-<peripheralInstance derived_from="SGPIO" id="SGPIO" location="0x40101000"/>
+<peripheralInstance derived_from="I2C" id="I2C" location="0x40000000"/>
+<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40004000"/>
+<peripheralInstance derived_from="USART" id="USART" location="0x40008000"/>
+<peripheralInstance derived_from="CT16B0" id="CT16B0" location="0x4000c000"/>
+<peripheralInstance derived_from="CT16B1" id="CT16B1" location="0x40010000"/>
+<peripheralInstance derived_from="CT32B0" id="CT32B0" location="0x40014000"/>
+<peripheralInstance derived_from="CT32B1" id="CT32B1" location="0x40018000"/>
+<peripheralInstance derived_from="ADC" id="ADC" location="0x4001c000"/>
+<peripheralInstance derived_from="PMU" id="PMU" location="0x40038000"/>
+<peripheralInstance derived_from="FLASHCTRL" id="FLASHCTRL" location="0x4003c000"/>
+<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40040000"/>
+<peripheralInstance derived_from="IOCON" id="IOCON" location="0x40044000"/>
+<peripheralInstance derived_from="SYSCON" id="SYSCON" location="0x40048000"/>
+<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x4004c000"/>
+<peripheralInstance derived_from="SSP1" id="SSP1" location="0x40058000"/>
+<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x4005c000"/>
+<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40060000"/>
+<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x40064000"/>
+<peripheralInstance derived_from="USB" id="USB" location="0x40080000"/>
+<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x50000000"/>
</chip>
-<processor><name gcc_name="cortex-m4">Cortex-M4</name>
+<processor><name gcc_name="cortex-m3">Cortex-M3</name>
<family>Cortex-M</family>
</processor>
-<link href="nxp_lpc43xx_peripheral.xme" show="embed" type="simple"/>
+<link href="nxp_lpc13Uxx_peripheral.xme" show="embed" type="simple"/>
</info>
</infoList>
</TargetConfig>
diff --git a/demos/device/device_os_none/keyboardd_app.c b/demos/device/device_os_none/keyboardd_app.c
index 360b68f9c..842099eb6 100644
--- a/demos/device/device_os_none/keyboardd_app.c
+++ b/demos/device/device_os_none/keyboardd_app.c
@@ -59,6 +59,16 @@ static uint8_t keyboardd_report_count; // number of reports sent each mounted
//--------------------------------------------------------------------+
// tinyusb Callbacks
//--------------------------------------------------------------------+
+void tusbd_hid_keyboard_mounted_cb(uint8_t coreid)
+{
+ keyboardd_report_count = 0;
+}
+
+void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid)
+{
+
+}
+
void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes)
{
switch(event)
@@ -70,11 +80,6 @@ void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_
}
}
-void tusbd_hid_keyboard_mounted_cb(uint8_t coreid)
-{
- keyboardd_report_count = 0;
-}
-
//--------------------------------------------------------------------+
// APPLICATION CODE
//--------------------------------------------------------------------+
diff --git a/demos/device/device_os_none/moused_app.c b/demos/device/device_os_none/moused_app.c
index fa1cdb13f..e9cc16998 100644
--- a/demos/device/device_os_none/moused_app.c
+++ b/demos/device/device_os_none/moused_app.c
@@ -59,6 +59,16 @@ static uint8_t moused_report_count; // number of reports sent each mounted
//--------------------------------------------------------------------+
// tinyusb Callbacks
//--------------------------------------------------------------------+
+void tusbd_hid_mouse_mounted_cb(uint8_t coreid)
+{
+ moused_report_count = 0;
+}
+
+void tusbd_hid_mouse_unmounted_cb(uint8_t coreid)
+{
+
+}
+
void tusbd_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes)
{
switch(event)
@@ -70,11 +80,6 @@ void tusbd_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_byt
}
}
-void tusbd_hid_mouse_mounted_cb(uint8_t coreid)
-{
- moused_report_count = 0;
-}
-
//--------------------------------------------------------------------+
// APPLICATION CODE
//--------------------------------------------------------------------+
diff --git a/demos/device/device_os_none/tusb_config.h b/demos/device/device_os_none/tusb_config.h
index cd7ab97a4..c04aefcaa 100644
--- a/demos/device/device_os_none/tusb_config.h
+++ b/demos/device/device_os_none/tusb_config.h
@@ -86,8 +86,8 @@
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
#define TUSB_CFG_DEVICE_HID_MOUSE 1
#define TUSB_CFG_DEVICE_HID_GENERIC 0
-#define TUSB_CFG_DEVICE_MSC 1
-#define TUSB_CFG_DEVICE_CDC 1
+#define TUSB_CFG_DEVICE_MSC 0
+#define TUSB_CFG_DEVICE_CDC 0
diff --git a/demos/device/device_os_none/tusb_descriptors.c b/demos/device/device_os_none/tusb_descriptors.c
index fbdc0b5f7..51088f324 100644
--- a/demos/device/device_os_none/tusb_descriptors.c
+++ b/demos/device/device_os_none/tusb_descriptors.c
@@ -418,7 +418,7 @@ tusb_descriptor_string_t desc_str_product =
{
.bLength = STRING_LEN_UNICODE(14),
.bDescriptorType = TUSB_DESC_TYPE_STRING,
- .unicode_string = { 'D', 'e', 'v', 'i', 'c', 'e', ' ', 'E', 'x', 'a', 'm', 'p', 'l', 'e' } // len = 14
+ .unicode_string = { 't', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'D', 'e', 'v', 'i', 'c', 'e' } // len = 14
};
ATTR_USB_MIN_ALIGNMENT TUSB_CFG_ATTR_USBRAM
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c
index 65d41dc0c..3e171a1de 100644
--- a/tinyusb/class/hid_device.c
+++ b/tinyusb/class/hid_device.c
@@ -51,25 +51,62 @@
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
-ATTR_USB_MIN_ALIGNMENT uint8_t set_report[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ];
+ATTR_USB_MIN_ALIGNMENT uint8_t set_report[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ] TUSB_CFG_ATTR_USBRAM;
+
+enum {
+ HIDD_NUMBER_OF_SUBCLASS = 3
+};
typedef struct {
- uint8_t const * p_report_desc;
uint16_t report_length;
endpoint_handle_t ept_handle;
uint8_t interface_number;
}hidd_interface_t;
+typedef struct {
+ uint8_t const * const p_report_desc;
+ hidd_interface_t * const p_interface;
+ void (* const mounted_cb) (uint8_t coreid);
+ void (* const unmounted_cb) (uint8_t coreid);
+ void (* const xfer_cb) (uint8_t, tusb_event_t, uint32_t);
+}hidd_class_driver_t;
+
+extern ATTR_WEAK hidd_interface_t keyboardd_data;
+extern ATTR_WEAK hidd_interface_t moused_data;
+
+static hidd_class_driver_t const hidd_class_driver[HIDD_NUMBER_OF_SUBCLASS] =
+{
+// [HID_PROTOCOL_NONE] = for HID Generic
+
+#if TUSB_CFG_DEVICE_HID_KEYBOARD
+ [HID_PROTOCOL_KEYBOARD] =
+ {
+ .p_report_desc = app_tusb_keyboard_desc_report,
+ .p_interface = &keyboardd_data,
+ .mounted_cb = tusbd_hid_keyboard_mounted_cb,
+ .unmounted_cb = tusbd_hid_keyboard_unmounted_cb,
+ .xfer_cb = tusbd_hid_keyboard_cb
+ },
+#endif
+
+#if TUSB_CFG_DEVICE_HID_MOUSE
+ [HID_PROTOCOL_MOUSE] =
+ {
+ .p_report_desc = app_tusb_mouse_desc_report,
+ .p_interface = &moused_data,
+ .mounted_cb = tusbd_hid_mouse_mounted_cb,
+ .unmounted_cb = tusbd_hid_mouse_unmounted_cb,
+ .xfer_cb = tusbd_hid_mouse_cb
+ }
+#endif
+};
//--------------------------------------------------------------------+
// KEYBOARD APPLICATION API
//--------------------------------------------------------------------+
#if TUSB_CFG_DEVICE_HID_KEYBOARD
-STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t keyboardd_data =
-{
- .p_report_desc = app_tusb_keyboard_desc_report
-};
+STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t keyboardd_data;
bool tusbd_hid_keyboard_is_busy(uint8_t coreid)
{
@@ -92,10 +129,7 @@ tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const
// MOUSE APPLICATION API
//--------------------------------------------------------------------+
#if TUSB_CFG_DEVICE_HID_MOUSE
-STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t moused_data =
-{
- .p_report_desc = app_tusb_mouse_desc_report
-};
+STATIC_VAR TUSB_CFG_ATTR_USBRAM hidd_interface_t moused_data;
bool tusbd_hid_mouse_is_busy(uint8_t coreid)
{
@@ -112,35 +146,56 @@ tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_re
return TUSB_ERROR_NONE;
}
-
#endif
-
//--------------------------------------------------------------------+
// USBD-CLASS API
//--------------------------------------------------------------------+
+static void interface_clear(hidd_interface_t * p_interface)
+{
+ if ( p_interface != NULL )
+ {
+ memclr_(p_interface, sizeof(hidd_interface_t));
+ p_interface->interface_number = INTERFACE_INVALID_NUMBER;
+ }
+}
+
void hidd_init(void)
{
- // TODO not implemented yet
+ for(uint8_t i=0; iwIndex == keyboardd_data.interface_number) ? &keyboardd_data :
- #endif
- #if TUSB_CFG_DEVICE_HID_MOUSE
- (p_request->wIndex == moused_data.interface_number) ? &moused_data :
- #endif
- NULL;
+ uint8_t subclass_idx;
+ for(subclass_idx=0; subclass_idxwIndex == p_interface->interface_number) )
+ {
+ break;
+ }
+ }
- ASSERT_PTR(p_hid, TUSB_ERROR_FAILED);
+ ASSERT(subclass_idx < HIDD_NUMBER_OF_SUBCLASS, TUSB_ERROR_FAILED);
+
+ hidd_class_driver_t* const p_driver = &hidd_class_driver[subclass_idx];
+ hidd_interface_t* const p_hid = p_driver->p_interface;
//------------- STD Request -------------//
if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_STANDARD)
@@ -153,7 +208,7 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const *
ASSERT ( p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT,
TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT);
- dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, p_hid->p_report_desc, p_hid->report_length);
+ dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, p_driver->p_report_desc, p_hid->report_length);
}
//------------- Class Specific Request -------------//
else if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_CLASS)
@@ -166,7 +221,7 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const *
case HID_REQUEST_CONTROL_SET_REPORT:
{
- return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; // TODO test STALL control out endpoint (with mouse+keyboard)
+// return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; // TODO test STALL control out endpoint (with mouse+keyboard)aaaaa
// TODO HIDD set report support
hid_request_report_type_t report_type = u16_high_u8(p_request->wValue);
@@ -215,14 +270,8 @@ tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
case HID_PROTOCOL_KEYBOARD:
case HID_PROTOCOL_MOUSE:
{
- hidd_interface_t* p_hid =
- #if TUSB_CFG_DEVICE_HID_KEYBOARD
- (p_interface_desc->bInterfaceProtocol == HID_PROTOCOL_KEYBOARD) ? &keyboardd_data :
- #endif
- #if TUSB_CFG_DEVICE_HID_MOUSE
- (p_interface_desc->bInterfaceProtocol == HID_PROTOCOL_MOUSE) ? &moused_data :
- #endif
- NULL;
+ hidd_class_driver_t * const p_driver = &hidd_class_driver[p_interface_desc->bInterfaceProtocol];
+ hidd_interface_t * const p_hid = p_driver->p_interface;
ASSERT_PTR(p_hid, TUSB_ERROR_FAILED);
@@ -232,19 +281,7 @@ tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
p_hid->interface_number = p_interface_desc->bInterfaceNumber;
p_hid->report_length = p_desc_hid->wReportLength;
- #if TUSB_CFG_DEVICE_HID_KEYBOARD
- if (p_interface_desc->bInterfaceProtocol == HID_PROTOCOL_KEYBOARD)
- {
- tusbd_hid_keyboard_mounted_cb(coreid);
- }
- #endif
-
- #if TUSB_CFG_DEVICE_HID_MOUSE
- if (p_interface_desc->bInterfaceProtocol == HID_PROTOCOL_MOUSE)
- {
- tusbd_hid_mouse_mounted_cb(coreid);
- }
- #endif
+ p_driver->mounted_cb(coreid);
}
break;
@@ -263,19 +300,14 @@ tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
tusb_error_t hidd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes)
{
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
- if ( endpointhandle_is_equal(edpt_hdl, keyboardd_data.ept_handle) )
+ for(uint8_t i=0; iept_handle) )
+ {
+ hidd_class_driver[i].xfer_cb(edpt_hdl.coreid, event, xferred_bytes);
+ }
}
-#endif
-
-#if TUSB_CFG_DEVICE_HID_MOUSE
- if ( endpointhandle_is_equal(edpt_hdl, moused_data.ept_handle) )
- {
- tusbd_hid_mouse_cb(edpt_hdl.coreid, event, xferred_bytes);
- }
-#endif
return TUSB_ERROR_NONE;
}
@@ -300,49 +332,6 @@ static volatile bool bMouseChanged = false;
//--------------------------------------------------------------------+
// APPLICATION API
//--------------------------------------------------------------------+
-#if TUSB_CFG_DEVICE_HID_KEYBOARD
-tusb_error_t tusbd_hid_keyboard_send_report(hid_keyboard_report_t *p_kbd_report)
-{
-// uint32_t start_time = systickGetSecondsActive();
-// while (bKeyChanged) // TODO blocking while previous key has yet sent - can use fifo to improve this
-// {
-// ASSERT_MESSAGE(systickGetSecondsActive() - start_time < 5, ERR_FAILED, "HID Keyboard Timeout");
-// }
-
- if (bKeyChanged)
- {
- return TUSB_ERROR_FAILED;
- }
-
- ASSERT_PTR(p_kbd_report, TUSB_ERROR_FAILED);
-
- hid_keyboard_report = *p_kbd_report;
- bKeyChanged = true;
-
- return TUSB_ERROR_NONE;
-}
-#endif
-
-#if TUSB_CFG_DEVICE_HID_MOUSE
-tusb_error_t tusbd_hid_mouse_send_report(hid_mouse_report_t *p_mouse_report)
-{
-// uint32_t start_time = systickGetSecondsActive();
-// while (bMouseChanged) // TODO Block while previous key hasn't been sent - can use fifo to improve this
-// {
-// ASSERT_MESSAGE(systickGetSecondsActive() - start_time < 5, ERR_FAILED, "HID Mouse Timeout");
-// }
-
- if (bMouseChanged)
- {
- return TUSB_ERROR_FAILED;
- }
-
- hid_mouse_report = *p_mouse_report;
- bMouseChanged = true;
-
- return TUSB_ERROR_NONE;
-}
-#endif
//--------------------------------------------------------------------+
// IMPLEMENTATION
diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h
index edef9e25a..b51b0d8eb 100644
--- a/tinyusb/class/hid_device.h
+++ b/tinyusb/class/hid_device.h
@@ -56,8 +56,6 @@
/** \defgroup Keyboard_Device Device
* @{ */
-//bool tusbd_hid_keyboard_is_configured(uint8_t coreid);
-
/** \brief Check if the interface is currently busy or not
* \param[in] coreid USB Controller ID
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to host
@@ -82,6 +80,9 @@ tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
+void tusbd_hid_keyboard_mounted_cb(uint8_t coreid);
+void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid);
+
/** \brief Callback function that is invoked when an transferring event occurred
* after invoking \ref tusbd_hid_keyboard_send
* \param[in] coreid USB Controller ID
@@ -92,8 +93,9 @@ tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const
* - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
*/
void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes);
-void tusbd_hid_keyboard_mounted_cb(uint8_t coreid);
-void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid);
+
+void tusbd_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t report_data[]);
+void tusbd_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report);
/** @} */
/** @} */
@@ -132,6 +134,10 @@ tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_re
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
+
+void tusbd_hid_mouse_mounted_cb(uint8_t coreid);
+void tusbd_hid_mouse_unmounted_cb(uint8_t coreid);
+
/** \brief Callback function that is invoked when an transferring event occurred
* after invoking \ref tusbd_hid_mouse_send
* \param[in] coreid USB Controller ID
@@ -142,8 +148,6 @@ tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_re
* - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
*/
void tusbd_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes);
-void tusbd_hid_mouse_mounted_cb(uint8_t coreid);
-void tusbd_hid_mouse_unmounted_cb(uint8_t coreid);
/** @} */
/** @} */
diff --git a/tinyusb/common/tusb_types.h b/tinyusb/common/tusb_types.h
index 0c98b2aab..db2cfee31 100644
--- a/tinyusb/common/tusb_types.h
+++ b/tinyusb/common/tusb_types.h
@@ -212,6 +212,10 @@ enum {
DESCRIPTOR_OFFSET_TYPE = 1
};
+enum {
+ INTERFACE_INVALID_NUMBER = 0xff
+};
+
static inline uint8_t std_class_code_to_index(uint8_t std_class_code) ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint8_t std_class_code_to_index(uint8_t std_class_code)
{
diff --git a/tools/simpleHIDwrite/SimpleHIDWrite.exe b/tools/simpleHIDwrite/SimpleHIDWrite.exe
new file mode 100644
index 000000000..3eab800ab
Binary files /dev/null and b/tools/simpleHIDwrite/SimpleHIDWrite.exe differ