@@ -61,12 +61,9 @@ uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self) {
61
61
}
62
62
63
63
STATIC 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 ;
70
67
}
71
68
72
69
STATIC void _wait_for_callback (void ) {
@@ -89,7 +86,7 @@ STATIC mp_obj_t _get_string(const uint16_t *temp_buf) {
89
86
mp_obj_t common_hal_usb_core_device_get_serial_number (usb_core_device_obj_t * self ) {
90
87
_get_string_result = 0xff ;
91
88
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 )) {
93
90
return mp_const_none ;
94
91
}
95
92
_wait_for_callback ();
@@ -99,7 +96,7 @@ mp_obj_t common_hal_usb_core_device_get_serial_number(usb_core_device_obj_t *sel
99
96
mp_obj_t common_hal_usb_core_device_get_product (usb_core_device_obj_t * self ) {
100
97
_get_string_result = 0xff ;
101
98
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 )) {
103
100
return mp_const_none ;
104
101
}
105
102
_wait_for_callback ();
@@ -109,7 +106,7 @@ mp_obj_t common_hal_usb_core_device_get_product(usb_core_device_obj_t *self) {
109
106
mp_obj_t common_hal_usb_core_device_get_manufacturer (usb_core_device_obj_t * self ) {
110
107
_get_string_result = 0xff ;
111
108
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 )) {
113
110
return mp_const_none ;
114
111
}
115
112
_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
125
122
}
126
123
127
124
xfer_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 ;
133
127
}
134
128
135
129
mp_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,
145
139
.wIndex = wIndex ,
146
140
.wLength = len
147
141
};
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
+
148
150
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 );
153
153
if (!result ) {
154
154
mp_raise_usb_core_USBError (NULL );
155
155
}
0 commit comments