diff options
| author | hathach <[email protected]> | 2013-06-03 14:31:17 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-06-03 14:31:17 +0700 |
| commit | b527e6ec4a9d0b6ecad5a6ce74b27458d1cd24be (patch) | |
| tree | 2d7c009e15d1fd73d9df62217c9e4a748ebe026f /tinyusb/device | |
| parent | 7d78fc1baf24c537ea7386f698e1e20ed80f16ba (diff) | |
refractor tusb_descriptors
usbd device_class_driver
added & tested HID mouse for device (work together with hid keyboard)
rename DEVICE_ROM_REG_BASE, DEVICE_ROM_DRIVER_ADDR
Diffstat (limited to 'tinyusb/device')
| -rw-r--r-- | tinyusb/device/dcd.c | 2 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc11uxx_lpc13xx.h | 4 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc18xx_lpc43xx.h | 4 | ||||
| -rw-r--r-- | tinyusb/device/dcd_nxp_romdriver.c | 16 | ||||
| -rw-r--r-- | tinyusb/device/dcd_nxp_romdriver.h | 4 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 24 | ||||
| -rw-r--r-- | tinyusb/device/usbd.h | 5 |
7 files changed, 33 insertions, 26 deletions
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 |
