@@ -61,12 +61,9 @@ uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self) {
6161}
6262
6363STATIC xfer_result_t _get_string_result ;
64- STATIC bool _transfer_done_cb (uint8_t daddr , tusb_control_request_t const * request , xfer_result_t result ) {
65- // Store the result so we stop waiting for the transfer. We don't need the other data for now.
66- (void )daddr ;
67- (void )request ;
68- _get_string_result = result ;
69- return true;
64+ STATIC void _transfer_done_cb (tuh_xfer_t * xfer ) {
65+ // Store the result so we stop waiting for the transfer.
66+ _get_string_result = xfer -> result ;
7067}
7168
7269STATIC void _wait_for_callback (void ) {
@@ -89,7 +86,7 @@ STATIC mp_obj_t _get_string(const uint16_t *temp_buf) {
8986mp_obj_t common_hal_usb_core_device_get_serial_number (usb_core_device_obj_t * self ) {
9087 _get_string_result = 0xff ;
9188 uint16_t temp_buf [127 ];
92- if (!tuh_descriptor_string_serial_get (self -> device_number , 0 , temp_buf , MP_ARRAY_SIZE (temp_buf ), _transfer_done_cb )) {
89+ if (!tuh_descriptor_get_serial_string (self -> device_number , 0 , temp_buf , MP_ARRAY_SIZE (temp_buf ), _transfer_done_cb , 0 )) {
9390 return mp_const_none ;
9491 }
9592 _wait_for_callback ();
@@ -99,7 +96,7 @@ mp_obj_t common_hal_usb_core_device_get_serial_number(usb_core_device_obj_t *sel
9996mp_obj_t common_hal_usb_core_device_get_product (usb_core_device_obj_t * self ) {
10097 _get_string_result = 0xff ;
10198 uint16_t temp_buf [127 ];
102- if (!tuh_descriptor_string_product_get (self -> device_number , 0 , temp_buf , MP_ARRAY_SIZE (temp_buf ), _transfer_done_cb )) {
99+ if (!tuh_descriptor_get_product_string (self -> device_number , 0 , temp_buf , MP_ARRAY_SIZE (temp_buf ), _transfer_done_cb , 0 )) {
103100 return mp_const_none ;
104101 }
105102 _wait_for_callback ();
@@ -109,7 +106,7 @@ mp_obj_t common_hal_usb_core_device_get_product(usb_core_device_obj_t *self) {
109106mp_obj_t common_hal_usb_core_device_get_manufacturer (usb_core_device_obj_t * self ) {
110107 _get_string_result = 0xff ;
111108 uint16_t temp_buf [127 ];
112- if (!tuh_descriptor_string_manufacturer_get (self -> device_number , 0 , temp_buf , MP_ARRAY_SIZE (temp_buf ), _transfer_done_cb )) {
109+ if (!tuh_descriptor_get_manufacturer_string (self -> device_number , 0 , temp_buf , MP_ARRAY_SIZE (temp_buf ), _transfer_done_cb , 0 )) {
113110 return mp_const_none ;
114111 }
115112 _wait_for_callback ();
@@ -125,11 +122,8 @@ mp_obj_t common_hal_usb_core_device_read(usb_core_device_obj_t *self, mp_int_t e
125122}
126123
127124xfer_result_t control_result ;
128- STATIC bool _control_complete_cb (uint8_t dev_addr , tusb_control_request_t const * request , xfer_result_t result ) {
129- (void )dev_addr ;
130- (void )request ;
131- control_result = result ;
132- return true;
125+ STATIC void _control_complete_cb (tuh_xfer_t * xfer ) {
126+ control_result = xfer -> result ;
133127}
134128
135129mp_int_t common_hal_usb_core_device_ctrl_transfer (usb_core_device_obj_t * self ,
@@ -145,11 +139,17 @@ mp_int_t common_hal_usb_core_device_ctrl_transfer(usb_core_device_obj_t *self,
145139 .wIndex = wIndex ,
146140 .wLength = len
147141 };
142+ tuh_xfer_t xfer = {
143+ .daddr = self -> device_number ,
144+ .ep_addr = 0 ,
145+ .setup = & request ,
146+ .buffer = buffer ,
147+ .complete_cb = _control_complete_cb ,
148+ };
149+
148150 control_result = XFER_RESULT_STALLED ;
149- bool result = tuh_control_xfer (self -> device_number ,
150- & request ,
151- buffer ,
152- _control_complete_cb );
151+
152+ bool result = tuh_control_xfer (& xfer );
153153 if (!result ) {
154154 mp_raise_usb_core_USBError (NULL );
155155 }
0 commit comments