also migrate tud_descriptor_device_qualifier_cb() / tud_descriptor_other_speed_configuration_cb()
This commit is contained in:
@@ -59,6 +59,15 @@ TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TU_ATTR_WEAK uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||||
|
(void) index;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
TU_ATTR_WEAK void tud_mount_cb(void) {
|
TU_ATTR_WEAK void tud_mount_cb(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,15 +1084,12 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
|||||||
}
|
}
|
||||||
// break; // unreachable
|
// break; // unreachable
|
||||||
|
|
||||||
case TUSB_DESC_BOS:
|
case TUSB_DESC_BOS: {
|
||||||
{
|
|
||||||
TU_LOG_USBD(" BOS\r\n");
|
TU_LOG_USBD(" BOS\r\n");
|
||||||
|
|
||||||
// requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
|
// requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
|
||||||
if (!tud_descriptor_bos_cb) return false;
|
|
||||||
|
|
||||||
uintptr_t desc_bos = (uintptr_t) tud_descriptor_bos_cb();
|
uintptr_t desc_bos = (uintptr_t) tud_descriptor_bos_cb();
|
||||||
TU_ASSERT(desc_bos);
|
TU_VERIFY(desc_bos);
|
||||||
|
|
||||||
// Use offsetof to avoid pointer to the odd/misaligned address
|
// Use offsetof to avoid pointer to the odd/misaligned address
|
||||||
uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_bos + offsetof(tusb_desc_bos_t, wTotalLength))) );
|
uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_bos + offsetof(tusb_desc_bos_t, wTotalLength))) );
|
||||||
@@ -1093,24 +1099,20 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
|||||||
// break; // unreachable
|
// break; // unreachable
|
||||||
|
|
||||||
case TUSB_DESC_CONFIGURATION:
|
case TUSB_DESC_CONFIGURATION:
|
||||||
case TUSB_DESC_OTHER_SPEED_CONFIG:
|
case TUSB_DESC_OTHER_SPEED_CONFIG: {
|
||||||
{
|
|
||||||
uintptr_t desc_config;
|
uintptr_t desc_config;
|
||||||
|
|
||||||
if ( desc_type == TUSB_DESC_CONFIGURATION )
|
if ( desc_type == TUSB_DESC_CONFIGURATION ) {
|
||||||
{
|
|
||||||
TU_LOG_USBD(" Configuration[%u]\r\n", desc_index);
|
TU_LOG_USBD(" Configuration[%u]\r\n", desc_index);
|
||||||
desc_config = (uintptr_t) tud_descriptor_configuration_cb(desc_index);
|
desc_config = (uintptr_t) tud_descriptor_configuration_cb(desc_index);
|
||||||
}else
|
TU_ASSERT(desc_config);
|
||||||
{
|
}else {
|
||||||
// Host only request this after getting Device Qualifier descriptor
|
// Host only request this after getting Device Qualifier descriptor
|
||||||
TU_LOG_USBD(" Other Speed Configuration\r\n");
|
TU_LOG_USBD(" Other Speed Configuration\r\n");
|
||||||
TU_VERIFY( tud_descriptor_other_speed_configuration_cb );
|
|
||||||
desc_config = (uintptr_t) tud_descriptor_other_speed_configuration_cb(desc_index);
|
desc_config = (uintptr_t) tud_descriptor_other_speed_configuration_cb(desc_index);
|
||||||
|
TU_VERIFY(desc_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
TU_ASSERT(desc_config);
|
|
||||||
|
|
||||||
// Use offsetof to avoid pointer to the odd/misaligned address
|
// Use offsetof to avoid pointer to the odd/misaligned address
|
||||||
uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_config + offsetof(tusb_desc_configuration_t, wTotalLength))) );
|
uint16_t const total_len = tu_le16toh( tu_unaligned_read16((const void*) (desc_config + offsetof(tusb_desc_configuration_t, wTotalLength))) );
|
||||||
|
|
||||||
@@ -1131,16 +1133,10 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
|||||||
}
|
}
|
||||||
// break; // unreachable
|
// break; // unreachable
|
||||||
|
|
||||||
case TUSB_DESC_DEVICE_QUALIFIER:
|
case TUSB_DESC_DEVICE_QUALIFIER: {
|
||||||
{
|
|
||||||
TU_LOG_USBD(" Device Qualifier\r\n");
|
TU_LOG_USBD(" Device Qualifier\r\n");
|
||||||
|
|
||||||
TU_VERIFY( tud_descriptor_device_qualifier_cb );
|
|
||||||
|
|
||||||
uint8_t const* desc_qualifier = tud_descriptor_device_qualifier_cb();
|
uint8_t const* desc_qualifier = tud_descriptor_device_qualifier_cb();
|
||||||
TU_VERIFY(desc_qualifier);
|
TU_VERIFY(desc_qualifier);
|
||||||
|
|
||||||
// first byte of descriptor is its size
|
|
||||||
return tud_control_xfer(rhport, p_request, (void*) (uintptr_t) desc_qualifier, tu_desc_len(desc_qualifier));
|
return tud_control_xfer(rhport, p_request, (void*) (uintptr_t) desc_qualifier, tu_desc_len(desc_qualifier));
|
||||||
}
|
}
|
||||||
// break; // unreachable
|
// break; // unreachable
|
||||||
|
@@ -109,7 +109,7 @@ bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, vo
|
|||||||
bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request);
|
bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Application Callbacks (WEAK is optional)
|
// Application Callbacks
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Invoked when received GET DEVICE DESCRIPTOR request
|
// Invoked when received GET DEVICE DESCRIPTOR request
|
||||||
@@ -132,12 +132,12 @@ uint8_t const * tud_descriptor_bos_cb(void);
|
|||||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
|
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
|
||||||
// device_qualifier descriptor describes information about a high-speed capable device that would
|
// device_qualifier descriptor describes information about a high-speed capable device that would
|
||||||
// change if the device were operating at the other speed. If not highspeed capable stall this request.
|
// change if the device were operating at the other speed. If not highspeed capable stall this request.
|
||||||
TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void);
|
uint8_t const* tud_descriptor_device_qualifier_cb(void);
|
||||||
|
|
||||||
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
|
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
|
||||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||||
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
|
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
|
||||||
TU_ATTR_WEAK uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index);
|
uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index);
|
||||||
|
|
||||||
// Invoked when device is mounted (configured)
|
// Invoked when device is mounted (configured)
|
||||||
void tud_mount_cb(void);
|
void tud_mount_cb(void);
|
||||||
|
Reference in New Issue
Block a user