summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2014-03-23 10:15:32 +0700
committerhathach <[email protected]>2014-03-23 10:15:32 +0700
commite28170db2f43db51e0baff1e79c87490064c1258 (patch)
tree3b0ad8657ea0da5c79e8b2469a40650be0ac8aff /tinyusb
parent7ee4b550c2b29e0aab1ff00fdffa0bbc0230bd45 (diff)
adding usbd_enum_buffer to usbd
remove string descriptor USB RAM requirement
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/device/usbd.c8
-rw-r--r--tinyusb/tusb_option.h10
2 files changed, 13 insertions, 5 deletions
diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c
index b64b25f4a..2df0916aa 100644
--- a/tinyusb/device/usbd.c
+++ b/tinyusb/device/usbd.c
@@ -52,6 +52,7 @@
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
usbd_device_info_t usbd_devices[CONTROLLER_DEVICE_NUMBER];
+TUSB_CFG_ATTR_USBRAM uint8_t usbd_enum_buffer[TUSB_CFG_DEVICE_ENUM_BUFFER_SIZE];
static usbd_class_driver_t const usbd_class_drivers[] =
{
@@ -346,9 +347,12 @@ static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const
}
else if ( TUSB_DESC_TYPE_STRING == desc_type )
{
- if ( !(desc_index < TUSB_CFG_DEVICE_STRING_DESCRIPTOR_COUNT && tusbd_descriptor_pointers.p_string_arr[desc_index] != NULL) ) return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
+ if ( !(desc_index < TUSB_CFG_DEVICE_STRING_DESCRIPTOR_COUNT) ) return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
+ uint8_t const * const p_desc_string = tusbd_descriptor_pointers.p_string_arr[desc_index];
+ ASSERT( p_desc_string != NULL && p_desc_string[0] <= TUSB_CFG_DEVICE_ENUM_BUFFER_SIZE, TUSB_ERROR_NOT_ENOUGH_MEMORY);
- (*pp_buffer) = tusbd_descriptor_pointers.p_string_arr[desc_index];
+ memcpy(usbd_enum_buffer, p_desc_string, p_desc_string[0]); // first byte of descriptor is its size
+ (*pp_buffer) = usbd_enum_buffer;
(*p_length) = **pp_buffer;
}else
{
diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h
index b23941584..467abf397 100644
--- a/tinyusb/tusb_option.h
+++ b/tinyusb/tusb_option.h
@@ -163,11 +163,15 @@
//--------------------------------------------------------------------+
#if MODE_DEVICE_SUPPORTED
-#define DEVICE_CLASS_HID ( TUSB_CFG_DEVICE_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_MOUSE + TUSB_CFG_DEVICE_HID_GENERIC )
+ #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
+ #if TUSB_CFG_DEVICE_CONTROL_ENDOINT_SIZE > 64
#error Control Endpoint Max Package Size cannot larger than 64
-#endif
+ #endif
+
+ #ifndef TUSB_CFG_DEVICE_ENUM_BUFFER_SIZE
+ #define TUSB_CFG_DEVICE_ENUM_BUFFER_SIZE 256
+ #endif
#endif // MODE_DEVICE_SUPPORTED