diff --git a/demos/device/keyboard/main.c b/demos/device/keyboard/main.c index cdf7fe452..8f4d263ac 100644 --- a/demos/device/keyboard/main.c +++ b/demos/device/keyboard/main.c @@ -42,12 +42,17 @@ int main(void) #if TUSB_CFG_DEVICE_HID_MOUSE if (usb_isConfigured()) { - tusb_hid_mouse_send(0, 10, 10); + static uint32_t count =0; + if (count < 8) + { + count++; + tusb_hid_mouse_send(0, 20, 20); + } } #endif } - #if defined TUSB_CFG_DEVICE_CDC && 0 + #if TUSB_CFG_DEVICE_CDC && 0 if (usb_isConfigured()) { uint8_t cdc_char; diff --git a/demos/device/keyboard/tusb_config.h b/demos/device/keyboard/tusb_config.h index 3169c83db..68fe1dcaa 100644 --- a/demos/device/keyboard/tusb_config.h +++ b/demos/device/keyboard/tusb_config.h @@ -92,10 +92,10 @@ //------------- CLASS -------------// #define TUSB_CFG_DEVICE_HID_KEYBOARD 1 -#define TUSB_CFG_DEVICE_HID_MOUSE 0 +#define TUSB_CFG_DEVICE_HID_MOUSE 1 #define TUSB_CFG_DEVICE_HID_GENERIC 0 #define TUSB_CFG_DEVICE_MSC 0 -//#define TUSB_CFG_DEVICE_CDC +#define TUSB_CFG_DEVICE_CDC 0 //--------------------------------------------------------------------+ // COMMON CONFIGURATION diff --git a/demos/device/keyboard/tusb_descriptors.c b/demos/device/keyboard/tusb_descriptors.c index c3e9c5fd1..b69e30e3a 100644 --- a/demos/device/keyboard/tusb_descriptors.c +++ b/demos/device/keyboard/tusb_descriptors.c @@ -83,7 +83,7 @@ uint8_t app_tusb_keyboard_desc_report[] = { #if TUSB_CFG_DEVICE_HID_MOUSE TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) -uint8_t mouse_report_descriptor[] = { +uint8_t app_tusb_mouse_desc_report[] = { HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ), HID_COLLECTION ( HID_COLLECTION_APPLICATION ), @@ -178,7 +178,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration = }, #endif - #ifdef TUSB_CFG_DEVICE_CDC + #if TUSB_CFG_DEVICE_CDC // USB CDC Serial Interface // CDC Control Interface .CDC_CCI_Interface = @@ -273,7 +273,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration = { .bLength = sizeof(tusb_descriptor_interface_t), .bDescriptorType = TUSB_DESC_TYPE_INTERFACE, - .bInterfaceNumber = 1, + .bInterfaceNumber = INTERFACE_INDEX_HID_KEYBOARD, .bAlternateSetting = 0x00, .bNumEndpoints = 1, .bInterfaceClass = TUSB_CLASS_HID, @@ -297,7 +297,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration = { .bLength = sizeof(tusb_descriptor_endpoint_t), .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT, - .bEndpointAddress = 0x81, //HID_KEYBOARD_EP_IN, + .bEndpointAddress = HID_KEYBOARD_EP_IN, //todo HID_KEYBOARD_EP_IN, .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT }, .wMaxPacketSize = { .size = 0x08 }, .bInterval = 0x0A @@ -306,7 +306,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration = //------------- HID Mouse -------------// #if TUSB_CFG_DEVICE_HID_MOUSE - .HID_MouseInterface = + .mouse_interface = { .bLength = sizeof(tusb_descriptor_interface_t), .bDescriptorType = TUSB_DESC_TYPE_INTERFACE, @@ -314,7 +314,7 @@ app_descriptor_configuration_t app_tusb_desc_configuration = .bAlternateSetting = 0x00, .bNumEndpoints = 1, .bInterfaceClass = TUSB_CLASS_HID, - .bInterfaceSubClass = TUSB_HID_SUBCLASS_BOOT, + .bInterfaceSubClass = HID_SUBCLASS_BOOT, .bInterfaceProtocol = HID_PROTOCOL_MOUSE, .iInterface = 0x00 }, @@ -327,16 +327,16 @@ app_descriptor_configuration_t app_tusb_desc_configuration = .bCountryCode = HID_Local_NotSupported, .bNumDescriptors = 1, .bReportType = HID_DESC_TYPE_REPORT, - .wReportLength = sizeof(mouse_report_descriptor) + .wReportLength = sizeof(app_tusb_mouse_desc_report) }, .mouse_endpoint = { .bLength = sizeof(tusb_descriptor_endpoint_t), .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT, - .bEndpointAddress = 0x82, + .bEndpointAddress = HID_MOUSE_EP_IN, // TODO .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT }, - .wMaxPacketSize = 0x08, + .wMaxPacketSize = { .size = 0x08 }, .bInterval = 0x0A }, #endif @@ -390,19 +390,19 @@ app_descriptor_string_t app_tusb_desc_strings = //------------- index 1 -------------// .manufacturer = { - .bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1), + .bLength = STRING_LEN_BYTE2UNICODE(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1), .bDescriptorType = TUSB_DESC_TYPE_STRING, }, //------------- index 2 -------------// .product = { - .bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1), + .bLength = STRING_LEN_BYTE2UNICODE(sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1), .bDescriptorType = TUSB_DESC_TYPE_STRING, }, //------------- index 3 -------------// .serial = { - .bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1), + .bLength = STRING_LEN_BYTE2UNICODE(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1), .bDescriptorType = TUSB_DESC_TYPE_STRING, } }; diff --git a/demos/device/keyboard/tusb_descriptors.h b/demos/device/keyboard/tusb_descriptors.h index 3116e84d8..68dff8c93 100644 --- a/demos/device/keyboard/tusb_descriptors.h +++ b/demos/device/keyboard/tusb_descriptors.h @@ -35,20 +35,6 @@ #include "tusb.h" - - -/* USB Serial uses the MCUs unique 128-bit chip ID via an IAP call = 32 hex chars */ -#define USB_STRING_SERIAL_LEN 32 - -#define USB_STRING_LEN(n) (2 + ((n)<<1)) - -typedef ATTR_PACKED_STRUCT(struct) -{ - uint8_t bLength ; ///< Size of this descriptor in bytes - uint8_t bDescriptorType ; ///< Descriptor Type - uint16_t unicode_string[]; -} tusb_descriptor_string_t; - typedef ATTR_PACKED_STRUCT(struct) { //------------- index 0 -------------// @@ -90,31 +76,13 @@ typedef ATTR_PACKED_STRUCT(struct) /////////////////////////////////////////////////////////////////////// // Interface Assosication Descriptor if device is CDC + other class -#define IAD_DESC_REQUIRED ( defined(TUSB_CFG_DEVICE_CDC) && (DEVICE_CLASS_HID) ) +#define IAD_DESC_REQUIRED ( TUSB_CFG_DEVICE_CDC && DEVICE_CLASS_HID ) -#ifdef TUSB_CFG_DEVICE_CDC - #define INTERFACES_OF_CDC 2 -#else - #define INTERFACES_OF_CDC 0 -#endif +#define INTERFACES_OF_CDC (TUSB_CFG_DEVICE_CDC ? 2 : 0) -#if TUSB_CFG_DEVICE_HID_KEYBOARD - #define INTERFACES_OF_HID_KEYBOARD 1 -#else - #define INTERFACES_OF_HID_KEYBOARD 0 -#endif - -#if TUSB_CFG_DEVICE_HID_MOUSE - #define INTERFACES_OF_HID_MOUSE 1 -#else - #define INTERFACES_OF_HID_MOUSE 0 -#endif - -#if TUSB_CFG_HOST_HID_GENERIC - #define INTERFACES_OF_HID_GENERIC 1 -#else - #define INTERFACES_OF_HID_GENERIC 0 -#endif +#define INTERFACES_OF_HID_KEYBOARD (TUSB_CFG_DEVICE_HID_KEYBOARD ? 1 : 0) +#define INTERFACES_OF_HID_MOUSE (TUSB_CFG_DEVICE_HID_MOUSE ? 1 : 0) +#define INTERFACES_OF_HID_GENERIC (TUSB_CFG_DEVICE_HID_GENERIC ? 1 : 0) #if CFG_USB_MASS_STORAGE #define INTERFACES_OF_MASS_STORAGE 2 @@ -181,7 +149,6 @@ extern app_descriptor_configuration_t app_tusb_desc_configuration; extern app_descriptor_string_t app_tusb_desc_strings; extern uint8_t app_tusb_keyboard_desc_report[]; - -//extern const uint8_t HID_MouseReportDescriptor[]; +extern uint8_t app_tusb_mouse_desc_report[]; #endif diff --git a/tests/test/device/usbd/test_usbd.c b/tests/test/device/usbd/test_usbd.c index 66010375f..5e2282344 100644 --- a/tests/test/device/usbd/test_usbd.c +++ b/tests/test/device/usbd/test_usbd.c @@ -64,10 +64,34 @@ void test_dcd_init_failed(void) TEST_ASSERT_EQUAL( TUSB_ERROR_FAILED, usbd_init() ); } +tusb_error_t stub_hidd_init(tusb_descriptor_interface_t const* p_interface_desc, uint16_t* p_length, int num_call) +{ + switch(num_call) + { + case 0: + TEST_ASSERT_EQUAL_HEX32(&app_tusb_desc_configuration.keyboard_interface, p_interface_desc); + break; + + case 1: + TEST_ASSERT_EQUAL_HEX32(&app_tusb_desc_configuration.mouse_interface, p_interface_desc); + break; + + case 2: + break; + + default: + TEST_FAIL(); + return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE; + } + + return TUSB_ERROR_NONE; +} + void test_usbd_init_ok(void) { dcd_init_ExpectAndReturn(TUSB_ERROR_NONE); - hidd_init_ExpectAndReturn(&app_tusb_desc_configuration.keyboard_interface, TUSB_ERROR_NONE); + + hidd_init_StubWithCallback(stub_hidd_init); dcd_controller_connect_Expect(0); diff --git a/tests/test/support/tusb_config.h b/tests/test/support/tusb_config.h index 7498c717e..6edd59800 100644 --- a/tests/test/support/tusb_config.h +++ b/tests/test/support/tusb_config.h @@ -97,10 +97,10 @@ //------------- CLASS -------------// #define TUSB_CFG_DEVICE_HID_KEYBOARD 1 -#define TUSB_CFG_DEVICE_HID_MOUSE 0 +#define TUSB_CFG_DEVICE_HID_MOUSE 1 #define TUSB_CFG_DEVICE_HID_GENERIC 0 #define TUSB_CFG_DEVICE_MSC 0 -//#define TUSB_CFG_DEVICE_CDC +#define TUSB_CFG_DEVICE_CDC 0 //--------------------------------------------------------------------+ // COMMON CONFIGURATION diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c index 97e81627d..6d4d46fc9 100644 --- a/tinyusb/class/hid_device.c +++ b/tinyusb/class/hid_device.c @@ -58,6 +58,7 @@ static volatile bool bKeyChanged = false; #endif #if TUSB_CFG_DEVICE_HID_MOUSE +TUSB_CFG_ATTR_USBRAM uint8_t hidd_mouse_buffer[1024]; // TODO memory reduce TUSB_CFG_ATTR_USBRAM tusb_mouse_report_t hid_mouse_report; static volatile bool bMouseChanged = false; #endif @@ -81,7 +82,7 @@ ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event); //--------------------------------------------------------------------+ // CLASS-USBH API (don't require to verify parameters) //--------------------------------------------------------------------+ -tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc) +tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length) { uint8_t const *p_desc = (uint8_t const *) p_interface_desc; @@ -90,9 +91,37 @@ tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc) tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc; ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE); - ASSERT_STATUS( hidd_interface_init(p_interface_desc, - app_tusb_keyboard_desc_report, p_desc_hid->wReportLength, - hidd_keyboard_buffer , sizeof(hidd_keyboard_buffer)) ); + if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT) + { + switch(p_interface_desc->bInterfaceProtocol) + { + #if TUSB_CFG_DEVICE_HID_KEYBOARD + case HID_PROTOCOL_KEYBOARD: + ASSERT_STATUS( hidd_interface_init(p_interface_desc, + app_tusb_keyboard_desc_report, p_desc_hid->wReportLength, + hidd_keyboard_buffer , sizeof(hidd_keyboard_buffer)) ); + break; + #endif + + #if TUSB_CFG_DEVICE_HID_MOUSE + case HID_PROTOCOL_MOUSE: + ASSERT_STATUS( hidd_interface_init(p_interface_desc, + app_tusb_mouse_desc_report, p_desc_hid->wReportLength, + hidd_mouse_buffer , sizeof(hidd_mouse_buffer)) ); + break; + #endif + + default: // TODO unknown, unsupported protocol --> skip this interface + return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE; + } + *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t); + }else + { + // open generic + *p_length = 0; + return TUSB_ERROR_HIDD_DESCRIPTOR_INTERFACE; + } + return TUSB_ERROR_NONE; } diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h index 4dde81ab0..d3a87fb84 100644 --- a/tinyusb/class/hid_device.h +++ b/tinyusb/class/hid_device.h @@ -66,7 +66,7 @@ tusb_error_t tusbd_hid_mouse_send_report(uint8_t buttons, int8_t x, int8_t y); #ifdef _TINY_USB_SOURCE_FILE_ #include "device/romdriver/mw_usbd_rom_api.h" // TODO remove rom driver dependency -tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc); +tusb_error_t hidd_init(tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length); tusb_error_t hidd_configured(USBD_HANDLE_T hUsb); #endif diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index 4ba1556dd..b109430af 100644 --- a/tinyusb/class/hid_host.c +++ b/tinyusb/class/hid_host.c @@ -238,7 +238,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con break; #endif - default: // unknown protocol --> skip this interface + default: // TODO unknown, unsupported protocol --> skip this interface return TUSB_ERROR_NONE; } *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t); diff --git a/tinyusb/core/std_descriptors.h b/tinyusb/core/std_descriptors.h index 4cef29746..854bbe06f 100644 --- a/tinyusb/core/std_descriptors.h +++ b/tinyusb/core/std_descriptors.h @@ -53,6 +53,8 @@ extern "C" { #endif +#define STRING_LEN_BYTE2UNICODE(n) (2 + ((n)<<1)) + //--------------------------------------------------------------------+ // STANDARD DESCRIPTORS //--------------------------------------------------------------------+ @@ -177,6 +179,12 @@ typedef ATTR_PREPACKED struct ATTR_PACKED uint8_t bDescriptorType ; ///< Descriptor Type } tusb_descriptor_header_t; +//typedef ATTR_PACKED_STRUCT(struct) +//{ +// uint8_t bLength ; ///< Size of this descriptor in bytes +// uint8_t bDescriptorType ; ///< Descriptor Type +// uint16_t unicode_string[]; +//} tusb_descriptor_string_t; #ifdef __cplusplus } diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c index 4406b911c..3b36b649f 100644 --- a/tinyusb/device/dcd.c +++ b/tinyusb/device/dcd.c @@ -90,7 +90,7 @@ tusb_error_t dcd_init(uint8_t coreid) USBD_API_INIT_PARAM_T usb_param = { - .usb_reg_base = DEVICE_ROM_REG_BASE, + .usb_reg_base = NXP_ROMDRIVER_REG_BASE, .max_num_ep = USB_MAX_EP_NUM, .mem_base = membase, .mem_size = memsize, diff --git a/tinyusb/device/dcd_lpc11uxx_lpc13xx.h b/tinyusb/device/dcd_lpc11uxx_lpc13xx.h index ce7fc90ea..aac9cf58f 100644 --- a/tinyusb/device/dcd_lpc11uxx_lpc13xx.h +++ b/tinyusb/device/dcd_lpc11uxx_lpc13xx.h @@ -46,8 +46,8 @@ #ifndef _TUSB_DCD_LPC11UXX_LPC13XX_H_ #define _TUSB_DCD_LPC11UXX_LPC13XX_H_ -#define DEVICE_ROM_REG_BASE LPC_USB_BASE -#define DEVICE_ROM_DRIVER_ADDR 0x1FFF1FF8 +#define NXP_ROMDRIVER_REG_BASE LPC_USB_BASE +#define NXP_ROMDRIVER_FUNCTION_ADDR 0x1FFF1FF8 #ifdef __cplusplus extern "C" { diff --git a/tinyusb/device/dcd_lpc18xx_lpc43xx.h b/tinyusb/device/dcd_lpc18xx_lpc43xx.h index a98196f6a..e7bdfad7c 100644 --- a/tinyusb/device/dcd_lpc18xx_lpc43xx.h +++ b/tinyusb/device/dcd_lpc18xx_lpc43xx.h @@ -50,8 +50,8 @@ extern "C" { #endif -#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1 -#define DEVICE_ROM_DRIVER_ADDR 0x1040011C +#define NXP_ROMDRIVER_REG_BASE LPC_USB0_BASE // TODO USB1 +#define NXP_ROMDRIVER_FUNCTION_ADDR 0x1040011C #ifdef __cplusplus } diff --git a/tinyusb/device/dcd_nxp_romdriver.c b/tinyusb/device/dcd_nxp_romdriver.c index 5c0e4d847..fb3084953 100644 --- a/tinyusb/device/dcd_nxp_romdriver.c +++ b/tinyusb/device/dcd_nxp_romdriver.c @@ -60,12 +60,6 @@ typedef struct { usbd_info_t usbd_info; // TODO rename -typedef struct { - void (* const init) (void); - void (* const configured) (void); - void (* const unmounted) (void); -}device_class_driver_t; - //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ @@ -91,7 +85,7 @@ ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb) ASSERT( TUSB_ERROR_NONE == hidd_configured(hUsb), ERR_FAILED ); #endif - #ifdef TUSB_CFG_DEVICE_CDC + #if TUSB_CFG_DEVICE_CDC ASSERT( TUSB_ERROR_NONE == tusb_cdc_configured(hUsb), ERR_FAILED ); #endif } @@ -123,7 +117,7 @@ tusb_error_t dcd_init(void) USBD_API_INIT_PARAM_T usb_param = { - .usb_reg_base = DEVICE_ROM_REG_BASE, + .usb_reg_base = NXP_ROMDRIVER_REG_BASE, .max_num_ep = USB_MAX_EP_NUM, .mem_base = membase, .mem_size = memsize, @@ -150,12 +144,6 @@ tusb_error_t dcd_init(void) membase += (memsize - usb_param.mem_size); memsize = usb_param.mem_size; - #if TUSB_CFG_DEVICE_HID_MOUSE - ASSERT_STATUS( tusb_hid_init(romdriver_hdl , &USB_FsConfigDescriptor.HID_MouseInterface , - HID_MouseReportDescriptor, USB_FsConfigDescriptor.HID_MouseHID.DescriptorList[0].wDescriptorLength, - &membase , &memsize) ); - #endif - return TUSB_ERROR_NONE; } diff --git a/tinyusb/device/dcd_nxp_romdriver.h b/tinyusb/device/dcd_nxp_romdriver.h index fb3540d49..4143805e7 100644 --- a/tinyusb/device/dcd_nxp_romdriver.h +++ b/tinyusb/device/dcd_nxp_romdriver.h @@ -55,10 +55,10 @@ #if (MCU == MCU_LPC18XX) || (MCU == MCU_LPC43XX) #include "dcd_lpc18xx_lpc43xx.h" - #define ROM_API ( * ((USBD_API_T**) DEVICE_ROM_DRIVER_ADDR) ) + #define ROM_API ( * ((USBD_API_T**) NXP_ROMDRIVER_FUNCTION_ADDR) ) #elif (MCU == MCU_LPC13UXX) || (MCU == MCU_LPC11UXX) #include "dcd_lpc11uxx_lpc13xx.h" - #define ROM_API ( * (*((USBD_API_T***) DEVICE_ROM_DRIVER_ADDR)) ) + #define ROM_API ( * (*((USBD_API_T***) NXP_ROMDRIVER_FUNCTION_ADDR)) ) #else #error forgot something, thach ? #endif diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 594112c88..160302d99 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -56,7 +56,15 @@ // //}; - +// TODO fix/compress number of class driver +static device_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] = +{ +#if DEVICE_CLASS_HID + [TUSB_CLASS_HID] = { + .init = hidd_init, + }, +#endif +}; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION @@ -80,8 +88,14 @@ tusb_error_t usbd_init (void) ASSERT_STATUS ( dcd_init() ); + uint16_t length = 0; + #if TUSB_CFG_DEVICE_HID_KEYBOARD - ASSERT_STATUS( hidd_init(&app_tusb_desc_configuration.keyboard_interface) ); + ASSERT_STATUS( hidd_init(&app_tusb_desc_configuration.keyboard_interface, &length) ); + #endif + + #if TUSB_CFG_DEVICE_HID_MOUSE + ASSERT_STATUS( hidd_init(&app_tusb_desc_configuration.mouse_interface, &length) ); #endif #ifndef _TEST_ @@ -100,13 +114,13 @@ tusb_error_t usbd_init (void) //--------------------------------------------------------------------+ static tusb_error_t usbd_string_descriptor_init(void) { - ASSERT_INT( USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1), + ASSERT_INT( STRING_LEN_BYTE2UNICODE(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1), app_tusb_desc_strings.manufacturer.bLength, TUSB_ERROR_USBD_DESCRIPTOR_STRING); - ASSERT_INT( USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1) , + ASSERT_INT( STRING_LEN_BYTE2UNICODE(sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1) , app_tusb_desc_strings.product.bLength , TUSB_ERROR_USBD_DESCRIPTOR_STRING); - ASSERT_INT( USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1) , + ASSERT_INT( STRING_LEN_BYTE2UNICODE(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1) , app_tusb_desc_strings.serial.bLength , TUSB_ERROR_USBD_DESCRIPTOR_STRING); for(uint32_t i=0; i < sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1; i++) diff --git a/tinyusb/device/usbd.h b/tinyusb/device/usbd.h index 364dba8af..8da6da229 100644 --- a/tinyusb/device/usbd.h +++ b/tinyusb/device/usbd.h @@ -61,6 +61,11 @@ //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ +typedef struct { + tusb_error_t (* const init)(tusb_descriptor_interface_t const *, uint16_t*); +// void (* const isr) (pipe_handle_t, tusb_event_t); +// void (* const close) (uint8_t); +} device_class_driver_t; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION