Skip to content

Commit 141a43c

Browse files
authored
Merge pull request #7702 from dhalbert/tinyusb-update
update tinyusb to latest
2 parents ab77725 + 2497b3e commit 141a43c

File tree

7 files changed

+31
-33
lines changed

7 files changed

+31
-33
lines changed

lib/tinyusb

Submodule tinyusb updated 863 files

ports/raspberrypi/sdk_config/pico/config_autogen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#define PICO_NO_HARDWARE (0)
1919
#define PICO_ON_DEVICE (1)
2020
#define PICO_PRINTF_ALWAYS_INCLUDED (1)
21+
#define PICO_RP2040_USB_DEVICE_ENUMERATION_FIX (1)
22+
#define PICO_RP2040_USB_DEVICE_UFRAME_FIX (1)
2123
#define PICO_STDIO_IGNORE_NESTED_STDOUT (0)
2224
#define PICO_USE_CRT_PRINTF (0)
2325
#define PICO_USE_OPTIMISTIC_SBRK (0)

ports/raspberrypi/supervisor/usb.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,8 @@ STATIC void _usb_irq_wrapper(void) {
3939
}
4040

4141
void post_usb_init(void) {
42-
irq_set_enabled(USBCTRL_IRQ, false);
43-
44-
irq_handler_t usb_handler = irq_get_exclusive_handler(USBCTRL_IRQ);
45-
if (usb_handler) {
46-
irq_remove_handler(USBCTRL_IRQ, usb_handler);
47-
}
48-
irq_set_exclusive_handler(USBCTRL_IRQ, _usb_irq_wrapper);
49-
50-
irq_set_enabled(USBCTRL_IRQ, true);
42+
irq_add_shared_handler(USBCTRL_IRQ, _usb_irq_wrapper,
43+
PICO_SHARED_IRQ_HANDLER_LOWEST_ORDER_PRIORITY);
5144

5245
// There is a small window where the USB interrupt may be handled by the
5346
// pico-sdk instead of CircuitPython. If that is the case, then we'll have

ports/stm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ ifneq ($(CIRCUITPY_AUDIOBUSIO_PDMIN),0)
215215
endif
216216

217217
ifneq ($(CIRCUITPY_USB),0)
218-
SRC_C += lib/tinyusb/src/portable/st/synopsys/dcd_synopsys.c
218+
SRC_C += lib/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c
219219
endif
220220

221221
SRC_S = \

shared-module/usb/core/Device.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,9 @@ uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self) {
6161
}
6262

6363
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;
7067
}
7168

7269
STATIC void _wait_for_callback(void) {
@@ -89,7 +86,7 @@ STATIC mp_obj_t _get_string(const uint16_t *temp_buf) {
8986
mp_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
9996
mp_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) {
109106
mp_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

127124
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;
133127
}
134128

135129
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,
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
}

supervisor/shared/usb/usb.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,17 @@ void usb_background_schedule(void) {
225225
}
226226

227227
void usb_irq_handler(int instance) {
228+
#if CFG_TUSB_MCU != OPT_MCU_RP2040
229+
// For rp2040, IRQ handler is already installed and invoked automatically
228230
if (instance == CIRCUITPY_USB_DEVICE_INSTANCE) {
229231
tud_int_handler(instance);
230-
} else if (instance == CIRCUITPY_USB_HOST_INSTANCE) {
231-
#if CIRCUITPY_USB_HOST
232+
}
233+
#if CIRCUITPY_USB_HOST
234+
else if (instance == CIRCUITPY_USB_HOST_INSTANCE) {
232235
tuh_int_handler(instance);
233-
#endif
234236
}
237+
#endif
238+
#endif
235239

236240
usb_background_schedule();
237241
}

supervisor/supervisor.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ ifeq ($(CIRCUITPY_USB),1)
163163
SRC_SUPERVISOR += \
164164
lib/tinyusb/src/host/hub.c \
165165
lib/tinyusb/src/host/usbh.c \
166-
lib/tinyusb/src/host/usbh_control.c \
167166

168167
endif
169168
endif

0 commit comments

Comments
 (0)