@@ -285,6 +285,11 @@ bool tuh_descriptor_device_get(uint8_t daddr, void* buffer, uint16_t len, tuh_co
285
285
return tuh_descriptor_get (daddr , TUSB_DESC_DEVICE , 0 , buffer , len , complete_cb );
286
286
}
287
287
288
+ bool tuh_descriptor_configuration_get (uint8_t daddr , uint8_t index , void * buffer , uint16_t len , tuh_control_complete_cb_t complete_cb )
289
+ {
290
+ return tuh_descriptor_get (daddr , TUSB_DESC_CONFIGURATION , index , buffer , len , complete_cb );
291
+ }
292
+
288
293
uint8_t tuh_i_manufacturer_get (uint8_t dev_addr ) {
289
294
TU_VERIFY (tuh_mounted (dev_addr ));
290
295
usbh_device_t const * dev = get_device (dev_addr );
@@ -948,23 +953,9 @@ static bool enum_get_device_desc_complete(uint8_t dev_addr, tusb_control_request
948
953
949
954
// if (tuh_attach_cb) tuh_attach_cb((tusb_desc_device_t*) _usbh_ctrl_buf);
950
955
951
- TU_LOG2 ("Get 9 bytes of Configuration Descriptor\r\n" );
952
- tusb_control_request_t const new_request =
953
- {
954
- .bmRequestType_bit =
955
- {
956
- .recipient = TUSB_REQ_RCPT_DEVICE ,
957
- .type = TUSB_REQ_TYPE_STANDARD ,
958
- .direction = TUSB_DIR_IN
959
- },
960
- .bRequest = TUSB_REQ_GET_DESCRIPTOR ,
961
- .wValue = (TUSB_DESC_CONFIGURATION << 8 ) | (CONFIG_NUM - 1 ),
962
- .wIndex = 0 ,
963
- .wLength = 9
964
- };
965
-
966
- TU_ASSERT ( tuh_control_xfer (dev_addr , & new_request , _usbh_ctrl_buf , enum_get_9byte_config_desc_complete ) );
967
-
956
+ // Get 9-byte for total length
957
+ TU_LOG2 ("Get Configuration[0] Descriptor (9 bytes)\r\n" );
958
+ TU_ASSERT ( tuh_descriptor_configuration_get (dev_addr , 0 , _usbh_ctrl_buf , 9 , enum_get_9byte_config_desc_complete ) );
968
959
return true;
969
960
}
970
961
@@ -982,24 +973,8 @@ static bool enum_get_9byte_config_desc_complete(uint8_t dev_addr, tusb_control_r
982
973
TU_ASSERT (total_len <= CFG_TUH_ENUMERATION_BUFSIZE );
983
974
984
975
// Get full configuration descriptor
985
- TU_LOG2 ("Get Configuration Descriptor\r\n" );
986
- tusb_control_request_t const new_request =
987
- {
988
- .bmRequestType_bit =
989
- {
990
- .recipient = TUSB_REQ_RCPT_DEVICE ,
991
- .type = TUSB_REQ_TYPE_STANDARD ,
992
- .direction = TUSB_DIR_IN
993
- },
994
- .bRequest = TUSB_REQ_GET_DESCRIPTOR ,
995
- .wValue = (TUSB_DESC_CONFIGURATION << 8 ) | (CONFIG_NUM - 1 ),
996
- .wIndex = 0 ,
997
- .wLength = total_len
998
-
999
- };
1000
-
1001
- TU_ASSERT ( tuh_control_xfer (dev_addr , & new_request , _usbh_ctrl_buf , enum_get_config_desc_complete ) );
1002
-
976
+ TU_LOG2 ("Get Configuration[0] Descriptor\r\n" );
977
+ TU_ASSERT ( tuh_descriptor_configuration_get (dev_addr , 0 , _usbh_ctrl_buf , total_len , enum_get_config_desc_complete ) );
1003
978
return true;
1004
979
}
1005
980
0 commit comments