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 | |
| 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')
| -rw-r--r-- | tinyusb/class/hid_device.c | 70 | ||||
| -rw-r--r-- | tinyusb/common/common.h | 2 | ||||
| -rw-r--r-- | tinyusb/device/dcd.c | 113 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc_11uxx_13uxx.c | 14 | ||||
| -rw-r--r-- | tinyusb/device/dcd_nxp_romdriver.c | 170 | ||||
| -rw-r--r-- | tinyusb/device/dcd_nxp_romdriver.h | 78 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 2 | ||||
| -rw-r--r-- | tinyusb/tusb_option.h | 5 |
8 files changed, 19 insertions, 435 deletions
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c index 40a46cd03..53efdb59d 100644 --- a/tinyusb/class/hid_device.c +++ b/tinyusb/class/hid_device.c @@ -51,14 +51,14 @@ //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ +ATTR_USB_MIN_ALIGNMENT uint8_t set_report[ MAX_OF(sizeof(hid_keyboard_report_t), sizeof(hid_mouse_report_t)) ]; + typedef struct { uint8_t const * p_report_desc; uint16_t report_length; endpoint_handle_t ept_handle; uint8_t interface_number; - - hid_keyboard_report_t report; // need to be in usb ram }hidd_interface_t; @@ -170,7 +170,7 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * hid_request_report_type_t report_type = u16_high_u8(p_request->wValue); uint8_t report_id = u16_low_u8(p_request->wValue); - dcd_pipe_control_xfer(coreid, TUSB_DIR_HOST_TO_DEV, &p_hid->report, p_request->wLength); + dcd_pipe_control_xfer(coreid, TUSB_DIR_HOST_TO_DEV, &set_report, p_request->wLength); } break; @@ -260,9 +260,7 @@ void hidd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_b #endif } -#if defined(CAP_DEVICE_ROMDRIVER) && TUSB_CFG_DEVICE_USE_ROM_DRIVER -#include "device/dcd_nxp_romdriver.h" // TODO remove rom driver dependency - +#if defined(CAP_DEVICE_ROMDRIVER) //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF @@ -280,18 +278,6 @@ static volatile bool bMouseChanged = false; #endif //--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -static tusb_error_t hidd_interface_init(tusb_descriptor_interface_t const *p_interface_desc, uint8_t const * const p_report_desc, - uint32_t report_length, uint8_t* mem_base, uint32_t mem_size); - -ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* plength); -ErrorCode_t HID_SetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length); -ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event); -ErrorCode_t HID_EpOut_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event); - - -//--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ #if TUSB_CFG_DEVICE_HID_KEYBOARD @@ -339,54 +325,6 @@ tusb_error_t tusbd_hid_mouse_send_report(hid_mouse_report_t *p_mouse_report) #endif //--------------------------------------------------------------------+ -// CLASS-USBH API (don't require to verify parameters) -//--------------------------------------------------------------------+ -tusb_error_t hidd_configured(void) -{ - #if TUSB_CFG_DEVICE_HID_KEYBOARD - ROM_API->hw->WriteEP(romdriver_hdl , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(hid_keyboard_report_t) ); // initial packet for IN endpoint , will not work if omitted - #endif - - #if TUSB_CFG_DEVICE_HID_MOUSE - ROM_API->hw->WriteEP(romdriver_hdl , HID_MOUSE_EP_IN , (uint8_t* ) &hid_mouse_report , sizeof(hid_mouse_report_t) ); // initial packet for IN endpoint, will not work if omitted - #endif - - return TUSB_ERROR_NONE; -} - - -tusb_error_t hidd_interface_init(tusb_descriptor_interface_t const *p_interface_desc, uint8_t const * const p_report_desc, - uint32_t report_length, uint8_t* mem_base, uint32_t mem_size) -{ - USB_HID_REPORT_T reports_data = - { - .desc = (uint8_t*) p_report_desc, - .len = report_length, - .idle_time = 0, - }; - - USBD_HID_INIT_PARAM_T hid_param = - { - .mem_base = (uint32_t) mem_base, - .mem_size = mem_size, - - .intf_desc = (uint8_t*)p_interface_desc, - .report_data = &reports_data, - .max_reports = 1, - - /* user defined functions */ - .HID_GetReport = HID_GetReport, - .HID_SetReport = HID_SetReport, - .HID_EpIn_Hdlr = HID_EpIn_Hdlr, - .HID_EpOut_Hdlr = HID_EpOut_Hdlr - }; - - ASSERT( LPC_OK == ROM_API->hid->init(romdriver_hdl, &hid_param), TUSB_ERROR_FAILED ); - - return TUSB_ERROR_NONE; -} - -//--------------------------------------------------------------------+ // IMPLEMENTATION //--------------------------------------------------------------------+ ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* plength) diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index 82b64576c..4ea40b0e2 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -92,6 +92,8 @@ #define STRING_CONCAT_(a, b) a##b // concat without expand #define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat +#define MAX_OF(a, b) ( (a) > (b) ? (a) : (b) ) + #define U16_HIGH_U8(u16) ((uint8_t) (((u16) >> 8) & 0x00ff)) #define U16_LOW_U8(u16) ((uint8_t) ((u16) & 0x00ff)) #define U16_TO_U8S_BE(u16) U16_HIGH_U8(u16), U16_LOW_U8(u16) 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 diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c index 73d2f759a..e4ea615ff 100644 --- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c @@ -234,6 +234,10 @@ void dcd_isr(uint8_t coreid) { // received control request from host
// copy setup request & acknowledge so that the next setup can be received by hw
tusb_control_request_t control_request = dcd_data.setup_request;
+
+ // NXP control flowchart clear Active & Stall on both Control IN/OUT endpoints
+ dcd_data.qhd[0][0].stall = dcd_data.qhd[1][0].stall = 0;
+
LPC_USB->DEVCMDSTAT |= CMDSTAT_MASK_SETUP_RECEIVED;
dcd_data.qhd[0][1].buff_addr_offset = addr_offset(&dcd_data.setup_request);
@@ -264,9 +268,10 @@ void dcd_isr(uint8_t coreid) // CONTROL PIPE API
//--------------------------------------------------------------------+
void dcd_pipe_control_stall(uint8_t coreid)
-{ // only need to stall IN Control endpoint
+{ // TODO cannot able to STALL Control OUT endpoint !!!!!
(void) coreid;
- dcd_data.qhd[1][0].stall = 1;
+
+ dcd_data.qhd[0][0].stall = dcd_data.qhd[1][0].stall = 1;
}
// control transfer does not need to use qtd find function
@@ -338,8 +343,9 @@ tusb_error_t dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr) {
uint8_t ep_id = edpt_addr2phy(edpt_addr);
- dcd_data.qhd[ep_id][0].stall = 0;
- dcd_data.qhd[ep_id][0].toggle_reset = 1;
+ dcd_data.qhd[ep_id][0].stall = 0;
+ dcd_data.qhd[ep_id][0].toggle_reset = 1;
+ dcd_data.qhd[ep_id][0].feedback_toggle = 0;
return TUSB_ERROR_NONE;
}
diff --git a/tinyusb/device/dcd_nxp_romdriver.c b/tinyusb/device/dcd_nxp_romdriver.c deleted file mode 100644 index ccb69cf3c..000000000 --- a/tinyusb/device/dcd_nxp_romdriver.c +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************/ -/*! - @file dcd_nxp_romdriver.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "tusb_option.h" - -#if MODE_DEVICE_SUPPORTED && (defined(CAP_DEVICE_ROMDRIVER) && TUSB_CFG_DEVICE_USE_ROM_DRIVER) - -#define _TINY_USB_SOURCE_FILE_ - -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#include "dcd.h" -#include "dcd_nxp_romdriver.h" -#include "tusb_descriptors.h" - -#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; - -typedef struct { - volatile uint8_t state; -}usbd_info_t; // TODO rename - -usbd_info_t usbd_info; // TODO rename - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ - - -//--------------------------------------------------------------------+ -// IMPLEMENTATION -//--------------------------------------------------------------------+ -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; - - #if DEVICE_CLASS_HID - ASSERT( TUSB_ERROR_NONE == hidd_configured(), ERR_FAILED ); - #endif - - #if TUSB_CFG_DEVICE_CDC - ASSERT( TUSB_ERROR_NONE == tusb_cdc_configured(hUsb), ERR_FAILED ); - #endif - } - - return LPC_OK; -} - -ErrorCode_t USB_Reset_Event (USBD_HANDLE_T hUsb) -{ - usbd_info.state = TUSB_DEVICE_STATE_UNPLUG; - return LPC_OK; -} - -ErrorCode_t USB_Interface_Event (USBD_HANDLE_T hUsb) -{ - return LPC_OK; -} - -ErrorCode_t USB_Error_Event (USBD_HANDLE_T hUsb, uint32_t param1) -{ - (void) param1; - return LPC_OK; -} - -tusb_error_t dcd_init(void) -{ - USBD_API_INIT_PARAM_T usb_param = - { - .usb_reg_base = NXP_ROMDRIVER_REG_BASE, - .max_num_ep = USB_MAX_EP_NUM, - .mem_base = (uint32_t) usb_RomDriver_buffer, - .mem_size = USB_ROM_SIZE, - - .USB_Configure_Event = USB_Configure_Event, - .USB_Reset_Event = USB_Reset_Event, - .USB_Error_Event = USB_Error_Event, - .USB_Interface_Event = USB_Interface_Event - }; - - USB_CORE_DESCS_T desc_core = - { - .device_desc = (uint8_t*) &app_tusb_desc_device, - .string_desc = (uint8_t*) &app_tusb_desc_strings, - .full_speed_desc = (uint8_t*) &app_tusb_desc_configuration, - .high_speed_desc = (uint8_t*) &app_tusb_desc_configuration, - .device_qualifier = NULL - }; - - /* USB hardware core initialization */ - ASSERT_INT(LPC_OK, ROM_API->hw->Init(&romdriver_hdl, &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); -// memsize = usb_param.mem_size; - - return TUSB_ERROR_NONE; -} - -bool tusb_device_is_configured(void) -{ - return usbd_info.state == TUSB_DEVICE_STATE_CONFIGURED; -} - -tusb_error_t dcd_controller_reset(uint8_t coreid) -{ -//TODO merge with hcd_controller_reset -// default mode is device ? - return TUSB_ERROR_NONE; -} - -void dcd_controller_connect(uint8_t coreid) -{ - ROM_API->hw->Connect(romdriver_hdl, 1); -} - -void dcd_isr(uint8_t coreid) -{ - ROM_API->hw->ISR(romdriver_hdl); -} - -#endif - diff --git a/tinyusb/device/dcd_nxp_romdriver.h b/tinyusb/device/dcd_nxp_romdriver.h deleted file mode 100644 index f6f12686a..000000000 --- a/tinyusb/device/dcd_nxp_romdriver.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************/ -/*! - @file dcd_nxp_romdriver.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -/** \ingroup TBD - * \defgroup TBD - * \brief TBD - * - * @{ - */ - -#ifndef _TUSB_DCD_NXP_ROMDRIVER_H_ -#define _TUSB_DCD_NXP_ROMDRIVER_H_ - -#include "common/common.h" - -#ifdef __cplusplus - extern "C" { -#endif - - -#define USB_MAX_IF_NUM 8 // maximum interface number supported, should be fixed to 8 - -#if (MCU == MCU_LPC18XX) || (MCU == MCU_LPC43XX) - #define ROM_API ( * ((USBD_API_T**) NXP_ROMDRIVER_FUNCTION_ADDR) ) - #define USB_MAX_EP_NUM 6 -#elif (MCU == MCU_LPC13UXX) || (MCU == MCU_LPC11UXX) - #define ROM_API ( * (*((USBD_API_T***) NXP_ROMDRIVER_FUNCTION_ADDR)) ) - #define USB_MAX_EP_NUM 5 -#else - #error forgot something, thach ? -#endif - -#include "romdriver/mw_usbd_rom_api.h" - -extern USBD_HANDLE_T romdriver_hdl; - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_DCD_NXP_ROMDRIVER_H_ */ - -/** @} */ diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index d3480b370..9d7d23c07 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -199,6 +199,8 @@ tusb_error_t std_get_descriptor(uint8_t coreid, tusb_control_request_t * p_reque break; case TUSB_DESC_TYPE_STRING: + if ( ! (desc_index < TUSB_CFG_DEVICE_STRING_DESCRIPTOR_COUNT) ) return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; + dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, desc_str_table[desc_index], desc_str_table[desc_index]->bLength); break; diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h index b356047ed..3e6ec3574 100644 --- a/tinyusb/tusb_option.h +++ b/tinyusb/tusb_option.h @@ -164,11 +164,6 @@ //--------------------------------------------------------------------+
#if MODE_DEVICE_SUPPORTED
-// TODO only support non rom driver
-//#if defined(CAP_DEVICE_ROMDRIVER) && !TUSB_CFG_DEVICE_USE_ROM_DRIVER
-// #error only rom driver for these mcu are supported now
-//#endif
-
#define DEVICE_CLASS_HID ( TUSB_CFG_DEVICE_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_MOUSE + TUSB_CFG_DEVICE_HID_GENERIC )
#if TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE > 64
|
