diff options
| author | hathach <[email protected]> | 2013-11-13 14:00:39 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-11-13 14:00:39 +0700 |
| commit | 7d84139bd4e69e0b4cb42fb638a7a6d52afe93de (patch) | |
| tree | 66247225ca9ced6cf01b3e5135a53ab0625f307a /tinyusb/device/dcd.c | |
| parent | 92d9c36dbcfd933f872c91ad061e2e5ab184b020 (diff) | |
fix potential issue with stall endpoints
NOTE: cannot able to STALL control OUT endpoints --> unsupported with data out request may got to an issue.
clean up configure, add max string descriptor configure as windows sometimes ask for string @ index 238 !!!
Diffstat (limited to 'tinyusb/device/dcd.c')
| -rw-r--r-- | tinyusb/device/dcd.c | 113 |
1 files changed, 1 insertions, 112 deletions
diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c index dfc0947b6..9ff5803b0 100644 --- a/tinyusb/device/dcd.c +++ b/tinyusb/device/dcd.c @@ -38,118 +38,7 @@ #include "dcd.h" -#if 0 +#if MODE_DEVICE_SUPPORTED -#include "descriptors.h" // TODO refractor later - -#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 romdriver_hdl; -static volatile bool isConfigured = false; - -/**************************************************************************/ -/*! - @brief Handler for the USB Configure Event -*/ -/**************************************************************************/ -ErrorCode_t USB_Configure_Event (USBD_HANDLE_T hUsb) -{ - USB_CORE_CTRL_T* pCtrl = (USB_CORE_CTRL_T*)hUsb; - if (pCtrl->config_value) - { - #if defined(DEVICE_CLASS_HID) - ASSERT( TUSB_ERROR_NONE == tusb_hid_configured(hUsb), ERR_FAILED ); - #endif - - #ifdef TUSB_CFG_DEVICE_CDC - ASSERT( TUSB_ERROR_NONE == tusb_cdc_configured(hUsb), ERR_FAILED ); - #endif - } - - isConfigured = true; - - return LPC_OK; -} - -/**************************************************************************/ -/*! - @brief Handler for the USB Reset Event -*/ -/**************************************************************************/ -ErrorCode_t USB_Reset_Event (USBD_HANDLE_T hUsb) -{ - isConfigured = false; - return LPC_OK; -} - -tusb_error_t dcd_init(uint8_t coreid) -{ -#ifdef DEVICE_ROMDRIVER // TODO refractor later - /* ROM DRIVER INIT */ - uint32_t membase = (uint32_t) usb_RomDriver_buffer; - uint32_t memsize = USB_ROM_SIZE; - - USBD_API_INIT_PARAM_T usb_param = - { - .usb_reg_base = NXP_ROMDRIVER_REG_BASE, - .max_num_ep = USB_MAX_EP_NUM, - .mem_base = membase, - .mem_size = memsize, - - .USB_Configure_Event = USB_Configure_Event, - .USB_Reset_Event = USB_Reset_Event - }; - - USB_CORE_DESCS_T DeviceDes = - { - .device_desc = (uint8_t*) &USB_DeviceDescriptor, - .string_desc = (uint8_t*) &USB_StringDescriptor, - .full_speed_desc = (uint8_t*) &USB_FsConfigDescriptor, - .high_speed_desc = (uint8_t*) &USB_FsConfigDescriptor, - .device_qualifier = NULL - }; - - /* USB hardware core initialization */ - ASSERT(LPC_OK == ROM_API->hw->Init(&romdriver_hdl, &DeviceDes, &usb_param), TUSB_ERROR_FAILED); - - membase += (memsize - usb_param.mem_size); - memsize = usb_param.mem_size; - - /* Initialise the class driver(s) */ - #ifdef TUSB_CFG_DEVICE_CDC - ASSERT_STATUS( tusb_cdc_init(romdriver_hdl, &USB_FsConfigDescriptor.CDC_CCI_Interface, - &USB_FsConfigDescriptor.CDC_DCI_Interface, &membase, &memsize) ); - #endif - - #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD - ASSERT_STATUS( tusb_hid_init(romdriver_hdl , &USB_FsConfigDescriptor.HID_KeyboardInterface , - HID_KeyboardReportDescriptor, USB_FsConfigDescriptor.HID_KeyboardHID.DescriptorList[0].wDescriptorLength, - &membase , &memsize) ); - #endif - - #ifdef 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 - - hal_interrupt_enable(); /* Enable the USB interrupt */ - - /* Perform USB soft connect */ - ROM_API->hw->Connect(romdriver_hdl, 1); -#endif - - return TUSB_ERROR_NONE; -} - -/**************************************************************************/ -/*! - @brief Indicates whether USB is configured or not -*/ -/**************************************************************************/ -bool usb_isConfigured(void) -{ - return isConfigured; -} #endif |
