refractor string descriptors, allow one-stop configure descriptor for

- manufacturer, product etc ... (only english now)
This commit is contained in:
hathach
2013-05-31 18:21:31 +07:00
parent abf1054745
commit 03d85acfc7
8 changed files with 93 additions and 21 deletions

View File

@@ -46,6 +46,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "tusb.h"
#include "tusb_descriptors.h" // TODO callback include
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
@@ -66,6 +67,30 @@
//--------------------------------------------------------------------+
tusb_error_t usbd_init (void)
{
ASSERT_INT( USB_STRING_LEN(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) ,
app_tusb_desc_strings.product.bLength , TUSB_ERROR_USBD_DESCRIPTOR_STRING);
ASSERT_INT( USB_STRING_LEN(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++)
{
app_tusb_desc_strings.manufacturer.unicode_string[i] = TUSB_CFG_DEVICE_STRING_MANUFACTURER[i];
}
for(uint32_t i=0; i < sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1; i++)
{
app_tusb_desc_strings.product.unicode_string[i] = TUSB_CFG_DEVICE_STRING_PRODUCT[i];
}
for(uint32_t i=0; i < sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1; i++)
{
app_tusb_desc_strings.serial.unicode_string[i] = TUSB_CFG_DEVICE_STRING_SERIAL[i];
}
ASSERT_STATUS ( dcd_init() );
return TUSB_ERROR_NONE;