change tud_descriptor_string_cb() to be consistent with other descriptor callback
This commit is contained in:
@@ -577,16 +577,11 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
uint16_t desc_str[CFG_TUD_ENDOINT0_SIZE/2]; // up to endpoint0 size only
|
||||
uint8_t len = 2*tud_descriptor_string_cb(desc_index, desc_str+1, CFG_TUD_ENDOINT0_SIZE/2-1);
|
||||
uint8_t const* desc_str = (uint8_t const*) tud_descriptor_string_cb(desc_index);
|
||||
TU_ASSERT(desc_str);
|
||||
|
||||
TU_ASSERT(len > 0);
|
||||
|
||||
// first byte of descriptor is size, second byte is string type
|
||||
len += 2; // header len
|
||||
desc_str[0] = tu_u16_from_u8(TUSB_DESC_STRING, len);
|
||||
|
||||
return usbd_control_xfer(rhport, p_request, desc_str, len);
|
||||
// first byte of descriptor is its size
|
||||
return usbd_control_xfer(rhport, p_request, (void*) desc_str, desc_str[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -63,19 +63,17 @@ bool tud_remote_wakeup(void);
|
||||
// Application Callbacks (WEAK is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received GET DEVICE DESCRIPTOR
|
||||
// Invoked when received GET DEVICE DESCRIPTOR request
|
||||
// Application return pointer to descriptor
|
||||
uint8_t const * tud_descriptor_device_cb(void);
|
||||
|
||||
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
// Descriptor contents must exist long enough for transfer to complete
|
||||
// Invoked when received GET CONFIGURATION DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint8_t const * tud_descriptor_configuration_cb(void);
|
||||
|
||||
// Invoked when received GET STRING DESC request
|
||||
// max_char is CFG_TUD_ENDOINT0_SIZE/2 -1, typically max_char = 31 if Endpoint0 size is 64
|
||||
// Return number of characters. Note usb string is in UTF-16 format
|
||||
uint8_t tud_descriptor_string_cb(uint8_t index, uint16_t* desc, uint8_t max_char);
|
||||
// Invoked when received GET STRING DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint16_t const* tud_descriptor_string_cb(uint8_t index);
|
||||
|
||||
// Invoked when device is mounted (configured)
|
||||
ATTR_WEAK void tud_mount_cb(void);
|
||||
|
||||
Reference in New Issue
Block a user