renesas-ra/usb: Use interrupt rather than polling for USB task.

Most ports using TinyUSB now schedule the USB tasks from the USB interrupt.
This commit updates the renesas-ra port to use this new pattern.

Signed-off-by: Andrew Leech <andrew@alelec.net>
This commit is contained in:
Andrew Leech 2024-07-26 10:03:32 +10:00 committed by Damien George
parent 6381ad5d0c
commit a2475ee9de
2 changed files with 3 additions and 16 deletions

View File

@ -157,6 +157,9 @@ LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)"
LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))" LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))"
endif endif
# Hook tinyusb USB interrupt if used to service usb task.
LDFLAGS += --wrap=dcd_event_handler
# Options for mpy-cross # Options for mpy-cross
MPY_CROSS_FLAGS += -march=armv7m MPY_CROSS_FLAGS += -march=armv7m

View File

@ -250,25 +250,10 @@ typedef unsigned int mp_uint_t; // must be pointer size
typedef long mp_off_t; typedef long mp_off_t;
#if MICROPY_HW_ENABLE_USBDEV
#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) { \
vm_hook_divisor = MICROPY_VM_HOOK_COUNT; \
MICROPY_HW_USBDEV_TASK_HOOK \
}
#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
#else
#define MICROPY_HW_USBDEV_TASK_HOOK
#endif
#if MICROPY_PY_THREAD #if MICROPY_PY_THREAD
#define MICROPY_EVENT_POLL_HOOK \ #define MICROPY_EVENT_POLL_HOOK \
do { \ do { \
extern void mp_handle_pending(bool); \ extern void mp_handle_pending(bool); \
MICROPY_HW_USBDEV_TASK_HOOK \
mp_handle_pending(true); \ mp_handle_pending(true); \
if (pyb_thread_enabled) { \ if (pyb_thread_enabled) { \
MP_THREAD_GIL_EXIT(); \ MP_THREAD_GIL_EXIT(); \
@ -284,7 +269,6 @@ typedef long mp_off_t;
#define MICROPY_EVENT_POLL_HOOK \ #define MICROPY_EVENT_POLL_HOOK \
do { \ do { \
extern void mp_handle_pending(bool); \ extern void mp_handle_pending(bool); \
MICROPY_HW_USBDEV_TASK_HOOK \
mp_handle_pending(true); \ mp_handle_pending(true); \
__WFI(); \ __WFI(); \
} while (0); } while (0);