diff options
| author | Damien George <damien@micropython.org> | 2023-11-09 16:56:06 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-11-09 17:56:58 +1100 |
| commit | d46dc5e1738d843b83f1668798669ff177119d03 (patch) | |
| tree | e613515badc6370fdea4fc95301153ab1fbc23d5 | |
| parent | 365913953a4e050eab45c00e637e92f612400b11 (diff) | |
shared/tinyusb: Expose mp_usbd_task as a public function.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | ports/renesas-ra/mpconfigport.h | 2 | ||||
| -rw-r--r-- | shared/tinyusb/mp_usbd.c | 17 | ||||
| -rw-r--r-- | shared/tinyusb/mp_usbd.h | 3 |
3 files changed, 12 insertions, 10 deletions
diff --git a/ports/renesas-ra/mpconfigport.h b/ports/renesas-ra/mpconfigport.h index d3bc3235f..222d5b919 100644 --- a/ports/renesas-ra/mpconfigport.h +++ b/ports/renesas-ra/mpconfigport.h @@ -272,7 +272,7 @@ static inline mp_uint_t disable_irq(void) { #define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state) #if MICROPY_HW_ENABLE_USBDEV -#define MICROPY_HW_USBDEV_TASK_HOOK extern void usbd_task(void); usbd_task(); +#define MICROPY_HW_USBDEV_TASK_HOOK extern void mp_usbd_task(void); mp_usbd_task(); #define MICROPY_VM_HOOK_COUNT (10) #define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT; #define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \ diff --git a/shared/tinyusb/mp_usbd.c b/shared/tinyusb/mp_usbd.c index 87c10310f..55af3d4fb 100644 --- a/shared/tinyusb/mp_usbd.c +++ b/shared/tinyusb/mp_usbd.c @@ -38,16 +38,15 @@ #include "device/usbd_pvt.h" #endif -// Legacy TinyUSB task function wrapper, called by some ports from the interpreter hook -void usbd_task(void) { - tud_task_ext(0, false); -} - // TinyUSB task function wrapper, as scheduled from the USB IRQ -static void mp_usbd_task(mp_sched_node_t *node); +static void mp_usbd_task_callback(mp_sched_node_t *node); extern void __real_dcd_event_handler(dcd_event_t const *event, bool in_isr); +void mp_usbd_task(void) { + tud_task_ext(0, false); +} + // If -Wl,--wrap=dcd_event_handler is passed to the linker, then this wrapper // will be called and allows MicroPython to schedule the TinyUSB task when // dcd_event_handler() is called from an ISR. @@ -55,12 +54,12 @@ TU_ATTR_FAST_FUNC void __wrap_dcd_event_handler(dcd_event_t const *event, bool i static mp_sched_node_t usbd_task_node; __real_dcd_event_handler(event, in_isr); - mp_sched_schedule_node(&usbd_task_node, mp_usbd_task); + mp_sched_schedule_node(&usbd_task_node, mp_usbd_task_callback); } -static void mp_usbd_task(mp_sched_node_t *node) { +static void mp_usbd_task_callback(mp_sched_node_t *node) { (void)node; - tud_task_ext(0, false); + mp_usbd_task(); } #endif diff --git a/shared/tinyusb/mp_usbd.h b/shared/tinyusb/mp_usbd.h index 2e4feaca9..340637c95 100644 --- a/shared/tinyusb/mp_usbd.h +++ b/shared/tinyusb/mp_usbd.h @@ -29,6 +29,9 @@ #include "py/obj.h" +// Call this to explicitly run the TinyUSB device task. +void mp_usbd_task(void); + // Function to be implemented in port code. // Can write a string up to MICROPY_HW_USB_DESC_STR_MAX characters long, plus terminating byte. extern void mp_usbd_port_get_serial_number(char *buf); |
