From 80339f1a33faadfe85d0276a2e22701ec9a5b82e Mon Sep 17 00:00:00 2001 From: robert-hh Date: Mon, 18 Jul 2022 15:38:04 +0200 Subject: [PATCH] ports: Adapt mimxrt, nrf and rp2 ports to work with latest TinyUSB. rp2: change tud_task() to tud_task_ext(). mimxrt: use lib/tinyusb/src/portable/chipidea/ci_hs/dcd_ci_hs.c instead of lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c. nrf: add a definition for the changed tud_task(). tud_task() is changed to tud_task_ext(), and the #define for backward compatibility is in src/device/usbd.h. The items I know which are fixed with this version: - Fix for the SAMD USB lock-up. - Support the MIMXRT11XX series of MCUs. - Fix a wrong pin definition for MIMXRT1050_EVKB. Tested with the MIMXRT boards, rp2 Pico, SAMD boards, nrf board. --- ports/mimxrt/Makefile | 2 +- ports/nrf/mpconfigport.h | 1 + ports/rp2/mpconfigport.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 150727577f..de560bdb66 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -91,7 +91,7 @@ SRC_TINYUSB_C += \ lib/tinyusb/src/common/tusb_fifo.c \ lib/tinyusb/src/device/usbd.c \ lib/tinyusb/src/device/usbd_control.c \ - lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c \ + lib/tinyusb/src/portable/chipidea/ci_hs/dcd_ci_hs.c \ lib/tinyusb/src/tusb.c # All settings for Ethernet support are controller by the value of MICROPY_PY_LWIP diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index b3a95614a4..8a2478d27d 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -311,6 +311,7 @@ typedef long mp_off_t; #define MP_STATE_PORT MP_STATE_VM #if MICROPY_HW_USB_CDC +#include "device/usbd.h" #define MICROPY_HW_USBDEV_TASK_HOOK extern void tud_task(void); tud_task(); #else #define MICROPY_HW_USBDEV_TASK_HOOK ; diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h index 3f332b6a82..14748a763d 100644 --- a/ports/rp2/mpconfigport.h +++ b/ports/rp2/mpconfigport.h @@ -220,7 +220,7 @@ extern void mp_thread_end_atomic_section(uint32_t); #define MICROPY_PY_LWIP_EXIT lwip_lock_release(); #if MICROPY_HW_ENABLE_USBDEV -#define MICROPY_HW_USBDEV_TASK_HOOK extern void tud_task(void); tud_task(); +#define MICROPY_HW_USBDEV_TASK_HOOK extern void tud_task_ext(uint32_t, bool); tud_task_ext(0, false); #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 (get_core_num() == 0 && --vm_hook_divisor == 0) { \