diff options
| author | hathach <[email protected]> | 2013-05-29 14:39:14 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-05-29 14:39:14 +0700 |
| commit | dda0808ebb5ca8cba6c9440c61bb5205b0a62b08 (patch) | |
| tree | bb270d96b6e7345bd0506e1c432412414ed67271 /tinyusb/device | |
| parent | 1e5bd82af28c6005fa0ecf008e44322a6ee46461 (diff) | |
fix lpcxpresso1347 board_leds
temp change USBD_API to ROM_API
add lpc13xx device support
fix romdriver pointer
able to init rom driver
Diffstat (limited to 'tinyusb/device')
| -rw-r--r-- | tinyusb/device/dcd.c | 6 | ||||
| -rw-r--r-- | tinyusb/device/dcd.h | 3 | ||||
| -rw-r--r-- | tinyusb/device/dcd_nxp_romdriver.c | 34 | ||||
| -rw-r--r-- | tinyusb/device/dcd_nxp_romdriver.h | 2 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 10 |
5 files changed, 34 insertions, 21 deletions
diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c index c0115c4e5..638ecdfe9 100644 --- a/tinyusb/device/dcd.c +++ b/tinyusb/device/dcd.c @@ -37,7 +37,7 @@ #include "dcd.h" -#ifdef TUSB_CFG_DEVICE +#if 0 #include "descriptors.h" // TODO refractor later @@ -109,7 +109,7 @@ tusb_error_t dcd_init(uint8_t coreid) }; /* USB hardware core initialization */ - ASSERT(LPC_OK == USBD_API->hw->Init(&g_hUsb, &DeviceDes, &usb_param), TUSB_ERROR_FAILED); + ASSERT(LPC_OK == ROM_API->hw->Init(&g_hUsb, &DeviceDes, &usb_param), TUSB_ERROR_FAILED); membase += (memsize - usb_param.mem_size); memsize = usb_param.mem_size; @@ -135,7 +135,7 @@ tusb_error_t dcd_init(uint8_t coreid) hal_interrupt_enable(); /* Enable the USB interrupt */ /* Perform USB soft connect */ - USBD_API->hw->Connect(g_hUsb, 1); + ROM_API->hw->Connect(g_hUsb, 1); #endif return TUSB_ERROR_NONE; diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h index be139b713..c4b98d990 100644 --- a/tinyusb/device/dcd.h +++ b/tinyusb/device/dcd.h @@ -56,6 +56,9 @@ #endif #include "common/common.h" +#include "dcd_nxp_romdriver.h" + +#define ROM_API ( * (*((USBD_API_T***) 0x1FFF1FF8)) ) // TODO remove rom API dependency tusb_error_t dcd_init(void) ATTR_WARN_UNUSED_RESULT; tusb_error_t dcd_controller_reset(uint8_t coreid) ATTR_WARN_UNUSED_RESULT; diff --git a/tinyusb/device/dcd_nxp_romdriver.c b/tinyusb/device/dcd_nxp_romdriver.c index 8587a66f3..34dfa5e35 100644 --- a/tinyusb/device/dcd_nxp_romdriver.c +++ b/tinyusb/device/dcd_nxp_romdriver.c @@ -51,11 +51,23 @@ #include "tusb_descriptors.h" -#define USBD_API ((USBD_API_T*) DEVICE_ROM_DRIVER_ADDR) + #define USB_ROM_SIZE (1024*2) // TODO dcd abstract later uint8_t usb_RomDriver_buffer[USB_ROM_SIZE] ATTR_ALIGNED(2048) TUSB_CFG_ATTR_USBRAM; USBD_HANDLE_T g_hUsb; +typedef struct { + volatile uint8_t state; +}usbd_info_t; // TODO rename + +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 //--------------------------------------------------------------------+ @@ -74,10 +86,10 @@ ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb) USB_CORE_CTRL_T* pCtrl = (USB_CORE_CTRL_T*)hUsb; if (pCtrl->config_value) { -// usbd_info.state = TUSB_DEVICE_STATE_CONFIGURED; + usbd_info.state = TUSB_DEVICE_STATE_CONFIGURED; #if defined(DEVICE_CLASS_HID) -// ASSERT( TUSB_ERROR_NONE == tusb_hid_configured(hUsb), ERR_FAILED ); + ASSERT( TUSB_ERROR_NONE == hidd_configured(hUsb), ERR_FAILED ); #endif #ifdef TUSB_CFG_DEVICE_CDC @@ -91,7 +103,7 @@ ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb) ErrorCode_t USB_Reset_Event (USBD_HANDLE_T hUsb) { -// usbd_info.state = TUSB_DEVICE_STATE_UNPLUG; + usbd_info.state = TUSB_DEVICE_STATE_UNPLUG; return LPC_OK; } @@ -122,7 +134,7 @@ tusb_error_t dcd_init(void) }; /* USB hardware core initialization */ - ASSERT(LPC_OK == USBD_API->hw->Init(&g_hUsb, &desc_core, &usb_param), TUSB_ERROR_FAILED); + ASSERT_INT(LPC_OK, ROM_API->hw->Init(&g_hUsb, &desc_core, &usb_param), TUSB_ERROR_FAILED); // TODO need to confirm the mem_size is reduced by the number of byte used membase += (memsize - usb_param.mem_size); @@ -130,7 +142,7 @@ tusb_error_t dcd_init(void) #if TUSB_CFG_DEVICE_HID_KEYBOARD - ASSERT_STATUS( tusb_hid_init(g_hUsb , &app_desc_configuration.keyboard_interface, + ASSERT_STATUS( hidd_init(g_hUsb , &app_desc_configuration.keyboard_interface, keyboard_report_descriptor, app_desc_configuration.keyboard_hid.wReportLength, &membase , &memsize) ); #endif @@ -141,10 +153,16 @@ tusb_error_t dcd_init(void) &membase , &memsize) ); #endif + ROM_API->hw->Connect(g_hUsb, 1); return TUSB_ERROR_NONE; } +bool usb_isConfigured(void) +{ + return usbd_info.state == TUSB_DEVICE_STATE_CONFIGURED; +} + tusb_error_t dcd_controller_reset(uint8_t coreid) { //TODO merge with hcd_controller_reset @@ -154,12 +172,12 @@ tusb_error_t dcd_controller_reset(uint8_t coreid) void dcd_controller_connect(uint8_t coreid) { -// USBD_API->hw->Connect(g_hUsb, 1); +// ROM_API->hw->Connect(g_hUsb, 1); } void dcd_isr(uint8_t coreid) { -// USBD_API->hw->ISR(g_hUsb); +// ROM_API->hw->ISR(g_hUsb); } #endif diff --git a/tinyusb/device/dcd_nxp_romdriver.h b/tinyusb/device/dcd_nxp_romdriver.h index c185bab07..616240151 100644 --- a/tinyusb/device/dcd_nxp_romdriver.h +++ b/tinyusb/device/dcd_nxp_romdriver.h @@ -54,6 +54,8 @@ #if (MCU == MCU_LPC18XX) || (MCU == MCU_LPC43XX) #include "dcd_lpc18xx_lpc43xx.h" +#elif (MCU == MCU_LPC13UXX) + #include "dcd_lpc13xx.h" #else #error forgot something, thach ? #endif diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index cbbc28995..efcf29ced 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -54,17 +54,7 @@ // volatile uint8_t state; // //}; -typedef struct { - volatile uint8_t state; -}usbd_info_t; // TODO rename -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; //--------------------------------------------------------------------+ |
