aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/lib/tinyusb/hw/bsp
diff options
context:
space:
mode:
Diffstat (limited to 'circuitpython/lib/tinyusb/hw/bsp')
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ansi_escape.h97
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/board.c149
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/board.h147
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/board_mcu.h157
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.h38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.mk5
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.c156
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.mk46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.h38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.mk3
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.h38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.mk3
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.c156
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.mk46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/brtmm90x/boards/mm900evxb/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.c215
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.mk67
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/d5035_01/board.mk61
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/d5035_01/d5035_01.c353
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/d5035_01/same51j19a_flash.ld163
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/board.mk55
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da14695_dk_usb.c134
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da1469x.ld245
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/gcc_startup_da1469x.S301
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/product_header.dumpbin0 -> 8192 bytes
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/syscfg/syscfg.h34
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/board.mk55
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x-dk-pro.c151
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x.ld245
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/gcc_startup_da1469x.S301
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/product_header.dumpbin0 -> 8192 bytes
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/syscfg/syscfg.h34
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4088qs/board.mk46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4088qs/ea4088qs.c190
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4088qs/lpc4088.ld184
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4357/board.mk48
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4357/ea4357.c291
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4357/lpc4357.ld324
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.c352
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.h94
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/CMakeLists.txt12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.cmake17
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.cmake17
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.cmake17
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/esp32s2.c153
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.cmake17
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.h44
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.cmake17
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.h45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/CMakeLists.txt8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/include/led_strip.h126
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/src/led_strip_rmt_ws2812.c171
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.cmake7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.mk24
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/CMakeLists.txt14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/esp32s3.c153
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.cmake7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.h44
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.cmake7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.h43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.cmake7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.h43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/CMakeLists.txt8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/include/led_strip.h126
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/src/led_strip_rmt_ws2812.c171
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.cmake7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.mk26
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/f1c100s/README.md20
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.h1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.mk52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/f1c100s/f1c100s.c130
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/family_support.cmake100
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.h40
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.mk1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/crt0-vexriscv.S83
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/dfu.py95
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/family.mk30
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.c120
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.ld104
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/include/csr.h750
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/include/hw/common.h33
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/include/irq.h71
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/output_format.ld1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/fomu/regions.ld6
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.h56
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.mk51
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/frdm_k32l2b.c140
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/board.mk52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/frdm_kl25z.c176
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.h20
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.mk13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.c197
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.mk67
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/gd32vf103/system_gd32vf103.c668
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.h53
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.c48
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.h267
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.h51
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.c48
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.h268
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.h51
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.c49
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.h268
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.h51
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.mk8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.c55
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.h269
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.h51
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.mk14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.c49
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.h268
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.mk14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.c49
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.h268
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.c49
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h268
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/family.c207
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/imxrt/family.mk63
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/kuiic/K32L2B31xxxxA_flash.ld217
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/kuiic/board.h45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/kuiic/board.mk52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/kuiic/kuiic.c203
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.h72
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.mk7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/lpc1549.ld246
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc15/family.c130
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc15/family.mk39
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h77
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk6
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld404
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.h94
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.mk7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld323
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/family.c159
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc18/family.mk37
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.h59
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.h59
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk18
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc54/family.c228
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc54/family.mk54
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/LPC55S69_cm33_core0_uf2.ld234
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.h63
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h56
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h56
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.h56
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/family.c283
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpc55/family.mk67
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/board.mk46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpc11u37.ld195
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c208
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/board.mk42
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpc11u68.ld242
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c135
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/board.mk45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpc1347.ld225
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpcxpresso1347.c152
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/board.mk43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpc1769.ld184
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpcxpresso1769.c209
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/board.mk52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c179
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mbed1768/board.mk45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mbed1768/lpc1768.ld184
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mbed1768/mbed1768.c197
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/board.mk8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/flash.ld163
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/mm32f327x_mb39.c172
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/mm32/family.mk36
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/msp430/family.c218
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/msp430/family.mk35
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.c203
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.mk41
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ngx4330/board.mk47
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.c264
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.ld343
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.mk10
-rwxr-xr-xcircuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/nrf52840_s140_v6.ld38
-rwxr-xr-xcircuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld32
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk10
-rwxr-xr-xcircuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/nrf52840_s140_v6.ld38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/nrf52840_s140_v6.ld38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld38
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk15
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.mk7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.mk15
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/pca10059.ld13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.mk7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk7
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/family.c224
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nrf/family.mk48
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/board.mk43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nuc121_flash.ld195
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c121
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/board.mk39
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nuc125_flash.ld195
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c121
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/board.mk45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nuc126_flash.ld195
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c153
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/board.mk41
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld195
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c133
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/board.mk60
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld199
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c129
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/board.mk5
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/olimex_emz64.c144
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/board.mk5
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/olimex_hmz144.c142
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.c110
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.mk20
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/board.h53
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/pico_sdk/board.cmake1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake1
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/family.c199
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/family.cmake179
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/family.mk19
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rp2040/pico_sdk_import.cmake62
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/board.mk24
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/gr_citrus.c275
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/hwinit.c31
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/r5f5631fd.ld127
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/board.mk25
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/r5f565ne.ld168
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/rx65n_target.c325
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/rx/family.mk33
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.h46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld144
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.h46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld144
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/family.c150
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd11/family.mk40
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld144
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.mk14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld144
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.h46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld144
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.h46
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/qtpy.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.h34
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.mk5
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/family.c249
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd21/family.mk49
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.mk8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld166
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld166
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld166
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.mk8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/pybadge.ld166
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.mk8
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/pyportal.ld166
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/family.c162
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samd51/family.mk50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/board.mk48
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_flash.ld163
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_sram.ld162
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54xplainedpro.c306
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/board.mk56
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_pmc_config.h1053
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_usart_config.h215
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_xdmac_config.h4400
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/peripheral_clk_config.h126
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/same70_qmtech.c159
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_xplained/board.mk56
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_pmc_config.h1053
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_usart_config.h215
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_xdmac_config.h4400
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_xplained/peripheral_clk_config.h126
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/same70_xplained/same70_xplained.c156
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samg55xplained/board.mk52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samg55xplained/hpl_usart_config.h215
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samg55xplained/peripheral_clk_config.h85
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55j19_flash.ld158
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55xplained.c157
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.h50
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld153
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.h47
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.h47
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld146
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/family.c163
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/saml2x/family.mk51
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/sltb009a/board.mk43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/sltb009a/sltb009a.c721
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/spresense/board.mk74
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/spresense/board_spresense.c105
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.h93
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/stm32F070rbtx_flash.ld200
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/STM32F072RBTx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.h85
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld177
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.h102
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.c182
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.mk40
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f0/stm32f0xx_hal_conf.h321
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/STM32F103X8_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.h92
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/STM32F103XC_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.h92
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.c167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.mk45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f1/stm32f1xx_hal_conf.h379
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/STM32F207ZGTx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/board.mk48
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f207nucleo.c213
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f2xx_hal_conf.h407
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/STM32F303VCTx_FLASH.ld189
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/board.mk49
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f303disco.c215
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f3xx_hal_conf.h357
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/STM32F405RGTx_FLASH.ld189
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.h104
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/stm32f4xx_hal_conf.h491
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/STM32F405RGTx_FLASH.ld189
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.h102
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/stm32f4xx_hal_conf.h491
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/STM32F401VCTx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.h106
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/stm32f4xx_hal_conf.h493
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/STM32F407VGTx_FLASH.ld189
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.h105
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/stm32f4xx_hal_conf.h493
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/STM32F411CEUx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.h106
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/stm32f4xx_hal_conf.h493
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/STM32F411VETx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.h104
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/stm32f4xx_hal_conf.h493
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/STM32F412ZGTx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.h118
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/stm32f4xx_hal_conf.h493
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/STM32F412ZGTx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.h119
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/stm32f4xx_hal_conf.h493
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/STM32F439ZITX_FLASH.ld206
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.h108
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/stm32f4xx_hal_conf.h486
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.c201
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.mk43
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/STM32F723xE_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.h101
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/stm32f7xx_hal_conf.h472
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/STM32F723xE_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.h105
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.mk15
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/stm32f7xx_hal_conf.h472
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/STM32F746ZGTx_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.h100
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/stm32f7xx_hal_conf.h472
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/STM32F746ZGTx_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.h98
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk12
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/stm32f7xx_hal_conf.h472
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/STM32F767ZITx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.h102
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk15
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/stm32f7xx_hal_conf.h472
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/STM32F769ZITx_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.h101
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.mk13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/stm32f7xx_hal_conf.h472
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.c314
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.mk54
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/STM32G474RETx_FLASH.ld190
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.h134
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.c186
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.mk44
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32g4/stm32g4xx_hal_conf.h381
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.h143
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.mk14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/stm32h743xx_flash.ld173
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h122
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk13
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/stm32h743xx_flash.ld173
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.h139
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.mk17
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/STM32H743IITX_FLASH.ld175
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.h229
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.mk19
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.c268
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.mk57
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32h7/stm32h7xx_hal_conf.h483
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/STM32L053C8Tx_FLASH.ld169
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/board.mk54
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0538disco.c205
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0xx_hal_conf.h331
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/STM32L476VGTx_FLASH.ld183
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.h139
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/STM32L4P5ZGTX_FLASH.ld200
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.h137
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk10
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/STM32L4RXxI_FLASH.ld167
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.h137
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk14
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.c198
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.mk45
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32l4/stm32l4xx_hal_conf.h420
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.h122
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/stm32wb55xx_flash_cm4.ld171
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.c190
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.mk44
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/stm32wb/stm32wbxx_hal_conf.h349
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h52
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk11
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld65
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.c178
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.mk36
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.h88
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.mk9
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.c130
-rw-r--r--circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.mk40
499 files changed, 67688 insertions, 0 deletions
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ansi_escape.h b/circuitpython/lib/tinyusb/hw/bsp/ansi_escape.h
new file mode 100644
index 0000000..35342cf
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ansi_escape.h
@@ -0,0 +1,97 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+/** \ingroup group_board
+ * \defgroup group_ansi_esc ANSI Esacpe Code
+ * @{ */
+
+#ifndef _TUSB_ANSI_ESC_CODE_H_
+#define _TUSB_ANSI_ESC_CODE_H_
+
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define CSI_CODE(seq) "\33[" seq
+#define CSI_SGR(x) CSI_CODE(#x) "m"
+
+//------------- Cursor movement -------------//
+/** \defgroup group_ansi_cursor Cursor Movement
+ * @{ */
+#define ANSI_CURSOR_UP(n) CSI_CODE(#n "A") ///< Move cursor up
+#define ANSI_CURSOR_DOWN(n) CSI_CODE(#n "B") ///< Move cursor down
+#define ANSI_CURSOR_FORWARD(n) CSI_CODE(#n "C") ///< Move cursor forward
+#define ANSI_CURSOR_BACKWARD(n) CSI_CODE(#n "D") ///< Move cursor backward
+#define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E") ///< Move cursor to the beginning of the line (n) down
+#define ANSI_CURSOR_LINE_UP(n) CSI_CODE(#n "F") ///< Move cursor to the beginning of the line (n) up
+#define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H") ///< Move cursor to position (n, m)
+/** @} */
+
+//------------- Screen -------------//
+/** \defgroup group_ansi_screen Screen Control
+ * @{ */
+#define ANSI_ERASE_SCREEN(n) CSI_CODE(#n "J") ///< Erase the screen
+#define ANSI_ERASE_LINE(n) CSI_CODE(#n "K") ///< Erase the line (n)
+#define ANSI_SCROLL_UP(n) CSI_CODE(#n "S") ///< Scroll the whole page up (n) lines
+#define ANSI_SCROLL_DOWN(n) CSI_CODE(#n "T") ///< Scroll the whole page down (n) lines
+/** @} */
+
+//------------- Text Color -------------//
+/** \defgroup group_ansi_text Text Color
+ * @{ */
+#define ANSI_TEXT_BLACK CSI_SGR(30)
+#define ANSI_TEXT_RED CSI_SGR(31)
+#define ANSI_TEXT_GREEN CSI_SGR(32)
+#define ANSI_TEXT_YELLOW CSI_SGR(33)
+#define ANSI_TEXT_BLUE CSI_SGR(34)
+#define ANSI_TEXT_MAGENTA CSI_SGR(35)
+#define ANSI_TEXT_CYAN CSI_SGR(36)
+#define ANSI_TEXT_WHITE CSI_SGR(37)
+#define ANSI_TEXT_DEFAULT CSI_SGR(39)
+/** @} */
+
+//------------- Background Color -------------//
+/** \defgroup group_ansi_background Background Color
+ * @{ */
+#define ANSI_BG_BLACK CSI_SGR(40)
+#define ANSI_BG_RED CSI_SGR(41)
+#define ANSI_BG_GREEN CSI_SGR(42)
+#define ANSI_BG_YELLOW CSI_SGR(43)
+#define ANSI_BG_BLUE CSI_SGR(44)
+#define ANSI_BG_MAGENTA CSI_SGR(45)
+#define ANSI_BG_CYAN CSI_SGR(46)
+#define ANSI_BG_WHITE CSI_SGR(47)
+#define ANSI_BG_DEFAULT CSI_SGR(49)
+/** @} */
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _TUSB_ANSI_ESC_CODE_H_ */
+
+/** @} */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/board.c b/circuitpython/lib/tinyusb/hw/bsp/board.c
new file mode 100644
index 0000000..e208624
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/board.c
@@ -0,0 +1,149 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "board.h"
+
+#if 0
+#define LED_PHASE_MAX 8
+
+static struct
+{
+ uint32_t phase[LED_PHASE_MAX];
+ uint8_t phase_count;
+
+ bool led_state;
+ uint8_t current_phase;
+ uint32_t current_ms;
+}led_pattern;
+
+void board_led_pattern(uint32_t const phase_ms[], uint8_t count)
+{
+ memcpy(led_pattern.phase, phase_ms, 4*count);
+ led_pattern.phase_count = count;
+
+ // reset with 1st phase is on
+ led_pattern.current_ms = board_millis();
+ led_pattern.current_phase = 0;
+ led_pattern.led_state = true;
+ board_led_on();
+}
+
+void board_led_task(void)
+{
+ if ( led_pattern.phase_count == 0 ) return;
+
+ uint32_t const duration = led_pattern.phase[led_pattern.current_phase];
+
+ // return if not enough time
+ if (board_millis() - led_pattern.current_ms < duration) return;
+
+ led_pattern.led_state = !led_pattern.led_state;
+ board_led_write(led_pattern.led_state);
+
+ led_pattern.current_ms += duration;
+ led_pattern.current_phase++;
+
+ if (led_pattern.current_phase == led_pattern.phase_count)
+ {
+ led_pattern.current_phase = 0;
+ led_pattern.led_state = true;
+ board_led_on();
+ }
+}
+#endif
+
+//--------------------------------------------------------------------+
+// newlib read()/write() retarget
+//--------------------------------------------------------------------+
+
+#if defined(__MSP430__) || defined(__RX__)
+ #define sys_write write
+ #define sys_read read
+#else
+ #define sys_write _write
+ #define sys_read _read
+#endif
+
+#if defined(LOGGER_RTT)
+// Logging with RTT
+
+// If using SES IDE, use the Syscalls/SEGGER_RTT_Syscalls_SES.c instead
+#if !(defined __SES_ARM) && !(defined __SES_RISCV) && !(defined __CROSSWORKS_ARM)
+#include "SEGGER_RTT.h"
+
+TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
+{
+ (void) fhdl;
+ SEGGER_RTT_Write(0, (const char*) buf, (int) count);
+ return count;
+}
+
+TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
+{
+ (void) fhdl;
+ return SEGGER_RTT_Read(0, buf, count);
+}
+#endif
+
+#elif defined(LOGGER_SWO)
+// Logging with SWO for ARM Cortex
+
+#include "board_mcu.h"
+
+TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
+{
+ (void) fhdl;
+ uint8_t const* buf8 = (uint8_t const*) buf;
+ for(size_t i=0; i<count; i++)
+ {
+ ITM_SendChar(buf8[i]);
+ }
+ return count;
+}
+
+TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
+{
+ (void) fhdl;
+ (void) buf;
+ (void) count;
+ return 0;
+}
+
+#else
+
+// Default logging with on-board UART
+TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
+{
+ (void) fhdl;
+ return board_uart_write(buf, (int) count);
+}
+
+TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
+{
+ (void) fhdl;
+ return board_uart_read((uint8_t*) buf, (int) count);
+}
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/board.h b/circuitpython/lib/tinyusb/hw/bsp/board.h
new file mode 100644
index 0000000..b4e0cb2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/board.h
@@ -0,0 +1,147 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+/** \ingroup group_demo
+ * \defgroup group_board Boards Abstraction Layer
+ * @{ */
+
+#ifndef _BSP_BOARD_H_
+#define _BSP_BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "ansi_escape.h"
+#include "tusb.h"
+
+#define CFG_BOARD_UART_BAUDRATE 115200
+
+//--------------------------------------------------------------------+
+// Board Porting API
+// For simplicity, only one LED and one Button are used
+//--------------------------------------------------------------------+
+
+// Initialize on-board peripherals : led, button, uart and USB
+void board_init(void);
+
+// Turn LED on or off
+void board_led_write(bool state);
+
+// Control led pattern using phase duration in ms.
+// For each phase, LED is toggle then repeated, board_led_task() is required to be called
+//void board_led_pattern(uint32_t const phase_ms[], uint8_t count);
+
+// Get the current state of button
+// a '1' means active (pressed), a '0' means inactive.
+uint32_t board_button_read(void);
+
+// Get characters from UART
+int board_uart_read(uint8_t* buf, int len);
+
+// Send characters to UART
+int board_uart_write(void const * buf, int len);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // Get current milliseconds, must be implemented when no RTOS is used
+ uint32_t board_millis(void);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ static inline uint32_t board_millis(void)
+ {
+ return ( ( ((uint64_t) xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ );
+ }
+
+#elif CFG_TUSB_OS == OPT_OS_MYNEWT
+ static inline uint32_t board_millis(void)
+ {
+ return os_time_ticks_to_ms32( os_time_get() );
+ }
+
+#elif CFG_TUSB_OS == OPT_OS_PICO
+ #include "pico/time.h"
+ static inline uint32_t board_millis(void)
+ {
+ return to_ms_since_boot(get_absolute_time());
+ }
+
+#elif CFG_TUSB_OS == OPT_OS_RTTHREAD
+ static inline uint32_t board_millis(void)
+ {
+ return (((uint64_t)rt_tick_get()) * 1000 / RT_TICK_PER_SECOND);
+ }
+
+#else
+ #error "board_millis() is not implemented for this OS"
+#endif
+
+//--------------------------------------------------------------------+
+// Helper functions
+//--------------------------------------------------------------------+
+static inline void board_led_on(void)
+{
+ board_led_write(true);
+}
+
+static inline void board_led_off(void)
+{
+ board_led_write(false);
+}
+
+// TODO remove
+static inline void board_delay(uint32_t ms)
+{
+ uint32_t start_ms = board_millis();
+ while (board_millis() - start_ms < ms)
+ {
+ #if CFG_TUD_ENABLED
+ // take chance to run usb background
+ tud_task();
+ #endif
+ }
+}
+
+static inline int board_uart_getchar(void)
+{
+ uint8_t c;
+ return board_uart_read(&c, 1) ? (int) c : (-1);
+}
+
+static inline int board_uart_putchar(uint8_t c)
+{
+ return board_uart_write(&c, 1);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _BSP_BOARD_H_ */
+
+/** @} */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/board_mcu.h b/circuitpython/lib/tinyusb/hw/bsp/board_mcu.h
new file mode 100644
index 0000000..b911e1e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/board_mcu.h
@@ -0,0 +1,157 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_MCU_H_
+#define BOARD_MCU_H_
+
+#include "tusb_option.h"
+
+//--------------------------------------------------------------------+
+// Low Level MCU header include. TinyUSB stack and example should be
+// platform independent and mostly doesn't need to include this file.
+// However there are still certain situation where this file is needed:
+// - FreeRTOSConfig.h to set up correct clock and NVIC interrupts for ARM Cortex
+// - SWO logging for Cortex M with ITM_SendChar() / ITM_ReceiveChar()
+//--------------------------------------------------------------------+
+
+// Include order follows OPT_MCU_ number
+#if CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX || \
+ CFG_TUSB_MCU == OPT_MCU_LPC15XX || CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || \
+ CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC18XX || \
+ CFG_TUSB_MCU == OPT_MCU_LPC40XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX
+ #include "chip.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_LPC51UXX || CFG_TUSB_MCU == OPT_MCU_LPC54XXX || \
+ CFG_TUSB_MCU == OPT_MCU_LPC55XX || CFG_TUSB_MCU == OPT_MCU_MKL25ZXX || \
+ CFG_TUSB_MCU == OPT_MCU_K32L2BXX
+ #include "fsl_device_registers.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_NRF5X
+ #include "nrf.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_SAMD11 || CFG_TUSB_MCU == OPT_MCU_SAMD21 || \
+ CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X || \
+ CFG_TUSB_MCU == OPT_MCU_SAML22 || CFG_TUSB_MCU == OPT_MCU_SAML21
+ #include "sam.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_SAMG
+ #undef LITTLE_ENDIAN // hack to suppress "LITTLE_ENDIAN" redefined
+ #include "sam.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F0
+ #include "stm32f0xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F1
+ #include "stm32f1xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F2
+ #include "stm32f2xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
+ #include "stm32f3xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F4
+ #include "stm32f4xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32F7
+ #include "stm32f7xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32H7
+ #include "stm32h7xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32L0
+ #include "stm32l0xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32L1
+ #include "stm32l1xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_STM32L4
+ #include "stm32l4xx.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // no header needed
+
+#elif CFG_TUSB_MCU == OPT_MCU_MSP430x5xx
+ #include "msp430.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4
+ #include "msp.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_VALENTYUSB_EPTRI
+ // no header needed
+
+#elif CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX
+ #include "fsl_device_registers.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_NUC120
+ #include "NUC100Series.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_NUC121 || CFG_TUSB_MCU == OPT_MCU_NUC126
+ #include "NuMicro.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_NUC505
+ #include "NUC505Series.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_ESP32S2
+ // no header needed
+
+#elif CFG_TUSB_MCU == OPT_MCU_ESP32S3
+ // no header needed
+
+#elif CFG_TUSB_MCU == OPT_MCU_DA1469X
+ #include "DA1469xAB.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_RP2040
+ #include "pico.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_EFM32GG
+ #include "em_device.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_RX63X || CFG_TUSB_MCU == OPT_MCU_RX65X
+ // no header needed
+
+#elif CFG_TUSB_MCU == OPT_MCU_GD32VF103
+ #include "gd32vf103.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_MM32F327X
+ #include "mm32_device.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_XMC4000
+ #include "xmc_device.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_TM4C123
+ #include "TM4C123.h"
+
+#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
+ // no header needed
+
+#else
+ #error "Missing MCU header"
+#endif
+
+
+#endif /* BOARD_MCU_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.h b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.h
new file mode 100644
index 0000000..1d3565d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.h
@@ -0,0 +1,38 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.mk b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.mk
new file mode 100644
index 0000000..52e9e45
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.mk
@@ -0,0 +1,5 @@
+CFLAGS += -mcpu=arm1176jzf-s \
+ -DBCM_VERSION=2835 \
+ -DCFG_TUSB_MCU=OPT_MCU_BCM2835
+
+SUFFIX =
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.c b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.c
new file mode 100644
index 0000000..f7a11fb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.c
@@ -0,0 +1,156 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+
+#include "broadcom/cpu.h"
+#include "broadcom/gpio.h"
+#include "broadcom/interrupts.h"
+#include "broadcom/mmu.h"
+#include "broadcom/caches.h"
+#include "broadcom/vcmailbox.h"
+
+// LED
+#define LED_PIN 18
+#define LED_STATE_ON 1
+
+// UART TX
+#define UART_TX_PIN 14
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+void board_init(void)
+{
+ setup_mmu_flat_map();
+ init_caches();
+
+ // LED
+ gpio_set_function(LED_PIN, GPIO_FUNCTION_OUTPUT);
+ gpio_set_pull(LED_PIN, BP_PULL_NONE);
+ board_led_write(true);
+
+ // Uart
+ COMPLETE_MEMORY_READS;
+ AUX->ENABLES_b.UART_1 = true;
+
+ UART1->IER = 0;
+ UART1->CNTL = 0;
+ UART1->LCR_b.DATA_SIZE = UART1_LCR_DATA_SIZE_MODE_8BIT;
+ UART1->MCR = 0;
+ UART1->IER = 0;
+
+ uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
+ UART1->BAUD = ((source_clock / (115200 * 8)) - 1);
+ UART1->CNTL |= UART1_CNTL_TX_ENABLE_Msk;
+ COMPLETE_MEMORY_READS;
+
+ gpio_set_function(UART_TX_PIN, GPIO_FUNCTION_ALT5);
+
+ // Turn on USB peripheral.
+ vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true);
+
+ // Timer 1/1024 second tick
+ SYSTMR->CS_b.M1 = 1;
+ SYSTMR->C1 = SYSTMR->CLO + 977;
+ BP_EnableIRQ(TIMER_1_IRQn);
+
+ BP_SetPriority(USB_IRQn, 0x00);
+ BP_ClearPendingIRQ(USB_IRQn);
+ BP_EnableIRQ(USB_IRQn);
+ BP_EnableIRQs();
+}
+
+void board_led_write(bool state)
+{
+ gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ for (int i = 0; i < len; i++) {
+ const char* cbuf = buf;
+ while (!UART1->STAT_b.TX_READY) {}
+ if (cbuf[i] == '\n') {
+ UART1->IO = '\r';
+ while (!UART1->STAT_b.TX_READY) {}
+ }
+ UART1->IO = cbuf[i];
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void TIMER_1_IRQHandler(void)
+{
+ system_ticks++;
+ SYSTMR->C1 += 977;
+ SYSTMR->CS_b.M1 = 1;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ // asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.mk b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.mk
new file mode 100644
index 0000000..98744c5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_32bit/family.mk
@@ -0,0 +1,46 @@
+MCU_DIR = hw/mcu/broadcom
+DEPS_SUBMODULES += $(MCU_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -Wall \
+ -O0 \
+ -ffreestanding \
+ -nostdlib \
+ -nostartfiles \
+ -mgeneral-regs-only \
+ -fno-exceptions \
+ -std=c17
+
+CROSS_COMPILE = arm-none-eabi-
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(MCU_DIR)/broadcom/gen/interrupt_handlers.c \
+ $(MCU_DIR)/broadcom/gpio.c \
+ $(MCU_DIR)/broadcom/interrupts.c \
+ $(MCU_DIR)/broadcom/mmu.c \
+ $(MCU_DIR)/broadcom/caches.c \
+ $(MCU_DIR)/broadcom/vcmailbox.c
+
+SKIP_NANOLIB = 1
+
+LD_FILE = $(MCU_DIR)/broadcom/link$(SUFFIX).ld
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)
+
+SRC_S += $(MCU_DIR)/broadcom/boot$(SUFFIX).S
+
+$(BUILD)/kernel$(SUFFIX).img: $(BUILD)/$(PROJECT).elf
+ $(OBJCOPY) -O binary $^ $@
+
+# Copy to kernel to netboot drive or SD card
+# Change destinaation to fit your need
+flash: $(BUILD)/kernel$(SUFFIX).img
+ @$(CP) $< /home/$(USER)/Documents/code/pi_tinyusb/boot_cpy
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.h b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.h
new file mode 100644
index 0000000..1d3565d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.h
@@ -0,0 +1,38 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.mk b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.mk
new file mode 100644
index 0000000..5706b83
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.mk
@@ -0,0 +1,3 @@
+CFLAGS += -mcpu=cortex-a72 \
+ -DBCM_VERSION=2711 \
+ -DCFG_TUSB_MCU=OPT_MCU_BCM2711
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.h b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.h
new file mode 100644
index 0000000..1d3565d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.h
@@ -0,0 +1,38 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.mk b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.mk
new file mode 100644
index 0000000..3060b05
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.mk
@@ -0,0 +1,3 @@
+CFLAGS += -mcpu=cortex-a53 \
+ -DBCM_VERSION=2837 \
+ -DCFG_TUSB_MCU=OPT_MCU_BCM2837
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.c b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.c
new file mode 100644
index 0000000..f7a11fb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.c
@@ -0,0 +1,156 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+
+#include "broadcom/cpu.h"
+#include "broadcom/gpio.h"
+#include "broadcom/interrupts.h"
+#include "broadcom/mmu.h"
+#include "broadcom/caches.h"
+#include "broadcom/vcmailbox.h"
+
+// LED
+#define LED_PIN 18
+#define LED_STATE_ON 1
+
+// UART TX
+#define UART_TX_PIN 14
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+void board_init(void)
+{
+ setup_mmu_flat_map();
+ init_caches();
+
+ // LED
+ gpio_set_function(LED_PIN, GPIO_FUNCTION_OUTPUT);
+ gpio_set_pull(LED_PIN, BP_PULL_NONE);
+ board_led_write(true);
+
+ // Uart
+ COMPLETE_MEMORY_READS;
+ AUX->ENABLES_b.UART_1 = true;
+
+ UART1->IER = 0;
+ UART1->CNTL = 0;
+ UART1->LCR_b.DATA_SIZE = UART1_LCR_DATA_SIZE_MODE_8BIT;
+ UART1->MCR = 0;
+ UART1->IER = 0;
+
+ uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
+ UART1->BAUD = ((source_clock / (115200 * 8)) - 1);
+ UART1->CNTL |= UART1_CNTL_TX_ENABLE_Msk;
+ COMPLETE_MEMORY_READS;
+
+ gpio_set_function(UART_TX_PIN, GPIO_FUNCTION_ALT5);
+
+ // Turn on USB peripheral.
+ vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true);
+
+ // Timer 1/1024 second tick
+ SYSTMR->CS_b.M1 = 1;
+ SYSTMR->C1 = SYSTMR->CLO + 977;
+ BP_EnableIRQ(TIMER_1_IRQn);
+
+ BP_SetPriority(USB_IRQn, 0x00);
+ BP_ClearPendingIRQ(USB_IRQn);
+ BP_EnableIRQ(USB_IRQn);
+ BP_EnableIRQs();
+}
+
+void board_led_write(bool state)
+{
+ gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ for (int i = 0; i < len; i++) {
+ const char* cbuf = buf;
+ while (!UART1->STAT_b.TX_READY) {}
+ if (cbuf[i] == '\n') {
+ UART1->IO = '\r';
+ while (!UART1->STAT_b.TX_READY) {}
+ }
+ UART1->IO = cbuf[i];
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void TIMER_1_IRQHandler(void)
+{
+ system_ticks++;
+ SYSTMR->C1 += 977;
+ SYSTMR->CS_b.M1 = 1;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ // asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.mk b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.mk
new file mode 100644
index 0000000..7239267
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/broadcom_64bit/family.mk
@@ -0,0 +1,46 @@
+MCU_DIR = hw/mcu/broadcom
+DEPS_SUBMODULES += $(MCU_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -Wall \
+ -O0 \
+ -ffreestanding \
+ -nostdlib \
+ -nostartfiles \
+ -mgeneral-regs-only \
+ -std=c17
+
+CROSS_COMPILE = aarch64-none-elf-
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(MCU_DIR)/broadcom/gen/interrupt_handlers.c \
+ $(MCU_DIR)/broadcom/gpio.c \
+ $(MCU_DIR)/broadcom/interrupts.c \
+ $(MCU_DIR)/broadcom/mmu.c \
+ $(MCU_DIR)/broadcom/caches.c \
+ $(MCU_DIR)/broadcom/vcmailbox.c
+
+SKIP_NANOLIB = 1
+
+LD_FILE = $(MCU_DIR)/broadcom/link8.ld
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core_A/Include
+
+SRC_S += $(MCU_DIR)/broadcom/boot8.S
+
+$(BUILD)/kernel8.img: $(BUILD)/$(PROJECT).elf
+ $(OBJCOPY) -O binary $^ $@
+
+# Copy to kernel to netboot drive or SD card
+# Change destinaation to fit your need
+flash: $(BUILD)/kernel8.img
+ @$(CP) $< /home/$(USER)/Documents/code/pi_tinyusb/boot_cpy
diff --git a/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/boards/mm900evxb/board.h b/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/boards/mm900evxb/board.h
new file mode 100644
index 0000000..57936fd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/boards/mm900evxb/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright 2021 Bridgetek Pte Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// Note: This definition file covers all MM900EV1B, MM900EV2B, and MM900EV3B boards.
+// Each of these boards has an FT900 device.
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define GPIO_UART0_TX 48
+#define GPIO_UART0_RX 49
+#define GPIO_ETH_LED0 61
+#define GPIO_ETH_LED1 62
+#define GPIO_REMOTE_WAKEUP_PIN 18
+#define USBD_VBUS_DTC_PIN 3
+
+#define GPIO_REMOTE_WAKEUP
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.c b/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.c
new file mode 100644
index 0000000..6b3c1f5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.c
@@ -0,0 +1,215 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright 2021 Bridgetek Pte Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+
+#include <registers/ft900_registers.h>
+#include <ft900.h>
+
+#if CFG_TUD_ENABLED
+int8_t board_ft90x_vbus(void); // Board specific implementation of VBUS detection for USB device.
+extern void ft90x_usbd_pm_ISR(uint16_t pmcfg); // Interrupt handler for USB device power management
+#endif
+
+#ifdef GPIO_REMOTE_WAKEUP
+void gpio_ISR(void);
+#endif
+void timer_ISR(void);
+volatile unsigned int timer_ms = 0;
+void board_pm_ISR(void);
+
+#define WELCOME_MSG "\x1B[2J\x1B[H" \
+ "MM900EVxB board\r\n"
+
+// Initialize on-board peripherals : led, button, uart and USB
+void board_init(void)
+{
+ sys_reset_all();
+ // Enable the UART Device.
+ sys_enable(sys_device_uart0);
+ // Set UART0 GPIO functions to UART0_TXD and UART0_RXD.
+ gpio_function(GPIO_UART0_TX, pad_uart0_txd); /* UART0 TXD */
+ gpio_function(GPIO_UART0_RX, pad_uart0_rxd); /* UART0 RXD */
+ uart_open(UART0, /* Device */
+ 1, /* Prescaler = 1 */
+ UART_DIVIDER_19200_BAUD, /* Divider = 1302 */
+ uart_data_bits_8, /* No. Data Bits */
+ uart_parity_none, /* Parity */
+ uart_stop_bits_1); /* No. Stop Bits */
+ // Print out a welcome message.
+ // Use sizeof to avoid pulling in strlen unnecessarily.
+ board_uart_write(WELCOME_MSG, sizeof(WELCOME_MSG));
+
+#if 0
+ // Ethernet LEDs
+ gpio_function(GPIO_ETH_LED0, pad_gpio4); /* ETH LED0 */
+ gpio_dir(GPIO_ETH_LED0, pad_dir_open_drain);
+ gpio_function(GPIO_ETH_LED1, pad_gpio5); /* ETH LED1 */
+ gpio_dir(GPIO_ETH_LED1, pad_dir_output);
+#endif
+
+ sys_enable(sys_device_timer_wdt);
+ /* Timer A = 1ms */
+ timer_prescaler(timer_select_a, 1000);
+ timer_init(timer_select_a, 100, timer_direction_down, timer_prescaler_select_on, timer_mode_continuous);
+ timer_enable_interrupt(timer_select_a);
+ timer_start(timer_select_a);
+ interrupt_attach(interrupt_timers, (int8_t)interrupt_timers, timer_ISR);
+
+ // Setup VBUS detect GPIO. If the device is connected then this
+ // will set the MASK_SYS_PMCFG_DEV_DETECT_EN bit in PMCFG.
+ gpio_interrupt_disable(USBD_VBUS_DTC_PIN);
+ gpio_function(USBD_VBUS_DTC_PIN, pad_vbus_dtc);
+ gpio_pull(USBD_VBUS_DTC_PIN, pad_pull_pulldown);
+ gpio_dir(USBD_VBUS_DTC_PIN, pad_dir_input);
+
+ interrupt_attach(interrupt_0, (int8_t)interrupt_0, board_pm_ISR);
+
+#ifdef GPIO_REMOTE_WAKEUP
+ //Configuring GPIO pin to wakeup.
+ // Set up the wakeup pin.
+ gpio_dir(GPIO_REMOTE_WAKEUP_PIN, pad_dir_input);
+ gpio_pull(GPIO_REMOTE_WAKEUP_PIN, pad_pull_pullup);
+
+ // Attach an interrupt handler.
+ interrupt_attach(interrupt_gpio, (uint8_t)interrupt_gpio, gpio_ISR);
+ gpio_interrupt_enable(GPIO_REMOTE_WAKEUP_PIN, gpio_int_edge_falling);
+#endif
+
+ uart_disable_interrupt(UART0, uart_interrupt_tx);
+ uart_disable_interrupt(UART0, uart_interrupt_rx);
+
+ // Enable all peripheral interrupts.
+ interrupt_enable_globally();
+
+ TU_LOG1("MM900EV1B board setup complete\r\n");
+};
+
+void timer_ISR(void)
+{
+ if (timer_is_interrupted(timer_select_a))
+ {
+ timer_ms++;
+ }
+}
+
+#ifdef GPIO_REMOTE_WAKEUP
+void gpio_ISR(void)
+{
+ if (gpio_is_interrupted(GPIO_REMOTE_WAKEUP_PIN))
+ {
+ }
+}
+#endif
+
+/* Power management ISR */
+void board_pm_ISR(void)
+{
+ uint16_t pmcfg = SYS->PMCFG_H;
+
+#if defined(__FT930__)
+ if (pmcfg & MASK_SYS_PMCFG_SLAVE_PERI_IRQ_PEND)
+ {
+ // Clear d2xx hw engine wakeup.
+ SYS->PMCFG_H = MASK_SYS_PMCFG_SLAVE_PERI_IRQ_PEND;
+ }
+#endif
+ if (pmcfg & MASK_SYS_PMCFG_PM_GPIO_IRQ_PEND)
+ {
+ // Clear GPIO wakeup pending.
+ SYS->PMCFG_H = MASK_SYS_PMCFG_PM_GPIO_IRQ_PEND;
+ }
+
+#if defined(__FT900__)
+ // USB device power management interrupts.
+ if (pmcfg & (MASK_SYS_PMCFG_DEV_CONN_DEV |
+ MASK_SYS_PMCFG_DEV_DIS_DEV |
+ MASK_SYS_PMCFG_HOST_RST_DEV |
+ MASK_SYS_PMCFG_HOST_RESUME_DEV)
+ )
+ {
+#if CFG_TUD_ENABLED
+ ft90x_usbd_pm_ISR(pmcfg);
+#endif
+ }
+#endif
+}
+
+#if CFG_TUD_ENABLED
+int8_t board_ft90x_vbus(void)
+{
+ return gpio_read(USBD_VBUS_DTC_PIN);
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+// Turn LED on or off
+void board_led_write(bool state)
+{
+ gpio_write(GPIO_ETH_LED0, state);
+}
+
+// Get the current state of button
+// a '1' means active (pressed), a '0' means inactive.
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+// Get characters from UART
+int board_uart_read(uint8_t *buf, int len)
+{
+ int r = uart_readn(UART0, (uint8_t *)buf, len);
+
+ return r;
+}
+
+// Send characters to UART
+int board_uart_write(void const *buf, int len)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual" // uart_writen does not have const for buffer parameter.
+ int r = uart_writen(UART0, (uint8_t *)((const void *)buf), len);
+#pragma GCC diagnostic pop
+
+ return r;
+}
+
+// Get current milliseconds
+uint32_t board_millis(void)
+{
+ uint32_t safe_ms;
+
+ CRITICAL_SECTION_BEGIN
+ safe_ms = timer_ms;
+ CRITICAL_SECTION_END
+
+ return safe_ms;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.mk b/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.mk
new file mode 100644
index 0000000..3933f15
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/brtmm90x/family.mk
@@ -0,0 +1,67 @@
+# GCC prefix for FT90X compile tools.
+CROSS_COMPILE = ft32-elf-
+SKIP_NANOLIB = 1
+
+# Set to use FT90X prebuilt libraries.
+FT90X_PREBUILT_LIBS = 0
+ifeq ($(FT90X_PREBUILT_LIBS),1)
+# If the FT90X toolchain is installed on Windows systems then the SDK
+# include files and prebuilt libraries are at: %FT90X_TOOLCHAIN%/hardware
+FT9XX_SDK = $(FT90X_TOOLCHAIN)/hardware
+INC += $(FT9XX_SDK)/include
+else
+# The submodule BRTSG-FOSS/ft90x-sdk contains header files and source
+# code for the Bridgetek SDK. This can be used instead of the prebuilt
+# library.
+DEPS_SUBMODULES += hw/mcu/bridgetek/ft9xx/ft90x-sdk
+# The SDK can be used to load specific files from the Bridgetek SDK.
+FT9XX_SDK = hw/mcu/bridgetek/ft9xx/ft90x-sdk/Source
+INC += $(TOP)/$(FT9XX_SDK)/include
+endif
+
+# Add include files which are within the TinyUSB directory structure.
+INC += \
+ $(TOP)/$(BOARD_PATH)
+
+# Add required C Compiler flags for FT90X.
+CFLAGS += \
+ -D__FT900__ \
+ -fvar-tracking \
+ -fvar-tracking-assignments \
+ -fmessage-length=0 \
+ -ffunction-sections \
+ -DCFG_TUSB_MCU=OPT_MCU_FT90X
+
+# lwip/src/core/raw.c:334:43: error: declaration of 'recv' shadows a global declaration
+CFLAGS += -Wno-error=shadow
+
+# Add include files outside the TinyUSB structure that are added manually.
+CFLAGS += -I"$(FT9XX_SDK)/include"
+
+# Set Linker flags.
+LD_FILE = hw/mcu/bridgetek/ft9xx/scripts/ldscript.ld
+LDFLAGS += $(addprefix -L,$(LDINC)) \
+ -Xlinker --entry=_start \
+ -Wl,-lc
+
+# Additional Source files for FT90X.
+SRC_C += src/portable/bridgetek/ft9xx/dcd_ft9xx.c
+
+# Linker library.
+ifneq ($(FT90X_PREBUILT_LIBS),1)
+# Optionally add in files from the Bridgetek SDK instead of the prebuilt
+# library. These are the minimum required.
+SRC_C += $(FT9XX_SDK)/src/sys.c
+SRC_C += $(FT9XX_SDK)/src/interrupt.c
+SRC_C += $(FT9XX_SDK)/src/delay.c
+SRC_C += $(FT9XX_SDK)/src/timers.c
+SRC_C += $(FT9XX_SDK)/src/uart_simple.c
+SRC_C += $(FT9XX_SDK)/src/gpio.c
+else
+# Or if using the prebuilt libraries add them.
+LDFLAGS += -L"$(FT9XX_SDK)/lib"
+LIBS += -lft900
+endif
+
+# Not required crt0 file for FT90X. Use compiler built-in file.
+#SRC_S += hw/mcu/bridgetek/ft9xx/scripts/crt0.S
diff --git a/circuitpython/lib/tinyusb/hw/bsp/d5035_01/board.mk b/circuitpython/lib/tinyusb/hw/bsp/d5035_01/board.mk
new file mode 100644
index 0000000..b7796b9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/d5035_01/board.mk
@@ -0,0 +1,61 @@
+DEPS_SUBMODULES += hw/mcu/microchip
+HWREV ?= 1
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mlong-calls \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -D__SAME51J19A__ \
+ -DCONF_CPU_FREQUENCY=80000000 \
+ -DCONF_GCLK_USB_FREQUENCY=48000000 \
+ -DCFG_TUSB_MCU=OPT_MCU_SAME5X \
+ -DD5035_01=1 \
+ -DBOARD_NAME="\"D5035-01\"" \
+ -DSVC_Handler=SVCall_Handler \
+ -DHWREV=$(HWREV)
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-qual
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/same51j19a_flash.ld
+
+SRC_C += \
+ src/portable/microchip/samd/dcd_samd.c \
+ hw/mcu/microchip/same51/gcc/gcc/startup_same51.c \
+ hw/mcu/microchip/same51/gcc/system_same51.c
+
+ifdef SYSCALLS
+ifneq ($(SYSCALLS),0)
+ SRC_C += hw/mcu/microchip/same51/hal/utils/src/utils_syscalls.c
+endif
+endif
+
+ifdef LOG
+ifneq ($(LOG),0)
+ SRC_C += hw/mcu/microchip/same51/hal/utils/src/utils_syscalls.c
+endif
+endif
+
+INC += \
+ $(TOP)/hw/mcu/microchip/same51/ \
+ $(TOP)/hw/mcu/microchip/same51/config \
+ $(TOP)/hw/mcu/microchip/same51/include \
+ $(TOP)/hw/mcu/microchip/same51/hal/include \
+ $(TOP)/hw/mcu/microchip/same51/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/same51/hpl/port \
+ $(TOP)/hw/mcu/microchip/same51/hri \
+ $(TOP)/hw/mcu/microchip/same51/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAME51J19
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/d5035_01/d5035_01.c b/circuitpython/lib/tinyusb/hw/bsp/d5035_01/d5035_01.c
new file mode 100644
index 0000000..f356851
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/d5035_01/d5035_01.c
@@ -0,0 +1,353 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jean Gressmann <jean@0x42.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include <sam.h>
+#include "bsp/board.h"
+
+#include <hal/include/hal_gpio.h>
+
+#if CONF_CPU_FREQUENCY != 80000000
+# error "CONF_CPU_FREQUENCY" must 80000000
+#endif
+
+#if CONF_GCLK_USB_FREQUENCY != 48000000
+# error "CONF_GCLK_USB_FREQUENCY" must 48000000
+#endif
+
+#if !defined(HWREV)
+# error Define "HWREV"
+#endif
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_0_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+void USB_1_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+void USB_2_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+void USB_3_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+#define LED_PIN PIN_PA02
+
+#if HWREV < 3
+# define BOARD_SERCOM SERCOM5
+#else
+# define BOARD_SERCOM SERCOM0
+#endif
+
+static inline void init_clock(void)
+{
+ /* AUTOWS is enabled by default in REG_NVMCTRL_CTRLA - no need to change the number of wait states when changing the core clock */
+#if HWREV == 1
+ /* configure XOSC1 for a 16MHz crystal connected to XIN1/XOUT1 */
+ OSCCTRL->XOSCCTRL[1].reg =
+ OSCCTRL_XOSCCTRL_STARTUP(6) | // 1,953 ms
+ OSCCTRL_XOSCCTRL_RUNSTDBY |
+ OSCCTRL_XOSCCTRL_ENALC |
+ OSCCTRL_XOSCCTRL_IMULT(4) |
+ OSCCTRL_XOSCCTRL_IPTAT(3) |
+ OSCCTRL_XOSCCTRL_XTALEN |
+ OSCCTRL_XOSCCTRL_ENABLE;
+ while(0 == OSCCTRL->STATUS.bit.XOSCRDY1);
+
+ OSCCTRL->Dpll[0].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_DIV(3) | OSCCTRL_DPLLCTRLB_REFCLK(OSCCTRL_DPLLCTRLB_REFCLK_XOSC1_Val); /* pre-scaler = 8, input = XOSC1 */
+ OSCCTRL->Dpll[0].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0x0) | OSCCTRL_DPLLRATIO_LDR(39); /* multiply by 40 -> 80 MHz */
+ OSCCTRL->Dpll[0].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_RUNSTDBY | OSCCTRL_DPLLCTRLA_ENABLE;
+ while(0 == OSCCTRL->Dpll[0].DPLLSTATUS.bit.CLKRDY); /* wait for the PLL0 to be ready */
+
+ OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_DIV(7) | OSCCTRL_DPLLCTRLB_REFCLK(OSCCTRL_DPLLCTRLB_REFCLK_XOSC1_Val); /* pre-scaler = 16, input = XOSC1 */
+ OSCCTRL->Dpll[1].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0x0) | OSCCTRL_DPLLRATIO_LDR(47); /* multiply by 48 -> 48 MHz */
+ OSCCTRL->Dpll[1].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_RUNSTDBY | OSCCTRL_DPLLCTRLA_ENABLE;
+ while(0 == OSCCTRL->Dpll[1].DPLLSTATUS.bit.CLKRDY); /* wait for the PLL1 to be ready */
+#else // HWREV >= 1
+ /* configure XOSC0 for a 16MHz crystal connected to XIN0/XOUT0 */
+ OSCCTRL->XOSCCTRL[0].reg =
+ OSCCTRL_XOSCCTRL_STARTUP(6) | // 1,953 ms
+ OSCCTRL_XOSCCTRL_RUNSTDBY |
+ OSCCTRL_XOSCCTRL_ENALC |
+ OSCCTRL_XOSCCTRL_IMULT(4) |
+ OSCCTRL_XOSCCTRL_IPTAT(3) |
+ OSCCTRL_XOSCCTRL_XTALEN |
+ OSCCTRL_XOSCCTRL_ENABLE;
+ while(0 == OSCCTRL->STATUS.bit.XOSCRDY0);
+
+ OSCCTRL->Dpll[0].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_DIV(3) | OSCCTRL_DPLLCTRLB_REFCLK(OSCCTRL_DPLLCTRLB_REFCLK_XOSC0_Val); /* pre-scaler = 8, input = XOSC1 */
+ OSCCTRL->Dpll[0].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0x0) | OSCCTRL_DPLLRATIO_LDR(39); /* multiply by 40 -> 80 MHz */
+ OSCCTRL->Dpll[0].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_RUNSTDBY | OSCCTRL_DPLLCTRLA_ENABLE;
+ while(0 == OSCCTRL->Dpll[0].DPLLSTATUS.bit.CLKRDY); /* wait for the PLL0 to be ready */
+
+ OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_DIV(7) | OSCCTRL_DPLLCTRLB_REFCLK(OSCCTRL_DPLLCTRLB_REFCLK_XOSC0_Val); /* pre-scaler = 16, input = XOSC1 */
+ OSCCTRL->Dpll[1].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0x0) | OSCCTRL_DPLLRATIO_LDR(47); /* multiply by 48 -> 48 MHz */
+ OSCCTRL->Dpll[1].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_RUNSTDBY | OSCCTRL_DPLLCTRLA_ENABLE;
+ while(0 == OSCCTRL->Dpll[1].DPLLSTATUS.bit.CLKRDY); /* wait for the PLL1 to be ready */
+#endif // HWREV
+
+ /* configure clock-generator 0 to use DPLL0 as source -> GCLK0 is used for the core */
+ GCLK->GENCTRL[0].reg =
+ GCLK_GENCTRL_DIV(0) |
+ GCLK_GENCTRL_RUNSTDBY |
+ GCLK_GENCTRL_GENEN |
+ GCLK_GENCTRL_SRC_DPLL0 | /* DPLL0 */
+ GCLK_GENCTRL_IDC ;
+ while(1 == GCLK->SYNCBUSY.bit.GENCTRL0); /* wait for the synchronization between clock domains to be complete */
+
+ /* configure clock-generator 1 to use DPLL1 as source -> for use with some peripheral */
+ GCLK->GENCTRL[1].reg =
+ GCLK_GENCTRL_DIV(0) |
+ GCLK_GENCTRL_RUNSTDBY |
+ GCLK_GENCTRL_GENEN |
+ GCLK_GENCTRL_SRC_DPLL1 |
+ GCLK_GENCTRL_IDC ;
+ while(1 == GCLK->SYNCBUSY.bit.GENCTRL1); /* wait for the synchronization between clock domains to be complete */
+
+ /* configure clock-generator 2 to use DPLL0 as source -> for use with SERCOM */
+ GCLK->GENCTRL[2].reg =
+ GCLK_GENCTRL_DIV(1) | /* 80MHz */
+ GCLK_GENCTRL_RUNSTDBY |
+ GCLK_GENCTRL_GENEN |
+ GCLK_GENCTRL_SRC_DPLL0 |
+ GCLK_GENCTRL_IDC ;
+ while(1 == GCLK->SYNCBUSY.bit.GENCTRL2); /* wait for the synchronization between clock domains to be complete */
+}
+
+static inline void uart_init(void)
+{
+#if HWREV < 3
+ /* configure SERCOM5 on PB02 */
+ PORT->Group[1].WRCONFIG.reg =
+ PORT_WRCONFIG_WRPINCFG |
+ PORT_WRCONFIG_WRPMUX |
+ PORT_WRCONFIG_PMUX(3) | /* function D */
+ PORT_WRCONFIG_DRVSTR |
+ PORT_WRCONFIG_PINMASK(0x0004) | /* PB02 */
+ PORT_WRCONFIG_PMUXEN;
+
+ MCLK->APBDMASK.bit.SERCOM5_ = 1;
+ GCLK->PCHCTRL[SERCOM5_GCLK_ID_CORE].reg = GCLK_PCHCTRL_GEN_GCLK2 | GCLK_PCHCTRL_CHEN; /* setup SERCOM to use GLCK2 -> 80MHz */
+
+ SERCOM5->USART.CTRLA.reg = 0x00; /* disable SERCOM -> enable config */
+ while(SERCOM5->USART.SYNCBUSY.bit.ENABLE);
+
+ SERCOM5->USART.CTRLA.reg = /* CMODE = 0 -> async, SAMPA = 0, FORM = 0 -> USART frame, SMPR = 0 -> arithmetic baud rate */
+ SERCOM_USART_CTRLA_SAMPR(1) | /* 0 = 16x / arithmetic baud rate, 1 = 16x / fractional baud rate */
+// SERCOM_USART_CTRLA_FORM(0) | /* 0 = USART Frame, 2 = LIN Master */
+ SERCOM_USART_CTRLA_DORD | /* LSB first */
+ SERCOM_USART_CTRLA_MODE(1) | /* 0 = Asynchronous, 1 = USART with internal clock */
+ SERCOM_USART_CTRLA_RXPO(1) | /* SERCOM PAD[1] is used for data reception */
+ SERCOM_USART_CTRLA_TXPO(0); /* SERCOM PAD[0] is used for data transmission */
+
+ SERCOM5->USART.CTRLB.reg = /* RXEM = 0 -> receiver disabled, LINCMD = 0 -> normal USART transmission, SFDE = 0 -> start-of-frame detection disabled, SBMODE = 0 -> one stop bit, CHSIZE = 0 -> 8 bits */
+ SERCOM_USART_CTRLB_TXEN; /* transmitter enabled */
+ SERCOM5->USART.CTRLC.reg = 0x00;
+ // 21.701388889 @ baud rate of 230400 bit/s, table 33-2, p 918 of DS60001507E
+ SERCOM5->USART.BAUD.reg = SERCOM_USART_BAUD_FRAC_FP(7) | SERCOM_USART_BAUD_FRAC_BAUD(21);
+
+// SERCOM5->USART.INTENSET.reg = SERCOM_USART_INTENSET_TXC;
+ SERCOM5->SPI.CTRLA.bit.ENABLE = 1; /* activate SERCOM */
+ while(SERCOM5->USART.SYNCBUSY.bit.ENABLE); /* wait for SERCOM to be ready */
+#else
+/* configure SERCOM0 on PA08 */
+ PORT->Group[0].WRCONFIG.reg =
+ PORT_WRCONFIG_WRPINCFG |
+ PORT_WRCONFIG_WRPMUX |
+ PORT_WRCONFIG_PMUX(2) | /* function C */
+ PORT_WRCONFIG_DRVSTR |
+ PORT_WRCONFIG_PINMASK(0x0100) | /* PA08 */
+ PORT_WRCONFIG_PMUXEN;
+
+ MCLK->APBAMASK.bit.SERCOM0_ = 1;
+ GCLK->PCHCTRL[SERCOM0_GCLK_ID_CORE].reg = GCLK_PCHCTRL_GEN_GCLK2 | GCLK_PCHCTRL_CHEN; /* setup SERCOM to use GLCK2 -> 80MHz */
+
+ SERCOM0->USART.CTRLA.reg = 0x00; /* disable SERCOM -> enable config */
+ while(SERCOM0->USART.SYNCBUSY.bit.ENABLE);
+
+ SERCOM0->USART.CTRLA.reg = /* CMODE = 0 -> async, SAMPA = 0, FORM = 0 -> USART frame, SMPR = 0 -> arithmetic baud rate */
+ SERCOM_USART_CTRLA_SAMPR(1) | /* 0 = 16x / arithmetic baud rate, 1 = 16x / fractional baud rate */
+// SERCOM_USART_CTRLA_FORM(0) | /* 0 = USART Frame, 2 = LIN Master */
+ SERCOM_USART_CTRLA_DORD | /* LSB first */
+ SERCOM_USART_CTRLA_MODE(1) | /* 0 = Asynchronous, 1 = USART with internal clock */
+ SERCOM_USART_CTRLA_RXPO(1) | /* SERCOM PAD[1] is used for data reception */
+ SERCOM_USART_CTRLA_TXPO(0); /* SERCOM PAD[0] is used for data transmission */
+
+ SERCOM0->USART.CTRLB.reg = /* RXEM = 0 -> receiver disabled, LINCMD = 0 -> normal USART transmission, SFDE = 0 -> start-of-frame detection disabled, SBMODE = 0 -> one stop bit, CHSIZE = 0 -> 8 bits */
+ SERCOM_USART_CTRLB_TXEN; /* transmitter enabled */
+ SERCOM0->USART.CTRLC.reg = 0x00;
+ // 21.701388889 @ baud rate of 230400 bit/s, table 33-2, p 918 of DS60001507E
+ SERCOM0->USART.BAUD.reg = SERCOM_USART_BAUD_FRAC_FP(7) | SERCOM_USART_BAUD_FRAC_BAUD(21);
+
+// SERCOM0->USART.INTENSET.reg = SERCOM_USART_INTENSET_TXC;
+ SERCOM0->SPI.CTRLA.bit.ENABLE = 1; /* activate SERCOM */
+ while(SERCOM0->USART.SYNCBUSY.bit.ENABLE); /* wait for SERCOM to be ready */
+#endif
+}
+
+static inline void uart_send_buffer(uint8_t const *text, size_t len)
+{
+ for (size_t i = 0; i < len; ++i) {
+ BOARD_SERCOM->USART.DATA.reg = text[i];
+ while((BOARD_SERCOM->USART.INTFLAG.reg & SERCOM_SPI_INTFLAG_TXC) == 0);
+ }
+}
+
+static inline void uart_send_str(const char* text)
+{
+ while (*text) {
+ BOARD_SERCOM->USART.DATA.reg = *text++;
+ while((BOARD_SERCOM->USART.INTFLAG.reg & SERCOM_SPI_INTFLAG_TXC) == 0);
+ }
+}
+
+
+void board_init(void)
+{
+ init_clock();
+
+ SystemCoreClock = CONF_CPU_FREQUENCY;
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ uart_init();
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " UART initialized\n");
+ tu_printf(BOARD_NAME " reset cause %#02x\n", RSTC->RCAUSE.reg);
+#endif
+
+ // Led init
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(LED_PIN, 0);
+
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " LED pin configured\n");
+#endif
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_3_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+
+#if CFG_TUD_ENABLED
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " USB device enabled\n");
+#endif
+
+ /* USB clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation. */
+ hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+ hri_mclk_set_AHBMASK_USB_bit(MCLK);
+ hri_mclk_set_APBBMASK_USB_bit(MCLK);
+
+ // USB pin init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24H_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25H_USB_DP);
+
+
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " USB device configured\n");
+#endif
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // this board has no button
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ if (len < 0) {
+ uart_send_str(buf);
+ } else {
+ uart_send_buffer(buf, len);
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/d5035_01/same51j19a_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/d5035_01/same51j19a_flash.ld
new file mode 100644
index 0000000..328d1c7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/d5035_01/same51j19a_flash.ld
@@ -0,0 +1,163 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAME51J19A
+ *
+ * Copyright (c) 2019 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/board.mk b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/board.mk
new file mode 100644
index 0000000..e969c79
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/board.mk
@@ -0,0 +1,55 @@
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mthumb-interwork \
+ -mabi=aapcs \
+ -mcpu=cortex-m33+nodsp \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-sp-d16 \
+ -nostdlib \
+ -DCORE_M33 \
+ -DCFG_TUSB_MCU=OPT_MCU_DA1469X \
+ -DCFG_TUD_ENDPOINT0_SIZE=8\
+
+MCU_FAMILY_DIR = hw/mcu/dialog/da1469x
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/da1469x.ld
+
+# While this is for da1469x chip, there is chance that da1468x chip family will also work
+SRC_C += \
+ src/portable/dialog/da146xx/dcd_da146xx.c \
+ $(MCU_FAMILY_DIR)/src/system_da1469x.c \
+ $(MCU_FAMILY_DIR)/src/da1469x_clock.c \
+ $(MCU_FAMILY_DIR)/src/hal_gpio.c \
+
+SRC_S += hw/bsp/$(BOARD)/gcc_startup_da1469x.S
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(MCU_FAMILY_DIR)/include \
+ $(TOP)/$(MCU_FAMILY_DIR)/SDK_10.0.8.105/sdk/bsp/include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM33_NTZ/non_secure
+
+# For flash-jlink target
+JLINK_DEVICE = DA14695
+
+# flash using jlink but with some twists
+flash: flash-dialog
+
+flash-dialog: $(BUILD)/$(PROJECT).bin
+ @echo '#define SW_VERSION "v_1.0.0.1"' >$(BUILD)/version.h
+ @echo '#define SW_VERSION_DATE "'`date +"%Y-%m-%d %H:%M"`'"' >>$(BUILD)/version.h
+ mkimage da1469x $(BUILD)/$(PROJECT).bin $(BUILD)/version.h $^.img
+ cp $(TOP)/hw/bsp/$(BOARD)/product_header.dump $(BUILD)/$(BOARD)-image.bin
+ cat $^.img >> $(BUILD)/$(BOARD)-image.bin
+ @echo r > $(BUILD)/$(BOARD).jlink
+ @echo halt >> $(BUILD)/$(BOARD).jlink
+ @echo loadfile $(BUILD)/$(BOARD)-image.bin 0x16000000 >> $(BUILD)/$(BOARD).jlink
+ @echo r >> $(BUILD)/$(BOARD).jlink
+ @echo go >> $(BUILD)/$(BOARD).jlink
+ @echo exit >> $(BUILD)/$(BOARD).jlink
+ $(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da14695_dk_usb.c b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da14695_dk_usb.c
new file mode 100644
index 0000000..a4d9968
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da14695_dk_usb.c
@@ -0,0 +1,134 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include <hal/hal_gpio.h>
+#include <mcu/mcu.h>
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+#define LED_PIN 33 // P1.1
+#define LED_STATE_ON 1
+#define LED_STATE_OFF (1-LED_STATE_ON)
+
+#define BUTTON_PIN 6
+
+void UnhandledIRQ(void)
+{
+ CRG_TOP->SYS_CTRL_REG = 0x80;
+ __BKPT(1);
+ while(1);
+}
+
+// DA146xx driver function that must be called whenever VBUS changes.
+extern void tusb_vbus_changed(bool present);
+
+void board_init(void)
+{
+ // LED
+ hal_gpio_init_out(LED_PIN, LED_STATE_ON);
+
+ hal_gpio_init_out(1, 0);
+ hal_gpio_init_out(2, 0);
+ hal_gpio_init_out(3, 0);
+ hal_gpio_init_out(4, 0);
+ hal_gpio_init_out(5, 0);
+
+ // Button
+ hal_gpio_init_in(BUTTON_PIN, HAL_GPIO_PULL_DOWN);
+
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#if CFG_TUD_ENABLED
+ // This board is USB powered there is no need to monitor
+ // VBUS line. Notify driver that VBUS is present.
+ tusb_vbus_changed(true);
+
+ /* Setup USB IRQ */
+ NVIC_SetPriority(USB_IRQn, 2);
+ NVIC_EnableIRQ(USB_IRQn);
+
+ /* Use PLL96 / 2 clock not HCLK */
+ CRG_TOP->CLK_CTRL_REG &= ~CRG_TOP_CLK_CTRL_REG_USB_CLK_SRC_Msk;
+
+ mcu_gpio_set_pin_function(14, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
+ mcu_gpio_set_pin_function(15, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ hal_gpio_write(LED_PIN, state ? LED_STATE_ON : LED_STATE_OFF);
+}
+
+uint32_t board_button_read(void)
+{
+ // button is active HIGH
+ return hal_gpio_read(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void)buf;
+ (void)len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void)buf;
+ (void)len;
+
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da1469x.ld b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da1469x.ld
new file mode 100644
index 0000000..96507d6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/da1469x.ld
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+MEMORY
+{
+ /*
+ * Flash is remapped at 0x0 by 1st stage bootloader, but this is done with
+ * an offset derived from image header thus it is safer to use remapped
+ * address space at 0x0 instead of QSPI_M address space at 0x16000000.
+ * Bootloader partition is 32K, but 9K is currently reserved for product
+ * header (8K) and image header (1K).
+ * First 512 bytes of SYSRAM are remapped at 0x0 and used as ISR vector
+ * (there's no need to reallocate ISR vector) and thus cannot be used by
+ * application.
+ */
+
+ FLASH (r) : ORIGIN = (0x00000000), LENGTH = (1024 * 1024)
+ RAM (rw) : ORIGIN = (0x20000000), LENGTH = (512 * 1024)
+}
+
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __HeapBase
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __bssnz_start__
+ * __bssnz_end__
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ __text = .;
+
+ .text :
+ {
+ __isr_vector_start = .;
+ KEEP(*(.isr_vector))
+ /* ISR vector shall have exactly 512 bytes */
+ . = __isr_vector_start + 0x200;
+ __isr_vector_end = .;
+
+ *(.text)
+ *(.text.*)
+
+ *(.libcmac.rom)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ *(.eh_frame*)
+ . = ALIGN(4);
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ . = ALIGN(4);
+ } > FLASH
+ __exidx_end = .;
+
+ .intvect :
+ {
+ . = ALIGN(4);
+ __intvect_start__ = .;
+ . = . + (__isr_vector_end - __isr_vector_start);
+ . = ALIGN(4);
+ } > RAM
+
+ .sleep_state (NOLOAD) :
+ {
+ . = ALIGN(4);
+ *(sleep_state)
+ } > RAM
+
+ /* This section will be zeroed by RTT package init */
+ .rtt (NOLOAD):
+ {
+ . = ALIGN(4);
+ *(.rtt)
+ . = ALIGN(4);
+ } > RAM
+
+ __text_ram_addr = LOADADDR(.text_ram);
+
+ .text_ram :
+ {
+ . = ALIGN(4);
+ __text_ram_start__ = .;
+ *(.text_ram*)
+ . = ALIGN(4);
+ __text_ram_end__ = .;
+ } > RAM AT > FLASH
+
+ __etext = LOADADDR(.data);
+
+ .data :
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ *(.preinit_array)
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ *(SORT(.init_array.*))
+ *(.init_array)
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ *(SORT(.fini_array.*))
+ *(.fini_array)
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ *(.jcr)
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+ } > RAM AT > FLASH
+
+ .bssnz :
+ {
+ . = ALIGN(4);
+ __bssnz_start__ = .;
+ *(.bss.core.nz*)
+ . = ALIGN(4);
+ __bssnz_end__ = .;
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .cmac (NOLOAD) :
+ {
+ . = ALIGN(0x400);
+ *(.libcmac.ram)
+ } > RAM
+
+ /* Heap starts after BSS */
+ . = ALIGN(8);
+ __HeapBase = .;
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > RAM
+
+ _ram_start = ORIGIN(RAM);
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Top of head is the bottom of the stack */
+ __HeapLimit = __StackLimit;
+ end = __HeapLimit;
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack")
+
+ /* Check that intvect is at the beginning of RAM */
+ ASSERT(__intvect_start__ == ORIGIN(RAM), "intvect is not at beginning of RAM")
+}
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/gcc_startup_da1469x.S b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/gcc_startup_da1469x.S
new file mode 100644
index 0000000..d47fbcd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/gcc_startup_da1469x.S
@@ -0,0 +1,301 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ #include "syscfg/syscfg.h"
+
+ .syntax unified
+ .arch armv7-m
+
+ .section .stack
+ .align 3
+#ifdef __STACK_SIZE
+ .equ Stack_Size, __STACK_SIZE
+#else
+ .equ Stack_Size, 0xC00
+#endif
+ .equ SYS_CTRL_REG, 0x50000024
+ .equ CACHE_FLASH_REG, 0x100C0040
+ .equ RESET_STAT_REG, 0x500000BC
+
+ .globl __StackTop
+ .globl __StackLimit
+__StackLimit:
+ .space Stack_Size
+ .size __StackLimit, . - __StackLimit
+__StackTop:
+ .size __StackTop, . - __StackTop
+
+ .section .heap
+ .align 3
+#ifdef __HEAP_SIZE
+ .equ Heap_Size, __HEAP_SIZE
+#else
+ .equ Heap_Size, 0
+#endif
+ .globl __HeapBase
+ .globl __HeapLimit
+__HeapBase:
+ .if Heap_Size
+ .space Heap_Size
+ .endif
+ .size __HeapBase, . - __HeapBase
+__HeapLimit:
+ .size __HeapLimit, . - __HeapLimit
+
+ .section .isr_vector
+ .align 2
+ .globl __isr_vector
+__isr_vector:
+ .long __StackTop
+ .long Reset_Handler
+ /* Cortex-M33 interrupts */
+ .long NMI_Handler
+ .long HardFault_Handler
+ .long MemoryManagement_Handler
+ .long BusFault_Handler
+ .long UsageFault_Handler
+ .long SecureFault_Handler
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long SVC_Handler
+ .long DebugMonitor_Handler
+ .long 0 /* Reserved */
+ .long PendSV_Handler
+ .long SysTick_Handler
+ /* DA1469x interrupts */
+ .long SENSOR_NODE_IRQHandler
+ .long DMA_IRQHandler
+ .long CHARGER_STATE_IRQHandler
+ .long CHARGER_ERROR_IRQHandler
+ .long CMAC2SYS_IRQHandler
+ .long UART_IRQHandler
+ .long UART2_IRQHandler
+ .long UART3_IRQHandler
+ .long I2C_IRQHandler
+ .long I2C2_IRQHandler
+ .long SPI_IRQHandler
+ .long SPI2_IRQHandler
+ .long PCM_IRQHandler
+ .long SRC_IN_IRQHandler
+ .long SRC_OUT_IRQHandler
+ .long USB_IRQHandler
+ .long TIMER_IRQHandler
+ .long TIMER2_IRQHandler
+ .long RTC_IRQHandler
+ .long KEY_WKUP_GPIO_IRQHandler
+ .long PDC_IRQHandler
+ .long VBUS_IRQHandler
+ .long MRM_IRQHandler
+ .long MOTOR_CONTROLLER_IRQHandler
+ .long TRNG_IRQHandler
+ .long DCDC_IRQHandler
+ .long XTAL32M_RDY_IRQHandler
+ .long ADC_IRQHandler
+ .long ADC2_IRQHandler
+ .long CRYPTO_IRQHandler
+ .long CAPTIMER1_IRQHandler
+ .long RFDIAG_IRQHandler
+ .long LCD_CONTROLLER_IRQHandler
+ .long PLL_LOCK_IRQHandler
+ .long TIMER3_IRQHandler
+ .long TIMER4_IRQHandler
+ .long LRA_IRQHandler
+ .long RTC_EVENT_IRQHandler
+ .long GPIO_P0_IRQHandler
+ .long GPIO_P1_IRQHandler
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .size __isr_vector, . - __isr_vector
+
+ .text
+ .thumb
+ .thumb_func
+ .align 2
+ .globl Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ /* Make sure interrupt vector is remapped at 0x0 */
+ ldr r1, =SYS_CTRL_REG
+ ldrh r2, [r1, #0]
+ orrs r2, r2, #8
+ strh r2, [r1, #0]
+
+#if !MYNEWT_VAL(RAM_RESIDENT)
+/*
+ * Flash is remapped at 0x0 with an offset, i.e. 0x0 does not correspond to
+ * 0x16000000 but to start of an image on flash. This is calculated from product
+ * header by 1st state bootloader and configured in CACHE_FLASH_REG. We need to
+ * retrieve proper offset value for calculations later.
+ */
+ ldr r1, =CACHE_FLASH_REG
+ ldr r4, [r1, #0]
+ mov r2, r4
+ mov r3, #0xFFFF
+ bic r4, r4, r3 /* CACHE_FLASH_REG[FLASH_REGION_BASE] */
+ mov r3, #0xFFF0
+ and r2, r2, r3 /* CACHE_FLASH_REG[FLASH_REGION_OFFSET] */
+ lsr r2, r2, #2
+ orr r4, r4, r2
+
+/* Copy ISR vector from flash to RAM */
+ ldr r1, =__isr_vector_start /* src ptr */
+ ldr r2, =__isr_vector_end /* src end */
+ ldr r3, =__intvect_start__ /* dst ptr */
+/* Make sure we copy from QSPIC address range, not from remapped range */
+ cmp r1, r4
+ itt lt
+ addlt r1, r1, r4
+ addlt r2, r2, r4
+.loop_isr_copy:
+ cmp r1, r2
+ ittt lt
+ ldrlt r0, [r1], #4
+ strlt r0, [r3], #4
+ blt .loop_isr_copy
+
+/* Copy QSPI code from flash to RAM */
+ ldr r1, =__text_ram_addr /* src ptr */
+ ldr r2, =__text_ram_start__ /* ptr */
+ ldr r3, =__text_ram_end__ /* dst end */
+.loop_code_text_ram_copy:
+ cmp r2, r3
+ ittt lt
+ ldrlt r0, [r1], #4
+ strlt r0, [r2], #4
+ blt .loop_code_text_ram_copy
+
+/* Copy data from flash to RAM */
+ ldr r1, =__etext /* src ptr */
+ ldr r2, =__data_start__ /* dst ptr */
+ ldr r3, =__data_end__ /* dst end */
+.loop_data_copy:
+ cmp r2, r3
+ ittt lt
+ ldrlt r0, [r1], #4
+ strlt r0, [r2], #4
+ blt .loop_data_copy
+#endif
+
+/* Clear BSS */
+ movs r0, 0
+ ldr r1, =__bss_start__
+ ldr r2, =__bss_end__
+.loop_bss_clear:
+ cmp r1, r2
+ itt lt
+ strlt r0, [r1], #4
+ blt .loop_bss_clear
+
+ ldr r0, =__HeapBase
+ ldr r1, =__HeapLimit
+/* Call static constructors */
+ bl __libc_init_array
+
+ bl SystemInit
+ bl main
+
+ .pool
+ .size Reset_Handler, . - Reset_Handler
+
+/* Default interrupt handler */
+ .type Default_Handler, %function
+Default_Handler:
+ ldr r1, =SYS_CTRL_REG
+ ldrh r2, [r1, #0]
+ orrs r2, r2, #0x80 /* DEBUGGER_ENABLE */
+ strh r2, [r1, #0]
+ b .
+
+ .size Default_Handler, . - Default_Handler
+
+/* Default handlers for all interrupts */
+ .macro IRQ handler
+ .weak \handler
+ .set \handler, Default_Handler
+ .endm
+
+ /* Cortex-M33 interrupts */
+ IRQ NMI_Handler
+ IRQ HardFault_Handler
+ IRQ MemoryManagement_Handler
+ IRQ BusFault_Handler
+ IRQ UsageFault_Handler
+ IRQ SecureFault_Handler
+ IRQ SVC_Handler
+ IRQ DebugMonitor_Handler
+ IRQ PendSV_Handler
+ IRQ SysTick_Handler
+ /* DA1469x interrupts */
+ IRQ SENSOR_NODE_IRQHandler
+ IRQ DMA_IRQHandler
+ IRQ CHARGER_STATE_IRQHandler
+ IRQ CHARGER_ERROR_IRQHandler
+ IRQ CMAC2SYS_IRQHandler
+ IRQ UART_IRQHandler
+ IRQ UART2_IRQHandler
+ IRQ UART3_IRQHandler
+ IRQ I2C_IRQHandler
+ IRQ I2C2_IRQHandler
+ IRQ SPI_IRQHandler
+ IRQ SPI2_IRQHandler
+ IRQ PCM_IRQHandler
+ IRQ SRC_IN_IRQHandler
+ IRQ SRC_OUT_IRQHandler
+ IRQ USB_IRQHandler
+ IRQ TIMER_IRQHandler
+ IRQ TIMER2_IRQHandler
+ IRQ RTC_IRQHandler
+ IRQ KEY_WKUP_GPIO_IRQHandler
+ IRQ PDC_IRQHandler
+ IRQ VBUS_IRQHandler
+ IRQ MRM_IRQHandler
+ IRQ MOTOR_CONTROLLER_IRQHandler
+ IRQ TRNG_IRQHandler
+ IRQ DCDC_IRQHandler
+ IRQ XTAL32M_RDY_IRQHandler
+ IRQ ADC_IRQHandler
+ IRQ ADC2_IRQHandler
+ IRQ CRYPTO_IRQHandler
+ IRQ CAPTIMER1_IRQHandler
+ IRQ RFDIAG_IRQHandler
+ IRQ LCD_CONTROLLER_IRQHandler
+ IRQ PLL_LOCK_IRQHandler
+ IRQ TIMER3_IRQHandler
+ IRQ TIMER4_IRQHandler
+ IRQ LRA_IRQHandler
+ IRQ RTC_EVENT_IRQHandler
+ IRQ GPIO_P0_IRQHandler
+ IRQ GPIO_P1_IRQHandler
+ IRQ RESERVED40_IRQHandler
+ IRQ RESERVED41_IRQHandler
+ IRQ RESERVED42_IRQHandler
+ IRQ RESERVED43_IRQHandler
+ IRQ RESERVED44_IRQHandler
+ IRQ RESERVED45_IRQHandler
+ IRQ RESERVED46_IRQHandler
+ IRQ RESERVED47_IRQHandler
+
+.end
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/product_header.dump b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/product_header.dump
new file mode 100644
index 0000000..ea48422
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/product_header.dump
Binary files differ
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/syscfg/syscfg.h b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/syscfg/syscfg.h
new file mode 100644
index 0000000..6cbb431
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da14695_dk_usb/syscfg/syscfg.h
@@ -0,0 +1,34 @@
+/**
+ * This file was generated by Apache newt version: 1.9.0-dev
+ */
+
+#ifndef H_MYNEWT_SYSCFG_
+#define H_MYNEWT_SYSCFG_
+
+/**
+ * This macro exists to ensure code includes this header when needed. If code
+ * checks the existence of a setting directly via ifdef without including this
+ * header, the setting macro will silently evaluate to 0. In contrast, an
+ * attempt to use these macros without including this header will result in a
+ * compiler error.
+ */
+#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
+#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
+
+#ifndef MYNEWT_VAL_RAM_RESIDENT
+#define MYNEWT_VAL_RAM_RESIDENT (0)
+#endif
+
+#ifndef MYNEWT_VAL_MCU_GPIO_MAX_IRQ
+#define MYNEWT_VAL_MCU_GPIO_MAX_IRQ (4)
+#endif
+
+#ifndef MYNEWT_VAL_MCU_GPIO_RETAINABLE_NUM
+#define MYNEWT_VAL_MCU_GPIO_RETAINABLE_NUM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_MCU_CLOCK_XTAL32M_SETTLE_TIME_US
+#define MYNEWT_VAL_MCU_CLOCK_XTAL32M_SETTLE_TIME_US (2000)
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/board.mk b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/board.mk
new file mode 100644
index 0000000..980fc42
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/board.mk
@@ -0,0 +1,55 @@
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mthumb-interwork \
+ -mabi=aapcs \
+ -mcpu=cortex-m33+nodsp \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-sp-d16 \
+ -nostdlib \
+ -DCORE_M33 \
+ -DCFG_TUSB_MCU=OPT_MCU_DA1469X \
+ -DCFG_TUD_ENDPOINT0_SIZE=8\
+
+MCU_FAMILY_DIR = hw/mcu/dialog/da1469x
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/da1469x.ld
+
+# While this is for da1469x chip, there is chance that da1468x chip family will also work
+SRC_C += \
+ src/portable/dialog/da146xx/dcd_da146xx.c \
+ $(MCU_FAMILY_DIR)/src/system_da1469x.c \
+ $(MCU_FAMILY_DIR)/src/da1469x_clock.c \
+ $(MCU_FAMILY_DIR)/src/hal_gpio.c \
+
+SRC_S += hw/bsp/$(BOARD)/gcc_startup_da1469x.S
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(MCU_FAMILY_DIR)/include \
+ $(TOP)/$(MCU_FAMILY_DIR)/SDK_10.0.8.105/sdk/bsp/include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM33_NTZ/non_secure
+
+# For flash-jlink target
+JLINK_DEVICE = DA14699
+
+# flash using jlink but with some twists
+flash: flash-dialog
+
+flash-dialog: $(BUILD)/$(PROJECT).bin
+ @echo '#define SW_VERSION "v_1.0.0.1"' >$(BUILD)/version.h
+ @echo '#define SW_VERSION_DATE "'`date +"%Y-%m-%d %H:%M"`'"' >>$(BUILD)/version.h
+ mkimage da1469x $(BUILD)/$(PROJECT).bin $(BUILD)/version.h $^.img
+ cp $(TOP)/hw/bsp/$(BOARD)/product_header.dump $(BUILD)/$(BOARD)-image.bin
+ cat $^.img >> $(BUILD)/$(BOARD)-image.bin
+ @echo r > $(BUILD)/$(BOARD).jlink
+ @echo halt >> $(BUILD)/$(BOARD).jlink
+ @echo loadfile $(BUILD)/$(BOARD)-image.bin 0x16000000 >> $(BUILD)/$(BOARD).jlink
+ @echo r >> $(BUILD)/$(BOARD).jlink
+ @echo go >> $(BUILD)/$(BOARD).jlink
+ @echo exit >> $(BUILD)/$(BOARD).jlink
+ $(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x-dk-pro.c b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x-dk-pro.c
new file mode 100644
index 0000000..13113fb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x-dk-pro.c
@@ -0,0 +1,151 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include <hal/hal_gpio.h>
+#include <mcu/mcu.h>
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+#if CFG_TUD_ENABLED
+// DA146xx driver function that must be called whenever VBUS changes
+extern void tusb_vbus_changed(bool present);
+
+// VBUS change interrupt handler
+void VBUS_IRQHandler(void)
+{
+ bool present = (CRG_TOP->ANA_STATUS_REG & CRG_TOP_ANA_STATUS_REG_VBUS_AVAILABLE_Msk) != 0;
+ // Clear VBUS interrupt
+ CRG_TOP->VBUS_IRQ_CLEAR_REG = 1;
+
+ tusb_vbus_changed(present);
+}
+#endif
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+#define LED_PIN 33
+#define LED_STATE_ON 1
+#define LED_STATE_OFF 0
+
+#define BUTTON_PIN 6
+
+void UnhandledIRQ(void)
+{
+ CRG_TOP->SYS_CTRL_REG = 0x80;
+ __BKPT(1);
+ while(1);
+}
+
+void board_init(void)
+{
+ // LED
+ hal_gpio_init_out(LED_PIN, LED_STATE_ON);
+
+ hal_gpio_init_out(1, 0);
+ hal_gpio_init_out(2, 0);
+ hal_gpio_init_out(3, 0);
+ hal_gpio_init_out(4, 0);
+ hal_gpio_init_out(5, 0);
+
+ // Button
+ hal_gpio_init_in(BUTTON_PIN, HAL_GPIO_PULL_UP);
+
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#if CFG_TUD_ENABLED
+ // Setup interrupt for both connect and disconnect
+ CRG_TOP->VBUS_IRQ_MASK_REG = CRG_TOP_VBUS_IRQ_MASK_REG_VBUS_IRQ_EN_FALL_Msk |
+ CRG_TOP_VBUS_IRQ_MASK_REG_VBUS_IRQ_EN_RISE_Msk;
+ NVIC_SetPriority(VBUS_IRQn, 2);
+ // Trigger interrupt at the start to inform driver about VBUS state at start
+ // otherwise it could go unnoticed.
+ NVIC_SetPendingIRQ(VBUS_IRQn);
+ NVIC_EnableIRQ(VBUS_IRQn);
+
+ /* Setup USB IRQ */
+ NVIC_SetPriority(USB_IRQn, 2);
+ NVIC_EnableIRQ(USB_IRQn);
+
+ /* Use PLL96 / 2 clock not HCLK */
+ CRG_TOP->CLK_CTRL_REG &= ~CRG_TOP_CLK_CTRL_REG_USB_CLK_SRC_Msk;
+
+ mcu_gpio_set_pin_function(14, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
+ mcu_gpio_set_pin_function(15, MCU_GPIO_MODE_INPUT, MCU_GPIO_FUNC_USB);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ hal_gpio_write(LED_PIN, state ? LED_STATE_ON : LED_STATE_OFF);
+}
+
+uint32_t board_button_read(void)
+{
+ // button is active LOW
+ return hal_gpio_read(BUTTON_PIN) ^ 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void)buf;
+ (void)len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void)buf;
+ (void)len;
+
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x.ld b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x.ld
new file mode 100644
index 0000000..96507d6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/da1469x.ld
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+MEMORY
+{
+ /*
+ * Flash is remapped at 0x0 by 1st stage bootloader, but this is done with
+ * an offset derived from image header thus it is safer to use remapped
+ * address space at 0x0 instead of QSPI_M address space at 0x16000000.
+ * Bootloader partition is 32K, but 9K is currently reserved for product
+ * header (8K) and image header (1K).
+ * First 512 bytes of SYSRAM are remapped at 0x0 and used as ISR vector
+ * (there's no need to reallocate ISR vector) and thus cannot be used by
+ * application.
+ */
+
+ FLASH (r) : ORIGIN = (0x00000000), LENGTH = (1024 * 1024)
+ RAM (rw) : ORIGIN = (0x20000000), LENGTH = (512 * 1024)
+}
+
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __HeapBase
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __bssnz_start__
+ * __bssnz_end__
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ __text = .;
+
+ .text :
+ {
+ __isr_vector_start = .;
+ KEEP(*(.isr_vector))
+ /* ISR vector shall have exactly 512 bytes */
+ . = __isr_vector_start + 0x200;
+ __isr_vector_end = .;
+
+ *(.text)
+ *(.text.*)
+
+ *(.libcmac.rom)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ *(.eh_frame*)
+ . = ALIGN(4);
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ . = ALIGN(4);
+ } > FLASH
+ __exidx_end = .;
+
+ .intvect :
+ {
+ . = ALIGN(4);
+ __intvect_start__ = .;
+ . = . + (__isr_vector_end - __isr_vector_start);
+ . = ALIGN(4);
+ } > RAM
+
+ .sleep_state (NOLOAD) :
+ {
+ . = ALIGN(4);
+ *(sleep_state)
+ } > RAM
+
+ /* This section will be zeroed by RTT package init */
+ .rtt (NOLOAD):
+ {
+ . = ALIGN(4);
+ *(.rtt)
+ . = ALIGN(4);
+ } > RAM
+
+ __text_ram_addr = LOADADDR(.text_ram);
+
+ .text_ram :
+ {
+ . = ALIGN(4);
+ __text_ram_start__ = .;
+ *(.text_ram*)
+ . = ALIGN(4);
+ __text_ram_end__ = .;
+ } > RAM AT > FLASH
+
+ __etext = LOADADDR(.data);
+
+ .data :
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ *(.preinit_array)
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ *(SORT(.init_array.*))
+ *(.init_array)
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ *(SORT(.fini_array.*))
+ *(.fini_array)
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ *(.jcr)
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+ } > RAM AT > FLASH
+
+ .bssnz :
+ {
+ . = ALIGN(4);
+ __bssnz_start__ = .;
+ *(.bss.core.nz*)
+ . = ALIGN(4);
+ __bssnz_end__ = .;
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .cmac (NOLOAD) :
+ {
+ . = ALIGN(0x400);
+ *(.libcmac.ram)
+ } > RAM
+
+ /* Heap starts after BSS */
+ . = ALIGN(8);
+ __HeapBase = .;
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > RAM
+
+ _ram_start = ORIGIN(RAM);
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Top of head is the bottom of the stack */
+ __HeapLimit = __StackLimit;
+ end = __HeapLimit;
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__HeapBase <= __HeapLimit, "region RAM overflowed with stack")
+
+ /* Check that intvect is at the beginning of RAM */
+ ASSERT(__intvect_start__ == ORIGIN(RAM), "intvect is not at beginning of RAM")
+}
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/gcc_startup_da1469x.S b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/gcc_startup_da1469x.S
new file mode 100644
index 0000000..d47fbcd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/gcc_startup_da1469x.S
@@ -0,0 +1,301 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ #include "syscfg/syscfg.h"
+
+ .syntax unified
+ .arch armv7-m
+
+ .section .stack
+ .align 3
+#ifdef __STACK_SIZE
+ .equ Stack_Size, __STACK_SIZE
+#else
+ .equ Stack_Size, 0xC00
+#endif
+ .equ SYS_CTRL_REG, 0x50000024
+ .equ CACHE_FLASH_REG, 0x100C0040
+ .equ RESET_STAT_REG, 0x500000BC
+
+ .globl __StackTop
+ .globl __StackLimit
+__StackLimit:
+ .space Stack_Size
+ .size __StackLimit, . - __StackLimit
+__StackTop:
+ .size __StackTop, . - __StackTop
+
+ .section .heap
+ .align 3
+#ifdef __HEAP_SIZE
+ .equ Heap_Size, __HEAP_SIZE
+#else
+ .equ Heap_Size, 0
+#endif
+ .globl __HeapBase
+ .globl __HeapLimit
+__HeapBase:
+ .if Heap_Size
+ .space Heap_Size
+ .endif
+ .size __HeapBase, . - __HeapBase
+__HeapLimit:
+ .size __HeapLimit, . - __HeapLimit
+
+ .section .isr_vector
+ .align 2
+ .globl __isr_vector
+__isr_vector:
+ .long __StackTop
+ .long Reset_Handler
+ /* Cortex-M33 interrupts */
+ .long NMI_Handler
+ .long HardFault_Handler
+ .long MemoryManagement_Handler
+ .long BusFault_Handler
+ .long UsageFault_Handler
+ .long SecureFault_Handler
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long SVC_Handler
+ .long DebugMonitor_Handler
+ .long 0 /* Reserved */
+ .long PendSV_Handler
+ .long SysTick_Handler
+ /* DA1469x interrupts */
+ .long SENSOR_NODE_IRQHandler
+ .long DMA_IRQHandler
+ .long CHARGER_STATE_IRQHandler
+ .long CHARGER_ERROR_IRQHandler
+ .long CMAC2SYS_IRQHandler
+ .long UART_IRQHandler
+ .long UART2_IRQHandler
+ .long UART3_IRQHandler
+ .long I2C_IRQHandler
+ .long I2C2_IRQHandler
+ .long SPI_IRQHandler
+ .long SPI2_IRQHandler
+ .long PCM_IRQHandler
+ .long SRC_IN_IRQHandler
+ .long SRC_OUT_IRQHandler
+ .long USB_IRQHandler
+ .long TIMER_IRQHandler
+ .long TIMER2_IRQHandler
+ .long RTC_IRQHandler
+ .long KEY_WKUP_GPIO_IRQHandler
+ .long PDC_IRQHandler
+ .long VBUS_IRQHandler
+ .long MRM_IRQHandler
+ .long MOTOR_CONTROLLER_IRQHandler
+ .long TRNG_IRQHandler
+ .long DCDC_IRQHandler
+ .long XTAL32M_RDY_IRQHandler
+ .long ADC_IRQHandler
+ .long ADC2_IRQHandler
+ .long CRYPTO_IRQHandler
+ .long CAPTIMER1_IRQHandler
+ .long RFDIAG_IRQHandler
+ .long LCD_CONTROLLER_IRQHandler
+ .long PLL_LOCK_IRQHandler
+ .long TIMER3_IRQHandler
+ .long TIMER4_IRQHandler
+ .long LRA_IRQHandler
+ .long RTC_EVENT_IRQHandler
+ .long GPIO_P0_IRQHandler
+ .long GPIO_P1_IRQHandler
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .long 0 /* Reserved */
+ .size __isr_vector, . - __isr_vector
+
+ .text
+ .thumb
+ .thumb_func
+ .align 2
+ .globl Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ /* Make sure interrupt vector is remapped at 0x0 */
+ ldr r1, =SYS_CTRL_REG
+ ldrh r2, [r1, #0]
+ orrs r2, r2, #8
+ strh r2, [r1, #0]
+
+#if !MYNEWT_VAL(RAM_RESIDENT)
+/*
+ * Flash is remapped at 0x0 with an offset, i.e. 0x0 does not correspond to
+ * 0x16000000 but to start of an image on flash. This is calculated from product
+ * header by 1st state bootloader and configured in CACHE_FLASH_REG. We need to
+ * retrieve proper offset value for calculations later.
+ */
+ ldr r1, =CACHE_FLASH_REG
+ ldr r4, [r1, #0]
+ mov r2, r4
+ mov r3, #0xFFFF
+ bic r4, r4, r3 /* CACHE_FLASH_REG[FLASH_REGION_BASE] */
+ mov r3, #0xFFF0
+ and r2, r2, r3 /* CACHE_FLASH_REG[FLASH_REGION_OFFSET] */
+ lsr r2, r2, #2
+ orr r4, r4, r2
+
+/* Copy ISR vector from flash to RAM */
+ ldr r1, =__isr_vector_start /* src ptr */
+ ldr r2, =__isr_vector_end /* src end */
+ ldr r3, =__intvect_start__ /* dst ptr */
+/* Make sure we copy from QSPIC address range, not from remapped range */
+ cmp r1, r4
+ itt lt
+ addlt r1, r1, r4
+ addlt r2, r2, r4
+.loop_isr_copy:
+ cmp r1, r2
+ ittt lt
+ ldrlt r0, [r1], #4
+ strlt r0, [r3], #4
+ blt .loop_isr_copy
+
+/* Copy QSPI code from flash to RAM */
+ ldr r1, =__text_ram_addr /* src ptr */
+ ldr r2, =__text_ram_start__ /* ptr */
+ ldr r3, =__text_ram_end__ /* dst end */
+.loop_code_text_ram_copy:
+ cmp r2, r3
+ ittt lt
+ ldrlt r0, [r1], #4
+ strlt r0, [r2], #4
+ blt .loop_code_text_ram_copy
+
+/* Copy data from flash to RAM */
+ ldr r1, =__etext /* src ptr */
+ ldr r2, =__data_start__ /* dst ptr */
+ ldr r3, =__data_end__ /* dst end */
+.loop_data_copy:
+ cmp r2, r3
+ ittt lt
+ ldrlt r0, [r1], #4
+ strlt r0, [r2], #4
+ blt .loop_data_copy
+#endif
+
+/* Clear BSS */
+ movs r0, 0
+ ldr r1, =__bss_start__
+ ldr r2, =__bss_end__
+.loop_bss_clear:
+ cmp r1, r2
+ itt lt
+ strlt r0, [r1], #4
+ blt .loop_bss_clear
+
+ ldr r0, =__HeapBase
+ ldr r1, =__HeapLimit
+/* Call static constructors */
+ bl __libc_init_array
+
+ bl SystemInit
+ bl main
+
+ .pool
+ .size Reset_Handler, . - Reset_Handler
+
+/* Default interrupt handler */
+ .type Default_Handler, %function
+Default_Handler:
+ ldr r1, =SYS_CTRL_REG
+ ldrh r2, [r1, #0]
+ orrs r2, r2, #0x80 /* DEBUGGER_ENABLE */
+ strh r2, [r1, #0]
+ b .
+
+ .size Default_Handler, . - Default_Handler
+
+/* Default handlers for all interrupts */
+ .macro IRQ handler
+ .weak \handler
+ .set \handler, Default_Handler
+ .endm
+
+ /* Cortex-M33 interrupts */
+ IRQ NMI_Handler
+ IRQ HardFault_Handler
+ IRQ MemoryManagement_Handler
+ IRQ BusFault_Handler
+ IRQ UsageFault_Handler
+ IRQ SecureFault_Handler
+ IRQ SVC_Handler
+ IRQ DebugMonitor_Handler
+ IRQ PendSV_Handler
+ IRQ SysTick_Handler
+ /* DA1469x interrupts */
+ IRQ SENSOR_NODE_IRQHandler
+ IRQ DMA_IRQHandler
+ IRQ CHARGER_STATE_IRQHandler
+ IRQ CHARGER_ERROR_IRQHandler
+ IRQ CMAC2SYS_IRQHandler
+ IRQ UART_IRQHandler
+ IRQ UART2_IRQHandler
+ IRQ UART3_IRQHandler
+ IRQ I2C_IRQHandler
+ IRQ I2C2_IRQHandler
+ IRQ SPI_IRQHandler
+ IRQ SPI2_IRQHandler
+ IRQ PCM_IRQHandler
+ IRQ SRC_IN_IRQHandler
+ IRQ SRC_OUT_IRQHandler
+ IRQ USB_IRQHandler
+ IRQ TIMER_IRQHandler
+ IRQ TIMER2_IRQHandler
+ IRQ RTC_IRQHandler
+ IRQ KEY_WKUP_GPIO_IRQHandler
+ IRQ PDC_IRQHandler
+ IRQ VBUS_IRQHandler
+ IRQ MRM_IRQHandler
+ IRQ MOTOR_CONTROLLER_IRQHandler
+ IRQ TRNG_IRQHandler
+ IRQ DCDC_IRQHandler
+ IRQ XTAL32M_RDY_IRQHandler
+ IRQ ADC_IRQHandler
+ IRQ ADC2_IRQHandler
+ IRQ CRYPTO_IRQHandler
+ IRQ CAPTIMER1_IRQHandler
+ IRQ RFDIAG_IRQHandler
+ IRQ LCD_CONTROLLER_IRQHandler
+ IRQ PLL_LOCK_IRQHandler
+ IRQ TIMER3_IRQHandler
+ IRQ TIMER4_IRQHandler
+ IRQ LRA_IRQHandler
+ IRQ RTC_EVENT_IRQHandler
+ IRQ GPIO_P0_IRQHandler
+ IRQ GPIO_P1_IRQHandler
+ IRQ RESERVED40_IRQHandler
+ IRQ RESERVED41_IRQHandler
+ IRQ RESERVED42_IRQHandler
+ IRQ RESERVED43_IRQHandler
+ IRQ RESERVED44_IRQHandler
+ IRQ RESERVED45_IRQHandler
+ IRQ RESERVED46_IRQHandler
+ IRQ RESERVED47_IRQHandler
+
+.end
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/product_header.dump b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/product_header.dump
new file mode 100644
index 0000000..ea48422
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/product_header.dump
Binary files differ
diff --git a/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/syscfg/syscfg.h b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/syscfg/syscfg.h
new file mode 100644
index 0000000..6cbb431
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/da1469x_dk_pro/syscfg/syscfg.h
@@ -0,0 +1,34 @@
+/**
+ * This file was generated by Apache newt version: 1.9.0-dev
+ */
+
+#ifndef H_MYNEWT_SYSCFG_
+#define H_MYNEWT_SYSCFG_
+
+/**
+ * This macro exists to ensure code includes this header when needed. If code
+ * checks the existence of a setting directly via ifdef without including this
+ * header, the setting macro will silently evaluate to 0. In contrast, an
+ * attempt to use these macros without including this header will result in a
+ * compiler error.
+ */
+#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
+#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
+
+#ifndef MYNEWT_VAL_RAM_RESIDENT
+#define MYNEWT_VAL_RAM_RESIDENT (0)
+#endif
+
+#ifndef MYNEWT_VAL_MCU_GPIO_MAX_IRQ
+#define MYNEWT_VAL_MCU_GPIO_MAX_IRQ (4)
+#endif
+
+#ifndef MYNEWT_VAL_MCU_GPIO_RETAINABLE_NUM
+#define MYNEWT_VAL_MCU_GPIO_RETAINABLE_NUM (-1)
+#endif
+
+#ifndef MYNEWT_VAL_MCU_CLOCK_XTAL32M_SETTLE_TIME_US
+#define MYNEWT_VAL_MCU_CLOCK_XTAL32M_SETTLE_TIME_US (2000)
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/board.mk b/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/board.mk
new file mode 100644
index 0000000..b325dfe
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/board.mk
@@ -0,0 +1,46 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib \
+ -DCORE_M4 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data.$$RAM2")))' \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC40XX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc40xx/lpc_chip_40xx
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc4088.ld
+
+SRC_C += \
+ src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc40xx.c \
+ $(MCU_DIR)/src/chip_17xx_40xx.c \
+ $(MCU_DIR)/src/clock_17xx_40xx.c \
+ $(MCU_DIR)/src/gpio_17xx_40xx.c \
+ $(MCU_DIR)/src/iocon_17xx_40xx.c \
+ $(MCU_DIR)/src/sysctl_17xx_40xx.c \
+ $(MCU_DIR)/src/sysinit_17xx_40xx.c \
+ $(MCU_DIR)/src/uart_17xx_40xx.c \
+ $(MCU_DIR)/src/fpu_init.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = LPC4088
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/ea4088qs.c b/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/ea4088qs.c
new file mode 100644
index 0000000..b25f910
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/ea4088qs.c
@@ -0,0 +1,190 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+#define LED_PORT 2
+#define LED_PIN 19
+
+#define BUTTON_PORT 2
+#define BUTTON_PIN 10
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = 12000000;
+const uint32_t RTCOscRateIn = 32768;
+
+/* Pin muxing configuration */
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ // LED
+ {2, 19, (IOCON_FUNC0 | IOCON_MODE_INACT)},
+
+ // Button
+ {2, 10, (IOCON_FUNC0 | IOCON_MODE_INACT | IOCON_MODE_PULLUP)},
+};
+
+static const PINMUX_GRP_T pin_usb_mux[] =
+{
+ // USB1 as Host
+ {0, 29, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // D+1
+ {0, 30, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // D-1
+ {1, 18, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // UP LED1
+ {1, 19, (IOCON_FUNC2 | IOCON_MODE_INACT)}, // PPWR1
+// {2, 14, (IOCON_FUNC2 | IOCON_MODE_INACT)}, // VBUS1
+// {2, 15, (IOCON_FUNC2 | IOCON_MODE_INACT)}, // OVRCR1
+
+ // USB2 as Device
+ {0, 31, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // D+2
+ {0, 13, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // UP LED
+ {0, 14, (IOCON_FUNC3 | IOCON_MODE_INACT)}, // CONNECT2
+
+ /* VBUS is not connected on this board, so leave the pin at default setting. */
+ /*Chip_IOCON_PinMux(LPC_IOCON, 1, 30, IOCON_MODE_INACT, IOCON_FUNC2);*/ /* USB VBUS */
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+#ifdef __USE_LPCOPEN
+ extern void (* const g_pfnVectors[])(void);
+ unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;
+ *pSCB_VTOR = (unsigned int) g_pfnVectors;
+
+#if __FPU_USED == 1
+ fpuInit();
+#endif
+#endif // __USE_LPCOPEN
+
+ Chip_IOCON_Init(LPC_IOCON);
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+
+ /* CPU clock source starts with IRC */
+ /* Enable PBOOST for CPU clock over 100MHz */
+ Chip_SYSCTL_EnableBoost();
+
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+
+ // UART
+
+ //------------- USB -------------//
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pin_usb_mux, sizeof(pin_usb_mux) / sizeof(PINMUX_GRP_T));
+
+ // Port1 as Host, Port2: Device
+ Chip_USB_Init();
+
+ enum {
+ USBCLK_DEVCIE = 0x12, // AHB + Device
+ USBCLK_HOST = 0x19 , // AHB + OTG + Host
+ USBCLK_ALL = 0x1B // Host + Device + OTG + AHB
+ };
+
+ LPC_USB->OTGClkCtrl = USBCLK_ALL;
+ while ( (LPC_USB->OTGClkSt & USBCLK_ALL) != USBCLK_ALL ) {}
+
+ // set portfunc: USB1 = host, USB2 = device
+ LPC_USB->StCtrl = 0x3;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ //return UART_ReceiveByte(BOARD_UART_PORT);
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ //UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/lpc4088.ld b/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/lpc4088.ld
new file mode 100644
index 0000000..4b1cddd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4088qs/lpc4088.ld
@@ -0,0 +1,184 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC4088
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 15, 2019 5:16:07 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ RamLoc64 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x10000 /* 64K bytes (alias RAM) */
+ RamPeriph32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM2) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash512 = 0x0 ; /* MFlash512 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash512 = 0x0 + 0x80000 ; /* 512K bytes */
+ __top_Flash = 0x0 + 0x80000 ; /* 512K bytes */
+ __base_RamLoc64 = 0x10000000 ; /* RamLoc64 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc64 = 0x10000000 + 0x10000 ; /* 64K bytes */
+ __top_RAM = 0x10000000 + 0x10000 ; /* 64K bytes */
+ __base_RamPeriph32 = 0x20000000 ; /* RamPeriph32 */
+ __base_RAM2 = 0x20000000 ; /* RAM2 */
+ __top_RamPeriph32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM2 = 0x20000000 + 0x8000 ; /* 32K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash512
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash512
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamPeriph32 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamPeriph32)
+ *(.data.$RAM2*)
+ *(.data.$RamPeriph32*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamPeriph32 AT>MFlash512
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc64
+
+ /* Main DATA section (RamLoc64) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc64 AT>MFlash512
+
+ /* BSS section for RamPeriph32 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$RamPeriph32*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamPeriph32
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc64
+
+ /* NOINIT section for RamPeriph32 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$RamPeriph32*)
+ . = ALIGN(4) ;
+ } > RamPeriph32
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc64
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc64 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4357/board.mk b/circuitpython/lib/tinyusb/hw/bsp/ea4357/board.mk
new file mode 100644
index 0000000..6f243c6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4357/board.mk
@@ -0,0 +1,48 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib \
+ -DCORE_M4 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC43XX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc4357.ld
+
+SRC_C += \
+ src/portable/chipidea/ci_hs/dcd_ci_hs.c \
+ src/portable/chipidea/ci_hs/hcd_ci_hs.c \
+ src/portable/ehci/ehci.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc43xx.c \
+ $(MCU_DIR)/src/chip_18xx_43xx.c \
+ $(MCU_DIR)/src/clock_18xx_43xx.c \
+ $(MCU_DIR)/src/gpio_18xx_43xx.c \
+ $(MCU_DIR)/src/sysinit_18xx_43xx.c \
+ $(MCU_DIR)/src/i2c_18xx_43xx.c \
+ $(MCU_DIR)/src/i2cm_18xx_43xx.c \
+ $(MCU_DIR)/src/uart_18xx_43xx.c \
+ $(MCU_DIR)/src/fpu_init.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc \
+ $(TOP)/$(MCU_DIR)/inc/config_43xx
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = LPC4357_M4
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4357/ea4357.c b/circuitpython/lib/tinyusb/hw/bsp/ea4357/ea4357.c
new file mode 100644
index 0000000..aa206a2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4357/ea4357.c
@@ -0,0 +1,291 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+#include "pca9532.h"
+
+#define UART_DEV LPC_USART0
+#define UART_PORT 0x0f
+#define UART_PIN_TX 10
+#define UART_PIN_RX 11
+
+// P9_1 joystick down
+#define BUTTON_PORT 4
+#define BUTTON_PIN 13
+
+//static const struct {
+// uint8_t mux_port;
+// uint8_t mux_pin;
+//
+// uint8_t gpio_port;
+// uint8_t gpio_pin;
+//}buttons[] =
+//{
+// {0x0a, 3, 4, 10 }, // Joystick up
+// {0x09, 1, 4, 13 }, // Joystick down
+// {0x0a, 2, 4, 9 }, // Joystick left
+// {0x09, 0, 4, 12 }, // Joystick right
+// {0x0a, 1, 4, 8 }, // Joystick press
+// {0x02, 7, 0, 7 }, // SW6
+//};
+
+/*------------------------------------------------------------------*/
+/* BOARD API
+ *------------------------------------------------------------------*/
+
+/* System configuration variables used by chip driver */
+const uint32_t OscRateIn = 12000000;
+const uint32_t ExtRateIn = 0;
+
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ // Button ( Joystick down )
+ {0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP)},
+
+ // UART
+ {UART_PORT, UART_PIN_TX, SCU_MODE_PULLDOWN | SCU_MODE_FUNC1},
+ {UART_PORT, UART_PIN_RX, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1},
+
+ // USB
+};
+
+/* Pin clock mux values, re-used structure, value in first index is meaningless */
+static const PINMUX_GRP_T pinclockmuxing[] =
+{
+ {0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ {0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ {0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ {0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+#ifdef __USE_LPCOPEN
+ extern void (* const g_pfnVectors[])(void);
+ unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;
+ *pSCB_VTOR = (unsigned int) g_pfnVectors;
+
+#if __FPU_USED == 1
+ fpuInit();
+#endif
+#endif // __USE_LPCOPEN
+
+ /* Setup system level pin muxing */
+ Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+
+ /* Clock pins only, group field not used */
+ for (int i = 0; i <(int) (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
+ {
+ Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
+ }
+
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ //NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO_PORT);
+
+ // LED via pca9532 I2C
+ Chip_SCU_I2C0PinConfig(I2C0_STANDARD_FAST_MODE);
+ Chip_I2C_Init(I2C0);
+ Chip_I2C_SetClockRate(I2C0, 100000);
+ Chip_I2C_SetMasterEventHandler(I2C0, Chip_I2C_EventHandlerPolling);
+
+ pca9532_init();
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
+
+ //------------- UART -------------//
+ Chip_UART_Init(UART_DEV);
+ Chip_UART_SetBaud(UART_DEV, CFG_BOARD_UART_BAUDRATE);
+ Chip_UART_ConfigData(UART_DEV, UART_LCR_WLEN8 | UART_LCR_SBS_1BIT | UART_LCR_PARITY_DIS);
+ Chip_UART_TXEnable(UART_DEV);
+
+ //------------- USB -------------//
+ enum {
+ USBMODE_DEVICE = 2,
+ USBMODE_HOST = 3
+ };
+
+ enum {
+ USBMODE_VBUS_LOW = 0,
+ USBMODE_VBUS_HIGH = 1
+ };
+
+ /* From EA4357 user manual
+ *
+ * USB0 Device operation:
+ * - Insert jumpers in position 1-2 in JP17/JP18/JP19.
+ * - GPIO28 controls USB connect functionality
+ * - LED32 lights when the USB Device is connected. SJ4 has pads 1-2 shorted by default.
+ * - LED33 is controlled by GPIO27 and signals USB-up state. GPIO54 is used for VBUS
+ * sensing.
+ *
+ * USB0 Host operation:
+ * - insert jumpers in position 2-3 in JP17/JP18/JP19.
+ * - USB Host power is controlled via distribution switch U20 (found in schematic page 11).
+ * - Signal GPIO26 is active low and enables +5V on VBUS2.
+ * - LED35 light whenever +5V is present on VBUS2.
+ * - GPIO55 is connected to status feedback from the distribution switch.
+ * - GPIO54 is used for VBUS sensing. 15Kohm pull-down resistors are always active
+ *
+ * Note:
+ * - Insert jumpers in position 2-3 in JP17/JP18/JP19
+ * - Insert jumpers in JP31 (OTG)
+ */
+#if CFG_TUSB_RHPORT0_MODE
+ Chip_USB0_Init();
+#endif
+
+ /* From EA4357 user manual
+ *
+ * For USB1 Device:
+ * - a 1.5Kohm pull-up resistor is needed on the USB DP data signal. There are two methods to create this.
+ * JP15 is inserted and the pull-up resistor is always enabled. Alternatively, the pull-up resistor is activated
+ * inside the USB OTG chip (U31), and this has to be done via the I2C interface of GPIO52/GPIO53. In the latter case,
+ * JP15 shall not be inserted.
+ * - J19 is the connector to use when USB Device is used. Normally it should be a USB-B connector for
+ * creating a USB Device interface, but the mini-AB connector can also be used in this case. The status
+ * of VBUS can be read via U31.
+ * - JP16 shall not be inserted.
+ *
+ * For USB1 Host:
+ * - 15Kohm pull-down resistors are needed on the USB data signals. These are activated inside the USB OTG chip (U31),
+ * and this has to be done via the I2C interface of GPIO52/GPIO53.
+ * - J20 is the connector to use when USB Host is used. In order to provide +5V to the external USB
+ * device connected to this connector (J20), channel A of U20 must be enabled. It is enabled by default
+ * since SJ5 is normally connected between pin 1-2.
+ * - LED34 lights green when +5V is available on J20.
+ * - JP15 shall not be inserted. JP16 has no effect
+ */
+#if CFG_TUSB_RHPORT1_MODE
+ Chip_USB1_Init();
+#endif
+
+ // USB0 Vbus Power: P2_3 on EA4357 channel B U20 GPIO26 active low (base board)
+ Chip_SCU_PinMuxSet(2, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC7);
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ // P9_5 (GPIO5[18]) (GPIO28 on oem base) as USB connect, active low.
+ Chip_SCU_PinMuxSet(9, 5, SCU_MODE_PULLDOWN | SCU_MODE_FUNC4);
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 18);
+ #endif
+
+ // USB1 Power: EA4357 channel A U20 is enabled by SJ5 connected to pad 1-2, no more action required
+ // TODO Remove R170, R171, solder a pair of 15K to USB1 D+/D- to test with USB1 Host
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+void USB1_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
+ tuh_int_handler(1);
+ #endif
+
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ tud_int_handler(1);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ if (state)
+ {
+ pca9532_setLeds( LED1, 0 );
+ }else
+ {
+ pca9532_setLeds( 0, LED1);
+ }
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return Chip_GPIO_GetPinState(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ //return UART_ReceiveByte(BOARD_UART_DEV);
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ uint8_t const* buf8 = (uint8_t const*) buf;
+ for(int i=0; i<len; i++)
+ {
+ while ((Chip_UART_ReadLineStatus(UART_DEV) & UART_LSR_THRE) == 0) {}
+ Chip_UART_SendByte(UART_DEV, buf8[i]);
+ }
+
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4357/lpc4357.ld b/circuitpython/lib/tinyusb/hw/bsp/ea4357/lpc4357.ld
new file mode 100644
index 0000000..14a0df3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4357/lpc4357.ld
@@ -0,0 +1,324 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC4357
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 15, 2019 5:48:43 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlashA512 (rx) : ORIGIN = 0x1a000000, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ MFlashB512 (rx) : ORIGIN = 0x1b000000, LENGTH = 0x80000 /* 512K bytes (alias Flash2) */
+ RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ RamLoc40 (rwx) : ORIGIN = 0x10080000, LENGTH = 0xa000 /* 40K bytes (alias RAM2) */
+ RamAHB32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM3) */
+ RamAHB16 (rwx) : ORIGIN = 0x20008000, LENGTH = 0x4000 /* 16K bytes (alias RAM4) */
+ RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlashA512 = 0x1a000000 ; /* MFlashA512 */
+ __base_Flash = 0x1a000000 ; /* Flash */
+ __top_MFlashA512 = 0x1a000000 + 0x80000 ; /* 512K bytes */
+ __top_Flash = 0x1a000000 + 0x80000 ; /* 512K bytes */
+ __base_MFlashB512 = 0x1b000000 ; /* MFlashB512 */
+ __base_Flash2 = 0x1b000000 ; /* Flash2 */
+ __top_MFlashB512 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+ __top_Flash2 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+ __base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __base_RamLoc40 = 0x10080000 ; /* RamLoc40 */
+ __base_RAM2 = 0x10080000 ; /* RAM2 */
+ __top_RamLoc40 = 0x10080000 + 0xa000 ; /* 40K bytes */
+ __top_RAM2 = 0x10080000 + 0xa000 ; /* 40K bytes */
+ __base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
+ __base_RAM3 = 0x20000000 ; /* RAM3 */
+ __top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
+ __base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
+ __base_RAM4 = 0x20008000 ; /* RAM4 */
+ __top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
+ __top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
+ __base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
+ __base_RAM5 = 0x2000c000 ; /* RAM5 */
+ __top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+ __top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ .text_Flash2 : ALIGN(4)
+ {
+ FILL(0xff)
+ *(.text_Flash2*) /* for compatibility with previous releases */
+ *(.text_MFlashB512*) /* for compatibility with previous releases */
+ *(.text.$Flash2*)
+ *(.text.$MFlashB512*)
+ *(.rodata.$Flash2*)
+ *(.rodata.$MFlashB512*)
+ } > MFlashB512
+
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ LONG(LOADADDR(.data_RAM4));
+ LONG( ADDR(.data_RAM4));
+ LONG( SIZEOF(.data_RAM4));
+ LONG(LOADADDR(.data_RAM5));
+ LONG( ADDR(.data_RAM5));
+ LONG( SIZEOF(.data_RAM5));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ LONG( ADDR(.bss_RAM4));
+ LONG( SIZEOF(.bss_RAM4));
+ LONG( ADDR(.bss_RAM5));
+ LONG( SIZEOF(.bss_RAM5));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlashA512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlashA512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlashA512
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlashA512
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamLoc40 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamLoc40)
+ *(.data.$RAM2*)
+ *(.data.$RamLoc40*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamLoc40 AT>MFlashA512
+ /* DATA section for RamAHB32 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM3*)
+ *(.data.$RamAHB32*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ } > RamAHB32 AT>MFlashA512
+ /* DATA section for RamAHB16 */
+
+ .data_RAM4 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM4 = .) ;
+ *(.ramfunc.$RAM4)
+ *(.ramfunc.$RamAHB16)
+ *(.data.$RAM4*)
+ *(.data.$RamAHB16*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM4 = .) ;
+ } > RamAHB16 AT>MFlashA512
+ /* DATA section for RamAHB_ETB16 */
+
+ .data_RAM5 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM5 = .) ;
+ *(.ramfunc.$RAM5)
+ *(.ramfunc.$RamAHB_ETB16)
+ *(.data.$RAM5*)
+ *(.data.$RamAHB_ETB16*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM5 = .) ;
+ } > RamAHB_ETB16 AT>MFlashA512
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc32
+
+ /* Main DATA section (RamLoc32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc32 AT>MFlashA512
+
+ /* BSS section for RamLoc40 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$RamLoc40*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamLoc40
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM3 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM3 = .) ;
+ *(.bss.$RAM3*)
+ *(.bss.$RamAHB32*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ } > RamAHB32
+
+ /* BSS section for RamAHB16 */
+ .bss_RAM4 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM4 = .) ;
+ *(.bss.$RAM4*)
+ *(.bss.$RamAHB16*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM4 = .) ;
+ } > RamAHB16
+
+ /* BSS section for RamAHB_ETB16 */
+ .bss_RAM5 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM5 = .) ;
+ *(.bss.$RAM5*)
+ *(.bss.$RamAHB_ETB16*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM5 = .) ;
+ } > RamAHB_ETB16
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc32
+
+ /* NOINIT section for RamLoc40 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$RamLoc40*)
+ . = ALIGN(4) ;
+ } > RamLoc40
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM3 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM3*)
+ *(.noinit.$RamAHB32*)
+ . = ALIGN(4) ;
+ } > RamAHB32
+
+ /* NOINIT section for RamAHB16 */
+ .noinit_RAM4 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM4*)
+ *(.noinit.$RamAHB16*)
+ . = ALIGN(4) ;
+ } > RamAHB16
+
+ /* NOINIT section for RamAHB_ETB16 */
+ .noinit_RAM5 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM5*)
+ *(.noinit.$RamAHB_ETB16*)
+ . = ALIGN(4) ;
+ } > RamAHB_ETB16
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.c b/circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.c
new file mode 100644
index 0000000..eae3805
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.c
@@ -0,0 +1,352 @@
+/*****************************************************************************
+ *
+ * Copyright(C) 2011, Embedded Artists AB
+ * All rights reserved.
+ *
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * Embedded Artists AB assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. Embedded Artists AB
+ * reserves the right to make changes in the software without
+ * notification. Embedded Artists AB also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ *****************************************************************************/
+
+/*
+ * NOTE: I2C must have been initialized before calling any functions in this
+ * file.
+ */
+
+/******************************************************************************
+ * Includes
+ *****************************************************************************/
+
+//#include "board.h"
+#include "chip.h"
+
+#include "pca9532.h"
+
+/******************************************************************************
+ * Defines and typedefs
+ *****************************************************************************/
+
+#define I2C_PORT (LPC_I2C0)
+
+#define LS_MODE_ON 0x01
+#define LS_MODE_BLINK0 0x02
+#define LS_MODE_BLINK1 0x03
+
+/******************************************************************************
+ * External global variables
+ *****************************************************************************/
+
+
+/******************************************************************************
+ * Local variables
+ *****************************************************************************/
+
+static uint16_t blink0Shadow = 0;
+static uint16_t blink1Shadow = 0;
+static uint16_t ledStateShadow = 0;
+
+/******************************************************************************
+ * Local Functions
+ *****************************************************************************/
+
+static Status I2CWrite(uint32_t addr, uint8_t* buf, uint32_t len)
+{
+ I2CM_XFER_T i2cData;
+
+ i2cData.slaveAddr = addr;
+ i2cData.options = 0;
+ i2cData.status = 0;
+ i2cData.txBuff = buf;
+ i2cData.txSz = len;
+ i2cData.rxBuff = NULL;
+ i2cData.rxSz = 0;
+
+ if (Chip_I2CM_XferBlocking(LPC_I2C0, &i2cData) == 0) {
+ return ERROR;
+ }
+ return SUCCESS;
+}
+
+static Status I2CRead(uint32_t addr, uint8_t* buf, uint32_t len)
+{
+ I2CM_XFER_T i2cData;
+
+ i2cData.slaveAddr = addr;
+ i2cData.options = 0;
+ i2cData.status = 0;
+ i2cData.txBuff = NULL;
+ i2cData.txSz = 0;
+ i2cData.rxBuff = buf;
+ i2cData.rxSz = len;
+
+ if (Chip_I2CM_XferBlocking(LPC_I2C0, &i2cData) == 0) {
+ return ERROR;
+ }
+ return SUCCESS;
+}
+
+static void setLsStates(uint16_t states, uint8_t* ls, uint8_t mode)
+{
+#define IS_LED_SET(bit, x) ( ( ((x) & (bit)) != 0 ) ? 1 : 0 )
+
+ int i = 0;
+
+ for (i = 0; i < 4; i++) {
+
+ ls[i] |= ( (IS_LED_SET(0x0001, states)*mode << 0)
+ | (IS_LED_SET(0x0002, states)*mode << 2)
+ | (IS_LED_SET(0x0004, states)*mode << 4)
+ | (IS_LED_SET(0x0008, states)*mode << 6) );
+
+ states >>= 4;
+ }
+}
+
+static void setLeds(void)
+{
+ uint8_t buf[5];
+ uint8_t ls[4] = {0,0,0,0};
+ uint16_t states = ledStateShadow;
+
+ /* LEDs in On/Off state */
+ setLsStates(states, ls, LS_MODE_ON);
+
+ /* set the LEDs that should blink */
+ setLsStates(blink0Shadow, ls, LS_MODE_BLINK0);
+ setLsStates(blink1Shadow, ls, LS_MODE_BLINK1);
+
+
+ buf[0] = PCA9532_LS0 | PCA9532_AUTO_INC;
+ buf[1] = ls[0];
+ buf[2] = ls[1];
+ buf[3] = ls[2];
+ buf[4] = ls[3];
+ I2CWrite(PCA9532_I2C_ADDR, buf, 5);
+}
+
+/******************************************************************************
+ * Public Functions
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * Description:
+ * Initialize the PCA9532 Device
+ *
+ *****************************************************************************/
+void pca9532_init (void)
+{
+ /* nothing to initialize */
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Get the LED states
+ *
+ * Params:
+ * [in] shadow - TRUE if the states should be retrieved from the shadow
+ * variables. The shadow variable are updated when any
+ * of setLeds, setBlink0Leds and/or setBlink1Leds are
+ * called.
+ *
+ * FALSE if the state should be retrieved from the PCA9532
+ * device. A blinkin LED may be reported as on or off
+ * depending on the state when calling the function.
+ *
+ * Returns:
+ * A mask where a 1 indicates that a LED is on (or blinking).
+ *
+ *****************************************************************************/
+uint16_t pca9532_getLedState (uint32_t shadow)
+{
+ uint8_t buf[2];
+ uint16_t ret = 0;
+
+ if (shadow) {
+ /* a blink LED is reported as on*/
+ ret = (ledStateShadow | blink0Shadow | blink1Shadow);
+ }
+ else {
+
+ /*
+ * A blinking LED may be reported as on or off depending on
+ * its state when reading the Input register.
+ */
+
+ buf[0] = PCA9532_INPUT0;
+ I2CWrite(PCA9532_I2C_ADDR, buf, 1);
+
+ I2CRead(PCA9532_I2C_ADDR, buf, 1);
+ ret = buf[0];
+
+
+ buf[0] = PCA9532_INPUT1;
+ I2CWrite(PCA9532_I2C_ADDR, buf, 1);
+
+ I2CRead(PCA9532_I2C_ADDR, buf, 1);
+ ret |= (buf[0] << 8);
+
+
+ /* invert since LEDs are active low */
+ ret = ((~ret) & 0xFFFF);
+ }
+
+ return (ret & ~PCA9532_NOT_USED);
+}
+
+
+/******************************************************************************
+ *
+ * Description:
+ * Set LED states (on or off).
+ *
+ * Params:
+ * [in] ledOnMask - The LEDs that should be turned on. This mask has
+ * priority over ledOffMask
+ * [in] ledOffMask - The LEDs that should be turned off.
+ *
+ *****************************************************************************/
+void pca9532_setLeds (uint16_t ledOnMask, uint16_t ledOffMask)
+{
+ /* turn off leds */
+ ledStateShadow &= (~(ledOffMask) & 0xffff);
+
+ /* ledOnMask has priority over ledOffMask */
+ ledStateShadow |= ledOnMask;
+
+ /* turn off blinking */
+ blink0Shadow &= (~(ledOffMask) & 0xffff);
+ blink1Shadow &= (~(ledOffMask) & 0xffff);
+
+ setLeds();
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Set the blink period for PWM0. Valid values are 0 - 255 where 0
+ * means 152 Hz and 255 means 0.59 Hz. A value of 151 means 1 Hz.
+ *
+ * Params:
+ * [in] period - the period for pwm0
+ *
+ *****************************************************************************/
+void pca9532_setBlink0Period(uint8_t period)
+{
+ uint8_t buf[2];
+
+ buf[0] = PCA9532_PSC0;
+ buf[1] = period;
+ I2CWrite(PCA9532_I2C_ADDR, buf, 2);
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Set the duty cycle for PWM0. Valid values are 0 - 100. 25 means the LED
+ * is on 25% of the period.
+ *
+ * Params:
+ * [in] duty - duty cycle
+ *
+ *****************************************************************************/
+void pca9532_setBlink0Duty(uint8_t duty)
+{
+ uint8_t buf[2];
+ uint32_t tmp = duty;
+ if (tmp > 100) {
+ tmp = 100;
+ }
+
+ tmp = (256 * tmp)/100;
+
+ buf[0] = PCA9532_PWM0;
+ buf[1] = tmp;
+ I2CWrite(PCA9532_I2C_ADDR, buf, 2);
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Set the LEDs that should blink with rate and duty cycle from PWM0.
+ * Blinking is turned off with pca9532_setLeds.
+ *
+ * Params:
+ * [in] ledMask - LEDs that should blink.
+ *
+ *****************************************************************************/
+void pca9532_setBlink0Leds(uint16_t ledMask)
+{
+ blink0Shadow |= ledMask;
+ setLeds();
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Set the blink period for PWM1. Valid values are 0 - 255 where 0
+ * means 152 Hz and 255 means 0.59 Hz. A value of 151 means 1 Hz.
+ *
+ * Params:
+ * [in] period - The period for PWM1
+ *
+ *****************************************************************************/
+void pca9532_setBlink1Period(uint8_t period)
+{
+ uint8_t buf[2];
+
+ buf[0] = PCA9532_PSC1;
+ buf[1] = period;
+ I2CWrite(PCA9532_I2C_ADDR, buf, 2);
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Set the duty cycle for PWM1. Valid values are 0 - 100. 25 means the LED
+ * is on 25% of the period.
+ *
+ * Params:
+ * [in] duty - duty cycle.
+ *
+ *****************************************************************************/
+void pca9532_setBlink1Duty(uint8_t duty)
+{
+ uint8_t buf[2];
+
+ uint32_t tmp = duty;
+ if (tmp > 100) {
+ tmp = 100;
+ }
+
+ tmp = (256 * tmp)/100;
+
+ buf[0] = PCA9532_PWM1;
+ buf[1] = tmp;
+ I2CWrite(PCA9532_I2C_ADDR, buf, 2);
+}
+
+/******************************************************************************
+ *
+ * Description:
+ * Set the LEDs that should blink with rate and duty cycle from PWM1.
+ * Blinking is turned off with pca9532_setLeds.
+ *
+ * Params:
+ * [in] ledMask - LEDs that should blink.
+ *
+ *****************************************************************************/
+void pca9532_setBlink1Leds(uint16_t ledMask)
+{
+ blink1Shadow |= ledMask;
+ setLeds();
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.h b/circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.h
new file mode 100644
index 0000000..7a7c6e1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ea4357/pca9532.h
@@ -0,0 +1,94 @@
+/*****************************************************************************
+ *
+ * Copyright(C) 2011, Embedded Artists AB
+ * All rights reserved.
+ *
+ ******************************************************************************
+ * Software that is described herein is for illustrative purposes only
+ * which provides customers with programming information regarding the
+ * products. This software is supplied "AS IS" without any warranties.
+ * Embedded Artists AB assumes no responsibility or liability for the
+ * use of the software, conveys no license or title under any patent,
+ * copyright, or mask work right to the product. Embedded Artists AB
+ * reserves the right to make changes in the software without
+ * notification. Embedded Artists AB also make no representation or
+ * warranty that such application will be suitable for the specified
+ * use without further testing or modification.
+ *****************************************************************************/
+#ifndef __PCA9532C_H
+#define __PCA9532C_H
+
+
+#define PCA9532_I2C_ADDR (0xC0>>1)
+
+#define PCA9532_INPUT0 0x00
+#define PCA9532_INPUT1 0x01
+#define PCA9532_PSC0 0x02
+#define PCA9532_PWM0 0x03
+#define PCA9532_PSC1 0x04
+#define PCA9532_PWM1 0x05
+#define PCA9532_LS0 0x06
+#define PCA9532_LS1 0x07
+#define PCA9532_LS2 0x08
+#define PCA9532_LS3 0x09
+
+#define PCA9532_AUTO_INC 0x10
+
+
+/*
+ * The Keys on the base board are mapped to LED0 -> LED3 on
+ * the PCA9532.
+ */
+
+#define KEY1 0x0001
+#define KEY2 0x0002
+#define KEY3 0x0004
+#define KEY4 0x0008
+
+#define KEY_MASK 0x000F
+
+/*
+ * MMC Card Detect and MMC Write Protect are mapped to LED4
+ * and LED5 on the PCA9532. Please note that WP is active low.
+ */
+
+#define MMC_CD 0x0010
+#define MMC_WP 0x0020
+
+#define MMC_MASK 0x30
+
+/* NOTE: LED6 and LED7 on PCA9532 are not connected to anything */
+#define PCA9532_NOT_USED 0xC0
+
+/*
+ * Below are the LED constants to use when enabling/disabling a LED.
+ * The LED names are the names printed on the base board and not
+ * the names from the PCA9532 device. base_LED1 -> LED8 on PCA9532,
+ * base_LED2 -> LED9, and so on.
+ */
+
+#define LED1 0x0100
+#define LED2 0x0200
+#define LED3 0x0400
+#define LED4 0x0800
+#define LED5 0x1000
+#define LED6 0x2000
+#define LED7 0x4000
+#define LED8 0x8000
+
+#define LED_MASK 0xFF00
+
+void pca9532_init (void);
+uint16_t pca9532_getLedState (uint32_t shadow);
+void pca9532_setLeds (uint16_t ledOnMask, uint16_t ledOffMask);
+void pca9532_setBlink0Period(uint8_t period);
+void pca9532_setBlink0Duty(uint8_t duty);
+void pca9532_setBlink0Leds(uint16_t ledMask);
+void pca9532_setBlink1Period(uint8_t period);
+void pca9532_setBlink1Duty(uint8_t duty);
+void pca9532_setBlink1Leds(uint16_t ledMask);
+
+#endif /* end __PCA9532C_H */
+/****************************************************************************
+** End Of File
+*****************************************************************************/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/CMakeLists.txt b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/CMakeLists.txt
new file mode 100644
index 0000000..c3c687a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/CMakeLists.txt
@@ -0,0 +1,12 @@
+idf_component_register(SRCS esp32s2.c
+ INCLUDE_DIRS "." "${BOARD}"
+ PRIV_REQUIRES "driver"
+ REQUIRES freertos src led_strip)
+
+# Apply board specific content
+include("${BOARD}/board.cmake")
+
+target_include_directories(${COMPONENT_TARGET} PUBLIC
+ "${TOP}/hw"
+ "${TOP}/src"
+)
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.cmake
new file mode 100644
index 0000000..d339626
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.cmake
@@ -0,0 +1,17 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+message(STATUS "Apply ${BOARD}(${idf_target}) specific options for component: ${COMPONENT_TARGET}")
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+ message(FATAL_ERROR "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET}(${idf_target}), try to clean the build first." )
+endif()
+
+set(IDF_TARGET "esp32s2" FORCE)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h
new file mode 100644
index 0000000..43e0090
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_feather_esp32s2/board.h
@@ -0,0 +1,45 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define NEOPIXEL_PIN 33
+#define NEOPIXEL_POWER_PIN 21
+#define NEOPIXEL_POWER_STATE 1
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.cmake
new file mode 100644
index 0000000..d339626
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.cmake
@@ -0,0 +1,17 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+message(STATUS "Apply ${BOARD}(${idf_target}) specific options for component: ${COMPONENT_TARGET}")
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+ message(FATAL_ERROR "Incorrect target for board ${BOARD}: $ENV{IDF_TARGET}(${idf_target}), try to clean the build first." )
+endif()
+
+set(IDF_TARGET "esp32s2" FORCE)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h
new file mode 100644
index 0000000..16e30b6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_magtag_29gray/board.h
@@ -0,0 +1,45 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define NEOPIXEL_PIN 1
+#define NEOPIXEL_POWER_PIN 21
+#define NEOPIXEL_POWER_STATE 0
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.cmake
new file mode 100644
index 0000000..d5c17b9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.cmake
@@ -0,0 +1,17 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+message(STATUS "Apply ${BOARD}(${idf_target}) specific options for component: ${COMPONENT_TARGET}")
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+ message(FATAL_ERROR "Incorrect target for board ${BOARD}: (${idf_target}), try to clean the build first." )
+endif()
+
+set(IDF_TARGET "esp32s2" FORCE)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h
new file mode 100644
index 0000000..49a2474
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/adafruit_metro_esp32s2/board.h
@@ -0,0 +1,43 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define NEOPIXEL_PIN 45
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/esp32s2.c b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/esp32s2.c
new file mode 100644
index 0000000..a7ca82d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/esp32s2.c
@@ -0,0 +1,153 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../../board.h"
+#include "board.h"
+
+#include "esp_rom_gpio.h"
+#include "hal/gpio_ll.h"
+#include "hal/usb_hal.h"
+#include "soc/usb_periph.h"
+
+#include "driver/rmt.h"
+
+#if ESP_IDF_VERSION_MAJOR > 4
+ #include "esp_private/periph_ctrl.h"
+#else
+ #include "driver/periph_ctrl.h"
+#endif
+
+#ifdef NEOPIXEL_PIN
+#include "led_strip.h"
+static led_strip_t *strip;
+#endif
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+static void configure_pins(usb_hal_context_t *usb);
+
+// Initialize on-board peripherals : led, button, uart and USB
+void board_init(void)
+{
+
+#ifdef NEOPIXEL_PIN
+ #ifdef NEOPIXEL_POWER_PIN
+ gpio_reset_pin(NEOPIXEL_POWER_PIN);
+ gpio_set_direction(NEOPIXEL_POWER_PIN, GPIO_MODE_OUTPUT);
+ gpio_set_level(NEOPIXEL_POWER_PIN, NEOPIXEL_POWER_STATE);
+ #endif
+
+ // WS2812 Neopixel driver with RMT peripheral
+ rmt_config_t config = RMT_DEFAULT_CONFIG_TX(NEOPIXEL_PIN, RMT_CHANNEL_0);
+ config.clk_div = 2; // set counter clock to 40MHz
+
+ rmt_config(&config);
+ rmt_driver_install(config.channel, 0, 0);
+
+ led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel);
+ strip = led_strip_new_rmt_ws2812(&strip_config);
+ strip->clear(strip, 100); // off led
+#endif
+
+ // Button
+ esp_rom_gpio_pad_select_gpio(BUTTON_PIN);
+ gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
+ gpio_set_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN_ONLY : GPIO_PULLUP_ONLY);
+
+ // USB Controller Hal init
+ periph_module_reset(PERIPH_USB_MODULE);
+ periph_module_enable(PERIPH_USB_MODULE);
+
+ usb_hal_context_t hal = {
+ .use_external_phy = false // use built-in PHY
+ };
+ usb_hal_init(&hal);
+ configure_pins(&hal);
+}
+
+static void configure_pins(usb_hal_context_t *usb)
+{
+ /* usb_periph_iopins currently configures USB_OTG as USB Device.
+ * Introduce additional parameters in usb_hal_context_t when adding support
+ * for USB Host.
+ */
+ for (const usb_iopin_dsc_t *iopin = usb_periph_iopins; iopin->pin != -1; ++iopin) {
+ if ((usb->use_external_phy) || (iopin->ext_phy_only == 0)) {
+ esp_rom_gpio_pad_select_gpio(iopin->pin);
+ if (iopin->is_output) {
+ esp_rom_gpio_connect_out_signal(iopin->pin, iopin->func, false, false);
+ } else {
+ esp_rom_gpio_connect_in_signal(iopin->pin, iopin->func, false);
+#if ESP_IDF_VERSION_MAJOR > 4
+ if ((iopin->pin != GPIO_MATRIX_CONST_ZERO_INPUT) && (iopin->pin != GPIO_MATRIX_CONST_ONE_INPUT))
+#else
+ if ((iopin->pin != GPIO_FUNC_IN_LOW) && (iopin->pin != GPIO_FUNC_IN_HIGH))
+#endif
+ {
+ gpio_ll_input_enable(&GPIO, iopin->pin);
+ }
+ }
+ esp_rom_gpio_pad_unhold(iopin->pin);
+ }
+ }
+ if (!usb->use_external_phy) {
+ gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
+ gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
+ }
+}
+
+// Turn LED on or off
+void board_led_write(bool state)
+{
+#ifdef NEOPIXEL_PIN
+ strip->set_pixel(strip, 0, (state ? 0x88 : 0x00), 0x00, 0x00);
+ strip->refresh(strip, 100);
+#endif
+}
+
+// Get the current state of button
+// a '1' means active (pressed), a '0' means inactive.
+uint32_t board_button_read(void)
+{
+ return gpio_get_level(BUTTON_PIN) == BUTTON_STATE_ACTIVE;
+}
+
+// Get characters from UART
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+// Send characters to UART
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.cmake
new file mode 100644
index 0000000..d5c17b9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.cmake
@@ -0,0 +1,17 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+message(STATUS "Apply ${BOARD}(${idf_target}) specific options for component: ${COMPONENT_TARGET}")
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+ message(FATAL_ERROR "Incorrect target for board ${BOARD}: (${idf_target}), try to clean the build first." )
+endif()
+
+set(IDF_TARGET "esp32s2" FORCE)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.h
new file mode 100644
index 0000000..6bb44f7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_kaluga_1/board.h
@@ -0,0 +1,44 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Note: need to insert jumper next to WS2812 pixel
+#define NEOPIXEL_PIN 45
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.cmake
new file mode 100644
index 0000000..d5c17b9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.cmake
@@ -0,0 +1,17 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+idf_build_get_property(idf_target IDF_TARGET)
+
+message(STATUS "Apply ${BOARD}(${idf_target}) specific options for component: ${COMPONENT_TARGET}")
+
+if(NOT ${idf_target} STREQUAL "esp32s2")
+ message(FATAL_ERROR "Incorrect target for board ${BOARD}: (${idf_target}), try to clean the build first." )
+endif()
+
+set(IDF_TARGET "esp32s2" FORCE)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.h
new file mode 100644
index 0000000..f450b9a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/boards/espressif_saola_1/board.h
@@ -0,0 +1,45 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Note: On the production version (v1.2) WS2812 is connected to GPIO 18,
+// however earlier revision v1.1 WS2812 is connected to GPIO 17
+#define NEOPIXEL_PIN 18
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/CMakeLists.txt b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/CMakeLists.txt
new file mode 100644
index 0000000..6d0fcbc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(component_srcs "src/led_strip_rmt_ws2812.c")
+
+idf_component_register(SRCS "${component_srcs}"
+ INCLUDE_DIRS "include"
+ PRIV_INCLUDE_DIRS ""
+ PRIV_REQUIRES "driver"
+ REQUIRES "")
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/include/led_strip.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/include/led_strip.h
new file mode 100644
index 0000000..a9dffc3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/include/led_strip.h
@@ -0,0 +1,126 @@
+// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "esp_err.h"
+
+/**
+* @brief LED Strip Type
+*
+*/
+typedef struct led_strip_s led_strip_t;
+
+/**
+* @brief LED Strip Device Type
+*
+*/
+typedef void *led_strip_dev_t;
+
+/**
+* @brief Declare of LED Strip Type
+*
+*/
+struct led_strip_s {
+ /**
+ * @brief Set RGB for a specific pixel
+ *
+ * @param strip: LED strip
+ * @param index: index of pixel to set
+ * @param red: red part of color
+ * @param green: green part of color
+ * @param blue: blue part of color
+ *
+ * @return
+ * - ESP_OK: Set RGB for a specific pixel successfully
+ * - ESP_ERR_INVALID_ARG: Set RGB for a specific pixel failed because of invalid parameters
+ * - ESP_FAIL: Set RGB for a specific pixel failed because other error occurred
+ */
+ esp_err_t (*set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue);
+
+ /**
+ * @brief Refresh memory colors to LEDs
+ *
+ * @param strip: LED strip
+ * @param timeout_ms: timeout value for refreshing task
+ *
+ * @return
+ * - ESP_OK: Refresh successfully
+ * - ESP_ERR_TIMEOUT: Refresh failed because of timeout
+ * - ESP_FAIL: Refresh failed because some other error occurred
+ *
+ * @note:
+ * After updating the LED colors in the memory, a following invocation of this API is needed to flush colors to strip.
+ */
+ esp_err_t (*refresh)(led_strip_t *strip, uint32_t timeout_ms);
+
+ /**
+ * @brief Clear LED strip (turn off all LEDs)
+ *
+ * @param strip: LED strip
+ * @param timeout_ms: timeout value for clearing task
+ *
+ * @return
+ * - ESP_OK: Clear LEDs successfully
+ * - ESP_ERR_TIMEOUT: Clear LEDs failed because of timeout
+ * - ESP_FAIL: Clear LEDs failed because some other error occurred
+ */
+ esp_err_t (*clear)(led_strip_t *strip, uint32_t timeout_ms);
+
+ /**
+ * @brief Free LED strip resources
+ *
+ * @param strip: LED strip
+ *
+ * @return
+ * - ESP_OK: Free resources successfully
+ * - ESP_FAIL: Free resources failed because error occurred
+ */
+ esp_err_t (*del)(led_strip_t *strip);
+};
+
+/**
+* @brief LED Strip Configuration Type
+*
+*/
+typedef struct {
+ uint32_t max_leds; /*!< Maximum LEDs in a single strip */
+ led_strip_dev_t dev; /*!< LED strip device (e.g. RMT channel, PWM channel, etc) */
+} led_strip_config_t;
+
+/**
+ * @brief Default configuration for LED strip
+ *
+ */
+#define LED_STRIP_DEFAULT_CONFIG(number, dev_hdl) \
+ { \
+ .max_leds = number, \
+ .dev = dev_hdl, \
+ }
+
+/**
+* @brief Install a new ws2812 driver (based on RMT peripheral)
+*
+* @param config: LED strip configuration
+* @return
+* LED strip instance or NULL
+*/
+led_strip_t *led_strip_new_rmt_ws2812(const led_strip_config_t *config);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/src/led_strip_rmt_ws2812.c b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/src/led_strip_rmt_ws2812.c
new file mode 100644
index 0000000..025d3c5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/components/led_strip/src/led_strip_rmt_ws2812.c
@@ -0,0 +1,171 @@
+// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#include <stdlib.h>
+#include <string.h>
+#include <sys/cdefs.h>
+#include "esp_log.h"
+#include "esp_attr.h"
+#include "led_strip.h"
+#include "driver/rmt.h"
+
+static const char *TAG = "ws2812";
+#define STRIP_CHECK(a, str, goto_tag, ret_value, ...) \
+ do \
+ { \
+ if (!(a)) \
+ { \
+ ESP_LOGE(TAG, "%s(%d): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+ ret = ret_value; \
+ goto goto_tag; \
+ } \
+ } while (0)
+
+#define WS2812_T0H_NS (350)
+#define WS2812_T0L_NS (1000)
+#define WS2812_T1H_NS (1000)
+#define WS2812_T1L_NS (350)
+#define WS2812_RESET_US (280)
+
+static uint32_t ws2812_t0h_ticks = 0;
+static uint32_t ws2812_t1h_ticks = 0;
+static uint32_t ws2812_t0l_ticks = 0;
+static uint32_t ws2812_t1l_ticks = 0;
+
+typedef struct {
+ led_strip_t parent;
+ rmt_channel_t rmt_channel;
+ uint32_t strip_len;
+ uint8_t buffer[0];
+} ws2812_t;
+
+/**
+ * @brief Conver RGB data to RMT format.
+ *
+ * @note For WS2812, R,G,B each contains 256 different choices (i.e. uint8_t)
+ *
+ * @param[in] src: source data, to converted to RMT format
+ * @param[in] dest: place where to store the convert result
+ * @param[in] src_size: size of source data
+ * @param[in] wanted_num: number of RMT items that want to get
+ * @param[out] translated_size: number of source data that got converted
+ * @param[out] item_num: number of RMT items which are converted from source data
+ */
+static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size,
+ size_t wanted_num, size_t *translated_size, size_t *item_num)
+{
+ if (src == NULL || dest == NULL) {
+ *translated_size = 0;
+ *item_num = 0;
+ return;
+ }
+ const rmt_item32_t bit0 = {{{ ws2812_t0h_ticks, 1, ws2812_t0l_ticks, 0 }}}; //Logical 0
+ const rmt_item32_t bit1 = {{{ ws2812_t1h_ticks, 1, ws2812_t1l_ticks, 0 }}}; //Logical 1
+ size_t size = 0;
+ size_t num = 0;
+ uint8_t *psrc = (uint8_t *)src;
+ rmt_item32_t *pdest = dest;
+ while (size < src_size && num < wanted_num) {
+ for (int i = 0; i < 8; i++) {
+ // MSB first
+ if (*psrc & (1 << (7 - i))) {
+ pdest->val = bit1.val;
+ } else {
+ pdest->val = bit0.val;
+ }
+ num++;
+ pdest++;
+ }
+ size++;
+ psrc++;
+ }
+ *translated_size = size;
+ *item_num = num;
+}
+
+static esp_err_t ws2812_set_pixel(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue)
+{
+ esp_err_t ret = ESP_OK;
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ STRIP_CHECK(index < ws2812->strip_len, "index out of the maximum number of leds", err, ESP_ERR_INVALID_ARG);
+ uint32_t start = index * 3;
+ // In thr order of GRB
+ ws2812->buffer[start + 0] = green & 0xFF;
+ ws2812->buffer[start + 1] = red & 0xFF;
+ ws2812->buffer[start + 2] = blue & 0xFF;
+ return ESP_OK;
+err:
+ return ret;
+}
+
+static esp_err_t ws2812_refresh(led_strip_t *strip, uint32_t timeout_ms)
+{
+ esp_err_t ret = ESP_OK;
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ STRIP_CHECK(rmt_write_sample(ws2812->rmt_channel, ws2812->buffer, ws2812->strip_len * 3, true) == ESP_OK,
+ "transmit RMT samples failed", err, ESP_FAIL);
+ return rmt_wait_tx_done(ws2812->rmt_channel, pdMS_TO_TICKS(timeout_ms));
+err:
+ return ret;
+}
+
+static esp_err_t ws2812_clear(led_strip_t *strip, uint32_t timeout_ms)
+{
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ // Write zero to turn off all leds
+ memset(ws2812->buffer, 0, ws2812->strip_len * 3);
+ return ws2812_refresh(strip, timeout_ms);
+}
+
+static esp_err_t ws2812_del(led_strip_t *strip)
+{
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ free(ws2812);
+ return ESP_OK;
+}
+
+led_strip_t *led_strip_new_rmt_ws2812(const led_strip_config_t *config)
+{
+ led_strip_t *ret = NULL;
+ STRIP_CHECK(config, "configuration can't be null", err, NULL);
+
+ // 24 bits per led
+ uint32_t ws2812_size = sizeof(ws2812_t) + config->max_leds * 3;
+ ws2812_t *ws2812 = calloc(1, ws2812_size);
+ STRIP_CHECK(ws2812, "request memory for ws2812 failed", err, NULL);
+
+ uint32_t counter_clk_hz = 0;
+ STRIP_CHECK(rmt_get_counter_clock((rmt_channel_t)config->dev, &counter_clk_hz) == ESP_OK,
+ "get rmt counter clock failed", err, NULL);
+ // ns -> ticks
+ float ratio = (float)counter_clk_hz / 1e9;
+ ws2812_t0h_ticks = (uint32_t)(ratio * WS2812_T0H_NS);
+ ws2812_t0l_ticks = (uint32_t)(ratio * WS2812_T0L_NS);
+ ws2812_t1h_ticks = (uint32_t)(ratio * WS2812_T1H_NS);
+ ws2812_t1l_ticks = (uint32_t)(ratio * WS2812_T1L_NS);
+
+ // set ws2812 to rmt adapter
+ rmt_translator_init((rmt_channel_t)config->dev, ws2812_rmt_adapter);
+
+ ws2812->rmt_channel = (rmt_channel_t)config->dev;
+ ws2812->strip_len = config->max_leds;
+
+ ws2812->parent.set_pixel = ws2812_set_pixel;
+ ws2812->parent.refresh = ws2812_refresh;
+ ws2812->parent.clear = ws2812_clear;
+ ws2812->parent.del = ws2812_del;
+
+ return &ws2812->parent;
+err:
+ return ret;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.cmake
new file mode 100644
index 0000000..f3d41d0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.cmake
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.5)
+
+# Add example src and bsp directories
+set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s2/boards" "${TOP}/hw/bsp/esp32s2/components")
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+set(SUPPORTED_TARGETS esp32s2)
+set(FAMILY_MCUS ESP32S2)
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.mk b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.mk
new file mode 100644
index 0000000..b95098e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s2/family.mk
@@ -0,0 +1,24 @@
+#DEPS_SUBMODULES +=
+
+.PHONY: all clean flash bootloader-flash app-flash erase monitor dfu-flash dfu
+
+all:
+ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) -DIDF_TARGET=esp32s2 build
+
+build: all
+
+fullclean:
+ if test -f sdkconfig; then $(RM) -f sdkconfig ; fi
+ if test -d $(BUILD); then $(RM) -rf $(BUILD) ; fi
+ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@
+
+clean flash bootloader-flash app-flash erase monitor dfu-flash dfu size size-components size-files:
+ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@
+
+uf2: $(BUILD)/$(PROJECT).uf2
+
+UF2_FAMILY_ID = 0xbfdd4eee
+$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).bin
+ @echo CREATE $@
+ $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -b 0x0 -c -o $@ $^
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/CMakeLists.txt b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/CMakeLists.txt
new file mode 100644
index 0000000..e1b921a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/CMakeLists.txt
@@ -0,0 +1,14 @@
+idf_component_register(SRCS esp32s3.c
+ INCLUDE_DIRS "." "${BOARD}"
+ PRIV_REQUIRES "driver"
+ REQUIRES freertos src led_strip)
+
+# Apply board specific content
+include("${BOARD}/board.cmake")
+
+idf_component_get_property( FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
+target_include_directories(${COMPONENT_TARGET} PUBLIC
+ "${FREERTOS_ORIG_INCLUDE_PATH}"
+ "${TOP}/hw"
+ "${TOP}/src"
+)
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/esp32s3.c b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/esp32s3.c
new file mode 100644
index 0000000..a7ca82d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/esp32s3.c
@@ -0,0 +1,153 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../../board.h"
+#include "board.h"
+
+#include "esp_rom_gpio.h"
+#include "hal/gpio_ll.h"
+#include "hal/usb_hal.h"
+#include "soc/usb_periph.h"
+
+#include "driver/rmt.h"
+
+#if ESP_IDF_VERSION_MAJOR > 4
+ #include "esp_private/periph_ctrl.h"
+#else
+ #include "driver/periph_ctrl.h"
+#endif
+
+#ifdef NEOPIXEL_PIN
+#include "led_strip.h"
+static led_strip_t *strip;
+#endif
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+static void configure_pins(usb_hal_context_t *usb);
+
+// Initialize on-board peripherals : led, button, uart and USB
+void board_init(void)
+{
+
+#ifdef NEOPIXEL_PIN
+ #ifdef NEOPIXEL_POWER_PIN
+ gpio_reset_pin(NEOPIXEL_POWER_PIN);
+ gpio_set_direction(NEOPIXEL_POWER_PIN, GPIO_MODE_OUTPUT);
+ gpio_set_level(NEOPIXEL_POWER_PIN, NEOPIXEL_POWER_STATE);
+ #endif
+
+ // WS2812 Neopixel driver with RMT peripheral
+ rmt_config_t config = RMT_DEFAULT_CONFIG_TX(NEOPIXEL_PIN, RMT_CHANNEL_0);
+ config.clk_div = 2; // set counter clock to 40MHz
+
+ rmt_config(&config);
+ rmt_driver_install(config.channel, 0, 0);
+
+ led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel);
+ strip = led_strip_new_rmt_ws2812(&strip_config);
+ strip->clear(strip, 100); // off led
+#endif
+
+ // Button
+ esp_rom_gpio_pad_select_gpio(BUTTON_PIN);
+ gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
+ gpio_set_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN_ONLY : GPIO_PULLUP_ONLY);
+
+ // USB Controller Hal init
+ periph_module_reset(PERIPH_USB_MODULE);
+ periph_module_enable(PERIPH_USB_MODULE);
+
+ usb_hal_context_t hal = {
+ .use_external_phy = false // use built-in PHY
+ };
+ usb_hal_init(&hal);
+ configure_pins(&hal);
+}
+
+static void configure_pins(usb_hal_context_t *usb)
+{
+ /* usb_periph_iopins currently configures USB_OTG as USB Device.
+ * Introduce additional parameters in usb_hal_context_t when adding support
+ * for USB Host.
+ */
+ for (const usb_iopin_dsc_t *iopin = usb_periph_iopins; iopin->pin != -1; ++iopin) {
+ if ((usb->use_external_phy) || (iopin->ext_phy_only == 0)) {
+ esp_rom_gpio_pad_select_gpio(iopin->pin);
+ if (iopin->is_output) {
+ esp_rom_gpio_connect_out_signal(iopin->pin, iopin->func, false, false);
+ } else {
+ esp_rom_gpio_connect_in_signal(iopin->pin, iopin->func, false);
+#if ESP_IDF_VERSION_MAJOR > 4
+ if ((iopin->pin != GPIO_MATRIX_CONST_ZERO_INPUT) && (iopin->pin != GPIO_MATRIX_CONST_ONE_INPUT))
+#else
+ if ((iopin->pin != GPIO_FUNC_IN_LOW) && (iopin->pin != GPIO_FUNC_IN_HIGH))
+#endif
+ {
+ gpio_ll_input_enable(&GPIO, iopin->pin);
+ }
+ }
+ esp_rom_gpio_pad_unhold(iopin->pin);
+ }
+ }
+ if (!usb->use_external_phy) {
+ gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
+ gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
+ }
+}
+
+// Turn LED on or off
+void board_led_write(bool state)
+{
+#ifdef NEOPIXEL_PIN
+ strip->set_pixel(strip, 0, (state ? 0x88 : 0x00), 0x00, 0x00);
+ strip->refresh(strip, 100);
+#endif
+}
+
+// Get the current state of button
+// a '1' means active (pressed), a '0' means inactive.
+uint32_t board_button_read(void)
+{
+ return gpio_get_level(BUTTON_PIN) == BUTTON_STATE_ACTIVE;
+}
+
+// Get characters from UART
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+// Send characters to UART
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.cmake
new file mode 100644
index 0000000..8996ff9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.cmake
@@ -0,0 +1,7 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S3"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.h
new file mode 100644
index 0000000..fff24ba
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_addax_1/board.h
@@ -0,0 +1,44 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Note: On the production version (v1.1) WS2812 is connected to GPIO 47
+#define NEOPIXEL_PIN 47
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.cmake
new file mode 100644
index 0000000..8996ff9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.cmake
@@ -0,0 +1,7 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S3"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.h
new file mode 100644
index 0000000..c7940c5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitc/board.h
@@ -0,0 +1,43 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define NEOPIXEL_PIN 48
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.cmake
new file mode 100644
index 0000000..8996ff9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.cmake
@@ -0,0 +1,7 @@
+# Apply board specific content here
+target_include_directories(${COMPONENT_LIB} PRIVATE .)
+
+target_compile_options(${COMPONENT_TARGET} PUBLIC
+ "-DCFG_TUSB_MCU=OPT_MCU_ESP32S3"
+ "-DCFG_TUSB_OS=OPT_OS_FREERTOS"
+) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.h
new file mode 100644
index 0000000..c7940c5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/boards/espressif_s3_devkitm/board.h
@@ -0,0 +1,43 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define NEOPIXEL_PIN 48
+
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/CMakeLists.txt b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/CMakeLists.txt
new file mode 100644
index 0000000..6d0fcbc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(component_srcs "src/led_strip_rmt_ws2812.c")
+
+idf_component_register(SRCS "${component_srcs}"
+ INCLUDE_DIRS "include"
+ PRIV_INCLUDE_DIRS ""
+ PRIV_REQUIRES "driver"
+ REQUIRES "")
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/include/led_strip.h b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/include/led_strip.h
new file mode 100644
index 0000000..a9dffc3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/include/led_strip.h
@@ -0,0 +1,126 @@
+// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "esp_err.h"
+
+/**
+* @brief LED Strip Type
+*
+*/
+typedef struct led_strip_s led_strip_t;
+
+/**
+* @brief LED Strip Device Type
+*
+*/
+typedef void *led_strip_dev_t;
+
+/**
+* @brief Declare of LED Strip Type
+*
+*/
+struct led_strip_s {
+ /**
+ * @brief Set RGB for a specific pixel
+ *
+ * @param strip: LED strip
+ * @param index: index of pixel to set
+ * @param red: red part of color
+ * @param green: green part of color
+ * @param blue: blue part of color
+ *
+ * @return
+ * - ESP_OK: Set RGB for a specific pixel successfully
+ * - ESP_ERR_INVALID_ARG: Set RGB for a specific pixel failed because of invalid parameters
+ * - ESP_FAIL: Set RGB for a specific pixel failed because other error occurred
+ */
+ esp_err_t (*set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue);
+
+ /**
+ * @brief Refresh memory colors to LEDs
+ *
+ * @param strip: LED strip
+ * @param timeout_ms: timeout value for refreshing task
+ *
+ * @return
+ * - ESP_OK: Refresh successfully
+ * - ESP_ERR_TIMEOUT: Refresh failed because of timeout
+ * - ESP_FAIL: Refresh failed because some other error occurred
+ *
+ * @note:
+ * After updating the LED colors in the memory, a following invocation of this API is needed to flush colors to strip.
+ */
+ esp_err_t (*refresh)(led_strip_t *strip, uint32_t timeout_ms);
+
+ /**
+ * @brief Clear LED strip (turn off all LEDs)
+ *
+ * @param strip: LED strip
+ * @param timeout_ms: timeout value for clearing task
+ *
+ * @return
+ * - ESP_OK: Clear LEDs successfully
+ * - ESP_ERR_TIMEOUT: Clear LEDs failed because of timeout
+ * - ESP_FAIL: Clear LEDs failed because some other error occurred
+ */
+ esp_err_t (*clear)(led_strip_t *strip, uint32_t timeout_ms);
+
+ /**
+ * @brief Free LED strip resources
+ *
+ * @param strip: LED strip
+ *
+ * @return
+ * - ESP_OK: Free resources successfully
+ * - ESP_FAIL: Free resources failed because error occurred
+ */
+ esp_err_t (*del)(led_strip_t *strip);
+};
+
+/**
+* @brief LED Strip Configuration Type
+*
+*/
+typedef struct {
+ uint32_t max_leds; /*!< Maximum LEDs in a single strip */
+ led_strip_dev_t dev; /*!< LED strip device (e.g. RMT channel, PWM channel, etc) */
+} led_strip_config_t;
+
+/**
+ * @brief Default configuration for LED strip
+ *
+ */
+#define LED_STRIP_DEFAULT_CONFIG(number, dev_hdl) \
+ { \
+ .max_leds = number, \
+ .dev = dev_hdl, \
+ }
+
+/**
+* @brief Install a new ws2812 driver (based on RMT peripheral)
+*
+* @param config: LED strip configuration
+* @return
+* LED strip instance or NULL
+*/
+led_strip_t *led_strip_new_rmt_ws2812(const led_strip_config_t *config);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/src/led_strip_rmt_ws2812.c b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/src/led_strip_rmt_ws2812.c
new file mode 100644
index 0000000..025d3c5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/components/led_strip/src/led_strip_rmt_ws2812.c
@@ -0,0 +1,171 @@
+// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#include <stdlib.h>
+#include <string.h>
+#include <sys/cdefs.h>
+#include "esp_log.h"
+#include "esp_attr.h"
+#include "led_strip.h"
+#include "driver/rmt.h"
+
+static const char *TAG = "ws2812";
+#define STRIP_CHECK(a, str, goto_tag, ret_value, ...) \
+ do \
+ { \
+ if (!(a)) \
+ { \
+ ESP_LOGE(TAG, "%s(%d): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+ ret = ret_value; \
+ goto goto_tag; \
+ } \
+ } while (0)
+
+#define WS2812_T0H_NS (350)
+#define WS2812_T0L_NS (1000)
+#define WS2812_T1H_NS (1000)
+#define WS2812_T1L_NS (350)
+#define WS2812_RESET_US (280)
+
+static uint32_t ws2812_t0h_ticks = 0;
+static uint32_t ws2812_t1h_ticks = 0;
+static uint32_t ws2812_t0l_ticks = 0;
+static uint32_t ws2812_t1l_ticks = 0;
+
+typedef struct {
+ led_strip_t parent;
+ rmt_channel_t rmt_channel;
+ uint32_t strip_len;
+ uint8_t buffer[0];
+} ws2812_t;
+
+/**
+ * @brief Conver RGB data to RMT format.
+ *
+ * @note For WS2812, R,G,B each contains 256 different choices (i.e. uint8_t)
+ *
+ * @param[in] src: source data, to converted to RMT format
+ * @param[in] dest: place where to store the convert result
+ * @param[in] src_size: size of source data
+ * @param[in] wanted_num: number of RMT items that want to get
+ * @param[out] translated_size: number of source data that got converted
+ * @param[out] item_num: number of RMT items which are converted from source data
+ */
+static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size,
+ size_t wanted_num, size_t *translated_size, size_t *item_num)
+{
+ if (src == NULL || dest == NULL) {
+ *translated_size = 0;
+ *item_num = 0;
+ return;
+ }
+ const rmt_item32_t bit0 = {{{ ws2812_t0h_ticks, 1, ws2812_t0l_ticks, 0 }}}; //Logical 0
+ const rmt_item32_t bit1 = {{{ ws2812_t1h_ticks, 1, ws2812_t1l_ticks, 0 }}}; //Logical 1
+ size_t size = 0;
+ size_t num = 0;
+ uint8_t *psrc = (uint8_t *)src;
+ rmt_item32_t *pdest = dest;
+ while (size < src_size && num < wanted_num) {
+ for (int i = 0; i < 8; i++) {
+ // MSB first
+ if (*psrc & (1 << (7 - i))) {
+ pdest->val = bit1.val;
+ } else {
+ pdest->val = bit0.val;
+ }
+ num++;
+ pdest++;
+ }
+ size++;
+ psrc++;
+ }
+ *translated_size = size;
+ *item_num = num;
+}
+
+static esp_err_t ws2812_set_pixel(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue)
+{
+ esp_err_t ret = ESP_OK;
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ STRIP_CHECK(index < ws2812->strip_len, "index out of the maximum number of leds", err, ESP_ERR_INVALID_ARG);
+ uint32_t start = index * 3;
+ // In thr order of GRB
+ ws2812->buffer[start + 0] = green & 0xFF;
+ ws2812->buffer[start + 1] = red & 0xFF;
+ ws2812->buffer[start + 2] = blue & 0xFF;
+ return ESP_OK;
+err:
+ return ret;
+}
+
+static esp_err_t ws2812_refresh(led_strip_t *strip, uint32_t timeout_ms)
+{
+ esp_err_t ret = ESP_OK;
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ STRIP_CHECK(rmt_write_sample(ws2812->rmt_channel, ws2812->buffer, ws2812->strip_len * 3, true) == ESP_OK,
+ "transmit RMT samples failed", err, ESP_FAIL);
+ return rmt_wait_tx_done(ws2812->rmt_channel, pdMS_TO_TICKS(timeout_ms));
+err:
+ return ret;
+}
+
+static esp_err_t ws2812_clear(led_strip_t *strip, uint32_t timeout_ms)
+{
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ // Write zero to turn off all leds
+ memset(ws2812->buffer, 0, ws2812->strip_len * 3);
+ return ws2812_refresh(strip, timeout_ms);
+}
+
+static esp_err_t ws2812_del(led_strip_t *strip)
+{
+ ws2812_t *ws2812 = __containerof(strip, ws2812_t, parent);
+ free(ws2812);
+ return ESP_OK;
+}
+
+led_strip_t *led_strip_new_rmt_ws2812(const led_strip_config_t *config)
+{
+ led_strip_t *ret = NULL;
+ STRIP_CHECK(config, "configuration can't be null", err, NULL);
+
+ // 24 bits per led
+ uint32_t ws2812_size = sizeof(ws2812_t) + config->max_leds * 3;
+ ws2812_t *ws2812 = calloc(1, ws2812_size);
+ STRIP_CHECK(ws2812, "request memory for ws2812 failed", err, NULL);
+
+ uint32_t counter_clk_hz = 0;
+ STRIP_CHECK(rmt_get_counter_clock((rmt_channel_t)config->dev, &counter_clk_hz) == ESP_OK,
+ "get rmt counter clock failed", err, NULL);
+ // ns -> ticks
+ float ratio = (float)counter_clk_hz / 1e9;
+ ws2812_t0h_ticks = (uint32_t)(ratio * WS2812_T0H_NS);
+ ws2812_t0l_ticks = (uint32_t)(ratio * WS2812_T0L_NS);
+ ws2812_t1h_ticks = (uint32_t)(ratio * WS2812_T1H_NS);
+ ws2812_t1l_ticks = (uint32_t)(ratio * WS2812_T1L_NS);
+
+ // set ws2812 to rmt adapter
+ rmt_translator_init((rmt_channel_t)config->dev, ws2812_rmt_adapter);
+
+ ws2812->rmt_channel = (rmt_channel_t)config->dev;
+ ws2812->strip_len = config->max_leds;
+
+ ws2812->parent.set_pixel = ws2812_set_pixel;
+ ws2812->parent.refresh = ws2812_refresh;
+ ws2812->parent.clear = ws2812_clear;
+ ws2812->parent.del = ws2812_del;
+
+ return &ws2812->parent;
+err:
+ return ret;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.cmake b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.cmake
new file mode 100644
index 0000000..511dd58
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.cmake
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.5)
+
+# Add example src and bsp directories
+set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s3/boards" "${TOP}/hw/bsp/esp32s3/components")
+include($ENV{IDF_PATH}/tools/cmake/project.cmake)
+set(SUPPORTED_TARGETS esp32s3)
+set(FAMILY_MCUS ESP32S3)
diff --git a/circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.mk b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.mk
new file mode 100644
index 0000000..cf153ff
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/esp32s3/family.mk
@@ -0,0 +1,26 @@
+#DEPS_SUBMODULES +=
+
+.PHONY: all clean flash bootloader-flash app-flash erase monitor dfu-flash dfu
+
+all:
+ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) -DIDF_TARGET=esp32s3 build
+
+build: all
+
+clean:
+ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean
+
+fullclean:
+ if test -f sdkconfig; then $(RM) -f sdkconfig ; fi
+ if test -d $(BUILD); then $(RM) -rf $(BUILD) ; fi
+
+flash bootloader-flash app-flash erase monitor dfu-flash dfu:
+ idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@
+
+uf2: $(BUILD)/$(PROJECT).uf2
+
+UF2_FAMILY_ID = 0xc47e5767
+$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).bin
+ @echo CREATE $@
+ $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -b 0x0 -c -o $@ $^
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/f1c100s/README.md b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/README.md
new file mode 100644
index 0000000..3250447
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/README.md
@@ -0,0 +1,20 @@
+# BSP support for F1Cx00s boards
+
+This folder contains necessary file and scripts to run TinyUSB examples on F1Cx00s boards.
+
+Currently tested on:
+
+- Lichee Pi Nano (F1C100s)
+- [Widora Tiny200 v2 (also called MangoPi-R3c)](https://mangopi.org/tiny200)
+
+## Flashing
+
+There are two options to put your code into the MCU: `flash` and `exec`. Both modes require you to install [xfel](https://github.com/xboot/xfel) tool to your PATH. You must enter FEL mode before any operation can be done. To enter FEL mode, press BOOT button, then press RESET once, and release BOOT button. You will find VID/PID=1f3a:efe8 on your PC.
+
+Exec: `make BOARD=f1c100s exec` will just upload the image to the DDR ram and execute it. It will not touch anything in the SPI flash.
+
+Flash: `make BOARD=f1c100s flash` will write the image to SPI flash, and then reset the chip to execute it.
+
+## TODO
+
+* Add F1C100s to `#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX` high speed MCU check in examples (maybe we should extract the logic?) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.h b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.h
new file mode 100644
index 0000000..238ac79
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.h
@@ -0,0 +1 @@
+// Nothing valuable here \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.mk b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.mk
new file mode 100644
index 0000000..5fe26a9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/board.mk
@@ -0,0 +1,52 @@
+DEPS_SUBMODULES += hw/mcu/allwinner
+
+DEFINES += -D__ARM32_ARCH__=5 -D__ARM926EJS__
+
+CFLAGS += \
+ -ffreestanding \
+ -std=gnu99 \
+ -march=armv5te \
+ -mtune=arm926ej-s \
+ -mfloat-abi=soft \
+ -marm \
+ -mno-thumb-interwork \
+ -Wno-unused-parameter \
+ -Wno-float-equal \
+ -DCFG_TUSB_MCU=OPT_MCU_F1C100S \
+ -Wno-error=cast-align \
+ -Wno-error=address-of-packed-member \
+ $(DEFINES)
+
+LD_FILE = hw/mcu/allwinner/f1c100s/f1c100s.ld
+LDFLAGS += -nostdlib -lgcc
+MCU_DIR = hw/mcu/allwinner/f1c100s
+
+SRC_C += \
+ src/portable/sunxi/dcd_sunxi_musb.c \
+ $(MCU_DIR)/machine/sys-uart.c \
+ $(MCU_DIR)/machine/exception.c \
+ $(MCU_DIR)/machine/sys-clock.c \
+ $(MCU_DIR)/machine/sys-copyself.c \
+ $(MCU_DIR)/machine/sys-dram.c \
+ $(MCU_DIR)/machine/sys-mmu.c \
+ $(MCU_DIR)/machine/sys-spi-flash.c \
+ $(MCU_DIR)/machine/f1c100s-intc.c \
+ $(MCU_DIR)/lib/malloc.c \
+ $(MCU_DIR)/lib/printf.c
+
+SRC_S += \
+ $(MCU_DIR)/machine/start.S \
+ $(MCU_DIR)/lib/memcpy.S \
+ $(MCU_DIR)/lib/memset.S
+
+INC += \
+ $(TOP)/$(MCU_DIR)/include \
+ $(TOP)/$(BOARD_PATH)
+
+# flash target using xfel
+flash: flash-xfel
+
+exec: $(BUILD)/$(PROJECT).bin
+ xfel ddr
+ xfel write 0x80000000 $<
+ xfel exec 0x80000000 \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/f1c100s/f1c100s.c b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/f1c100s.c
new file mode 100644
index 0000000..d45072e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/f1c100s/f1c100s.c
@@ -0,0 +1,130 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include <stdint.h>
+#include <malloc.h>
+#include <irqflags.h>
+#include <f1c100s-irq.h>
+#include "bsp/board.h"
+#include "board.h"
+
+extern void sys_uart_putc(char c);
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+static void timer_init(void);
+
+void board_init(void)
+{
+ arch_local_irq_disable();
+ do_init_mem_pool();
+ f1c100s_intc_init();
+ timer_init();
+ printf("Timer INIT done\n");
+ arch_local_irq_enable();
+}
+
+// No LED, no button
+void board_led_write(bool state)
+{
+
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ int txsize = len;
+ while (txsize--) {
+ sys_uart_putc(*(uint8_t const*)buf);
+ buf++;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+
+static void timer_handler(void)
+{
+ volatile uint32_t *temp_addr = (uint32_t *)(0x01C20C00 + 0x04);
+
+ /* clear timer */
+ *temp_addr |= 0x01;
+
+ system_ticks++;
+}
+
+static void timer_init(void) {
+ uint32_t temp;
+ volatile uint32_t *temp_addr;
+
+ /* reload value */
+ temp = 12000000 / 1000;
+ temp_addr = (uint32_t *)(0x01C20C00 + 0x14);
+ *temp_addr = temp;
+
+ /* continuous | /2 | 24Mhz | reload*/
+ temp = (0x00 << 7) | (0x01 << 4) | (0x01 << 2) | (0x00 << 1);
+ temp_addr = (uint32_t *)(0x01C20C00 + 0x10);
+ *temp_addr &= 0xffffff00;
+ *temp_addr |= temp;
+
+ /* open timer irq */
+ temp = 0x01 << 0;
+ temp_addr = (uint32_t *)(0x01C20C00);
+ *temp_addr |= temp;
+
+ /* set init value */
+ temp_addr = (uint32_t *)(0x01C20C00 + 0x18);
+ *temp_addr = 0;
+
+ /* begin run timer */
+ temp = 0x01 << 0;
+ temp_addr = (uint32_t *)(0x01C20C00 + 0x10);
+ *temp_addr |= temp;
+
+ f1c100s_intc_set_isr(F1C100S_IRQ_TIMER0, timer_handler);
+ f1c100s_intc_enable_irq(F1C100S_IRQ_TIMER0);
+}
+#else
+static void timer_init(void) { }
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/family_support.cmake b/circuitpython/lib/tinyusb/hw/bsp/family_support.cmake
new file mode 100644
index 0000000..ee29cab
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/family_support.cmake
@@ -0,0 +1,100 @@
+if (NOT TARGET _family_support_marker)
+ add_library(_family_support_marker INTERFACE)
+
+ if (NOT FAMILY)
+ message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, eps32s2, esp32s3). You can do this via -DFAMILY=xxx on the cmake command line")
+ endif()
+
+ if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)
+ message(FATAL_ERROR "Family '${FAMILY}' is not known/supported")
+ endif()
+
+ function(family_filter RESULT DIR)
+ get_filename_component(DIR ${DIR} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+ if (EXISTS "${DIR}/only.txt")
+ file(READ "${DIR}/only.txt" ONLYS)
+ # Replace newlines with semicolon so that it is treated as a list by CMake
+ string(REPLACE "\n" ";" ONLYS_LINES ${ONLYS})
+ # For each mcu
+ foreach(MCU IN LISTS FAMILY_MCUS)
+ # For each line in only.txt
+ foreach(_line ${ONLYS_LINES})
+ # If mcu:xxx exists for this mcu then include
+ if (${_line} STREQUAL "mcu:${MCU}")
+ set(${RESULT} 1 PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+ endforeach()
+
+ # Didn't find it in only file so don't build
+ set(${RESULT} 0 PARENT_SCOPE)
+
+ elseif (EXISTS "${DIR}/skip.txt")
+ file(READ "${DIR}/skip.txt" SKIPS)
+ # Replace newlines with semicolon so that it is treated as a list by CMake
+ string(REPLACE "\n" ";" SKIPS_LINES ${SKIPS})
+ # For each mcu
+ foreach(MCU IN LISTS FAMILY_MCUS)
+ # For each line in only.txt
+ foreach(_line ${SKIPS_LINES})
+ # If mcu:xxx exists for this mcu then skip
+ if (${_line} STREQUAL "mcu:${MCU}")
+ set(${RESULT} 0 PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+ endforeach()
+
+ # Didn't find in skip file so build
+ set(${RESULT} 1 PARENT_SCOPE)
+
+ else()
+
+ # Didn't find skip or only file so build
+ set(${RESULT} 1 PARENT_SCOPE)
+
+ endif()
+
+ endfunction()
+
+ function(family_add_subdirectory DIR)
+ family_filter(SHOULD_ADD "${DIR}")
+ if (SHOULD_ADD)
+ add_subdirectory(${DIR})
+ endif()
+ endfunction()
+
+ function(family_get_project_name OUTPUT_NAME DIR)
+ get_filename_component(SHORT_NAME ${DIR} NAME)
+ set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${SHORT_NAME} PARENT_SCOPE)
+ endfunction()
+
+ function(family_initialize_project PROJECT DIR)
+ family_filter(ALLOWED "${DIR}")
+ if (NOT ALLOWED)
+ get_filename_component(SHORT_NAME ${DIR} NAME)
+ message(FATAL_ERROR "${SHORT_NAME} is not supported on FAMILY=${FAMILY}")
+ endif()
+ endfunction()
+
+ # configure an executable target to link to tinyusb in device mode, and add the board implementation
+ function(family_configure_device_example TARGET)
+ # default implentation is empty, the function should be redefined in the FAMILY/family.cmake
+ endfunction()
+
+ # configure an executable target to link to tinyusb in host mode, and add the board implementation
+ function(family_configure_host_example TARGET)
+ # default implentation is empty, the function should be redefined in the FAMILY/family.cmake
+ endfunction()
+
+ include(${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)
+
+ if (NOT FAMILY_MCUS)
+ set(FAMILY_MCUS ${FAMILY})
+ endif()
+
+ # save it in case of re-inclusion
+ set(FAMILY_MCUS ${FAMILY_MCUS} CACHE INTERNAL "")
+endif() \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.h b/circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.h
new file mode 100644
index 0000000..666ba1d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.h
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Place holder only
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.mk b/circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.mk
new file mode 100644
index 0000000..8ced114
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/boards/fomu/board.mk
@@ -0,0 +1 @@
+# place holder \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/crt0-vexriscv.S b/circuitpython/lib/tinyusb/hw/bsp/fomu/crt0-vexriscv.S
new file mode 100644
index 0000000..d80a29e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/crt0-vexriscv.S
@@ -0,0 +1,83 @@
+.global main
+.global isr
+
+.section .text.start
+.global _start
+
+_start:
+ j crt_init
+
+.section .text
+.global trap_entry
+trap_entry:
+ sw x1, - 1*4(sp)
+ sw x5, - 2*4(sp)
+ sw x6, - 3*4(sp)
+ sw x7, - 4*4(sp)
+ sw x10, - 5*4(sp)
+ sw x11, - 6*4(sp)
+ sw x12, - 7*4(sp)
+ sw x13, - 8*4(sp)
+ sw x14, - 9*4(sp)
+ sw x15, -10*4(sp)
+ sw x16, -11*4(sp)
+ sw x17, -12*4(sp)
+ sw x28, -13*4(sp)
+ sw x29, -14*4(sp)
+ sw x30, -15*4(sp)
+ sw x31, -16*4(sp)
+ addi sp,sp,-16*4
+ call isr
+ lw x1 , 15*4(sp)
+ lw x5, 14*4(sp)
+ lw x6, 13*4(sp)
+ lw x7, 12*4(sp)
+ lw x10, 11*4(sp)
+ lw x11, 10*4(sp)
+ lw x12, 9*4(sp)
+ lw x13, 8*4(sp)
+ lw x14, 7*4(sp)
+ lw x15, 6*4(sp)
+ lw x16, 5*4(sp)
+ lw x17, 4*4(sp)
+ lw x28, 3*4(sp)
+ lw x29, 2*4(sp)
+ lw x30, 1*4(sp)
+ lw x31, 0*4(sp)
+ addi sp,sp,16*4
+ mret
+
+.text
+crt_init:
+ la sp, _estack - 4
+ la a0, trap_entry
+ csrw mtvec, a0
+
+bss_init:
+ la a0, _sbss
+ la a1, _ebss + 4
+bss_loop:
+ beq a0,a1,bss_done
+ sw zero,0(a0)
+ add a0,a0,4
+ j bss_loop
+bss_done:
+
+ /* Load DATA */
+ la t0, _etext
+ la t1, _srelocate
+ la t2, _erelocate + 4
+3:
+ lw t3, 0(t0)
+ sw t3, 0(t1)
+ /* _edata is aligned to 4 bytes. Use word-xfers. */
+ addi t0, t0, 4
+ addi t1, t1, 4
+ bltu t1, t2, 3b
+
+ li a0, 0x880 //880 enable timer + external interrupt sources (until mstatus.MIE is set, they will never trigger an interrupt)
+ csrw mie,a0
+
+ call main
+infinite_loop:
+ j infinite_loop
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/dfu.py b/circuitpython/lib/tinyusb/hw/bsp/fomu/dfu.py
new file mode 100644
index 0000000..3247935
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/dfu.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+# Written by Antonio Galea - 2010/11/18
+# Updated for DFU 1.1 by Sean Cross - 2020/03/31
+# Distributed under Gnu LGPL 3.0
+# see http://www.gnu.org/licenses/lgpl-3.0.txt
+
+import sys,struct,zlib,os
+from optparse import OptionParser
+
+DEFAULT_DEVICE="0x1209:0x5bf0"
+
+def named(tuple,names):
+ return dict(zip(names.split(),tuple))
+def consume(fmt,data,names):
+ n = struct.calcsize(fmt)
+ return named(struct.unpack(fmt,data[:n]),names),data[n:]
+def cstring(string):
+ return string.split('\0',1)[0]
+def compute_crc(data):
+ return 0xFFFFFFFF & -zlib.crc32(data) -1
+
+def parse(file,dump_images=False):
+ print ('File: "%s"' % file)
+ data = open(file,'rb').read()
+ crc = compute_crc(data[:-4])
+ data = data[len(data)-16:]
+ suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc')
+ print ('usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix)
+ if crc != suffix['crc']:
+ print ("CRC ERROR: computed crc32 is 0x%08x" % crc)
+ data = data[16:]
+ if data:
+ print ("PARSE ERROR")
+
+def build(file,data,device=DEFAULT_DEVICE):
+ # Parse the VID and PID from the `device` argument
+ v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1))
+
+ # Generate the DFU suffix, consisting of these fields:
+ # Field name | Length | Description
+ # ================+=========+================================
+ # bcdDevice | 2 | The release number of this firmware (0xffff - don't care)
+ # idProduct | 2 | PID of this device
+ # idVendor | 2 | VID of this device
+ # bcdDFU | 2 | Version of this DFU spec (0x01 0x00)
+ # ucDfuSignature | 3 | The characters 'DFU', printed in reverse order
+ # bLength | 1 | The length of this suffix (16 bytes)
+ # dwCRC | 4 | A CRC32 of the data, including this suffix
+ data += struct.pack('<4H3sB',0xffff,d,v,0x0100,b'UFD',16)
+ crc = compute_crc(data)
+ # Append the CRC32 of the entire block
+ data += struct.pack('<I',crc)
+ open(file,'wb').write(data)
+
+if __name__=="__main__":
+ usage = """
+%prog [-d|--dump] infile.dfu
+%prog {-b|--build} file.bin [{-D|--device}=vendor:device] outfile.dfu"""
+ parser = OptionParser(usage=usage)
+ parser.add_option("-b", "--build", action="store", dest="binfile",
+ help="build a DFU file from given BINFILE", metavar="BINFILE")
+ parser.add_option("-D", "--device", action="store", dest="device",
+ help="build for DEVICE, defaults to %s" % DEFAULT_DEVICE, metavar="DEVICE")
+ parser.add_option("-d", "--dump", action="store_true", dest="dump_images",
+ default=False, help="dump contained images to current directory")
+ (options, args) = parser.parse_args()
+
+ if options.binfile and len(args)==1:
+ binfile = options.binfile
+ if not os.path.isfile(binfile):
+ print ("Unreadable file '%s'." % binfile)
+ sys.exit(1)
+ target = open(binfile,'rb').read()
+ outfile = args[0]
+ device = DEFAULT_DEVICE
+ # If a device is specified, parse the pair into a VID:PID pair
+ # in order to validate them.
+ if options.device:
+ device=options.device
+ try:
+ v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1))
+ except:
+ print ("Invalid device '%s'." % device)
+ sys.exit(1)
+ build(outfile,target,device)
+ elif len(args)==1:
+ infile = args[0]
+ if not os.path.isfile(infile):
+ print ("Unreadable file '%s'." % infile)
+ sys.exit(1)
+ parse(infile, dump_images=options.dump_images)
+ else:
+ parser.print_help()
+ sys.exit(1)
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/family.mk b/circuitpython/lib/tinyusb/hw/bsp/fomu/family.mk
new file mode 100644
index 0000000..165535c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/family.mk
@@ -0,0 +1,30 @@
+CFLAGS += \
+ -flto \
+ -march=rv32i \
+ -mabi=ilp32 \
+ -nostdlib \
+ -DCFG_TUSB_MCU=OPT_MCU_VALENTYUSB_EPTRI
+
+# Toolchain from https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack
+CROSS_COMPILE = riscv-none-embed-
+
+# All source paths should be relative to the top level.
+LD_FILE = $(FAMILY_PATH)/fomu.ld
+
+SRC_C += src/portable/valentyusb/eptri/dcd_eptri.c
+
+SRC_S += $(FAMILY_PATH)/crt0-vexriscv.S
+
+INC += \
+ $(TOP)/$(FAMILY_PATH)/include
+
+# For freeRTOS port source
+FREERTOS_PORT = RISC-V
+
+# flash using dfu-util
+$(BUILD)/$(PROJECT).dfu: $(BUILD)/$(PROJECT).bin
+ @echo "Create $@"
+ python $(TOP)/hw/bsp/$(BOARD)/dfu.py -b $^ -D 0x1209:0x5bf0 $@
+
+flash: $(BUILD)/$(PROJECT).dfu
+ dfu-util -D $^
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.c b/circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.c
new file mode 100644
index 0000000..12b7bfd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.c
@@ -0,0 +1,120 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "../board.h"
+#include "csr.h"
+#include "irq.h"
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void fomu_error(uint32_t line)
+{
+ (void)line;
+ TU_BREAKPOINT();
+}
+
+volatile uint32_t system_ticks = 0;
+static void timer_init(void)
+{
+ int t;
+
+ timer0_en_write(0);
+ t = CONFIG_CLOCK_FREQUENCY / 1000; // 1000 kHz tick
+ timer0_reload_write(t);
+ timer0_load_write(t);
+ timer0_en_write(1);
+ timer0_ev_enable_write(1);
+ timer0_ev_pending_write(1);
+ irq_setmask(irq_getmask() | (1 << TIMER0_INTERRUPT));
+}
+
+void isr(void)
+{
+ unsigned int irqs;
+
+ irqs = irq_pending() & irq_getmask();
+
+#if CFG_TUSB_RHPORT0_MODE == OPT_MODE_DEVICE
+ if (irqs & (1 << USB_INTERRUPT)) {
+ tud_int_handler(0);
+ }
+#endif
+ if (irqs & (1 << TIMER0_INTERRUPT)) {
+ system_ticks++;
+ timer0_ev_pending_write(1);
+ }
+}
+
+void board_init(void)
+{
+ irq_setmask(0);
+ irq_setie(1);
+ timer_init();
+ return;
+}
+
+void board_led_write(bool state)
+{
+ rgb_ctrl_write(0xff);
+ rgb_raw_write(state);
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf;
+ (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ int32_t offset = 0;
+ uint8_t const* buf8 = (uint8_t const*) buf;
+ for (offset = 0; offset < len; offset++)
+ {
+ if (!(messible_status_read() & CSR_MESSIBLE_STATUS_FULL_OFFSET))
+ {
+ messible_in_write(buf8[offset]);
+ }
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.ld b/circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.ld
new file mode 100644
index 0000000..13278d2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/fomu.ld
@@ -0,0 +1,104 @@
+OUTPUT_FORMAT("elf32-littleriscv")
+ENTRY(_start)
+
+__DYNAMIC = 0;
+
+MEMORY {
+ csr : ORIGIN = 0x60000000, LENGTH = 0x01000000
+ vexriscv_debug : ORIGIN = 0xf00f0000, LENGTH = 0x00000100
+ ram : ORIGIN = 0x10000000, LENGTH = 0x00020000
+ rom : ORIGIN = 0x20040000, LENGTH = 0x00200000 - 0x40000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _ftext = .;
+ *(.text.start)
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+ } > rom
+
+ . = ALIGN(4);
+ _etext = .; /* End of text section */
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(.sbss .sbss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/include/csr.h b/circuitpython/lib/tinyusb/hw/bsp/fomu/include/csr.h
new file mode 100644
index 0000000..a2f60ec
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/include/csr.h
@@ -0,0 +1,750 @@
+//--------------------------------------------------------------------------------
+// Auto-generated by Migen (f4fcd10) & LiteX (1425a68d) on 2019-11-12 19:41:49
+//--------------------------------------------------------------------------------
+#ifndef __GENERATED_CSR_H
+#define __GENERATED_CSR_H
+#include <stdint.h>
+#ifdef CSR_ACCESSORS_DEFINED
+extern void csr_writeb(uint8_t value, unsigned long addr);
+extern uint8_t csr_readb(unsigned long addr);
+extern void csr_writew(uint16_t value, unsigned long addr);
+extern uint16_t csr_readw(unsigned long addr);
+extern void csr_writel(uint32_t value, unsigned long addr);
+extern uint32_t csr_readl(unsigned long addr);
+#else /* ! CSR_ACCESSORS_DEFINED */
+#include <hw/common.h>
+#endif /* ! CSR_ACCESSORS_DEFINED */
+
+/* ctrl */
+#define CSR_CTRL_BASE 0xe0000000L
+#define CSR_CTRL_RESET_ADDR 0xe0000000L
+#define CSR_CTRL_RESET_SIZE 1
+static inline unsigned char ctrl_reset_read(void) {
+ unsigned char r = csr_readl(0xe0000000L);
+ return r;
+}
+static inline void ctrl_reset_write(unsigned char value) {
+ csr_writel(value, 0xe0000000L);
+}
+#define CSR_CTRL_SCRATCH_ADDR 0xe0000004L
+#define CSR_CTRL_SCRATCH_SIZE 4
+static inline unsigned int ctrl_scratch_read(void) {
+ unsigned int r = csr_readl(0xe0000004L);
+ r <<= 8;
+ r |= csr_readl(0xe0000008L);
+ r <<= 8;
+ r |= csr_readl(0xe000000cL);
+ r <<= 8;
+ r |= csr_readl(0xe0000010L);
+ return r;
+}
+static inline void ctrl_scratch_write(unsigned int value) {
+ csr_writel(value >> 24, 0xe0000004L);
+ csr_writel(value >> 16, 0xe0000008L);
+ csr_writel(value >> 8, 0xe000000cL);
+ csr_writel(value, 0xe0000010L);
+}
+#define CSR_CTRL_BUS_ERRORS_ADDR 0xe0000014L
+#define CSR_CTRL_BUS_ERRORS_SIZE 4
+static inline unsigned int ctrl_bus_errors_read(void) {
+ unsigned int r = csr_readl(0xe0000014L);
+ r <<= 8;
+ r |= csr_readl(0xe0000018L);
+ r <<= 8;
+ r |= csr_readl(0xe000001cL);
+ r <<= 8;
+ r |= csr_readl(0xe0000020L);
+ return r;
+}
+
+/* messible */
+#define CSR_MESSIBLE_BASE 0xe0008000L
+#define CSR_MESSIBLE_IN_ADDR 0xe0008000L
+#define CSR_MESSIBLE_IN_SIZE 1
+static inline unsigned char messible_in_read(void) {
+ unsigned char r = csr_readl(0xe0008000L);
+ return r;
+}
+static inline void messible_in_write(unsigned char value) {
+ csr_writel(value, 0xe0008000L);
+}
+#define CSR_MESSIBLE_OUT_ADDR 0xe0008004L
+#define CSR_MESSIBLE_OUT_SIZE 1
+static inline unsigned char messible_out_read(void) {
+ unsigned char r = csr_readl(0xe0008004L);
+ return r;
+}
+#define CSR_MESSIBLE_STATUS_ADDR 0xe0008008L
+#define CSR_MESSIBLE_STATUS_SIZE 1
+static inline unsigned char messible_status_read(void) {
+ unsigned char r = csr_readl(0xe0008008L);
+ return r;
+}
+#define CSR_MESSIBLE_STATUS_FULL_OFFSET 0
+#define CSR_MESSIBLE_STATUS_FULL_SIZE 1
+#define CSR_MESSIBLE_STATUS_HAVE_OFFSET 1
+#define CSR_MESSIBLE_STATUS_HAVE_SIZE 1
+
+/* picorvspi */
+#define CSR_PICORVSPI_BASE 0xe0005000L
+#define CSR_PICORVSPI_CFG1_ADDR 0xe0005000L
+#define CSR_PICORVSPI_CFG1_SIZE 1
+static inline unsigned char picorvspi_cfg1_read(void) {
+ unsigned char r = csr_readl(0xe0005000L);
+ return r;
+}
+static inline void picorvspi_cfg1_write(unsigned char value) {
+ csr_writel(value, 0xe0005000L);
+}
+#define CSR_PICORVSPI_CFG1_BB_OUT_OFFSET 0
+#define CSR_PICORVSPI_CFG1_BB_OUT_SIZE 4
+#define CSR_PICORVSPI_CFG1_BB_CLK_OFFSET 4
+#define CSR_PICORVSPI_CFG1_BB_CLK_SIZE 1
+#define CSR_PICORVSPI_CFG1_BB_CS_OFFSET 5
+#define CSR_PICORVSPI_CFG1_BB_CS_SIZE 1
+#define CSR_PICORVSPI_CFG2_ADDR 0xe0005004L
+#define CSR_PICORVSPI_CFG2_SIZE 1
+static inline unsigned char picorvspi_cfg2_read(void) {
+ unsigned char r = csr_readl(0xe0005004L);
+ return r;
+}
+static inline void picorvspi_cfg2_write(unsigned char value) {
+ csr_writel(value, 0xe0005004L);
+}
+#define CSR_PICORVSPI_CFG2_BB_OE_OFFSET 0
+#define CSR_PICORVSPI_CFG2_BB_OE_SIZE 4
+#define CSR_PICORVSPI_CFG3_ADDR 0xe0005008L
+#define CSR_PICORVSPI_CFG3_SIZE 1
+static inline unsigned char picorvspi_cfg3_read(void) {
+ unsigned char r = csr_readl(0xe0005008L);
+ return r;
+}
+static inline void picorvspi_cfg3_write(unsigned char value) {
+ csr_writel(value, 0xe0005008L);
+}
+#define CSR_PICORVSPI_CFG3_RLAT_OFFSET 0
+#define CSR_PICORVSPI_CFG3_RLAT_SIZE 4
+#define CSR_PICORVSPI_CFG3_CRM_OFFSET 4
+#define CSR_PICORVSPI_CFG3_CRM_SIZE 1
+#define CSR_PICORVSPI_CFG3_QSPI_OFFSET 5
+#define CSR_PICORVSPI_CFG3_QSPI_SIZE 1
+#define CSR_PICORVSPI_CFG3_DDR_OFFSET 6
+#define CSR_PICORVSPI_CFG3_DDR_SIZE 1
+#define CSR_PICORVSPI_CFG4_ADDR 0xe000500cL
+#define CSR_PICORVSPI_CFG4_SIZE 1
+static inline unsigned char picorvspi_cfg4_read(void) {
+ unsigned char r = csr_readl(0xe000500cL);
+ return r;
+}
+static inline void picorvspi_cfg4_write(unsigned char value) {
+ csr_writel(value, 0xe000500cL);
+}
+#define CSR_PICORVSPI_CFG4_MEMIO_OFFSET 7
+#define CSR_PICORVSPI_CFG4_MEMIO_SIZE 1
+#define CSR_PICORVSPI_STAT1_ADDR 0xe0005010L
+#define CSR_PICORVSPI_STAT1_SIZE 1
+static inline unsigned char picorvspi_stat1_read(void) {
+ unsigned char r = csr_readl(0xe0005010L);
+ return r;
+}
+#define CSR_PICORVSPI_STAT1_BB_IN_OFFSET 0
+#define CSR_PICORVSPI_STAT1_BB_IN_SIZE 4
+#define CSR_PICORVSPI_STAT2_ADDR 0xe0005014L
+#define CSR_PICORVSPI_STAT2_SIZE 1
+static inline unsigned char picorvspi_stat2_read(void) {
+ unsigned char r = csr_readl(0xe0005014L);
+ return r;
+}
+#define CSR_PICORVSPI_STAT3_ADDR 0xe0005018L
+#define CSR_PICORVSPI_STAT3_SIZE 1
+static inline unsigned char picorvspi_stat3_read(void) {
+ unsigned char r = csr_readl(0xe0005018L);
+ return r;
+}
+#define CSR_PICORVSPI_STAT4_ADDR 0xe000501cL
+#define CSR_PICORVSPI_STAT4_SIZE 1
+static inline unsigned char picorvspi_stat4_read(void) {
+ unsigned char r = csr_readl(0xe000501cL);
+ return r;
+}
+
+/* reboot */
+#define CSR_REBOOT_BASE 0xe0006000L
+#define CSR_REBOOT_CTRL_ADDR 0xe0006000L
+#define CSR_REBOOT_CTRL_SIZE 1
+static inline unsigned char reboot_ctrl_read(void) {
+ unsigned char r = csr_readl(0xe0006000L);
+ return r;
+}
+static inline void reboot_ctrl_write(unsigned char value) {
+ csr_writel(value, 0xe0006000L);
+}
+#define CSR_REBOOT_CTRL_IMAGE_OFFSET 0
+#define CSR_REBOOT_CTRL_IMAGE_SIZE 2
+#define CSR_REBOOT_CTRL_KEY_OFFSET 2
+#define CSR_REBOOT_CTRL_KEY_SIZE 6
+#define CSR_REBOOT_ADDR_ADDR 0xe0006004L
+#define CSR_REBOOT_ADDR_SIZE 4
+static inline unsigned int reboot_addr_read(void) {
+ unsigned int r = csr_readl(0xe0006004L);
+ r <<= 8;
+ r |= csr_readl(0xe0006008L);
+ r <<= 8;
+ r |= csr_readl(0xe000600cL);
+ r <<= 8;
+ r |= csr_readl(0xe0006010L);
+ return r;
+}
+static inline void reboot_addr_write(unsigned int value) {
+ csr_writel(value >> 24, 0xe0006004L);
+ csr_writel(value >> 16, 0xe0006008L);
+ csr_writel(value >> 8, 0xe000600cL);
+ csr_writel(value, 0xe0006010L);
+}
+
+/* rgb */
+#define CSR_RGB_BASE 0xe0006800L
+#define CSR_RGB_DAT_ADDR 0xe0006800L
+#define CSR_RGB_DAT_SIZE 1
+static inline unsigned char rgb_dat_read(void) {
+ unsigned char r = csr_readl(0xe0006800L);
+ return r;
+}
+static inline void rgb_dat_write(unsigned char value) {
+ csr_writel(value, 0xe0006800L);
+}
+#define CSR_RGB_ADDR_ADDR 0xe0006804L
+#define CSR_RGB_ADDR_SIZE 1
+static inline unsigned char rgb_addr_read(void) {
+ unsigned char r = csr_readl(0xe0006804L);
+ return r;
+}
+static inline void rgb_addr_write(unsigned char value) {
+ csr_writel(value, 0xe0006804L);
+}
+#define CSR_RGB_CTRL_ADDR 0xe0006808L
+#define CSR_RGB_CTRL_SIZE 1
+static inline unsigned char rgb_ctrl_read(void) {
+ unsigned char r = csr_readl(0xe0006808L);
+ return r;
+}
+static inline void rgb_ctrl_write(unsigned char value) {
+ csr_writel(value, 0xe0006808L);
+}
+#define CSR_RGB_CTRL_EXE_OFFSET 0
+#define CSR_RGB_CTRL_EXE_SIZE 1
+#define CSR_RGB_CTRL_CURREN_OFFSET 1
+#define CSR_RGB_CTRL_CURREN_SIZE 1
+#define CSR_RGB_CTRL_RGBLEDEN_OFFSET 2
+#define CSR_RGB_CTRL_RGBLEDEN_SIZE 1
+#define CSR_RGB_CTRL_RRAW_OFFSET 3
+#define CSR_RGB_CTRL_RRAW_SIZE 1
+#define CSR_RGB_CTRL_GRAW_OFFSET 4
+#define CSR_RGB_CTRL_GRAW_SIZE 1
+#define CSR_RGB_CTRL_BRAW_OFFSET 5
+#define CSR_RGB_CTRL_BRAW_SIZE 1
+#define CSR_RGB_RAW_ADDR 0xe000680cL
+#define CSR_RGB_RAW_SIZE 1
+static inline unsigned char rgb_raw_read(void) {
+ unsigned char r = csr_readl(0xe000680cL);
+ return r;
+}
+static inline void rgb_raw_write(unsigned char value) {
+ csr_writel(value, 0xe000680cL);
+}
+#define CSR_RGB_RAW_R_OFFSET 0
+#define CSR_RGB_RAW_R_SIZE 1
+#define CSR_RGB_RAW_G_OFFSET 1
+#define CSR_RGB_RAW_G_SIZE 1
+#define CSR_RGB_RAW_B_OFFSET 2
+#define CSR_RGB_RAW_B_SIZE 1
+
+/* timer0 */
+#define CSR_TIMER0_BASE 0xe0002800L
+#define CSR_TIMER0_LOAD_ADDR 0xe0002800L
+#define CSR_TIMER0_LOAD_SIZE 4
+static inline unsigned int timer0_load_read(void) {
+ unsigned int r = csr_readl(0xe0002800L);
+ r <<= 8;
+ r |= csr_readl(0xe0002804L);
+ r <<= 8;
+ r |= csr_readl(0xe0002808L);
+ r <<= 8;
+ r |= csr_readl(0xe000280cL);
+ return r;
+}
+static inline void timer0_load_write(unsigned int value) {
+ csr_writel(value >> 24, 0xe0002800L);
+ csr_writel(value >> 16, 0xe0002804L);
+ csr_writel(value >> 8, 0xe0002808L);
+ csr_writel(value, 0xe000280cL);
+}
+#define CSR_TIMER0_RELOAD_ADDR 0xe0002810L
+#define CSR_TIMER0_RELOAD_SIZE 4
+static inline unsigned int timer0_reload_read(void) {
+ unsigned int r = csr_readl(0xe0002810L);
+ r <<= 8;
+ r |= csr_readl(0xe0002814L);
+ r <<= 8;
+ r |= csr_readl(0xe0002818L);
+ r <<= 8;
+ r |= csr_readl(0xe000281cL);
+ return r;
+}
+static inline void timer0_reload_write(unsigned int value) {
+ csr_writel(value >> 24, 0xe0002810L);
+ csr_writel(value >> 16, 0xe0002814L);
+ csr_writel(value >> 8, 0xe0002818L);
+ csr_writel(value, 0xe000281cL);
+}
+#define CSR_TIMER0_EN_ADDR 0xe0002820L
+#define CSR_TIMER0_EN_SIZE 1
+static inline unsigned char timer0_en_read(void) {
+ unsigned char r = csr_readl(0xe0002820L);
+ return r;
+}
+static inline void timer0_en_write(unsigned char value) {
+ csr_writel(value, 0xe0002820L);
+}
+#define CSR_TIMER0_UPDATE_VALUE_ADDR 0xe0002824L
+#define CSR_TIMER0_UPDATE_VALUE_SIZE 1
+static inline unsigned char timer0_update_value_read(void) {
+ unsigned char r = csr_readl(0xe0002824L);
+ return r;
+}
+static inline void timer0_update_value_write(unsigned char value) {
+ csr_writel(value, 0xe0002824L);
+}
+#define CSR_TIMER0_VALUE_ADDR 0xe0002828L
+#define CSR_TIMER0_VALUE_SIZE 4
+static inline unsigned int timer0_value_read(void) {
+ unsigned int r = csr_readl(0xe0002828L);
+ r <<= 8;
+ r |= csr_readl(0xe000282cL);
+ r <<= 8;
+ r |= csr_readl(0xe0002830L);
+ r <<= 8;
+ r |= csr_readl(0xe0002834L);
+ return r;
+}
+#define CSR_TIMER0_EV_STATUS_ADDR 0xe0002838L
+#define CSR_TIMER0_EV_STATUS_SIZE 1
+static inline unsigned char timer0_ev_status_read(void) {
+ unsigned char r = csr_readl(0xe0002838L);
+ return r;
+}
+static inline void timer0_ev_status_write(unsigned char value) {
+ csr_writel(value, 0xe0002838L);
+}
+#define CSR_TIMER0_EV_PENDING_ADDR 0xe000283cL
+#define CSR_TIMER0_EV_PENDING_SIZE 1
+static inline unsigned char timer0_ev_pending_read(void) {
+ unsigned char r = csr_readl(0xe000283cL);
+ return r;
+}
+static inline void timer0_ev_pending_write(unsigned char value) {
+ csr_writel(value, 0xe000283cL);
+}
+#define CSR_TIMER0_EV_ENABLE_ADDR 0xe0002840L
+#define CSR_TIMER0_EV_ENABLE_SIZE 1
+static inline unsigned char timer0_ev_enable_read(void) {
+ unsigned char r = csr_readl(0xe0002840L);
+ return r;
+}
+static inline void timer0_ev_enable_write(unsigned char value) {
+ csr_writel(value, 0xe0002840L);
+}
+
+/* touch */
+#define CSR_TOUCH_BASE 0xe0005800L
+#define CSR_TOUCH_O_ADDR 0xe0005800L
+#define CSR_TOUCH_O_SIZE 1
+static inline unsigned char touch_o_read(void) {
+ unsigned char r = csr_readl(0xe0005800L);
+ return r;
+}
+static inline void touch_o_write(unsigned char value) {
+ csr_writel(value, 0xe0005800L);
+}
+#define CSR_TOUCH_O_O_OFFSET 0
+#define CSR_TOUCH_O_O_SIZE 4
+#define CSR_TOUCH_OE_ADDR 0xe0005804L
+#define CSR_TOUCH_OE_SIZE 1
+static inline unsigned char touch_oe_read(void) {
+ unsigned char r = csr_readl(0xe0005804L);
+ return r;
+}
+static inline void touch_oe_write(unsigned char value) {
+ csr_writel(value, 0xe0005804L);
+}
+#define CSR_TOUCH_OE_OE_OFFSET 0
+#define CSR_TOUCH_OE_OE_SIZE 4
+#define CSR_TOUCH_I_ADDR 0xe0005808L
+#define CSR_TOUCH_I_SIZE 1
+static inline unsigned char touch_i_read(void) {
+ unsigned char r = csr_readl(0xe0005808L);
+ return r;
+}
+#define CSR_TOUCH_I_I_OFFSET 0
+#define CSR_TOUCH_I_I_SIZE 4
+
+/* usb */
+#define CSR_USB_BASE 0xe0004800L
+#define CSR_USB_PULLUP_OUT_ADDR 0xe0004800L
+#define CSR_USB_PULLUP_OUT_SIZE 1
+static inline unsigned char usb_pullup_out_read(void) {
+ unsigned char r = csr_readl(0xe0004800L);
+ return r;
+}
+static inline void usb_pullup_out_write(unsigned char value) {
+ csr_writel(value, 0xe0004800L);
+}
+#define CSR_USB_ADDRESS_ADDR 0xe0004804L
+#define CSR_USB_ADDRESS_SIZE 1
+static inline unsigned char usb_address_read(void) {
+ unsigned char r = csr_readl(0xe0004804L);
+ return r;
+}
+static inline void usb_address_write(unsigned char value) {
+ csr_writel(value, 0xe0004804L);
+}
+#define CSR_USB_ADDRESS_ADDR_OFFSET 0
+#define CSR_USB_ADDRESS_ADDR_SIZE 7
+#define CSR_USB_NEXT_EV_ADDR 0xe0004808L
+#define CSR_USB_NEXT_EV_SIZE 1
+static inline unsigned char usb_next_ev_read(void) {
+ unsigned char r = csr_readl(0xe0004808L);
+ return r;
+}
+#define CSR_USB_NEXT_EV_IN_OFFSET 0
+#define CSR_USB_NEXT_EV_IN_SIZE 1
+#define CSR_USB_NEXT_EV_OUT_OFFSET 1
+#define CSR_USB_NEXT_EV_OUT_SIZE 1
+#define CSR_USB_NEXT_EV_SETUP_OFFSET 2
+#define CSR_USB_NEXT_EV_SETUP_SIZE 1
+#define CSR_USB_NEXT_EV_RESET_OFFSET 3
+#define CSR_USB_NEXT_EV_RESET_SIZE 1
+#define CSR_USB_SETUP_DATA_ADDR 0xe000480cL
+#define CSR_USB_SETUP_DATA_SIZE 1
+static inline unsigned char usb_setup_data_read(void) {
+ unsigned char r = csr_readl(0xe000480cL);
+ return r;
+}
+#define CSR_USB_SETUP_DATA_DATA_OFFSET 0
+#define CSR_USB_SETUP_DATA_DATA_SIZE 8
+#define CSR_USB_SETUP_CTRL_ADDR 0xe0004810L
+#define CSR_USB_SETUP_CTRL_SIZE 1
+static inline unsigned char usb_setup_ctrl_read(void) {
+ unsigned char r = csr_readl(0xe0004810L);
+ return r;
+}
+static inline void usb_setup_ctrl_write(unsigned char value) {
+ csr_writel(value, 0xe0004810L);
+}
+#define CSR_USB_SETUP_CTRL_RESET_OFFSET 5
+#define CSR_USB_SETUP_CTRL_RESET_SIZE 1
+#define CSR_USB_SETUP_STATUS_ADDR 0xe0004814L
+#define CSR_USB_SETUP_STATUS_SIZE 1
+static inline unsigned char usb_setup_status_read(void) {
+ unsigned char r = csr_readl(0xe0004814L);
+ return r;
+}
+#define CSR_USB_SETUP_STATUS_EPNO_OFFSET 0
+#define CSR_USB_SETUP_STATUS_EPNO_SIZE 4
+#define CSR_USB_SETUP_STATUS_HAVE_OFFSET 4
+#define CSR_USB_SETUP_STATUS_HAVE_SIZE 1
+#define CSR_USB_SETUP_STATUS_PEND_OFFSET 5
+#define CSR_USB_SETUP_STATUS_PEND_SIZE 1
+#define CSR_USB_SETUP_STATUS_IS_IN_OFFSET 6
+#define CSR_USB_SETUP_STATUS_IS_IN_SIZE 1
+#define CSR_USB_SETUP_STATUS_DATA_OFFSET 7
+#define CSR_USB_SETUP_STATUS_DATA_SIZE 1
+#define CSR_USB_SETUP_EV_STATUS_ADDR 0xe0004818L
+#define CSR_USB_SETUP_EV_STATUS_SIZE 1
+static inline unsigned char usb_setup_ev_status_read(void) {
+ unsigned char r = csr_readl(0xe0004818L);
+ return r;
+}
+static inline void usb_setup_ev_status_write(unsigned char value) {
+ csr_writel(value, 0xe0004818L);
+}
+#define CSR_USB_SETUP_EV_PENDING_ADDR 0xe000481cL
+#define CSR_USB_SETUP_EV_PENDING_SIZE 1
+static inline unsigned char usb_setup_ev_pending_read(void) {
+ unsigned char r = csr_readl(0xe000481cL);
+ return r;
+}
+static inline void usb_setup_ev_pending_write(unsigned char value) {
+ csr_writel(value, 0xe000481cL);
+}
+#define CSR_USB_SETUP_EV_ENABLE_ADDR 0xe0004820L
+#define CSR_USB_SETUP_EV_ENABLE_SIZE 1
+static inline unsigned char usb_setup_ev_enable_read(void) {
+ unsigned char r = csr_readl(0xe0004820L);
+ return r;
+}
+static inline void usb_setup_ev_enable_write(unsigned char value) {
+ csr_writel(value, 0xe0004820L);
+}
+#define CSR_USB_IN_DATA_ADDR 0xe0004824L
+#define CSR_USB_IN_DATA_SIZE 1
+static inline unsigned char usb_in_data_read(void) {
+ unsigned char r = csr_readl(0xe0004824L);
+ return r;
+}
+static inline void usb_in_data_write(unsigned char value) {
+ csr_writel(value, 0xe0004824L);
+}
+#define CSR_USB_IN_DATA_DATA_OFFSET 0
+#define CSR_USB_IN_DATA_DATA_SIZE 8
+#define CSR_USB_IN_CTRL_ADDR 0xe0004828L
+#define CSR_USB_IN_CTRL_SIZE 1
+static inline unsigned char usb_in_ctrl_read(void) {
+ unsigned char r = csr_readl(0xe0004828L);
+ return r;
+}
+static inline void usb_in_ctrl_write(unsigned char value) {
+ csr_writel(value, 0xe0004828L);
+}
+#define CSR_USB_IN_CTRL_EPNO_OFFSET 0
+#define CSR_USB_IN_CTRL_EPNO_SIZE 4
+#define CSR_USB_IN_CTRL_RESET_OFFSET 5
+#define CSR_USB_IN_CTRL_RESET_SIZE 1
+#define CSR_USB_IN_CTRL_STALL_OFFSET 6
+#define CSR_USB_IN_CTRL_STALL_SIZE 1
+#define CSR_USB_IN_STATUS_ADDR 0xe000482cL
+#define CSR_USB_IN_STATUS_SIZE 1
+static inline unsigned char usb_in_status_read(void) {
+ unsigned char r = csr_readl(0xe000482cL);
+ return r;
+}
+#define CSR_USB_IN_STATUS_IDLE_OFFSET 0
+#define CSR_USB_IN_STATUS_IDLE_SIZE 1
+#define CSR_USB_IN_STATUS_HAVE_OFFSET 4
+#define CSR_USB_IN_STATUS_HAVE_SIZE 1
+#define CSR_USB_IN_STATUS_PEND_OFFSET 5
+#define CSR_USB_IN_STATUS_PEND_SIZE 1
+#define CSR_USB_IN_EV_STATUS_ADDR 0xe0004830L
+#define CSR_USB_IN_EV_STATUS_SIZE 1
+static inline unsigned char usb_in_ev_status_read(void) {
+ unsigned char r = csr_readl(0xe0004830L);
+ return r;
+}
+static inline void usb_in_ev_status_write(unsigned char value) {
+ csr_writel(value, 0xe0004830L);
+}
+#define CSR_USB_IN_EV_PENDING_ADDR 0xe0004834L
+#define CSR_USB_IN_EV_PENDING_SIZE 1
+static inline unsigned char usb_in_ev_pending_read(void) {
+ unsigned char r = csr_readl(0xe0004834L);
+ return r;
+}
+static inline void usb_in_ev_pending_write(unsigned char value) {
+ csr_writel(value, 0xe0004834L);
+}
+#define CSR_USB_IN_EV_ENABLE_ADDR 0xe0004838L
+#define CSR_USB_IN_EV_ENABLE_SIZE 1
+static inline unsigned char usb_in_ev_enable_read(void) {
+ unsigned char r = csr_readl(0xe0004838L);
+ return r;
+}
+static inline void usb_in_ev_enable_write(unsigned char value) {
+ csr_writel(value, 0xe0004838L);
+}
+#define CSR_USB_OUT_DATA_ADDR 0xe000483cL
+#define CSR_USB_OUT_DATA_SIZE 1
+static inline unsigned char usb_out_data_read(void) {
+ unsigned char r = csr_readl(0xe000483cL);
+ return r;
+}
+#define CSR_USB_OUT_DATA_DATA_OFFSET 0
+#define CSR_USB_OUT_DATA_DATA_SIZE 8
+#define CSR_USB_OUT_CTRL_ADDR 0xe0004840L
+#define CSR_USB_OUT_CTRL_SIZE 1
+static inline unsigned char usb_out_ctrl_read(void) {
+ unsigned char r = csr_readl(0xe0004840L);
+ return r;
+}
+static inline void usb_out_ctrl_write(unsigned char value) {
+ csr_writel(value, 0xe0004840L);
+}
+#define CSR_USB_OUT_CTRL_EPNO_OFFSET 0
+#define CSR_USB_OUT_CTRL_EPNO_SIZE 4
+#define CSR_USB_OUT_CTRL_ENABLE_OFFSET 4
+#define CSR_USB_OUT_CTRL_ENABLE_SIZE 1
+#define CSR_USB_OUT_CTRL_RESET_OFFSET 5
+#define CSR_USB_OUT_CTRL_RESET_SIZE 1
+#define CSR_USB_OUT_CTRL_STALL_OFFSET 6
+#define CSR_USB_OUT_CTRL_STALL_SIZE 1
+#define CSR_USB_OUT_STATUS_ADDR 0xe0004844L
+#define CSR_USB_OUT_STATUS_SIZE 1
+static inline unsigned char usb_out_status_read(void) {
+ unsigned char r = csr_readl(0xe0004844L);
+ return r;
+}
+#define CSR_USB_OUT_STATUS_EPNO_OFFSET 0
+#define CSR_USB_OUT_STATUS_EPNO_SIZE 4
+#define CSR_USB_OUT_STATUS_HAVE_OFFSET 4
+#define CSR_USB_OUT_STATUS_HAVE_SIZE 1
+#define CSR_USB_OUT_STATUS_PEND_OFFSET 5
+#define CSR_USB_OUT_STATUS_PEND_SIZE 1
+#define CSR_USB_OUT_EV_STATUS_ADDR 0xe0004848L
+#define CSR_USB_OUT_EV_STATUS_SIZE 1
+static inline unsigned char usb_out_ev_status_read(void) {
+ unsigned char r = csr_readl(0xe0004848L);
+ return r;
+}
+static inline void usb_out_ev_status_write(unsigned char value) {
+ csr_writel(value, 0xe0004848L);
+}
+#define CSR_USB_OUT_EV_PENDING_ADDR 0xe000484cL
+#define CSR_USB_OUT_EV_PENDING_SIZE 1
+static inline unsigned char usb_out_ev_pending_read(void) {
+ unsigned char r = csr_readl(0xe000484cL);
+ return r;
+}
+static inline void usb_out_ev_pending_write(unsigned char value) {
+ csr_writel(value, 0xe000484cL);
+}
+#define CSR_USB_OUT_EV_ENABLE_ADDR 0xe0004850L
+#define CSR_USB_OUT_EV_ENABLE_SIZE 1
+static inline unsigned char usb_out_ev_enable_read(void) {
+ unsigned char r = csr_readl(0xe0004850L);
+ return r;
+}
+static inline void usb_out_ev_enable_write(unsigned char value) {
+ csr_writel(value, 0xe0004850L);
+}
+#define CSR_USB_OUT_ENABLE_STATUS_ADDR 0xe0004854L
+#define CSR_USB_OUT_ENABLE_STATUS_SIZE 1
+static inline unsigned char usb_out_enable_status_read(void) {
+ unsigned char r = csr_readl(0xe0004854L);
+ return r;
+}
+#define CSR_USB_OUT_STALL_STATUS_ADDR 0xe0004858L
+#define CSR_USB_OUT_STALL_STATUS_SIZE 1
+static inline unsigned char usb_out_stall_status_read(void) {
+ unsigned char r = csr_readl(0xe0004858L);
+ return r;
+}
+
+/* version */
+#define CSR_VERSION_BASE 0xe0007000L
+#define CSR_VERSION_MAJOR_ADDR 0xe0007000L
+#define CSR_VERSION_MAJOR_SIZE 1
+static inline unsigned char version_major_read(void) {
+ unsigned char r = csr_readl(0xe0007000L);
+ return r;
+}
+#define CSR_VERSION_MINOR_ADDR 0xe0007004L
+#define CSR_VERSION_MINOR_SIZE 1
+static inline unsigned char version_minor_read(void) {
+ unsigned char r = csr_readl(0xe0007004L);
+ return r;
+}
+#define CSR_VERSION_REVISION_ADDR 0xe0007008L
+#define CSR_VERSION_REVISION_SIZE 1
+static inline unsigned char version_revision_read(void) {
+ unsigned char r = csr_readl(0xe0007008L);
+ return r;
+}
+#define CSR_VERSION_GITREV_ADDR 0xe000700cL
+#define CSR_VERSION_GITREV_SIZE 4
+static inline unsigned int version_gitrev_read(void) {
+ unsigned int r = csr_readl(0xe000700cL);
+ r <<= 8;
+ r |= csr_readl(0xe0007010L);
+ r <<= 8;
+ r |= csr_readl(0xe0007014L);
+ r <<= 8;
+ r |= csr_readl(0xe0007018L);
+ return r;
+}
+#define CSR_VERSION_GITEXTRA_ADDR 0xe000701cL
+#define CSR_VERSION_GITEXTRA_SIZE 2
+static inline unsigned short int version_gitextra_read(void) {
+ unsigned short int r = csr_readl(0xe000701cL);
+ r <<= 8;
+ r |= csr_readl(0xe0007020L);
+ return r;
+}
+#define CSR_VERSION_DIRTY_ADDR 0xe0007024L
+#define CSR_VERSION_DIRTY_SIZE 1
+static inline unsigned char version_dirty_read(void) {
+ unsigned char r = csr_readl(0xe0007024L);
+ return r;
+}
+#define CSR_VERSION_DIRTY_DIRTY_OFFSET 0
+#define CSR_VERSION_DIRTY_DIRTY_SIZE 1
+#define CSR_VERSION_MODEL_ADDR 0xe0007028L
+#define CSR_VERSION_MODEL_SIZE 1
+static inline unsigned char version_model_read(void) {
+ unsigned char r = csr_readl(0xe0007028L);
+ return r;
+}
+#define CSR_VERSION_MODEL_MODEL_OFFSET 0
+#define CSR_VERSION_MODEL_MODEL_SIZE 8
+#define CSR_VERSION_SEED_ADDR 0xe000702cL
+#define CSR_VERSION_SEED_SIZE 4
+static inline unsigned int version_seed_read(void) {
+ unsigned int r = csr_readl(0xe000702cL);
+ r <<= 8;
+ r |= csr_readl(0xe0007030L);
+ r <<= 8;
+ r |= csr_readl(0xe0007034L);
+ r <<= 8;
+ r |= csr_readl(0xe0007038L);
+ return r;
+}
+
+/* constants */
+#define TIMER0_INTERRUPT 2
+static inline int timer0_interrupt_read(void) {
+ return 2;
+}
+#define USB_INTERRUPT 3
+static inline int usb_interrupt_read(void) {
+ return 3;
+}
+#define CONFIG_BITSTREAM_SYNC_HEADER1 2123999870
+static inline int config_bitstream_sync_header1_read(void) {
+ return 2123999870;
+}
+#define CONFIG_BITSTREAM_SYNC_HEADER2 2125109630
+static inline int config_bitstream_sync_header2_read(void) {
+ return 2125109630;
+}
+#define CONFIG_CLOCK_FREQUENCY 12000000
+static inline int config_clock_frequency_read(void) {
+ return 12000000;
+}
+#define CONFIG_CPU_RESET_ADDR 0
+static inline int config_cpu_reset_addr_read(void) {
+ return 0;
+}
+#define CONFIG_CPU_TYPE "VEXRISCV"
+static inline const char * config_cpu_type_read(void) {
+ return "VEXRISCV";
+}
+#define CONFIG_CPU_TYPE_VEXRISCV 1
+static inline int config_cpu_type_vexriscv_read(void) {
+ return 1;
+}
+#define CONFIG_CPU_VARIANT "MIN"
+static inline const char * config_cpu_variant_read(void) {
+ return "MIN";
+}
+#define CONFIG_CPU_VARIANT_MIN 1
+static inline int config_cpu_variant_min_read(void) {
+ return 1;
+}
+#define CONFIG_CSR_ALIGNMENT 32
+static inline int config_csr_alignment_read(void) {
+ return 32;
+}
+#define CONFIG_CSR_DATA_WIDTH 8
+static inline int config_csr_data_width_read(void) {
+ return 8;
+}
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/include/hw/common.h b/circuitpython/lib/tinyusb/hw/bsp/fomu/include/hw/common.h
new file mode 100644
index 0000000..6a97ca2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/include/hw/common.h
@@ -0,0 +1,33 @@
+#ifndef _HW_COMMON_H_
+#define _HW_COMMON_H_
+#include <stdint.h>
+static inline void csr_writeb(uint8_t value, uint32_t addr)
+{
+ *((volatile uint8_t *)addr) = value;
+}
+
+static inline uint8_t csr_readb(uint32_t addr)
+{
+ return *(volatile uint8_t *)addr;
+}
+
+static inline void csr_writew(uint16_t value, uint32_t addr)
+{
+ *((volatile uint16_t *)addr) = value;
+}
+
+static inline uint16_t csr_readw(uint32_t addr)
+{
+ return *(volatile uint16_t *)addr;
+}
+
+static inline void csr_writel(uint32_t value, uint32_t addr)
+{
+ *((volatile uint32_t *)addr) = value;
+}
+
+static inline uint32_t csr_readl(uint32_t addr)
+{
+ return *(volatile uint32_t *)addr;
+}
+#endif /* _HW_COMMON_H_ */ \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/include/irq.h b/circuitpython/lib/tinyusb/hw/bsp/fomu/include/irq.h
new file mode 100644
index 0000000..a822189
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/include/irq.h
@@ -0,0 +1,71 @@
+#ifndef __IRQ_H
+#define __IRQ_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define CSR_MSTATUS_MIE 0x8
+
+#define CSR_IRQ_MASK 0xBC0
+#define CSR_IRQ_PENDING 0xFC0
+
+#define CSR_DCACHE_INFO 0xCC0
+
+#define csrr(reg) ({ unsigned long __tmp; \
+ asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \
+ __tmp; })
+
+#define csrw(reg, val) ({ \
+ if (__builtin_constant_p(val) && (unsigned long)(val) < 32) \
+ asm volatile ("csrw " #reg ", %0" :: "i"(val)); \
+ else \
+ asm volatile ("csrw " #reg ", %0" :: "r"(val)); })
+
+#define csrs(reg, bit) ({ \
+ if (__builtin_constant_p(bit) && (unsigned long)(bit) < 32) \
+ asm volatile ("csrrs x0, " #reg ", %0" :: "i"(bit)); \
+ else \
+ asm volatile ("csrrs x0, " #reg ", %0" :: "r"(bit)); })
+
+#define csrc(reg, bit) ({ \
+ if (__builtin_constant_p(bit) && (unsigned long)(bit) < 32) \
+ asm volatile ("csrrc x0, " #reg ", %0" :: "i"(bit)); \
+ else \
+ asm volatile ("csrrc x0, " #reg ", %0" :: "r"(bit)); })
+
+static inline unsigned int irq_getie(void)
+{
+ return (csrr(mstatus) & CSR_MSTATUS_MIE) != 0;
+}
+
+static inline void irq_setie(unsigned int ie)
+{
+ if(ie) csrs(mstatus,CSR_MSTATUS_MIE); else csrc(mstatus,CSR_MSTATUS_MIE);
+}
+
+static inline unsigned int irq_getmask(void)
+{
+ unsigned int mask;
+ asm volatile ("csrr %0, %1" : "=r"(mask) : "i"(CSR_IRQ_MASK));
+ return mask;
+}
+
+static inline void irq_setmask(unsigned int mask)
+{
+ asm volatile ("csrw %0, %1" :: "i"(CSR_IRQ_MASK), "r"(mask));
+}
+
+static inline unsigned int irq_pending(void)
+{
+ unsigned int pending;
+ asm volatile ("csrr %0, %1" : "=r"(pending) : "i"(CSR_IRQ_PENDING));
+ return pending;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IRQ_H */ \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/output_format.ld b/circuitpython/lib/tinyusb/hw/bsp/fomu/output_format.ld
new file mode 100644
index 0000000..5e76f5f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/output_format.ld
@@ -0,0 +1 @@
+OUTPUT_FORMAT("elf32-littleriscv")
diff --git a/circuitpython/lib/tinyusb/hw/bsp/fomu/regions.ld b/circuitpython/lib/tinyusb/hw/bsp/fomu/regions.ld
new file mode 100644
index 0000000..51811f6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/fomu/regions.ld
@@ -0,0 +1,6 @@
+MEMORY {
+ csr : ORIGIN = 0x60000000, LENGTH = 0x01000000
+ vexriscv_debug : ORIGIN = 0xf00f0000, LENGTH = 0x00000100
+ sram : ORIGIN = 0x10000000, LENGTH = 0x00020000
+ rom : ORIGIN = 0x00000000, LENGTH = 0x00002000
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.h b/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.h
new file mode 100644
index 0000000..8253679
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "fsl_device_registers.h"
+
+// LED
+#define LED_PIN_CLOCK kCLOCK_PortD
+#define LED_GPIO GPIOD
+#define LED_PORT PORTD
+#define LED_PIN 5
+#define LED_STATE_ON 0
+
+// SW3 button1
+#define BUTTON_PIN_CLOCK kCLOCK_PortC
+#define BUTTON_GPIO GPIOC
+#define BUTTON_PORT PORTC
+#define BUTTON_PIN 3
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART0
+#define UART_PIN_CLOCK kCLOCK_PortA
+#define UART_PIN_PORT PORTA
+#define UART_PIN_RX 1u
+#define UART_PIN_TX 2u
+#define SOPT5_LPUART0RXSRC_LPUART_RX 0x00u /*!<@brief LPUART0 Receive Data Source Select: LPUART_RX pin */
+#define SOPT5_LPUART0TXSRC_LPUART_TX 0x00u /*!<@brief LPUART0 Transmit Data Source Select: LPUART0_TX pin */
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.mk b/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.mk
new file mode 100644
index 0000000..56df553
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/board.mk
@@ -0,0 +1,51 @@
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += $(SDK_DIR)
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -DCPU_K32L2B31VLH0A \
+ -DCFG_TUSB_MCU=OPT_MCU_K32L2BXX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter
+
+MCU_DIR = $(SDK_DIR)/devices/K32L2B31A
+
+# All source paths should be relative to the top level.
+LD_FILE = $(MCU_DIR)/gcc/K32L2B31xxxxA_flash.ld
+
+SRC_C += \
+ src/portable/nxp/khci/dcd_khci.c \
+ $(MCU_DIR)/system_K32L2B31A.c \
+ $(MCU_DIR)/project_template/clock_config.c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(SDK_DIR)/drivers/gpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(SDK_DIR)/CMSIS/Include \
+ $(TOP)/$(SDK_DIR)/drivers/smc \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/gpio \
+ $(TOP)/$(SDK_DIR)/drivers/port \
+ $(TOP)/$(SDK_DIR)/drivers/lpuart \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(MCU_DIR)/project_template \
+
+SRC_S += $(MCU_DIR)/gcc/startup_K32L2B31A.S
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = MKL25Z128xxx4
+
+# For flash-pyocd target
+PYOCD_TARGET = K32L2B
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/frdm_k32l2b.c b/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/frdm_k32l2b.c
new file mode 100644
index 0000000..924bb18
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/frdm_k32l2b/frdm_k32l2b.c
@@ -0,0 +1,140 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2020, Koji Kitayama
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+#include "board.h"
+#include "fsl_gpio.h"
+#include "fsl_port.h"
+#include "fsl_clock.h"
+#include "fsl_lpuart.h"
+
+#include "clock_config.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void board_init(void)
+{
+ /* Enable port clocks for UART/LED/Button pins */
+ CLOCK_EnableClock(UART_PIN_CLOCK);
+ CLOCK_EnableClock(LED_PIN_CLOCK);
+ CLOCK_EnableClock(BUTTON_PIN_CLOCK);
+
+ gpio_pin_config_t led_config = { kGPIO_DigitalOutput, 0 };
+ GPIO_PinInit(LED_GPIO, LED_PIN, &led_config);
+ PORT_SetPinMux(LED_PORT, LED_PIN, kPORT_MuxAsGpio);
+
+ gpio_pin_config_t button_config = { kGPIO_DigitalInput, 0 };
+ GPIO_PinInit(BUTTON_GPIO, BUTTON_PIN, &button_config);
+ const port_pin_config_t BUTTON_CFG = {
+ kPORT_PullUp,
+ kPORT_FastSlewRate,
+ kPORT_PassiveFilterDisable,
+ kPORT_LowDriveStrength,
+ kPORT_MuxAsGpio
+ };
+ PORT_SetPinConfig(BUTTON_PORT, BUTTON_PIN, &BUTTON_CFG);
+
+ /* PORTA1 (pin 23) is configured as LPUART0_RX */
+ PORT_SetPinMux(PORTA, 1U, kPORT_MuxAlt2);
+ /* PORTA2 (pin 24) is configured as LPUART0_TX */
+ PORT_SetPinMux(PORTA, 2U, kPORT_MuxAlt2);
+
+ SIM->SOPT5 = ((SIM->SOPT5 &
+ /* Mask bits to zero which are setting */
+ (~(SIM_SOPT5_LPUART0TXSRC_MASK | SIM_SOPT5_LPUART0RXSRC_MASK)))
+ /* LPUART0 Transmit Data Source Select: LPUART0_TX pin. */
+ | SIM_SOPT5_LPUART0TXSRC(SOPT5_LPUART0TXSRC_LPUART_TX)
+ /* LPUART0 Receive Data Source Select: LPUART_RX pin. */
+ | SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX));
+
+ BOARD_BootClockRUN();
+ SystemCoreClockUpdate();
+ CLOCK_SetLpuart0Clock(1);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ lpuart_config_t uart_config;
+ LPUART_GetDefaultConfig(&uart_config);
+ uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
+ LPUART_Init(UART_PORT, &uart_config, CLOCK_GetFreq(kCLOCK_McgIrc48MClk));
+
+ // USB
+ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ GPIO_PinWrite(LED_GPIO, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_GPIO, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ LPUART_ReadBlocking(UART_PORT, buf, len);
+ return len;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ LPUART_WriteBlocking(UART_PORT, (uint8_t const*) buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/board.mk b/circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/board.mk
new file mode 100644
index 0000000..3585b8b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/board.mk
@@ -0,0 +1,52 @@
+SDK_DIR = hw/mcu/nxp/nxp_sdk
+DEPS_SUBMODULES += $(SDK_DIR)
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -DCPU_MKL25Z128VLK4 \
+ -DCFG_TUSB_MCU=OPT_MCU_MKL25ZXX \
+ -DCFG_EXAMPLE_VIDEO_READONLY
+
+LDFLAGS += \
+ -Wl,--defsym,__stack_size__=0x400 \
+ -Wl,--defsym,__heap_size__=0
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=format
+
+MCU_DIR = $(SDK_DIR)/devices/MKL25Z4
+
+# All source paths should be relative to the top level.
+LD_FILE = $(MCU_DIR)/gcc/MKL25Z128xxx4_flash.ld
+
+SRC_C += \
+ src/portable/nxp/khci/dcd_khci.c \
+ src/portable/nxp/khci/hcd_khci.c \
+ $(MCU_DIR)/system_MKL25Z4.c \
+ $(MCU_DIR)/project_template/clock_config.c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(MCU_DIR)/drivers/fsl_gpio.c \
+ $(MCU_DIR)/drivers/fsl_lpsci.c
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(SDK_DIR)/CMSIS/Include \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(MCU_DIR)/project_template \
+
+SRC_S += $(MCU_DIR)/gcc/startup_MKL25Z4.S
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = MKL25Z128xxx4
+
+# For flash-pyocd target
+PYOCD_TARGET = mkl25zl128
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/frdm_kl25z.c b/circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/frdm_kl25z.c
new file mode 100644
index 0000000..8d93fdb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/frdm_kl25z/frdm_kl25z.c
@@ -0,0 +1,176 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2020, Koji Kitayama
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+#include "fsl_device_registers.h"
+#include "fsl_gpio.h"
+#include "fsl_port.h"
+#include "fsl_clock.h"
+#include "fsl_lpsci.h"
+
+#include "clock_config.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+#if CFG_TUH_ENABLED
+ tuh_int_handler(0);
+#endif
+#if CFG_TUD_ENABLED
+ tud_int_handler(0);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_AD_B0_09_GPIO1_IO09
+#define LED_PORT GPIOB
+#define LED_PIN_CLOCK kCLOCK_PortB
+#define LED_PIN_PORT PORTB
+#define LED_PIN 19U
+#define LED_PIN_FUNCTION kPORT_MuxAsGpio
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN_CLOCK kCLOCK_PortC
+#define BUTTON_PIN_PORT PORTC
+#define BUTTON_PIN 9U
+#define BUTTON_PIN_FUNCTION kPORT_MuxAsGpio
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT UART0
+#define UART_PIN_CLOCK kCLOCK_PortA
+#define UART_PIN_PORT PORTA
+#define UART_PIN_RX 1u
+#define UART_PIN_TX 2u
+#define UART_PIN_FUNCTION kPORT_MuxAlt2
+#define SOPT5_UART0RXSRC_UART_RX 0x00u /*!< UART0 receive data source select: UART0_RX pin */
+#define SOPT5_UART0TXSRC_UART_TX 0x00u /*!< UART0 transmit data source select: UART0_TX pin */
+
+const uint8_t dcd_data[] = { 0x00 };
+
+void board_init(void)
+{
+ BOARD_BootClockRUN();
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ // LED
+ CLOCK_EnableClock(LED_PIN_CLOCK);
+ PORT_SetPinMux(LED_PIN_PORT, LED_PIN, LED_PIN_FUNCTION);
+ gpio_pin_config_t led_config = { kGPIO_DigitalOutput, 0 };
+ GPIO_PinInit(LED_PORT, LED_PIN, &led_config);
+ board_led_write(false);
+
+#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
+ // Button
+ CLOCK_EnableClock(BUTTON_PIN_CLOCK);
+ port_pin_config_t button_port = {
+ .pullSelect = kPORT_PullUp,
+ .mux = BUTTON_PIN_FUNCTION,
+ };
+ PORT_SetPinConfig(BUTTON_PIN_PORT, BUTTON_PIN, &button_port);
+ gpio_pin_config_t button_config = { kGPIO_DigitalInput, 0 };
+ GPIO_PinInit(BUTTON_PORT, BUTTON_PIN, &button_config);
+#endif
+
+ // UART
+ CLOCK_EnableClock(UART_PIN_CLOCK);
+ PORT_SetPinMux(UART_PIN_PORT, UART_PIN_RX, UART_PIN_FUNCTION);
+ PORT_SetPinMux(UART_PIN_PORT, UART_PIN_TX, UART_PIN_FUNCTION);
+ SIM->SOPT5 = ((SIM->SOPT5 &
+ (~(SIM_SOPT5_UART0TXSRC_MASK | SIM_SOPT5_UART0RXSRC_MASK)))
+ | SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX)
+ | SIM_SOPT5_UART0RXSRC(SOPT5_UART0RXSRC_UART_RX)
+ );
+
+ lpsci_config_t uart_config;
+ CLOCK_SetLpsci0Clock(1);
+ LPSCI_GetDefaultConfig(&uart_config);
+ uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
+ LPSCI_Init(UART_PORT, &uart_config, CLOCK_GetPllFllSelClkFreq());
+
+ // USB
+ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcPll0, CLOCK_GetFreq(kCLOCK_PllFllSelClk));
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ GPIO_WritePinOutput(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
+ return BUTTON_STATE_ACTIVE == GPIO_ReadPinInput(BUTTON_PORT, BUTTON_PIN);
+#endif
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ LPSCI_ReadBlocking(UART_PORT, buf, len);
+ return len;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ LPSCI_WriteBlocking(UART_PORT, (uint8_t const*) buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.h b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.h
new file mode 100644
index 0000000..fae7c40
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.h
@@ -0,0 +1,20 @@
+#ifndef _NUCLEI_SDK_HAL_H
+#define _NUCLEI_SDK_HAL_H
+
+#include "gd32vf103c_longan_nano.h"
+
+// 4 bits for interrupt level, 0 for priority.
+// level 0 = lowest priority, level 15 = highest priority.
+#define __ECLIC_INTCTLBITS 4
+
+#define __SYSTEM_CLOCK 72000000
+#define HXTAL_VALUE ((uint32_t)8000000)
+
+#define SOC_DEBUG_UART GD32_COM0
+
+#define DBG_KEY_UNLOCK 0x4B5A6978
+#define DBG_CMD_RESET 0x1
+#define DBG_KEY REG32(DBG + 0x0C)
+#define DBG_CMD REG32(DBG + 0x08)
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.mk b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.mk
new file mode 100644
index 0000000..3b89444
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/boards/sipeed_longan_nano/board.mk
@@ -0,0 +1,13 @@
+LONGAN_NANO_SDK_BSP = $(GD32VF103_SDK_SOC)/Board/gd32vf103c_longan_nano
+LINKER_SCRIPTS = $(LONGAN_NANO_SDK_BSP)/Source/GCC
+
+# All source paths should be relative to the top level.
+LD_FILE = $(LINKER_SCRIPTS)/gcc_gd32vf103xb_flashxip.ld # Longan Nano 128k ROM 32k RAM
+#LD_FILE = $(LINKER_SCRIPTS)/gcc_gd32vf103x8_flashxip.ld # Longan Nano Lite 64k ROM 20k RAM
+
+SRC_C += $(LONGAN_NANO_SDK_BSP)/Source/gd32vf103c_longan_nano.c
+INC += $(TOP)/$(LONGAN_NANO_SDK_BSP)/Include
+
+# Longan Nano 128k ROM 32k RAM
+JLINK_DEVICE = gd32vf103cbt6
+#JLINK_DEVICE = gd32vf103c8t6 # Longan Nano Lite 64k ROM 20k RAM
diff --git a/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.c b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.c
new file mode 100644
index 0000000..c207323
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.c
@@ -0,0 +1,197 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "board.h"
+#include "drv_usb_hw.h"
+#include "drv_usb_dev.h"
+
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+
+void USBFS_IRQHandler(void) { tud_int_handler(0); }
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+#define USB_NO_VBUS_PIN
+
+// According to GD32VF103 user manual clock tree:
+// Systick clock = AHB clock / 4.
+#define TIMER_TICKS ((SystemCoreClock / 4) / 1000)
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV SOC_DEBUG_UART
+
+#define LED_PIN LED_R
+
+void board_init(void) {
+ /* Disable interrupts during init */
+ __disable_irq();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ SysTick_Config(TIMER_TICKS);
+#endif
+
+ rcu_periph_clock_enable(RCU_GPIOA);
+ rcu_periph_clock_enable(RCU_GPIOB);
+ rcu_periph_clock_enable(RCU_GPIOC);
+ rcu_periph_clock_enable(RCU_GPIOD);
+ rcu_periph_clock_enable(RCU_AF);
+
+#ifdef BUTTON_PIN
+ gpio_init(BUTTON_PORT, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, BUTTON_PIN);
+#endif
+
+#ifdef LED_PIN
+ gd_led_init(LED_PIN);
+#endif
+
+#if defined(UART_DEV)
+ gd_com_init(UART_DEV);
+#endif
+
+ /* USB D+ and D- pins don't need to be configured. */
+ /* Configure VBUS Pin */
+#ifndef USB_NO_VBUS_PIN
+ gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_9);
+#endif
+
+ /* This for ID line debug */
+ // gpio_init(GPIOA, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, GPIO_PIN_10);
+
+ /* Enable USB OTG clock */
+ usb_rcu_config();
+
+ /* Reset USB OTG peripheral */
+ rcu_periph_reset_enable(RCU_USBFSRST);
+ rcu_periph_reset_disable(RCU_USBFSRST);
+
+ /* Configure USBFS IRQ */
+ ECLIC_Register_IRQ(USBFS_IRQn, ECLIC_NON_VECTOR_INTERRUPT,
+ ECLIC_POSTIVE_EDGE_TRIGGER, 3, 0, NULL);
+
+ /* Retrieve otg core registers */
+ usb_gr* otg_core_regs = (usb_gr*)(USBFS_REG_BASE + USB_REG_OFFSET_CORE);
+
+#ifdef USB_NO_VBUS_PIN
+ /* Disable VBUS sense*/
+ otg_core_regs->GCCFG |= GCCFG_VBUSIG | GCCFG_PWRON | GCCFG_VBUSBCEN;
+#else
+ /* Enable VBUS sense via pin PA9 */
+ otg_core_regs->GCCFG |= GCCFG_VBUSIG | GCCFG_PWRON | GCCFG_VBUSBCEN;
+ otg_core_regs->GCCFG &= ~GCCFG_VBUSIG;
+#endif
+
+ /* Enable interrupts globaly */
+ __enable_irq();
+}
+
+void gd32vf103_reset(void) {
+ /* The MTIMER unit of the GD32VF103 doesn't have the MSFRST
+ * register to generate a software reset request.
+ * BUT instead two undocumented registers in the debug peripheral
+ * that allow issueing a software reset.
+ * https://github.com/esmil/gd32vf103inator/blob/master/include/gd32vf103/dbg.h
+ */
+ DBG_KEY = DBG_KEY_UNLOCK;
+ DBG_CMD = DBG_CMD_RESET;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+ state ? gd_led_on(LED_PIN) : gd_led_off(LED_PIN);
+}
+
+uint32_t board_button_read(void) {
+ return BUTTON_STATE_ACTIVE == gpio_input_bit_get(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len) {
+#if defined(UART_DEV)
+ int rxsize = len;
+ while (rxsize--) {
+ *(uint8_t*)buf = usart_read(UART_DEV);
+ buf++;
+ }
+ return len;
+#else
+ (void)buf;
+ (void)len;
+ return 0;
+#endif
+}
+
+int board_uart_write(void const* buf, int len) {
+#if defined(UART_DEV)
+ int txsize = len;
+ while (txsize--) {
+ usart_write(UART_DEV, *(uint8_t const*)buf);
+ buf++;
+ }
+ return len;
+#else
+ (void)buf;
+ (void)len;
+ return 0;
+#endif
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void eclic_mtip_handler(void) {
+ system_ticks++;
+ SysTick_Reload(TIMER_TICKS);
+}
+uint32_t board_millis(void) { return system_ticks; }
+#endif
+
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
+void assert_failed(char* file, uint32_t line) {
+ /* USER CODE BEGIN 6 */
+ /* User can add his own implementation to report the file name and line
+ number,
+ tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line)
+ */
+ /* USER CODE END 6 */
+}
+#endif /* USE_FULL_ASSERT */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.mk b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.mk
new file mode 100644
index 0000000..49bacdf
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/family.mk
@@ -0,0 +1,67 @@
+# https://www.embecosm.com/resources/tool-chain-downloads/#riscv-stable
+#CROSS_COMPILE ?= riscv32-unknown-elf-
+
+# Toolchain from https://nucleisys.com/download.php
+#CROSS_COMPILE ?= riscv-nuclei-elf-
+
+# Toolchain from https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack
+CROSS_COMPILE ?= riscv-none-embed-
+
+# Submodules
+NUCLEI_SDK = hw/mcu/gd/nuclei-sdk
+DEPS_SUBMODULES += $(NUCLEI_SDK)
+
+# Nuclei-SDK paths
+GD32VF103_SDK_SOC = $(NUCLEI_SDK)/SoC/gd32vf103
+GD32VF103_SDK_DRIVER = $(GD32VF103_SDK_SOC)/Common/Source/Drivers
+LIBC_STUBS = $(GD32VF103_SDK_SOC)/Common/Source/Stubs
+STARTUP_ASM = $(GD32VF103_SDK_SOC)/Common/Source/GCC
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+SKIP_NANOLIB = 1
+
+CFLAGS += \
+ -march=rv32imac \
+ -mabi=ilp32 \
+ -mcmodel=medlow \
+ -mstrict-align \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_GD32VF103 \
+ -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(GD32VF103_SDK_DRIVER)/gd32vf103_rcu.c \
+ $(GD32VF103_SDK_DRIVER)/gd32vf103_gpio.c \
+ $(GD32VF103_SDK_DRIVER)/Usb/gd32vf103_usb_hw.c \
+ $(GD32VF103_SDK_DRIVER)/gd32vf103_usart.c \
+ $(LIBC_STUBS)/sbrk.c \
+ $(LIBC_STUBS)/close.c \
+ $(LIBC_STUBS)/isatty.c \
+ $(LIBC_STUBS)/fstat.c \
+ $(LIBC_STUBS)/lseek.c \
+ $(LIBC_STUBS)/read.c
+
+SRC_S += \
+ $(STARTUP_ASM)/startup_gd32vf103.S \
+ $(STARTUP_ASM)/intexc_gd32vf103.S
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(NUCLEI_SDK)/NMSIS/Core/Include \
+ $(TOP)/$(GD32VF103_SDK_SOC)/Common/Include \
+ $(TOP)/$(GD32VF103_SDK_SOC)/Common/Include/Usb
+
+# For freeRTOS port source
+FREERTOS_PORT = RISC-V
+
+# For flash-jlink target
+JLINK_IF = jtag
+
+# flash target ROM bootloader
+flash: $(BUILD)/$(PROJECT).bin
+ dfu-util -R -a 0 --dfuse-address 0x08000000 -D $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/system_gd32vf103.c b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/system_gd32vf103.c
new file mode 100644
index 0000000..29518a5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/gd32vf103/system_gd32vf103.c
@@ -0,0 +1,668 @@
+/*!
+ \file system_gd32vf103.h
+\brief RISC-V Device Peripheral Access Layer Source File for
+ GD32VF103 Device Series
+
+*/
+
+/*
+ Copyright (c) 2020, GigaDevice Semiconductor Inc.
+
+ Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/* This file refers the RISC-V standard, some adjustments are made according to GigaDevice chips */
+#include "board.h"
+
+/* system frequency define */
+#define __IRC8M (IRC8M_VALUE) /* internal 8 MHz RC oscillator frequency */
+#define __HXTAL (HXTAL_VALUE) /* high speed crystal oscillator frequency */
+#define __SYS_OSC_CLK (__IRC8M) /* main oscillator frequency */
+#define __SYSTEM_CLOCK_HXTAL (HXTAL_VALUE)
+
+#if !defined(__SYSTEM_CLOCK)
+#define __SYSTEM_CLOCK 72000000
+#endif
+
+#if __SYSTEM_CLOCK == 48000000
+ #define __SYSTEM_CLOCK_48M_PLL_HXTAL (uint32_t)(48000000)
+ uint32_t SystemCoreClock = __SYSTEM_CLOCK_48M_PLL_HXTAL;
+ static void system_clock_48m_hxtal(void);
+
+#elif __SYSTEM_CLOCK == 72000000
+ #define __SYSTEM_CLOCK_72M_PLL_HXTAL (uint32_t)(72000000)
+ uint32_t SystemCoreClock = __SYSTEM_CLOCK_72M_PLL_HXTAL;
+ static void system_clock_72m_hxtal(void);
+
+#elif __SYSTEM_CLOCK == 96000000
+ #define __SYSTEM_CLOCK_96M_PLL_HXTAL (uint32_t)(96000000)
+ uint32_t SystemCoreClock = __SYSTEM_CLOCK_96M_PLL_HXTAL;
+ static void system_clock_96m_hxtal(void);
+
+#else
+#error No valid system clock configuration set!
+#endif
+
+/* configure the system clock */
+static void system_clock_config(void);
+
+/*!
+ \brief configure the system clock
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_config(void)
+{
+#if defined (__SYSTEM_CLOCK_48M_PLL_HXTAL)
+ system_clock_48m_hxtal();
+#elif defined (__SYSTEM_CLOCK_72M_PLL_HXTAL)
+ system_clock_72m_hxtal();
+#elif defined (__SYSTEM_CLOCK_96M_PLL_HXTAL)
+ system_clock_96m_hxtal();
+#endif /* __SYSTEM_CLOCK_HXTAL */
+}
+
+/*!
+ \brief setup the microcontroller system, initialize the system
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+void SystemInit(void)
+{
+ /* reset the RCC clock configuration to the default reset state */
+ /* enable IRC8M */
+ RCU_CTL |= RCU_CTL_IRC8MEN;
+
+ /* reset SCS, AHBPSC, APB1PSC, APB2PSC, ADCPSC, CKOUT0SEL bits */
+ RCU_CFG0 &= ~(RCU_CFG0_SCS | RCU_CFG0_AHBPSC | RCU_CFG0_APB1PSC | RCU_CFG0_APB2PSC |
+ RCU_CFG0_ADCPSC | RCU_CFG0_ADCPSC_2 | RCU_CFG0_CKOUT0SEL);
+
+ /* reset HXTALEN, CKMEN, PLLEN bits */
+ RCU_CTL &= ~(RCU_CTL_HXTALEN | RCU_CTL_CKMEN | RCU_CTL_PLLEN);
+
+ /* Reset HXTALBPS bit */
+ RCU_CTL &= ~(RCU_CTL_HXTALBPS);
+
+ /* reset PLLSEL, PREDV0_LSB, PLLMF, USBFSPSC bits */
+
+ RCU_CFG0 &= ~(RCU_CFG0_PLLSEL | RCU_CFG0_PREDV0_LSB | RCU_CFG0_PLLMF |
+ RCU_CFG0_USBFSPSC | RCU_CFG0_PLLMF_4);
+ RCU_CFG1 = 0x00000000U;
+
+ /* Reset HXTALEN, CKMEN, PLLEN, PLL1EN and PLL2EN bits */
+ RCU_CTL &= ~(RCU_CTL_PLLEN | RCU_CTL_PLL1EN | RCU_CTL_PLL2EN | RCU_CTL_CKMEN | RCU_CTL_HXTALEN);
+ /* disable all interrupts */
+ RCU_INT = 0x00FF0000U;
+
+ /* Configure the System clock source, PLL Multiplier, AHB/APBx prescalers and Flash settings */
+ system_clock_config();
+}
+
+/*!
+ \brief update the SystemCoreClock with current core clock retrieved from cpu registers
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+void SystemCoreClockUpdate(void)
+{
+ uint32_t scss;
+ uint32_t pllsel, predv0sel, pllmf, ck_src;
+ uint32_t predv0, predv1, pll1mf;
+
+ scss = GET_BITS(RCU_CFG0, 2, 3);
+
+ switch (scss)
+ {
+ /* IRC8M is selected as CK_SYS */
+ case SEL_IRC8M:
+ SystemCoreClock = IRC8M_VALUE;
+ break;
+
+ /* HXTAL is selected as CK_SYS */
+ case SEL_HXTAL:
+ SystemCoreClock = HXTAL_VALUE;
+ break;
+
+ /* PLL is selected as CK_SYS */
+ case SEL_PLL:
+ /* PLL clock source selection, HXTAL or IRC8M/2 */
+ pllsel = (RCU_CFG0 & RCU_CFG0_PLLSEL);
+
+
+ if(RCU_PLLSRC_IRC8M_DIV2 == pllsel){
+ /* PLL clock source is IRC8M/2 */
+ ck_src = IRC8M_VALUE / 2U;
+ }else{
+ /* PLL clock source is HXTAL */
+ ck_src = HXTAL_VALUE;
+
+ predv0sel = (RCU_CFG1 & RCU_CFG1_PREDV0SEL);
+
+ /* source clock use PLL1 */
+ if(RCU_PREDV0SRC_CKPLL1 == predv0sel){
+ predv1 = ((RCU_CFG1 & RCU_CFG1_PREDV1) >> 4) + 1U;
+ pll1mf = ((RCU_CFG1 & RCU_CFG1_PLL1MF) >> 8) + 2U;
+ if(17U == pll1mf){
+ pll1mf = 20U;
+ }
+ ck_src = (ck_src / predv1) * pll1mf;
+ }
+ predv0 = (RCU_CFG1 & RCU_CFG1_PREDV0) + 1U;
+ ck_src /= predv0;
+ }
+
+ /* PLL multiplication factor */
+ pllmf = GET_BITS(RCU_CFG0, 18, 21);
+
+ if((RCU_CFG0 & RCU_CFG0_PLLMF_4)){
+ pllmf |= 0x10U;
+ }
+
+ if(pllmf >= 15U){
+ pllmf += 1U;
+ }else{
+ pllmf += 2U;
+ }
+
+ SystemCoreClock = ck_src * pllmf;
+
+ if(15U == pllmf){
+ /* PLL source clock multiply by 6.5 */
+ SystemCoreClock = ck_src * 6U + ck_src / 2U;
+ }
+
+ break;
+
+ /* IRC8M is selected as CK_SYS */
+ default:
+ SystemCoreClock = IRC8M_VALUE;
+ break;
+ }
+}
+
+#if defined (__SYSTEM_CLOCK_48M_PLL_HXTAL)
+/*!
+ \brief configure the system clock to 48M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_48m_hxtal(void)
+{
+ uint32_t timeout = 0U;
+ uint32_t stab_flag = 0U;
+
+ /* enable HXTAL */
+ RCU_CTL |= RCU_CTL_HXTALEN;
+
+ /* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
+ do{
+ timeout++;
+ stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
+ }while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
+
+ /* if fail */
+ if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
+ while(1){
+ }
+ }
+
+ /* HXTAL is stable */
+ /* AHB = SYSCLK */
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
+ /* APB2 = AHB/1 */
+ RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
+ /* APB1 = AHB/2 */
+ RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
+
+ /* CK_PLL = (CK_PREDIV0) * 12 = 48 MHz */
+ RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
+ RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL12);
+
+ if(HXTAL_VALUE==25000000){
+
+ /* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
+ RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
+ RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
+
+ /* enable PLL1 */
+ RCU_CTL |= RCU_CTL_PLL1EN;
+ /* wait till PLL1 is ready */
+ while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
+ }
+
+ }else if(HXTAL_VALUE==8000000){
+ RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
+ RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
+ }
+
+
+
+ /* enable PLL */
+ RCU_CTL |= RCU_CTL_PLLEN;
+
+ /* wait until PLL is stable */
+ while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
+ }
+
+ /* select PLL as system clock */
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+ RCU_CFG0 |= RCU_CKSYSSRC_PLL;
+
+ /* wait until PLL is selected as system clock */
+ while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
+ }
+}
+
+#elif defined (__SYSTEM_CLOCK_72M_PLL_HXTAL)
+/*!
+ \brief configure the system clock to 72M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_72m_hxtal(void)
+{
+ uint32_t timeout = 0U;
+ uint32_t stab_flag = 0U;
+
+ /* enable HXTAL */
+ RCU_CTL |= RCU_CTL_HXTALEN;
+
+ /* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
+ do{
+ timeout++;
+ stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
+ }while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
+
+ /* if fail */
+ if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
+ while(1){
+ }
+ }
+
+ /* HXTAL is stable */
+ /* AHB = SYSCLK */
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
+ /* APB2 = AHB/1 */
+ RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
+ /* APB1 = AHB/2 */
+ RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
+
+ /* CK_PLL = (CK_PREDIV0) * 18 = 72 MHz */
+ RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
+ RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL18);
+
+
+ if(HXTAL_VALUE==25000000){
+
+ /* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
+ RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
+ RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
+
+ /* enable PLL1 */
+ RCU_CTL |= RCU_CTL_PLL1EN;
+ /* wait till PLL1 is ready */
+ while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
+ }
+
+ }else if(HXTAL_VALUE==8000000){
+ RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
+ RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
+ }
+
+ /* enable PLL */
+ RCU_CTL |= RCU_CTL_PLLEN;
+
+ /* wait until PLL is stable */
+ while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
+ }
+
+ /* select PLL as system clock */
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+ RCU_CFG0 |= RCU_CKSYSSRC_PLL;
+
+ /* wait until PLL is selected as system clock */
+ while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
+ }
+}
+
+#elif defined (__SYSTEM_CLOCK_96M_PLL_HXTAL)
+/*!
+ \brief configure the system clock to 96M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
+ \param[in] none
+ \param[out] none
+ \retval none
+*/
+static void system_clock_96m_hxtal(void)
+{
+ uint32_t timeout = 0U;
+ uint32_t stab_flag = 0U;
+
+ /* enable HXTAL */
+ RCU_CTL |= RCU_CTL_HXTALEN;
+
+ /* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
+ do{
+ timeout++;
+ stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
+ }while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
+
+ /* if fail */
+ if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
+ while(1){
+ }
+ }
+
+ /* HXTAL is stable */
+ /* AHB = SYSCLK */
+ RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
+ /* APB2 = AHB/1 */
+ RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
+ /* APB1 = AHB/2 */
+ RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
+
+ if(HXTAL_VALUE==25000000){
+
+ /* CK_PLL = (CK_PREDIV0) * 24 = 96 MHz */
+ RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
+ RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL24);
+
+ /* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
+ RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
+ RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
+ /* enable PLL1 */
+ RCU_CTL |= RCU_CTL_PLL1EN;
+ /* wait till PLL1 is ready */
+ while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
+ }
+
+ }else if(HXTAL_VALUE==8000000){
+ /* CK_PLL = (CK_PREDIV0) * 24 = 96 MHz */
+ RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
+ RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL24);
+
+ RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
+ RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
+ }
+
+ /* enable PLL */
+ RCU_CTL |= RCU_CTL_PLLEN;
+
+ /* wait until PLL is stable */
+ while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
+ }
+
+ /* select PLL as system clock */
+ RCU_CFG0 &= ~RCU_CFG0_SCS;
+ RCU_CFG0 |= RCU_CKSYSSRC_PLL;
+
+ /* wait until PLL is selected as system clock */
+ while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
+ }
+}
+
+#endif
+
+/**
+ * \defgroup NMSIS_Core_IntExcNMI_Handling Interrupt and Exception and NMI Handling
+ * \brief Functions for interrupt, exception and nmi handle available in system_<device>.c.
+ * \details
+ * Nuclei provide a template for interrupt, exception and NMI handling. Silicon Vendor could adapat according
+ * to their requirement. Silicon vendor could implement interface for different exception code and
+ * replace current implementation.
+ *
+ * @{
+ */
+/** \brief Max exception handler number, don't include the NMI(0xFFF) one */
+#define MAX_SYSTEM_EXCEPTION_NUM 12
+/**
+ * \brief Store the exception handlers for each exception ID
+ * \note
+ * - This SystemExceptionHandlers are used to store all the handlers for all
+ * the exception codes Nuclei N/NX core provided.
+ * - Exception code 0 - 11, totally 12 exceptions are mapped to SystemExceptionHandlers[0:11]
+ * - Exception for NMI is also re-routed to exception handling(exception code 0xFFF) in startup code configuration, the handler itself is mapped to SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM]
+ */
+static unsigned long SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM + 1];
+
+/**
+ * \brief Exception Handler Function Typedef
+ * \note
+ * This typedef is only used internal in this system_gd32vf103.c file.
+ * It is used to do type conversion for registered exception handler before calling it.
+ */
+typedef void (*EXC_HANDLER)(unsigned long mcause, unsigned long sp);
+
+/**
+ * \brief System Default Exception Handler
+ * \details
+ * This function provided a default exception and NMI handling code for all exception ids.
+ * By default, It will just print some information for debug, Vendor can customize it according to its requirements.
+ */
+static void system_default_exception_handler(unsigned long mcause, unsigned long sp)
+{
+ /* TODO: Uncomment this if you have implement printf function */
+ /*printf("MCAUSE: 0x%lx\r\n", mcause);
+ printf("MEPC : 0x%lx\r\n", __RV_CSR_READ(CSR_MEPC));
+ printf("MTVAL : 0x%lx\r\n", __RV_CSR_READ(CSR_MBADADDR));*/
+ while (1);
+}
+
+/**
+ * \brief Initialize all the default core exception handlers
+ * \details
+ * The core exception handler for each exception id will be initialized to \ref system_default_exception_handler.
+ * \note
+ * Called in \ref _init function, used to initialize default exception handlers for all exception IDs
+ */
+static void Exception_Init(void)
+{
+ for (int i = 0; i < MAX_SYSTEM_EXCEPTION_NUM + 1; i++) {
+ SystemExceptionHandlers[i] = (unsigned long)system_default_exception_handler;
+ }
+}
+
+/**
+ * \brief Register an exception handler for exception code EXCn
+ * \details
+ * * For EXCn < \ref MAX_SYSTEM_EXCEPTION_NUM, it will be registered into SystemExceptionHandlers[EXCn-1].
+ * * For EXCn == NMI_EXCn, it will be registered into SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM].
+ * \param EXCn See \ref EXCn_Type
+ * \param exc_handler The exception handler for this exception code EXCn
+ */
+void Exception_Register_EXC(uint32_t EXCn, unsigned long exc_handler)
+{
+ if ((EXCn < MAX_SYSTEM_EXCEPTION_NUM) && (EXCn != 0)) {
+ SystemExceptionHandlers[EXCn] = exc_handler;
+ } else if (EXCn == NMI_EXCn) {
+ SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM] = exc_handler;
+ }
+}
+
+/**
+ * \brief Get current exception handler for exception code EXCn
+ * \details
+ * * For EXCn < \ref MAX_SYSTEM_EXCEPTION_NUM, it will return SystemExceptionHandlers[EXCn-1].
+ * * For EXCn == NMI_EXCn, it will return SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM].
+ * \param EXCn See \ref EXCn_Type
+ * \return Current exception handler for exception code EXCn, if not found, return 0.
+ */
+unsigned long Exception_Get_EXC(uint32_t EXCn)
+{
+ if ((EXCn < MAX_SYSTEM_EXCEPTION_NUM) && (EXCn != 0)) {
+ return SystemExceptionHandlers[EXCn];
+ } else if (EXCn == NMI_EXCn) {
+ return SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM];
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * \brief Common NMI and Exception handler entry
+ * \details
+ * This function provided a command entry for NMI and exception. Silicon Vendor could modify
+ * this template implementation according to requirement.
+ * \remarks
+ * - RISCV provided common entry for all types of exception. This is proposed code template
+ * for exception entry function, Silicon Vendor could modify the implementation.
+ * - For the core_exception_handler template, we provided exception register function \ref Exception_Register_EXC
+ * which can help developer to register your exception handler for specific exception number.
+ */
+uint32_t core_exception_handler(unsigned long mcause, unsigned long sp)
+{
+ uint32_t EXCn = (uint32_t)(mcause & 0X00000fff);
+ EXC_HANDLER exc_handler;
+
+ if ((EXCn < MAX_SYSTEM_EXCEPTION_NUM) && (EXCn > 0)) {
+ exc_handler = (EXC_HANDLER)SystemExceptionHandlers[EXCn];
+ } else if (EXCn == NMI_EXCn) {
+ exc_handler = (EXC_HANDLER)SystemExceptionHandlers[MAX_SYSTEM_EXCEPTION_NUM];
+ } else {
+ exc_handler = (EXC_HANDLER)system_default_exception_handler;
+ }
+ if (exc_handler != NULL) {
+ exc_handler(mcause, sp);
+ }
+ return 0;
+}
+/** @} */ /* End of Doxygen Group NMSIS_Core_ExceptionAndNMI */
+
+/**
+ * \brief initialize eclic config
+ * \details
+ * Eclic need initialize after boot up, Vendor could also change the initialization
+ * configuration.
+ */
+void ECLIC_Init(void)
+{
+ /* TODO: Add your own initialization code here. This function will be called by main */
+ ECLIC_SetMth(0);
+ ECLIC_SetCfgNlbits(__ECLIC_INTCTLBITS);
+}
+
+/**
+ * \brief Initialize a specific IRQ and register the handler
+ * \details
+ * This function set vector mode, trigger mode and polarity, interrupt level and priority,
+ * assign handler for specific IRQn.
+ * \param [in] IRQn NMI interrupt handler address
+ * \param [in] shv \ref ECLIC_NON_VECTOR_INTERRUPT means non-vector mode, and \ref ECLIC_VECTOR_INTERRUPT is vector mode
+ * \param [in] trig_mode see \ref ECLIC_TRIGGER_Type
+ * \param [in] lvl interupt level
+ * \param [in] priority interrupt priority
+ * \param [in] handler interrupt handler, if NULL, handler will not be installed
+ * \return -1 means invalid input parameter. 0 means successful.
+ * \remarks
+ * - This function use to configure specific eclic interrupt and register its interrupt handler and enable its interrupt.
+ * - If the vector table is placed in read-only section(FLASHXIP mode), handler could not be installed
+ */
+int32_t ECLIC_Register_IRQ(IRQn_Type IRQn, uint8_t shv, ECLIC_TRIGGER_Type trig_mode, uint8_t lvl, uint8_t priority, void* handler)
+{
+ if ((IRQn > SOC_INT_MAX) || (shv > ECLIC_VECTOR_INTERRUPT) \
+ || (trig_mode > ECLIC_NEGTIVE_EDGE_TRIGGER)) {
+ return -1;
+ }
+
+ /* set interrupt vector mode */
+ ECLIC_SetShvIRQ(IRQn, shv);
+ /* set interrupt trigger mode and polarity */
+ ECLIC_SetTrigIRQ(IRQn, trig_mode);
+ /* set interrupt level */
+ ECLIC_SetLevelIRQ(IRQn, lvl);
+ /* set interrupt priority */
+ ECLIC_SetPriorityIRQ(IRQn, priority);
+ if (handler != NULL) {
+ /* set interrupt handler entry to vector table */
+ ECLIC_SetVector(IRQn, (rv_csr_t)handler);
+ }
+ /* enable interrupt */
+ ECLIC_EnableIRQ(IRQn);
+ return 0;
+}
+/** @} */ /* End of Doxygen Group NMSIS_Core_ExceptionAndNMI */
+
+/**
+ * \brief early init function before main
+ * \details
+ * This function is executed right before main function.
+ * For RISC-V gnu toolchain, _init function might not be called
+ * by __libc_init_array function, so we defined a new function
+ * to do initialization
+ */
+void _premain_init(void)
+{
+ /* Initialize exception default handlers */
+ Exception_Init();
+ /* ECLIC initialization, mainly MTH and NLBIT */
+ ECLIC_Init();
+}
+
+/**
+ * \brief finish function after main
+ * \param [in] status status code return from main
+ * \details
+ * This function is executed right after main function.
+ * For RISC-V gnu toolchain, _fini function might not be called
+ * by __libc_fini_array function, so we defined a new function
+ * to do initialization
+ */
+void _postmain_fini(int status)
+{
+ /* TODO: Add your own finishing code here, called after main */
+}
+
+/**
+ * \brief _init function called in __libc_init_array()
+ * \details
+ * This `__libc_init_array()` function is called during startup code,
+ * user need to implement this function, otherwise when link it will
+ * error init.c:(.text.__libc_init_array+0x26): undefined reference to `_init'
+ * \note
+ * Please use \ref _premain_init function now
+ */
+void _init(void)
+{
+ /* Don't put any code here, please use _premain_init now */
+}
+
+/**
+ * \brief _fini function called in __libc_fini_array()
+ * \details
+ * This `__libc_fini_array()` function is called when exit main.
+ * user need to implement this function, otherwise when link it will
+ * error fini.c:(.text.__libc_fini_array+0x28): undefined reference to `_fini'
+ * \note
+ * Please use \ref _postmain_fini function now
+ */
+void _fini(void)
+{
+ /* Don't put any code here, please use _postmain_fini now */
+}
+
+/** @} */ /* End of Doxygen Group NMSIS_Core_SystemAndClock */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.h
new file mode 100644
index 0000000..4f21b52
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.h
@@ -0,0 +1,53 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "fsl_device_registers.h"
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (0x1000000U)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_11_GPIOMUX_IO11
+#define LED_PORT GPIO1
+#define LED_PIN 11
+#define LED_STATE_ON 0
+
+// SW8 button
+#define BUTTON_PINMUX IOMUXC_GPIO_SD_05_GPIO2_IO05
+#define BUTTON_PORT GPIO2
+#define BUTTON_PIN 5
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART1
+#define UART_RX_PINMUX IOMUXC_GPIO_09_LPUART1_RXD
+#define UART_TX_PINMUX IOMUXC_GPIO_10_LPUART1_TXD
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.mk
new file mode 100644
index 0000000..17dc01c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DCPU_MIMXRT1011DAE5A -DCFG_EXAMPLE_VIDEO_READONLY
+MCU_VARIANT = MIMXRT1011
+
+# For flash-jlink target
+JLINK_DEVICE = MIMXRT1011DAE5A
+
+# For flash-pyocd target
+PYOCD_TARGET = mimxrt1010
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.c
new file mode 100644
index 0000000..cd50a93
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "evkmimxrt1010_flexspi_nor_config.h"
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t qspiflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ .sflashPadType = kSerialFlash_4Pads,
+ .serialClkFreq = kFlexSpiSerialClk_100MHz,
+ .sflashA1Size = 16u * 1024u * 1024u,
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
+ FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
+ },
+ },
+ .pageSize = 256u,
+ .sectorSize = 4u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = false,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.h
new file mode 100644
index 0000000..4be2760
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1010_evk/evkmimxrt1010_flexspi_nor_config.h
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2019 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __EVKMIMXRT1011_FLEXSPI_NOR_CONFIG__
+#define __EVKMIMXRT1011_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_120MHz = 7,
+ kFlexSpiSerialClk_133MHz = 8,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKMIMXRT1011_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.h
new file mode 100644
index 0000000..932ce7f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.h
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (0x1000000U)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_SD_B1_01_GPIO3_IO21
+#define LED_PORT GPIO3
+#define LED_PIN 21
+#define LED_STATE_ON 0
+
+// SW8 button
+#define BUTTON_PINMUX IOMUXC_GPIO_EMC_09_GPIO2_IO09
+#define BUTTON_PORT GPIO2
+#define BUTTON_PIN 9
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART1
+#define UART_RX_PINMUX IOMUXC_GPIO_AD_B0_07_LPUART1_RX
+#define UART_TX_PINMUX IOMUXC_GPIO_AD_B0_06_LPUART1_TX
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.mk
new file mode 100644
index 0000000..20c697e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DCPU_MIMXRT1015DAF5A -DCFG_EXAMPLE_VIDEO_READONLY
+MCU_VARIANT = MIMXRT1015
+
+# For flash-jlink target
+JLINK_DEVICE = MIMXRT1015DAF5A
+
+# For flash-pyocd target
+PYOCD_TARGET = mimxrt1015
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.c
new file mode 100644
index 0000000..a396fe6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2018-2019 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "evkmimxrt1015_flexspi_nor_config.h"
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t qspiflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ .sflashPadType = kSerialFlash_4Pads,
+ .serialClkFreq = kFlexSpiSerialClk_100MHz,
+ .sflashA1Size = 16u * 1024u * 1024u,
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
+ FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
+ },
+ },
+ .pageSize = 256u,
+ .sectorSize = 4u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = false,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.h
new file mode 100644
index 0000000..94af5a1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1015_evk/evkmimxrt1015_flexspi_nor_config.h
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2018-2019 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __EVKMIMXRT1015_FLEXSPI_NOR_CONFIG__
+#define __EVKMIMXRT1015_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_133MHz = 7,
+ kFlexSpiSerialClk_166MHz = 8,
+ kFlexSpiSerialClk_200MHz = 9,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKMIMXRT1015_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.h
new file mode 100644
index 0000000..56ed585
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.h
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (0x800000U)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_AD_B0_05_GPIO1_IO05
+#define LED_PORT GPIO1
+#define LED_PIN 5
+#define LED_STATE_ON 0
+
+// SW8 button
+#define BUTTON_PINMUX IOMUXC_SNVS_WAKEUP_GPIO5_IO00
+#define BUTTON_PORT GPIO5
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART1
+#define UART_RX_PINMUX IOMUXC_GPIO_AD_B0_07_LPUART1_RX
+#define UART_TX_PINMUX IOMUXC_GPIO_AD_B0_06_LPUART1_TX
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.mk
new file mode 100644
index 0000000..b15da1b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DCPU_MIMXRT1021DAG5A
+MCU_VARIANT = MIMXRT1021
+
+# For flash-jlink target
+JLINK_DEVICE = MIMXRT1021DAG5A
+
+# For flash-pyocd target
+PYOCD_TARGET = mimxrt1020
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.c
new file mode 100644
index 0000000..6bafe19
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "evkmimxrt1020_flexspi_nor_config.h"
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t qspiflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock
+ .sflashPadType = kSerialFlash_4Pads,
+ .serialClkFreq = kFlexSpiSerialClk_100MHz,
+ .sflashA1Size = 8u * 1024u * 1024u,
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
+ FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
+ },
+ },
+ .pageSize = 256u,
+ .sectorSize = 4u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = false,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.h
new file mode 100644
index 0000000..f5e1aca
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1020_evk/evkmimxrt1020_flexspi_nor_config.h
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __EVKMIMXRT1020_FLEXSPI_NOR_CONFIG__
+#define __EVKMIMXRT1020_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_133MHz = 7,
+ kFlexSpiSerialClk_166MHz = 8,
+ kFlexSpiSerialClk_200MHz = 9,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKMIMXRT1020_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.h
new file mode 100644
index 0000000..928fbd7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.h
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (0x4000000U)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_AD_B0_09_GPIO1_IO09
+#define LED_PORT GPIO1
+#define LED_PIN 9
+#define LED_STATE_ON 0
+
+// SW8 button
+#define BUTTON_PINMUX IOMUXC_SNVS_WAKEUP_GPIO5_IO00
+#define BUTTON_PORT GPIO5
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART1
+#define UART_RX_PINMUX IOMUXC_GPIO_AD_B0_13_LPUART1_RX
+#define UART_TX_PINMUX IOMUXC_GPIO_AD_B0_12_LPUART1_TX
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.mk
new file mode 100644
index 0000000..9fd2291
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/board.mk
@@ -0,0 +1,8 @@
+CFLAGS += -DCPU_MIMXRT1052DVL6B
+MCU_VARIANT = MIMXRT1052
+
+# For flash-pyocd target
+PYOCD_TARGET = mimxrt1050
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.c
new file mode 100644
index 0000000..af6eabc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "evkbimxrt1050_flexspi_nor_config.h"
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t hyperflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_ExternalInputFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ .columnAddressWidth = 3u,
+ // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock
+ .controllerMiscOption =
+ (1u << kFlexSpiMiscOffset_DdrModeEnable) | (1u << kFlexSpiMiscOffset_WordAddressableEnable) |
+ (1u << kFlexSpiMiscOffset_SafeConfigFreqEnable) | (1u << kFlexSpiMiscOffset_DiffClkEnable),
+ .sflashPadType = kSerialFlash_8Pads,
+ .serialClkFreq = kFlexSpiSerialClk_133MHz,
+ .sflashA1Size = 64u * 1024u * 1024u,
+ .dataValidTime = {16u, 16u},
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_DDR, FLEXSPI_8PAD, 0xA0, RADDR_DDR, FLEXSPI_8PAD, 0x18),
+ FLEXSPI_LUT_SEQ(CADDR_DDR, FLEXSPI_8PAD, 0x10, DUMMY_DDR, FLEXSPI_8PAD, 0x06),
+ FLEXSPI_LUT_SEQ(READ_DDR, FLEXSPI_8PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0),
+ },
+ },
+ .pageSize = 512u,
+ .sectorSize = 256u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = true,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.h
new file mode 100644
index 0000000..fe40e7e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1050_evkb/evkbimxrt1050_flexspi_nor_config.h
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2016, Freescale Semiconductor, Inc.
+ * Copyright 2016-2017 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __EVKBIMXRT1050_FLEXSPI_NOR_CONFIG__
+#define __EVKBIMXRT1050_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_133MHz = 7,
+ kFlexSpiSerialClk_166MHz = 8,
+ kFlexSpiSerialClk_200MHz = 9,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKBIMXRT1050_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.h
new file mode 100644
index 0000000..7fa37e3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.h
@@ -0,0 +1,51 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (0x800000U)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_AD_B0_09_GPIO1_IO09
+#define LED_PORT GPIO1
+#define LED_PIN 9
+#define LED_STATE_ON 0
+
+// SW8 button
+#define BUTTON_PINMUX IOMUXC_SNVS_WAKEUP_GPIO5_IO00
+#define BUTTON_PORT GPIO5
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART1
+#define UART_RX_PINMUX IOMUXC_GPIO_AD_B0_13_LPUART1_RX
+#define UART_TX_PINMUX IOMUXC_GPIO_AD_B0_12_LPUART1_TX
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.mk
new file mode 100644
index 0000000..b14b2a6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/board.mk
@@ -0,0 +1,14 @@
+CFLAGS += -DCPU_MIMXRT1062DVL6A
+MCU_VARIANT = MIMXRT1062
+
+# For flash-jlink target
+JLINK_DEVICE = MIMXRT1062xxx6A
+
+# For flash-pyocd target
+PYOCD_TARGET = mimxrt1060
+
+BOARD_DEVICE_RHPORT_NUM = 1
+BOARD_HOST_RHPORT_NUM = 0
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.c
new file mode 100644
index 0000000..5df2b7c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "evkmimxrt1060_flexspi_nor_config.h"
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t qspiflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock
+ .sflashPadType = kSerialFlash_4Pads,
+ .serialClkFreq = kFlexSpiSerialClk_100MHz,
+ .sflashA1Size = 8u * 1024u * 1024u,
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
+ FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
+ },
+ },
+ .pageSize = 256u,
+ .sectorSize = 4u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = false,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.h
new file mode 100644
index 0000000..28d7db5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1060_evk/evkmimxrt1060_flexspi_nor_config.h
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __EVKMIMXRT1060_FLEXSPI_NOR_CONFIG__
+#define __EVKMIMXRT1060_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_120MHz = 7,
+ kFlexSpiSerialClk_133MHz = 8,
+ kFlexSpiSerialClk_166MHz = 9,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKMIMXRT1060_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.h
new file mode 100644
index 0000000..5f51e91
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (0x400000U)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_AD_B0_09_GPIO1_IO09
+#define LED_PORT GPIO1
+#define LED_PIN 9
+#define LED_STATE_ON 0
+
+// SW8 button
+#define BUTTON_PINMUX IOMUXC_SNVS_WAKEUP_GPIO5_IO00
+#define BUTTON_PORT GPIO5
+#define BUTTON_PIN 0
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART1
+#define UART_RX_PINMUX IOMUXC_GPIO_AD_B0_13_LPUART1_RX
+#define UART_TX_PINMUX IOMUXC_GPIO_AD_B0_12_LPUART1_TX
+
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.mk
new file mode 100644
index 0000000..2b47971
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/board.mk
@@ -0,0 +1,14 @@
+CFLAGS += -DCPU_MIMXRT1064DVL6A
+MCU_VARIANT = MIMXRT1064
+
+# For flash-jlink target
+JLINK_DEVICE = MIMXRT1064xxx6A
+
+# For flash-pyocd target
+PYOCD_TARGET = mimxrt1064
+
+BOARD_DEVICE_RHPORT_NUM = 1
+BOARD_HOST_RHPORT_NUM = 0
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.c
new file mode 100644
index 0000000..bfb1c2d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "evkmimxrt1064_flexspi_nor_config.h"
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t qspiflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock
+ .sflashPadType = kSerialFlash_4Pads,
+ .serialClkFreq = kFlexSpiSerialClk_100MHz,
+ .sflashA1Size = 8u * 1024u * 1024u,
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
+ FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
+ },
+ },
+ .pageSize = 256u,
+ .sectorSize = 4u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = false,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.h
new file mode 100644
index 0000000..efdfe58
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/mimxrt1064_evk/evkmimxrt1064_flexspi_nor_config.h
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __EVKMIMXRT1064_FLEXSPI_NOR_CONFIG__
+#define __EVKMIMXRT1064_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_120MHz = 7,
+ kFlexSpiSerialClk_133MHz = 8,
+ kFlexSpiSerialClk_166MHz = 9,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKMIMXRT1064_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.h
new file mode 100644
index 0000000..b3cc0a8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+
+// required since iMX RT10xx SDK include this file for board size
+#define BOARD_FLASH_SIZE (2 * 1024 * 1024)
+
+// LED
+#define LED_PINMUX IOMUXC_GPIO_B0_03_GPIO2_IO03 // D13
+#define LED_PORT GPIO2
+#define LED_PIN 3
+#define LED_STATE_ON 0
+
+// no button
+#define BUTTON_PINMUX IOMUXC_GPIO_B0_01_GPIO2_IO01 // D12
+#define BUTTON_PORT GPIO2
+#define BUTTON_PIN 1
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_PORT LPUART6
+#define UART_RX_PINMUX IOMUXC_GPIO_AD_B0_03_LPUART6_RX // D0
+#define UART_TX_PINMUX IOMUXC_GPIO_AD_B0_02_LPUART6_TX // D1
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.mk
new file mode 100644
index 0000000..0ad5ea5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/board.mk
@@ -0,0 +1,10 @@
+CFLAGS += -DCPU_MIMXRT1062DVL6A
+MCU_VARIANT = MIMXRT1062
+
+# For flash-jlink target
+JLINK_DEVICE = MIMXRT1062xxx6A
+
+# flash by using teensy_loader_cli https://github.com/PaulStoffregen/teensy_loader_cli
+# Make sure it is in your PATH
+flash: $(BUILD)/$(PROJECT).hex
+ teensy_loader_cli --mcu=imxrt1062 -v -w $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.c
new file mode 100644
index 0000000..7929906
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h>
+
+/* Component ID definition, used by tools. */
+#ifndef FSL_COMPONENT_ID
+#define FSL_COMPONENT_ID "platform.drivers.xip_board"
+#endif
+
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
+#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
+__attribute__((section(".boot_hdr.conf")))
+#elif defined(__ICCARM__)
+#pragma location = ".boot_hdr.conf"
+#endif
+
+const flexspi_nor_config_t qspiflash_config = {
+ .memConfig =
+ {
+ .tag = FLEXSPI_CFG_BLK_TAG,
+ .version = FLEXSPI_CFG_BLK_VERSION,
+ .readSampleClkSrc = kFlexSPIReadSampleClk_LoopbackFromDqsPad,
+ .csHoldTime = 3u,
+ .csSetupTime = 3u,
+ // Enable DDR mode, Wordaddassable, Safe configuration, Differential clock
+ .sflashPadType = kSerialFlash_4Pads,
+ .serialClkFreq = kFlexSpiSerialClk_100MHz,
+ .sflashA1Size = 2u * 1024u * 1024u,
+ .lookupTable =
+ {
+ // Read LUTs
+ FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEB, RADDR_SDR, FLEXSPI_4PAD, 0x18),
+ FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),
+ },
+ },
+ .pageSize = 256u,
+ .sectorSize = 4u * 1024u,
+ .blockSize = 256u * 1024u,
+ .isUniformBlockSize = false,
+};
+#endif /* XIP_BOOT_HEADER_ENABLE */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h
new file mode 100644
index 0000000..56068ec
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2018 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __TEENSY40_FLEXSPI_NOR_CONFIG__
+#define __TEENSY40_FLEXSPI_NOR_CONFIG__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "fsl_common.h"
+
+/*! @name Driver version */
+/*@{*/
+/*! @brief XIP_BOARD driver version 2.0.0. */
+#define FSL_XIP_BOARD_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
+/*@}*/
+
+/* FLEXSPI memory config block related defintions */
+#define FLEXSPI_CFG_BLK_TAG (0x42464346UL) // ascii "FCFB" Big Endian
+#define FLEXSPI_CFG_BLK_VERSION (0x56010400UL) // V1.4.0
+#define FLEXSPI_CFG_BLK_SIZE (512)
+
+/* FLEXSPI Feature related definitions */
+#define FLEXSPI_FEATURE_HAS_PARALLEL_MODE 1
+
+/* Lookup table related defintions */
+#define CMD_INDEX_READ 0
+#define CMD_INDEX_READSTATUS 1
+#define CMD_INDEX_WRITEENABLE 2
+#define CMD_INDEX_WRITE 4
+
+#define CMD_LUT_SEQ_IDX_READ 0
+#define CMD_LUT_SEQ_IDX_READSTATUS 1
+#define CMD_LUT_SEQ_IDX_WRITEENABLE 3
+#define CMD_LUT_SEQ_IDX_WRITE 9
+
+#define CMD_SDR 0x01
+#define CMD_DDR 0x21
+#define RADDR_SDR 0x02
+#define RADDR_DDR 0x22
+#define CADDR_SDR 0x03
+#define CADDR_DDR 0x23
+#define MODE1_SDR 0x04
+#define MODE1_DDR 0x24
+#define MODE2_SDR 0x05
+#define MODE2_DDR 0x25
+#define MODE4_SDR 0x06
+#define MODE4_DDR 0x26
+#define MODE8_SDR 0x07
+#define MODE8_DDR 0x27
+#define WRITE_SDR 0x08
+#define WRITE_DDR 0x28
+#define READ_SDR 0x09
+#define READ_DDR 0x29
+#define LEARN_SDR 0x0A
+#define LEARN_DDR 0x2A
+#define DATSZ_SDR 0x0B
+#define DATSZ_DDR 0x2B
+#define DUMMY_SDR 0x0C
+#define DUMMY_DDR 0x2C
+#define DUMMY_RWDS_SDR 0x0D
+#define DUMMY_RWDS_DDR 0x2D
+#define JMP_ON_CS 0x1F
+#define STOP 0
+
+#define FLEXSPI_1PAD 0
+#define FLEXSPI_2PAD 1
+#define FLEXSPI_4PAD 2
+#define FLEXSPI_8PAD 3
+
+#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1) \
+ (FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
+ FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))
+
+//!@brief Definitions for FlexSPI Serial Clock Frequency
+typedef enum _FlexSpiSerialClockFreq
+{
+ kFlexSpiSerialClk_30MHz = 1,
+ kFlexSpiSerialClk_50MHz = 2,
+ kFlexSpiSerialClk_60MHz = 3,
+ kFlexSpiSerialClk_75MHz = 4,
+ kFlexSpiSerialClk_80MHz = 5,
+ kFlexSpiSerialClk_100MHz = 6,
+ kFlexSpiSerialClk_120MHz = 7,
+ kFlexSpiSerialClk_133MHz = 8,
+ kFlexSpiSerialClk_166MHz = 9,
+} flexspi_serial_clk_freq_t;
+
+//!@brief FlexSPI clock configuration type
+enum
+{
+ kFlexSpiClk_SDR, //!< Clock configure for SDR mode
+ kFlexSpiClk_DDR, //!< Clock configurat for DDR mode
+};
+
+//!@brief FlexSPI Read Sample Clock Source definition
+typedef enum _FlashReadSampleClkSource
+{
+ kFlexSPIReadSampleClk_LoopbackInternally = 0,
+ kFlexSPIReadSampleClk_LoopbackFromDqsPad = 1,
+ kFlexSPIReadSampleClk_LoopbackFromSckPad = 2,
+ kFlexSPIReadSampleClk_ExternalInputFromDqsPad = 3,
+} flexspi_read_sample_clk_t;
+
+//!@brief Misc feature bit definitions
+enum
+{
+ kFlexSpiMiscOffset_DiffClkEnable = 0, //!< Bit for Differential clock enable
+ kFlexSpiMiscOffset_Ck2Enable = 1, //!< Bit for CK2 enable
+ kFlexSpiMiscOffset_ParallelEnable = 2, //!< Bit for Parallel mode enable
+ kFlexSpiMiscOffset_WordAddressableEnable = 3, //!< Bit for Word Addressable enable
+ kFlexSpiMiscOffset_SafeConfigFreqEnable = 4, //!< Bit for Safe Configuration Frequency enable
+ kFlexSpiMiscOffset_PadSettingOverrideEnable = 5, //!< Bit for Pad setting override enable
+ kFlexSpiMiscOffset_DdrModeEnable = 6, //!< Bit for DDR clock confiuration indication.
+};
+
+//!@brief Flash Type Definition
+enum
+{
+ kFlexSpiDeviceType_SerialNOR = 1, //!< Flash devices are Serial NOR
+ kFlexSpiDeviceType_SerialNAND = 2, //!< Flash devices are Serial NAND
+ kFlexSpiDeviceType_SerialRAM = 3, //!< Flash devices are Serial RAM/HyperFLASH
+ kFlexSpiDeviceType_MCP_NOR_NAND = 0x12, //!< Flash device is MCP device, A1 is Serial NOR, A2 is Serial NAND
+ kFlexSpiDeviceType_MCP_NOR_RAM = 0x13, //!< Flash deivce is MCP device, A1 is Serial NOR, A2 is Serial RAMs
+};
+
+//!@brief Flash Pad Definitions
+enum
+{
+ kSerialFlash_1Pad = 1,
+ kSerialFlash_2Pads = 2,
+ kSerialFlash_4Pads = 4,
+ kSerialFlash_8Pads = 8,
+};
+
+//!@brief FlexSPI LUT Sequence structure
+typedef struct _lut_sequence
+{
+ uint8_t seqNum; //!< Sequence Number, valid number: 1-16
+ uint8_t seqId; //!< Sequence Index, valid number: 0-15
+ uint16_t reserved;
+} flexspi_lut_seq_t;
+
+//!@brief Flash Configuration Command Type
+enum
+{
+ kDeviceConfigCmdType_Generic, //!< Generic command, for example: configure dummy cycles, drive strength, etc
+ kDeviceConfigCmdType_QuadEnable, //!< Quad Enable command
+ kDeviceConfigCmdType_Spi2Xpi, //!< Switch from SPI to DPI/QPI/OPI mode
+ kDeviceConfigCmdType_Xpi2Spi, //!< Switch from DPI/QPI/OPI to SPI mode
+ kDeviceConfigCmdType_Spi2NoCmd, //!< Switch to 0-4-4/0-8-8 mode
+ kDeviceConfigCmdType_Reset, //!< Reset device command
+};
+
+//!@brief FlexSPI Memory Configuration Block
+typedef struct _FlexSPIConfig
+{
+ uint32_t tag; //!< [0x000-0x003] Tag, fixed value 0x42464346UL
+ uint32_t version; //!< [0x004-0x007] Version,[31:24] -'V', [23:16] - Major, [15:8] - Minor, [7:0] - bugfix
+ uint32_t reserved0; //!< [0x008-0x00b] Reserved for future use
+ uint8_t readSampleClkSrc; //!< [0x00c-0x00c] Read Sample Clock Source, valid value: 0/1/3
+ uint8_t csHoldTime; //!< [0x00d-0x00d] CS hold time, default value: 3
+ uint8_t csSetupTime; //!< [0x00e-0x00e] CS setup time, default value: 3
+ uint8_t columnAddressWidth; //!< [0x00f-0x00f] Column Address with, for HyperBus protocol, it is fixed to 3, For
+ //! Serial NAND, need to refer to datasheet
+ uint8_t deviceModeCfgEnable; //!< [0x010-0x010] Device Mode Configure enable flag, 1 - Enable, 0 - Disable
+ uint8_t deviceModeType; //!< [0x011-0x011] Specify the configuration command type:Quad Enable, DPI/QPI/OPI switch,
+ //! Generic configuration, etc.
+ uint16_t waitTimeCfgCommands; //!< [0x012-0x013] Wait time for all configuration commands, unit: 100us, Used for
+ //! DPI/QPI/OPI switch or reset command
+ flexspi_lut_seq_t deviceModeSeq; //!< [0x014-0x017] Device mode sequence info, [7:0] - LUT sequence id, [15:8] - LUt
+ //! sequence number, [31:16] Reserved
+ uint32_t deviceModeArg; //!< [0x018-0x01b] Argument/Parameter for device configuration
+ uint8_t configCmdEnable; //!< [0x01c-0x01c] Configure command Enable Flag, 1 - Enable, 0 - Disable
+ uint8_t configModeType[3]; //!< [0x01d-0x01f] Configure Mode Type, similar as deviceModeTpe
+ flexspi_lut_seq_t
+ configCmdSeqs[3]; //!< [0x020-0x02b] Sequence info for Device Configuration command, similar as deviceModeSeq
+ uint32_t reserved1; //!< [0x02c-0x02f] Reserved for future use
+ uint32_t configCmdArgs[3]; //!< [0x030-0x03b] Arguments/Parameters for device Configuration commands
+ uint32_t reserved2; //!< [0x03c-0x03f] Reserved for future use
+ uint32_t controllerMiscOption; //!< [0x040-0x043] Controller Misc Options, see Misc feature bit definitions for more
+ //! details
+ uint8_t deviceType; //!< [0x044-0x044] Device Type: See Flash Type Definition for more details
+ uint8_t sflashPadType; //!< [0x045-0x045] Serial Flash Pad Type: 1 - Single, 2 - Dual, 4 - Quad, 8 - Octal
+ uint8_t serialClkFreq; //!< [0x046-0x046] Serial Flash Frequencey, device specific definitions, See System Boot
+ //! Chapter for more details
+ uint8_t lutCustomSeqEnable; //!< [0x047-0x047] LUT customization Enable, it is required if the program/erase cannot
+ //! be done using 1 LUT sequence, currently, only applicable to HyperFLASH
+ uint32_t reserved3[2]; //!< [0x048-0x04f] Reserved for future use
+ uint32_t sflashA1Size; //!< [0x050-0x053] Size of Flash connected to A1
+ uint32_t sflashA2Size; //!< [0x054-0x057] Size of Flash connected to A2
+ uint32_t sflashB1Size; //!< [0x058-0x05b] Size of Flash connected to B1
+ uint32_t sflashB2Size; //!< [0x05c-0x05f] Size of Flash connected to B2
+ uint32_t csPadSettingOverride; //!< [0x060-0x063] CS pad setting override value
+ uint32_t sclkPadSettingOverride; //!< [0x064-0x067] SCK pad setting override value
+ uint32_t dataPadSettingOverride; //!< [0x068-0x06b] data pad setting override value
+ uint32_t dqsPadSettingOverride; //!< [0x06c-0x06f] DQS pad setting override value
+ uint32_t timeoutInMs; //!< [0x070-0x073] Timeout threshold for read status command
+ uint32_t commandInterval; //!< [0x074-0x077] CS deselect interval between two commands
+ uint16_t dataValidTime[2]; //!< [0x078-0x07b] CLK edge to data valid time for PORT A and PORT B, in terms of 0.1ns
+ uint16_t busyOffset; //!< [0x07c-0x07d] Busy offset, valid value: 0-31
+ uint16_t busyBitPolarity; //!< [0x07e-0x07f] Busy flag polarity, 0 - busy flag is 1 when flash device is busy, 1 -
+ //! busy flag is 0 when flash device is busy
+ uint32_t lookupTable[64]; //!< [0x080-0x17f] Lookup table holds Flash command sequences
+ flexspi_lut_seq_t lutCustomSeq[12]; //!< [0x180-0x1af] Customizable LUT Sequences
+ uint32_t reserved4[4]; //!< [0x1b0-0x1bf] Reserved for future use
+} flexspi_mem_config_t;
+
+/* */
+#define NOR_CMD_INDEX_READ CMD_INDEX_READ //!< 0
+#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS //!< 1
+#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE //!< 2
+#define NOR_CMD_INDEX_ERASESECTOR 3 //!< 3
+#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE //!< 4
+#define NOR_CMD_INDEX_CHIPERASE 5 //!< 5
+#define NOR_CMD_INDEX_DUMMY 6 //!< 6
+#define NOR_CMD_INDEX_ERASEBLOCK 7 //!< 7
+
+#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ //!< 0 READ LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS \
+ CMD_LUT_SEQ_IDX_READSTATUS //!< 1 Read Status LUT sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI \
+ 2 //!< 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE \
+ CMD_LUT_SEQ_IDX_WRITEENABLE //!< 3 Write Enable sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI \
+ 4 //!< 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5 //!< 5 Erase Sector sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8 //!< 8 Erase Block sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM \
+ CMD_LUT_SEQ_IDX_WRITE //!< 9 Program sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11 //!< 11 Chip Erase sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13 //!< 13 Read SFDP sequence in lookupTable id stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD \
+ 14 //!< 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block
+#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD \
+ 15 //!< 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk
+
+/*
+ * Serial NOR configuration block
+ */
+typedef struct _flexspi_nor_config
+{
+ flexspi_mem_config_t memConfig; //!< Common memory configuration info via FlexSPI
+ uint32_t pageSize; //!< Page size of Serial NOR
+ uint32_t sectorSize; //!< Sector size of Serial NOR
+ uint8_t ipcmdSerialClkFreq; //!< Clock frequency for IP command
+ uint8_t isUniformBlockSize; //!< Sector/Block size is the same
+ uint8_t reserved0[2]; //!< Reserved for future use
+ uint8_t serialNorType; //!< Serial NOR Flash type: 0/1/2/3
+ uint8_t needExitNoCmdMode; //!< Need to exit NoCmd mode before other IP command
+ uint8_t halfClkForNonReadCmd; //!< Half the Serial Clock for non-read command: true/false
+ uint8_t needRestoreNoCmdMode; //!< Need to Restore NoCmd mode after IP commmand execution
+ uint32_t blockSize; //!< Block size
+ uint32_t reserve2[11]; //!< Reserved for future use
+} flexspi_nor_config_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __EVKMIMXRT1060_FLEXSPI_NOR_CONFIG__ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/family.c b/circuitpython/lib/tinyusb/hw/bsp/imxrt/family.c
new file mode 100644
index 0000000..a811a7e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/family.c
@@ -0,0 +1,207 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+#include "fsl_device_registers.h"
+#include "fsl_gpio.h"
+#include "fsl_iomuxc.h"
+#include "fsl_clock.h"
+#include "fsl_lpuart.h"
+
+#include "clock_config.h"
+
+// needed by fsl_flexspi_nor_boot
+const uint8_t dcd_data[] = { 0x00 };
+
+void board_init(void)
+{
+ // Init clock
+ BOARD_BootClockRUN();
+ SystemCoreClockUpdate();
+
+ // Enable IOCON clock
+ CLOCK_EnableClock(kCLOCK_Iomuxc);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+// NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ // LED
+ IOMUXC_SetPinMux( LED_PINMUX, 0U);
+ IOMUXC_SetPinConfig( LED_PINMUX, 0x10B0U);
+
+ gpio_pin_config_t led_config = { kGPIO_DigitalOutput, 0, kGPIO_NoIntmode };
+ GPIO_PinInit(LED_PORT, LED_PIN, &led_config);
+ board_led_write(true);
+
+ // Button
+ IOMUXC_SetPinMux( BUTTON_PINMUX, 0U);
+ IOMUXC_SetPinConfig(BUTTON_PINMUX, 0x01B0A0U);
+ gpio_pin_config_t button_config = { kGPIO_DigitalInput, 0, kGPIO_IntRisingEdge, };
+ GPIO_PinInit(BUTTON_PORT, BUTTON_PIN, &button_config);
+
+ // UART
+ IOMUXC_SetPinMux( UART_TX_PINMUX, 0U);
+ IOMUXC_SetPinMux( UART_RX_PINMUX, 0U);
+ IOMUXC_SetPinConfig( UART_TX_PINMUX, 0x10B0u);
+ IOMUXC_SetPinConfig( UART_RX_PINMUX, 0x10B0u);
+
+ lpuart_config_t uart_config;
+ LPUART_GetDefaultConfig(&uart_config);
+ uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
+
+ uint32_t freq;
+ if (CLOCK_GetMux(kCLOCK_UartMux) == 0) /* PLL3 div6 80M */
+ {
+ freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
+ }
+ else
+ {
+ freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
+ }
+
+ LPUART_Init(UART_PORT, &uart_config, freq);
+
+ //------------- USB0 -------------//
+
+ // Clock
+ CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
+ CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U);
+
+ USBPHY_Type* usb_phy;
+
+ // RT105x RT106x have dual USB controller.
+#ifdef USBPHY1
+ usb_phy = USBPHY1;
+#else
+ usb_phy = USBPHY;
+#endif
+
+ // Enable PHY support for Low speed device + LS via FS Hub
+ usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK;
+
+ // Enable all power for normal operation
+ usb_phy->PWD = 0;
+
+ // TX Timing
+ uint32_t phytx = usb_phy->TX;
+ phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK);
+ phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
+ usb_phy->TX = phytx;
+
+ // RT105x RT106x have dual USB controller.
+#ifdef USBPHY2
+ // USB1
+ CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
+ CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, 480000000U);
+
+ usb_phy = USBPHY2;
+
+ // Enable PHY support for Low speed device + LS via FS Hub
+ usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK;
+
+ // Enable all power for normal operation
+ usb_phy->PWD = 0;
+
+ // TX Timing
+ phytx = usb_phy->TX;
+ phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK);
+ phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
+ usb_phy->TX = phytx;
+#endif
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB_OTG1_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+void USB_OTG2_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
+ tuh_int_handler(1);
+ #endif
+
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ tud_int_handler(1);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ GPIO_PinWrite(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ LPUART_ReadBlocking(UART_PORT, buf, len);
+ return len;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ LPUART_WriteBlocking(UART_PORT, (uint8_t const*)buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/imxrt/family.mk b/circuitpython/lib/tinyusb/hw/bsp/imxrt/family.mk
new file mode 100644
index 0000000..0bf4a0d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/imxrt/family.mk
@@ -0,0 +1,63 @@
+UF2_FAMILY_ID = 0x4fb2d5bd
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += $(SDK_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-d16 \
+ -D__ARMVFP__=0 -D__ARMFPV5__=0\
+ -DXIP_EXTERNAL_FLASH=1 \
+ -DXIP_BOOT_HEADER_ENABLE=1 \
+ -DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX
+
+ifdef BOARD_DEVICE_RHPORT_NUM
+CFLAGS += -DBOARD_DEVICE_RHPORT_NUM=$(BOARD_DEVICE_RHPORT_NUM)
+endif
+ifdef BOARD_HOST_RHPORT_NUM
+CFLAGS += -DBOARD_HOST_RHPORT_NUM=$(BOARD_HOST_RHPORT_NUM)
+endif
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=implicit-fallthrough=
+
+MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
+
+# All source paths should be relative to the top level.
+LD_FILE = $(MCU_DIR)/gcc/$(MCU_VARIANT)xxxxx_flexspi_nor.ld
+
+# TODO for net_lwip_webserver exmaple, but may not needed !!
+LDFLAGS += \
+ -Wl,--defsym,__stack_size__=0x800 \
+
+SRC_C += \
+ src/portable/chipidea/ci_hs/dcd_ci_hs.c \
+ src/portable/chipidea/ci_hs/hcd_ci_hs.c \
+ src/portable/ehci/ehci.c \
+ $(MCU_DIR)/system_$(MCU_VARIANT).c \
+ $(MCU_DIR)/xip/fsl_flexspi_nor_boot.c \
+ $(MCU_DIR)/project_template/clock_config.c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(SDK_DIR)/drivers/common/fsl_common.c \
+ $(SDK_DIR)/drivers/igpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/project_template \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/igpio \
+ $(TOP)/$(SDK_DIR)/drivers/lpuart
+
+SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_VARIANT).S
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM7/r0p1
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/kuiic/K32L2B31xxxxA_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/kuiic/K32L2B31xxxxA_flash.ld
new file mode 100644
index 0000000..5420ffc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/kuiic/K32L2B31xxxxA_flash.ld
@@ -0,0 +1,217 @@
+/*
+** ###################################################################
+** Processors: K32L2B31VFM0A
+** K32L2B31VFT0A
+** K32L2B31VLH0A
+** K32L2B31VMP0A
+**
+** Compiler: GNU C Compiler
+** Reference manual: K32L2B3xRM, Rev.0, July 2019
+** Version: rev. 1.0, 2019-07-30
+** Build: b190930
+**
+** Abstract:
+** Linker file for the GNU C Compiler
+**
+** Copyright 2016 Freescale Semiconductor, Inc.
+** Copyright 2016-2019 NXP
+** All rights reserved.
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+** http: www.nxp.com
+** mail: support@nxp.com
+**
+** ###################################################################
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
+
+/* Specify the memory areas */
+MEMORY
+{
+ m_interrupts (RX) : ORIGIN = 0x00008000, LENGTH = 0x00000200
+ m_flash_config (RX) : ORIGIN = 0x00008400, LENGTH = 0x00000010
+ m_text (RX) : ORIGIN = 0x00008410, LENGTH = 0x00037BF0
+ m_data (RW) : ORIGIN = 0x1FFFE000, LENGTH = 0x00008000
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into internal flash */
+ .interrupts :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } > m_interrupts
+
+ .flash_config :
+ {
+ . = ALIGN(4);
+ KEEP(*(.FlashConfig)) /* Flash Configuration Field (FCF) */
+ . = ALIGN(4);
+ } > m_flash_config
+
+ /* The program code and other data goes into internal flash */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+ KEEP (*(.init))
+ KEEP (*(.fini))
+ . = ALIGN(4);
+ } > m_text
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > m_text
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } > m_text
+
+ .ctors :
+ {
+ __CTOR_LIST__ = .;
+ /* gcc uses crtbegin.o to find the start of
+ the constructors, so we make sure it is
+ first. Because this is a wildcard, it
+ doesn't matter if the user does not
+ actually link against crtbegin.o; the
+ linker won't look for a file to match a
+ wildcard. The wildcard also means that it
+ doesn't matter which directory crtbegin.o
+ is in. */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*crtbegin?.o(.ctors))
+ /* We don't want to include the .ctor section from
+ from the crtend.o file until after the sorted ctors.
+ The .ctor section from the crtend file contains the
+ end of ctors marker and it must be last */
+ KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ __CTOR_END__ = .;
+ } > m_text
+
+ .dtors :
+ {
+ __DTOR_LIST__ = .;
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*crtbegin?.o(.dtors))
+ KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ __DTOR_END__ = .;
+ } > m_text
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } > m_text
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } > m_text
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } > m_text
+
+ __etext = .; /* define a global symbol at end of code */
+ __DATA_ROM = .; /* Symbol is used by startup for data initialization */
+
+ /* reserve MTB memory at the beginning of m_data */
+ .mtb : /* MTB buffer address as defined by the hardware */
+ {
+ . = ALIGN(8);
+ _mtb_start = .;
+ KEEP(*(.mtb_buf)) /* need to KEEP Micro Trace Buffer as not referenced by application */
+ . = ALIGN(8);
+ _mtb_end = .;
+ } > m_data
+
+ .data : AT(__DATA_ROM)
+ {
+ . = ALIGN(4);
+ __DATA_RAM = .;
+ __data_start__ = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ __data_end__ = .; /* define a global symbol at data end */
+ } > m_data
+
+ __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
+ text_end = ORIGIN(m_text) + LENGTH(m_text);
+ ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
+
+ /* Uninitialized data section */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ . = ALIGN(4);
+ __START_BSS = .;
+ __bss_start__ = .;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ __END_BSS = .;
+ } > m_data
+
+ .heap :
+ {
+ . = ALIGN(8);
+ __end__ = .;
+ PROVIDE(end = .);
+ __HeapBase = .;
+ . += HEAP_SIZE;
+ __HeapLimit = .;
+ __heap_limit = .; /* Add for _sbrk */
+ } > m_data
+
+ .stack :
+ {
+ . = ALIGN(8);
+ . += STACK_SIZE;
+ } > m_data
+
+ /* Initializes stack on the end of block */
+ __StackTop = ORIGIN(m_data) + LENGTH(m_data);
+ __StackLimit = __StackTop - STACK_SIZE;
+ PROVIDE(__stack = __StackTop);
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+
+ ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
+}
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/kuiic/board.h b/circuitpython/lib/tinyusb/hw/bsp/kuiic/board.h
new file mode 100644
index 0000000..78ad83a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/kuiic/board.h
@@ -0,0 +1,45 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "fsl_device_registers.h"
+
+// LED
+#define LED_PIN_CLOCK kCLOCK_PortA
+#define LED_GPIO GPIOA
+#define LED_PORT PORTA
+#define LED_PIN 2
+#define LED_STATE_ON 1
+
+// UART
+#define UART_PORT LPUART1
+#define UART_PIN_RX 3u
+#define UART_PIN_TX 0u
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/kuiic/board.mk b/circuitpython/lib/tinyusb/hw/bsp/kuiic/board.mk
new file mode 100644
index 0000000..39e9d9d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/kuiic/board.mk
@@ -0,0 +1,52 @@
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += $(SDK_DIR) tools/uf2
+
+# This board uses TinyUF2 for updates
+UF2_FAMILY_ID = 0x7f83e793
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -DCPU_K32L2B31VLH0A \
+ -DCFG_TUSB_MCU=OPT_MCU_K32L2BXX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter
+
+MCU_DIR = $(SDK_DIR)/devices/K32L2B31A
+
+# All source paths should be relative to the top level.
+LD_FILE = /hw/bsp/$(BOARD)/K32L2B31xxxxA_flash.ld
+
+SRC_C += \
+ src/portable/nxp/khci/dcd_khci.c \
+ $(MCU_DIR)/system_K32L2B31A.c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(SDK_DIR)/drivers/gpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(SDK_DIR)/CMSIS/Include \
+ $(TOP)/$(SDK_DIR)/drivers/smc \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/gpio \
+ $(TOP)/$(SDK_DIR)/drivers/port \
+ $(TOP)/$(SDK_DIR)/drivers/lpuart \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/drivers
+
+SRC_S += $(MCU_DIR)/gcc/startup_K32L2B31A.S
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = MKL25Z128xxx4
+
+# For flash-pyocd target
+PYOCD_TARGET = K32L2B
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/kuiic/kuiic.c b/circuitpython/lib/tinyusb/hw/bsp/kuiic/kuiic.c
new file mode 100644
index 0000000..737ef3f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/kuiic/kuiic.c
@@ -0,0 +1,203 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ * Copyright (c) 2020, Koji Kitayama
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+#include "board.h"
+#include "fsl_smc.h"
+#include "fsl_gpio.h"
+#include "fsl_port.h"
+#include "fsl_clock.h"
+#include "fsl_lpuart.h"
+
+/*******************************************************************************
+ * Definitions
+ ******************************************************************************/
+#define SIM_OSC32KSEL_LPO_CLK 3U /*!< OSC32KSEL select: LPO clock */
+#define SOPT5_LPUART1RXSRC_LPUART_RX 0x00u /*!<@brief LPUART1 Receive Data Source Select: LPUART_RX pin */
+#define SOPT5_LPUART1TXSRC_LPUART_TX 0x00u /*!<@brief LPUART1 Transmit Data Source Select: LPUART_TX pin */
+#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 48000000U /*!< Core clock frequency: 48000000Hz */
+
+/*******************************************************************************
+ * Variables
+ ******************************************************************************/
+/* System clock frequency. */
+extern uint32_t SystemCoreClock;
+
+/*******************************************************************************
+ * Variables for BOARD_BootClockRUN configuration
+ ******************************************************************************/
+const mcglite_config_t mcgliteConfig_BOARD_BootClockRUN = {
+ .outSrc = kMCGLITE_ClkSrcHirc, /* MCGOUTCLK source is HIRC */
+ .irclkEnableMode = kMCGLITE_IrclkEnable, /* MCGIRCLK enabled, MCGIRCLK disabled in STOP mode */
+ .ircs = kMCGLITE_Lirc8M, /* Slow internal reference (LIRC) 8 MHz clock selected */
+ .fcrdiv = kMCGLITE_LircDivBy1, /* Low-frequency Internal Reference Clock Divider: divided by 1 */
+ .lircDiv2 = kMCGLITE_LircDivBy1, /* Second Low-frequency Internal Reference Clock Divider: divided by 1 */
+ .hircEnableInNotHircMode = true, /* HIRC source is enabled */
+};
+const sim_clock_config_t simConfig_BOARD_BootClockRUN = {
+ .er32kSrc = SIM_OSC32KSEL_LPO_CLK, /* OSC32KSEL select: LPO clock */
+ .clkdiv1 = 0x10000U, /* SIM_CLKDIV1 - OUTDIV1: /1, OUTDIV4: /2 */
+};
+
+/*******************************************************************************
+ * Code for BOARD_BootClockRUN configuration
+ ******************************************************************************/
+void BOARD_BootClockRUN(void)
+{
+ /* Set the system clock dividers in SIM to safe value. */
+ CLOCK_SetSimSafeDivs();
+ /* Set MCG to HIRC mode. */
+ CLOCK_SetMcgliteConfig(&mcgliteConfig_BOARD_BootClockRUN);
+ /* Set the clock configuration in SIM module. */
+ CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
+ /* Set SystemCoreClock variable. */
+ SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
+}
+
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void board_init(void)
+{
+ /* Enable port clocks for GPIO pins */
+ CLOCK_EnableClock(kCLOCK_PortA);
+ CLOCK_EnableClock(kCLOCK_PortB);
+ CLOCK_EnableClock(kCLOCK_PortC);
+ CLOCK_EnableClock(kCLOCK_PortD);
+ CLOCK_EnableClock(kCLOCK_PortE);
+
+
+ gpio_pin_config_t led_config = { kGPIO_DigitalOutput, 1 };
+ GPIO_PinInit(GPIOA, 1U, &led_config);
+ PORT_SetPinMux(PORTA, 1U, kPORT_MuxAsGpio);
+ led_config.outputLogic = 0;
+ GPIO_PinInit(GPIOA, 2U, &led_config);
+ PORT_SetPinMux(PORTA, 2U, kPORT_MuxAsGpio);
+
+#ifdef BUTTON_PIN
+ gpio_pin_config_t button_config = { kGPIO_DigitalInput, 0 };
+ GPIO_PinInit(BUTTON_GPIO, BUTTON_PIN, &button_config);
+ const port_pin_config_t BUTTON_CFG = {
+ kPORT_PullUp,
+ kPORT_FastSlewRate,
+ kPORT_PassiveFilterDisable,
+ kPORT_LowDriveStrength,
+ kPORT_MuxAsGpio
+ };
+ PORT_SetPinConfig(BUTTON_PORT, BUTTON_PIN, &BUTTON_CFG);
+#endif
+
+ /* PORTC3 is configured as LPUART0_RX */
+ PORT_SetPinMux(PORTC, 3U, kPORT_MuxAlt3);
+ /* PORTA2 (pin 24) is configured as LPUART0_TX */
+ PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3);
+
+ SIM->SOPT5 = ((SIM->SOPT5 &
+ /* Mask bits to zero which are setting */
+ (~(SIM_SOPT5_LPUART1TXSRC_MASK | SIM_SOPT5_LPUART1RXSRC_MASK)))
+ /* LPUART0 Transmit Data Source Select: LPUART0_TX pin. */
+ | SIM_SOPT5_LPUART1TXSRC(SOPT5_LPUART1TXSRC_LPUART_TX)
+ /* LPUART0 Receive Data Source Select: LPUART_RX pin. */
+ | SIM_SOPT5_LPUART1RXSRC(SOPT5_LPUART1RXSRC_LPUART_RX));
+
+ BOARD_BootClockRUN();
+ SystemCoreClockUpdate();
+ CLOCK_SetLpuart1Clock(1);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ lpuart_config_t uart_config;
+ LPUART_GetDefaultConfig(&uart_config);
+ uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
+ LPUART_Init(UART_PORT, &uart_config, CLOCK_GetFreq(kCLOCK_McgIrc48MClk));
+
+ // USB
+ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ if (state) {
+ LED_GPIO->PDDR |= GPIO_FIT_REG((1UL << LED_PIN));
+ } else {
+ LED_GPIO->PDDR &= GPIO_FIT_REG(~(1UL << LED_PIN));
+ }
+// GPIO_PinWrite(GPIOA, 1, state ? LED_STATE_ON : (1-LED_STATE_ON) );
+// GPIO_PinWrite(GPIOA, 2, state ? (1-LED_STATE_ON) : LED_STATE_ON );
+}
+
+uint32_t board_button_read(void)
+{
+#ifdef BUTTON_PIN
+ return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_GPIO, BUTTON_PIN);
+#else
+ return 0;
+#endif
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ LPUART_ReadBlocking(UART_PORT, buf, len);
+ return len;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ LPUART_WriteBlocking(UART_PORT, (uint8_t const*) buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.h
new file mode 100644
index 0000000..5ed5b75
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.h
@@ -0,0 +1,72 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// XTAL
+#define XTAL_OscRateIn 12000000
+#define XTAL_RTCOscRateIn 32768
+
+// LED
+#define LED_PORT 0
+#define LED_PIN 25
+
+// Wake Switch
+#define BUTTON_PORT 0
+#define BUTTON_PIN 17
+
+#define UART_PORT LPC_USART0
+
+static inline void board_lpc15_pinmux_swm_init(void)
+{
+ // Pinmux
+ const PINMUX_GRP_T pinmuxing[] =
+ {
+ {0, 25, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // PIO0_25-BREAK_CTRL-RED (low enable)
+ {0, 13, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // PIO0_13-ISP_RX
+ {0, 18, (IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // PIO0_18-ISP_TX
+ {1, 11, (IOCON_MODE_PULLDOWN | IOCON_DIGMODE_EN)}, // PIO1_11-ISP_1 (VBUS)
+ };
+
+ // Pin Mux
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+
+ // SWIM
+ Chip_SWM_MovablePortPinAssign(SWM_USB_VBUS_I , 1, 11);
+ Chip_SWM_MovablePortPinAssign(SWM_UART0_RXD_I, 0, 13);
+ Chip_SWM_MovablePortPinAssign(SWM_UART0_TXD_O, 0, 18);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.mk
new file mode 100644
index 0000000..b00fc71
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/board.mk
@@ -0,0 +1,7 @@
+CFLAGS += -DCFG_EXAMPLE_VIDEO_READONLY
+LD_FILE = $(BOARD_PATH)/lpc1549.ld
+
+JLINK_DEVICE = LPC1549
+
+# flash using pyocd
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/lpc1549.ld b/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/lpc1549.ld
new file mode 100644
index 0000000..6dd12ad
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc15/boards/lpcxpresso1549/lpc1549.ld
@@ -0,0 +1,246 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * Copyright (c) 2008-2013 Code Red Technologies Ltd,
+ * Copyright 2015, 2018-2019 NXP
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC1549
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v11.0.0 [Build 2516] [2019-06-05] on Oct 3, 2019 2:55:18 PM
+ */
+
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash256 (rx) : ORIGIN = 0x0, LENGTH = 0x40000 /* 256K bytes (alias Flash) */
+ Ram0_16 (rwx) : ORIGIN = 0x2000000, LENGTH = 0x4000 /* 16K bytes (alias RAM) */
+ Ram1_16 (rwx) : ORIGIN = 0x2004000, LENGTH = 0x4000 /* 16K bytes (alias RAM2) */
+ Ram2_4 (rwx) : ORIGIN = 0x2008000, LENGTH = 0x1000 /* 4K bytes (alias RAM3) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash256 = 0x0 ; /* MFlash256 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash256 = 0x0 + 0x40000 ; /* 256K bytes */
+ __top_Flash = 0x0 + 0x40000 ; /* 256K bytes */
+ __base_Ram0_16 = 0x2000000 ; /* Ram0_16 */
+ __base_RAM = 0x2000000 ; /* RAM */
+ __top_Ram0_16 = 0x2000000 + 0x4000 ; /* 16K bytes */
+ __top_RAM = 0x2000000 + 0x4000 ; /* 16K bytes */
+ __base_Ram1_16 = 0x2004000 ; /* Ram1_16 */
+ __base_RAM2 = 0x2004000 ; /* RAM2 */
+ __top_Ram1_16 = 0x2004000 + 0x4000 ; /* 16K bytes */
+ __top_RAM2 = 0x2004000 + 0x4000 ; /* 16K bytes */
+ __base_Ram2_4 = 0x2008000 ; /* Ram2_4 */
+ __base_RAM3 = 0x2008000 ; /* RAM3 */
+ __top_Ram2_4 = 0x2008000 + 0x1000 ; /* 4K bytes */
+ __top_RAM3 = 0x2008000 + 0x1000 ; /* 4K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash256
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash256
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash256
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash256
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for Ram1_16 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$Ram1_16)
+ *(.data.$RAM2)
+ *(.data.$Ram1_16)
+ *(.data.$RAM2.*)
+ *(.data.$Ram1_16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > Ram1_16 AT>MFlash256
+ /* DATA section for Ram2_4 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$Ram2_4)
+ *(.data.$RAM3)
+ *(.data.$Ram2_4)
+ *(.data.$RAM3.*)
+ *(.data.$Ram2_4.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ } > Ram2_4 AT>MFlash256
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > Ram0_16
+
+ /* Main DATA section (Ram0_16) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > Ram0_16 AT>MFlash256
+
+ /* BSS section for Ram1_16 */
+ .bss_RAM2 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2)
+ *(.bss.$Ram1_16)
+ *(.bss.$RAM2.*)
+ *(.bss.$Ram1_16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > Ram1_16
+
+ /* BSS section for Ram2_4 */
+ .bss_RAM3 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM3 = .) ;
+ *(.bss.$RAM3)
+ *(.bss.$Ram2_4)
+ *(.bss.$RAM3.*)
+ *(.bss.$Ram2_4.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ } > Ram2_4
+
+ /* MAIN BSS SECTION */
+ .bss :
+ {
+ . = ALIGN(4) ;
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > Ram0_16
+
+ /* NOINIT section for Ram1_16 */
+ .noinit_RAM2 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM2)
+ *(.noinit.$Ram1_16)
+ *(.noinit.$RAM2.*)
+ *(.noinit.$Ram1_16.*)
+ . = ALIGN(4) ;
+ } > Ram1_16
+
+ /* NOINIT section for Ram2_4 */
+ .noinit_RAM3 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM3)
+ *(.noinit.$Ram2_4)
+ *(.noinit.$RAM3.*)
+ *(.noinit.$Ram2_4.*)
+ . = ALIGN(4) ;
+ } > Ram2_4
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD):
+ {
+ . = ALIGN(4) ;
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > Ram0_16
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_Ram0_16 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc15/family.c b/circuitpython/lib/tinyusb/hw/bsp/lpc15/family.c
new file mode 100644
index 0000000..7f5984a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc15/family.c
@@ -0,0 +1,130 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = XTAL_OscRateIn;
+const uint32_t RTCOscRateIn = XTAL_RTCOscRateIn;
+
+// Invoked by startup code
+void SystemInit(void)
+{
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SRAM1);
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SRAM2);
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
+ Chip_SYSCTL_PeriphReset(RESET_IOCON);
+
+ board_lpc15_pinmux_swm_init();
+
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+
+ // UART
+ Chip_Clock_SetUARTBaseClockRate(Chip_Clock_GetMainClockRate(), false);
+ Chip_UART_Init(UART_PORT);
+ Chip_UART_ConfigData(UART_PORT, UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1);
+ Chip_UART_SetBaud(UART_PORT, CFG_BOARD_UART_BAUDRATE);
+ Chip_UART_Enable(UART_PORT);
+ Chip_UART_TXEnable(UART_PORT);
+
+ // USB: Setup PLL clock, and power
+ Chip_USB_Init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ return Chip_UART_SendBlocking(UART_PORT, buf, len);
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc15/family.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc15/family.mk
new file mode 100644
index 0000000..c7dd3f8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc15/family.mk
@@ -0,0 +1,39 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -nostdlib \
+ -DCORE_M3 \
+ -D__USE_LPCOPEN \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC15XX \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc15xx/lpc_chip_15xx
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc15xx.c \
+ $(MCU_DIR)/src/chip_15xx.c \
+ $(MCU_DIR)/src/clock_15xx.c \
+ $(MCU_DIR)/src/gpio_15xx.c \
+ $(MCU_DIR)/src/iocon_15xx.c \
+ $(MCU_DIR)/src/swm_15xx.c \
+ $(MCU_DIR)/src/sysctl_15xx.c \
+ $(MCU_DIR)/src/uart_15xx.c \
+ $(MCU_DIR)/src/sysinit_15xx.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h
new file mode 100644
index 0000000..b3a7bc4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.h
@@ -0,0 +1,77 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+// Note: For USB Host demo, install JP4
+// WARNING: don't install JP4 when running as device
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED Red
+#define LED_PORT 3
+#define LED_PIN 7
+
+// ISP Button
+#define BUTTON_PORT 0
+#define BUTTON_PIN 7
+
+#define UART_DEV LPC_USART0
+
+static inline void board_lpc18_pinmux(void)
+{
+ const PINMUX_GRP_T pinmuxing[] =
+ {
+ // LEDs
+ { 0x6, 9 , SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP | SCU_MODE_FUNC0 },
+ { 0x6, 11, SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP | SCU_MODE_FUNC0 },
+
+ // Button
+ { 0x2, 7, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0 },
+
+ // UART
+ { 0x06, 4, SCU_MODE_PULLDOWN | SCU_MODE_FUNC2 },
+ { 0x02, 1, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1 },
+
+ // USB0
+ //{ 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 }, // P6_3 USB0_PWR_EN, USB0 VBus function
+
+ //{ 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
+ //{ 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
+ {0x2, 5, SCU_MODE_INBUFF_EN | SCU_MODE_PULLUP | SCU_MODE_FUNC4 },
+ };
+
+ Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk
new file mode 100644
index 0000000..29b1291
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/board.mk
@@ -0,0 +1,6 @@
+LD_FILE = $(BOARD_PATH)/lpc1837.ld
+
+# For flash-jlink target
+JLINK_DEVICE = LPC18S37
+
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
new file mode 100644
index 0000000..51fd153
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
@@ -0,0 +1,404 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * Copyright (c) 2008-2013 Code Red Technologies Ltd,
+ * Copyright 2015, 2018-2019 NXP
+ * (c) NXP Semiconductors 2013-2021
+ * Generated linker script file for LPC1837
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v11.2.0 [Build 4120] [2020-07-09] on Mar 3, 2021 4:22:49 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlashA512 (rx) : ORIGIN = 0x1a000000, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ MFlashB512 (rx) : ORIGIN = 0x1b000000, LENGTH = 0x80000 /* 512K bytes (alias Flash2) */
+ RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ RamLoc40 (rwx) : ORIGIN = 0x10080000, LENGTH = 0xa000 /* 40K bytes (alias RAM2) */
+ RamAHB32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM3) */
+ RamAHB16 (rwx) : ORIGIN = 0x20008000, LENGTH = 0x4000 /* 16K bytes (alias RAM4) */
+ RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */
+}
+
+/* Define a symbol for the top of each memory region */
+__base_MFlashA512 = 0x1a000000 ; /* MFlashA512 */
+__base_Flash = 0x1a000000 ; /* Flash */
+__top_MFlashA512 = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__top_Flash = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__base_MFlashB512 = 0x1b000000 ; /* MFlashB512 */
+__base_Flash2 = 0x1b000000 ; /* Flash2 */
+__top_MFlashB512 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__top_Flash2 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+__base_RAM = 0x10000000 ; /* RAM */
+__top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+__top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+__base_RamLoc40 = 0x10080000 ; /* RamLoc40 */
+__base_RAM2 = 0x10080000 ; /* RAM2 */
+__top_RamLoc40 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__top_RAM2 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
+__base_RAM3 = 0x20000000 ; /* RAM3 */
+__top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
+__base_RAM4 = 0x20008000 ; /* RAM4 */
+__top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
+__base_RAM5 = 0x2000c000 ; /* RAM5 */
+__top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+__top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ .text_Flash2 : ALIGN(4)
+ {
+ FILL(0xff)
+ *(.text_Flash2) /* for compatibility with previous releases */
+ *(.text_MFlashB512) /* for compatibility with previous releases */
+ *(.text.$Flash2)
+ *(.text.$MFlashB512)
+ *(.text_Flash2.*) /* for compatibility with previous releases */
+ *(.text_MFlashB512.*) /* for compatibility with previous releases */
+ *(.text.$Flash2.*)
+ *(.text.$MFlashB512.*)
+ *(.rodata.$Flash2)
+ *(.rodata.$MFlashB512)
+ *(.rodata.$Flash2.*)
+ *(.rodata.$MFlashB512.*) } > MFlashB512
+
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ LONG(LOADADDR(.data_RAM4));
+ LONG( ADDR(.data_RAM4));
+ LONG( SIZEOF(.data_RAM4));
+ LONG(LOADADDR(.data_RAM5));
+ LONG( ADDR(.data_RAM5));
+ LONG( SIZEOF(.data_RAM5));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ LONG( ADDR(.bss_RAM4));
+ LONG( SIZEOF(.bss_RAM4));
+ LONG( ADDR(.bss_RAM5));
+ LONG( SIZEOF(.bss_RAM5));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlashA512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlashA512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlashA512
+
+ .ARM.exidx : ALIGN(4)
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > MFlashA512
+
+ _etext = .;
+
+ /* DATA section for RamLoc40 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ PROVIDE(__start_data_RamLoc40 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamLoc40)
+ *(.data.$RAM2)
+ *(.data.$RamLoc40)
+ *(.data.$RAM2.*)
+ *(.data.$RamLoc40.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ PROVIDE(__end_data_RamLoc40 = .) ;
+ } > RamLoc40 AT>MFlashA512
+
+ /* DATA section for RamAHB32 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ PROVIDE(__start_data_RamAHB32 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM3)
+ *(.data.$RamAHB32)
+ *(.data.$RAM3.*)
+ *(.data.$RamAHB32.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ PROVIDE(__end_data_RamAHB32 = .) ;
+ } > RamAHB32 AT>MFlashA512
+
+ /* DATA section for RamAHB16 */
+
+ .data_RAM4 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM4 = .) ;
+ PROVIDE(__start_data_RamAHB16 = .) ;
+ *(.ramfunc.$RAM4)
+ *(.ramfunc.$RamAHB16)
+ *(.data.$RAM4)
+ *(.data.$RamAHB16)
+ *(.data.$RAM4.*)
+ *(.data.$RamAHB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM4 = .) ;
+ PROVIDE(__end_data_RamAHB16 = .) ;
+ } > RamAHB16 AT>MFlashA512
+
+ /* DATA section for RamAHB_ETB16 */
+
+ .data_RAM5 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM5 = .) ;
+ PROVIDE(__start_data_RamAHB_ETB16 = .) ;
+ *(.ramfunc.$RAM5)
+ *(.ramfunc.$RamAHB_ETB16)
+ *(.data.$RAM5)
+ *(.data.$RamAHB_ETB16)
+ *(.data.$RAM5.*)
+ *(.data.$RamAHB_ETB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM5 = .) ;
+ PROVIDE(__end_data_RamAHB_ETB16 = .) ;
+ } > RamAHB_ETB16 AT>MFlashA512
+
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED (NOLOAD) : ALIGN(4)
+ {
+ _start_uninit_RESERVED = .;
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc32 AT> RamLoc32
+
+ /* Main DATA section (RamLoc32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ PROVIDE(__start_data_RAM = .) ;
+ PROVIDE(__start_data_RamLoc32 = .) ;
+ *(vtable)
+ *(.ramfunc*)
+ KEEP(*(CodeQuickAccess))
+ KEEP(*(DataQuickAccess))
+ *(RamFunction)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ PROVIDE(__end_data_RAM = .) ;
+ PROVIDE(__end_data_RamLoc32 = .) ;
+ } > RamLoc32 AT>MFlashA512
+
+ /* BSS section for RamLoc40 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ PROVIDE(__start_bss_RamLoc40 = .) ;
+ *(.bss.$RAM2)
+ *(.bss.$RamLoc40)
+ *(.bss.$RAM2.*)
+ *(.bss.$RamLoc40.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ PROVIDE(__end_bss_RamLoc40 = .) ;
+ } > RamLoc40 AT> RamLoc40
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM3 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM3 = .) ;
+ PROVIDE(__start_bss_RamAHB32 = .) ;
+ *(.bss.$RAM3)
+ *(.bss.$RamAHB32)
+ *(.bss.$RAM3.*)
+ *(.bss.$RamAHB32.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ PROVIDE(__end_bss_RamAHB32 = .) ;
+ } > RamAHB32 AT> RamAHB32
+
+ /* BSS section for RamAHB16 */
+ .bss_RAM4 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM4 = .) ;
+ PROVIDE(__start_bss_RamAHB16 = .) ;
+ *(.bss.$RAM4)
+ *(.bss.$RamAHB16)
+ *(.bss.$RAM4.*)
+ *(.bss.$RamAHB16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM4 = .) ;
+ PROVIDE(__end_bss_RamAHB16 = .) ;
+ } > RamAHB16 AT> RamAHB16
+
+ /* BSS section for RamAHB_ETB16 */
+ .bss_RAM5 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM5 = .) ;
+ PROVIDE(__start_bss_RamAHB_ETB16 = .) ;
+ *(.bss.$RAM5)
+ *(.bss.$RamAHB_ETB16)
+ *(.bss.$RAM5.*)
+ *(.bss.$RamAHB_ETB16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM5 = .) ;
+ PROVIDE(__end_bss_RamAHB_ETB16 = .) ;
+ } > RamAHB_ETB16 AT> RamAHB_ETB16
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ PROVIDE(__start_bss_RAM = .) ;
+ PROVIDE(__start_bss_RamLoc32 = .) ;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(__end_bss_RAM = .) ;
+ PROVIDE(__end_bss_RamLoc32 = .) ;
+ PROVIDE(end = .);
+ } > RamLoc32 AT> RamLoc32
+
+ /* NOINIT section for RamLoc40 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM2 = .) ;
+ PROVIDE(__start_noinit_RamLoc40 = .) ;
+ *(.noinit.$RAM2)
+ *(.noinit.$RamLoc40)
+ *(.noinit.$RAM2.*)
+ *(.noinit.$RamLoc40.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM2 = .) ;
+ PROVIDE(__end_noinit_RamLoc40 = .) ;
+ } > RamLoc40 AT> RamLoc40
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM3 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM3 = .) ;
+ PROVIDE(__start_noinit_RamAHB32 = .) ;
+ *(.noinit.$RAM3)
+ *(.noinit.$RamAHB32)
+ *(.noinit.$RAM3.*)
+ *(.noinit.$RamAHB32.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM3 = .) ;
+ PROVIDE(__end_noinit_RamAHB32 = .) ;
+ } > RamAHB32 AT> RamAHB32
+
+ /* NOINIT section for RamAHB16 */
+ .noinit_RAM4 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM4 = .) ;
+ PROVIDE(__start_noinit_RamAHB16 = .) ;
+ *(.noinit.$RAM4)
+ *(.noinit.$RamAHB16)
+ *(.noinit.$RAM4.*)
+ *(.noinit.$RamAHB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM4 = .) ;
+ PROVIDE(__end_noinit_RamAHB16 = .) ;
+ } > RamAHB16 AT> RamAHB16
+
+ /* NOINIT section for RamAHB_ETB16 */
+ .noinit_RAM5 (NOLOAD) : ALIGN(4)
+ {
+ PROVIDE(__start_noinit_RAM5 = .) ;
+ PROVIDE(__start_noinit_RamAHB_ETB16 = .) ;
+ *(.noinit.$RAM5)
+ *(.noinit.$RamAHB_ETB16)
+ *(.noinit.$RAM5.*)
+ *(.noinit.$RamAHB_ETB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_noinit_RAM5 = .) ;
+ PROVIDE(__end_noinit_RamAHB_ETB16 = .) ;
+ } > RamAHB_ETB16 AT> RamAHB_ETB16
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ PROVIDE(__start_noinit_RAM = .) ;
+ PROVIDE(__start_noinit_RamLoc32 = .) ;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ PROVIDE(__end_noinit_RAM = .) ;
+ PROVIDE(__end_noinit_RamLoc32 = .) ;
+ } > RamLoc32 AT> RamLoc32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.h
new file mode 100644
index 0000000..6111da9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.h
@@ -0,0 +1,94 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// PD_10
+#define LED_PORT 6
+#define LED_PIN 24
+
+// P4_0
+#define BUTTON_PORT 2
+#define BUTTON_PIN 0
+
+#define UART_DEV LPC_USART3
+
+static inline void board_lpc18_pinmux(void)
+{
+ const PINMUX_GRP_T pinmuxing[] =
+ {
+ // LEDs
+ { 0xD, 10, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4) },
+ { 0xD, 11, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0xD, 12, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0xD, 13, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0xD, 14, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4 | SCU_MODE_PULLDOWN) },
+ { 0x9, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+ { 0x9, 2, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLDOWN) },
+
+ // Button
+ { 0x4, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP) },
+
+ // UART
+ { 2, 3, SCU_MODE_PULLDOWN | SCU_MODE_FUNC2 },
+ { 2, 4, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 },
+
+ // USB0
+ { 0x6, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC1 }, // P6_3 USB0_PWR_EN, USB0 VBus function
+
+ { 0x9, 5, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2 }, // P9_5 USB1_VBUS_EN, USB1 VBus function
+ { 0x2, 5, SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2 }, // P2_5 USB1_VBUS, MUST CONFIGURE THIS SIGNAL FOR USB1 NORMAL OPERATION
+ };
+
+ Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+
+ /* Pin clock mux values, re-used structure, value in first index is meaningless */
+ const PINMUX_GRP_T pinclockmuxing[] =
+ {
+ { 0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ { 0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
+ };
+
+ /* Clock pins only, group field not used */
+ for (uint32_t i = 0; i < (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
+ {
+ Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
+ }
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.mk
new file mode 100644
index 0000000..0307a21
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/board.mk
@@ -0,0 +1,7 @@
+LD_FILE = $(BOARD_PATH)/lpc1857.ld
+
+# For flash-jlink target
+JLINK_DEVICE = LPC1857
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
new file mode 100644
index 0000000..9a308e3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
@@ -0,0 +1,323 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC1857
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 15, 2019 1:01:52 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlashA512 (rx) : ORIGIN = 0x1a000000, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ MFlashB512 (rx) : ORIGIN = 0x1b000000, LENGTH = 0x80000 /* 512K bytes (alias Flash2) */
+ RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ RamLoc40 (rwx) : ORIGIN = 0x10080000, LENGTH = 0xa000 /* 40K bytes (alias RAM2) */
+ RamAHB32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM3) */
+ RamAHB16 (rwx) : ORIGIN = 0x20008000, LENGTH = 0x4000 /* 16K bytes (alias RAM4) */
+ RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */
+}
+
+/* Define a symbol for the top of each memory region */
+__base_MFlashA512 = 0x1a000000 ; /* MFlashA512 */
+__base_Flash = 0x1a000000 ; /* Flash */
+__top_MFlashA512 = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__top_Flash = 0x1a000000 + 0x80000 ; /* 512K bytes */
+__base_MFlashB512 = 0x1b000000 ; /* MFlashB512 */
+__base_Flash2 = 0x1b000000 ; /* Flash2 */
+__top_MFlashB512 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__top_Flash2 = 0x1b000000 + 0x80000 ; /* 512K bytes */
+__base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+__base_RAM = 0x10000000 ; /* RAM */
+__top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+__top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+__base_RamLoc40 = 0x10080000 ; /* RamLoc40 */
+__base_RAM2 = 0x10080000 ; /* RAM2 */
+__top_RamLoc40 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__top_RAM2 = 0x10080000 + 0xa000 ; /* 40K bytes */
+__base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
+__base_RAM3 = 0x20000000 ; /* RAM3 */
+__top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
+__base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
+__base_RAM4 = 0x20008000 ; /* RAM4 */
+__top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
+__base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
+__base_RAM5 = 0x2000c000 ; /* RAM5 */
+__top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+__top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ .text_Flash2 : ALIGN(4)
+ {
+ FILL(0xff)
+ *(.text_Flash2*) /* for compatibility with previous releases */
+ *(.text_MFlashB512*) /* for compatibility with previous releases */
+ *(.text.$Flash2*)
+ *(.text.$MFlashB512*)
+ *(.rodata.$Flash2*)
+ *(.rodata.$MFlashB512*)
+ } > MFlashB512
+
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ LONG(LOADADDR(.data_RAM4));
+ LONG( ADDR(.data_RAM4));
+ LONG( SIZEOF(.data_RAM4));
+ LONG(LOADADDR(.data_RAM5));
+ LONG( ADDR(.data_RAM5));
+ LONG( SIZEOF(.data_RAM5));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ LONG( ADDR(.bss_RAM4));
+ LONG( SIZEOF(.bss_RAM4));
+ LONG( ADDR(.bss_RAM5));
+ LONG( SIZEOF(.bss_RAM5));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlashA512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlashA512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlashA512
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlashA512
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamLoc40 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamLoc40)
+ *(.data.$RAM2*)
+ *(.data.$RamLoc40*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamLoc40 AT>MFlashA512
+ /* DATA section for RamAHB32 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM3*)
+ *(.data.$RamAHB32*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ } > RamAHB32 AT>MFlashA512
+ /* DATA section for RamAHB16 */
+
+ .data_RAM4 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM4 = .) ;
+ *(.ramfunc.$RAM4)
+ *(.ramfunc.$RamAHB16)
+ *(.data.$RAM4*)
+ *(.data.$RamAHB16*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM4 = .) ;
+ } > RamAHB16 AT>MFlashA512
+ /* DATA section for RamAHB_ETB16 */
+
+ .data_RAM5 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM5 = .) ;
+ *(.ramfunc.$RAM5)
+ *(.ramfunc.$RamAHB_ETB16)
+ *(.data.$RAM5*)
+ *(.data.$RamAHB_ETB16*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM5 = .) ;
+ } > RamAHB_ETB16 AT>MFlashA512
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc32
+
+ /* Main DATA section (RamLoc32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc32 AT>MFlashA512
+
+ /* BSS section for RamLoc40 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$RamLoc40*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamLoc40
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM3 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM3 = .) ;
+ *(.bss.$RAM3*)
+ *(.bss.$RamAHB32*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ } > RamAHB32
+
+ /* BSS section for RamAHB16 */
+ .bss_RAM4 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM4 = .) ;
+ *(.bss.$RAM4*)
+ *(.bss.$RamAHB16*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM4 = .) ;
+ } > RamAHB16
+
+ /* BSS section for RamAHB_ETB16 */
+ .bss_RAM5 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM5 = .) ;
+ *(.bss.$RAM5*)
+ *(.bss.$RamAHB_ETB16*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM5 = .) ;
+ } > RamAHB_ETB16
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc32
+
+ /* NOINIT section for RamLoc40 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$RamLoc40*)
+ . = ALIGN(4) ;
+ } > RamLoc40
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM3 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM3*)
+ *(.noinit.$RamAHB32*)
+ . = ALIGN(4) ;
+ } > RamAHB32
+
+ /* NOINIT section for RamAHB16 */
+ .noinit_RAM4 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM4*)
+ *(.noinit.$RamAHB16*)
+ . = ALIGN(4) ;
+ } > RamAHB16
+
+ /* NOINIT section for RamAHB_ETB16 */
+ .noinit_RAM5 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM5*)
+ *(.noinit.$RamAHB_ETB16*)
+ . = ALIGN(4) ;
+ } > RamAHB_ETB16
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/family.c b/circuitpython/lib/tinyusb/hw/bsp/lpc18/family.c
new file mode 100644
index 0000000..d74ebcd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/family.c
@@ -0,0 +1,159 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+void USB1_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
+ tuh_int_handler(1);
+ #endif
+
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ tud_int_handler(1);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+
+/* System configuration variables used by chip driver */
+const uint32_t OscRateIn = 12000000;
+const uint32_t ExtRateIn = 0;
+
+// Invoked by startup code
+void SystemInit(void)
+{
+#ifdef __USE_LPCOPEN
+ extern void (* const g_pfnVectors[])(void);
+ unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;
+ *pSCB_VTOR = (unsigned int) g_pfnVectors;
+#endif
+
+ board_lpc18_pinmux();
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ //NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO_PORT);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
+
+ //------------- UART -------------//
+ Chip_UART_Init(UART_DEV);
+ Chip_UART_SetBaud(UART_DEV, CFG_BOARD_UART_BAUDRATE);
+ Chip_UART_ConfigData(UART_DEV, UART_LCR_WLEN8 | UART_LCR_SBS_1BIT | UART_LCR_PARITY_DIS);
+ Chip_UART_TXEnable(UART_DEV);
+
+ //------------- USB -------------//
+#if CFG_TUSB_RHPORT0_MODE
+ Chip_USB0_Init();
+#endif
+
+#if CFG_TUSB_RHPORT1_MODE
+ Chip_USB1_Init();
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return Chip_GPIO_GetPinState(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ //return UART_ReceiveByte(BOARD_UART_PORT);
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ uint8_t const* buf8 = (uint8_t const*) buf;
+ for(int i=0; i<len; i++)
+ {
+ while ((Chip_UART_ReadLineStatus(UART_DEV) & UART_LSR_THRE) == 0) {}
+ Chip_UART_SendByte(UART_DEV, buf8[i]);
+ }
+
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc18/family.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc18/family.mk
new file mode 100644
index 0000000..7aa36ab
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc18/family.mk
@@ -0,0 +1,37 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -nostdlib \
+ -DCORE_M3 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC18XX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc18xx/lpc_chip_18xx
+
+SRC_C += \
+ src/portable/chipidea/ci_hs/dcd_ci_hs.c \
+ src/portable/chipidea/ci_hs/hcd_ci_hs.c \
+ src/portable/ehci/ehci.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc18xx.c \
+ $(MCU_DIR)/src/chip_18xx_43xx.c \
+ $(MCU_DIR)/src/clock_18xx_43xx.c \
+ $(MCU_DIR)/src/gpio_18xx_43xx.c \
+ $(MCU_DIR)/src/sysinit_18xx_43xx.c \
+ $(MCU_DIR)/src/uart_18xx_43xx.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)/inc \
+ $(TOP)/$(MCU_DIR)/inc/config_18xx
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.h
new file mode 100644
index 0000000..b1ad425
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.h
@@ -0,0 +1,59 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 0
+#define LED_PIN 29
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 0
+#define BUTTON_PIN 24
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0, 0, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0, 1, IOCON_PIO_DIG_FUNC1_EN
+
+// USB0 VBUS
+#define USB0_VBUS_PINMUX 1, 6, IOCON_PIO_DIG_FUNC7_EN
+
+// XTAL
+//#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk
new file mode 100644
index 0000000..6e33d8c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54114/board.mk
@@ -0,0 +1,13 @@
+MCU_VARIANT = LPC54114
+MCU_CORE = LPC54114_cm4
+
+CFLAGS += -DCPU_LPC54114J256BD64_cm4
+LD_FILE = $(MCU_DIR)/gcc/LPC54114J256_cm4_flash.ld
+
+LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_cm4_hardabi.a
+
+JLINK_DEVICE = LPC54114J256_M4
+PYOCD_TARGET = LPC54114
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.h
new file mode 100644
index 0000000..6702775
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.h
@@ -0,0 +1,59 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 2
+#define LED_PIN 2
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 1
+#define BUTTON_PIN 1
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0, 29, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN
+
+// USB0 VBUS
+#define USB0_VBUS_PINMUX 0, 22, IOCON_PIO_DIG_FUNC7_EN
+
+// XTAL
+//#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
new file mode 100644
index 0000000..925374c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
@@ -0,0 +1,18 @@
+MCU_VARIANT = LPC54628
+MCU_CORE = LPC54628
+
+PORT ?= 0
+
+CFLAGS += -DCPU_LPC54628J512ET180
+CFLAGS += -Wno-error=double-promotion
+
+LD_FILE = $(MCU_DIR)/gcc/LPC54628J512_flash.ld
+
+LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a
+
+JLINK_DEVICE = LPC54628J512
+PYOCD_TARGET = LPC54628
+
+#flash: flash-pyocd
+
+flash: flash-jlink \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc54/family.c b/circuitpython/lib/tinyusb/hw/bsp/lpc54/family.c
new file mode 100644
index 0000000..4f1199c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc54/family.c
@@ -0,0 +1,228 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "fsl_device_registers.h"
+#include "fsl_gpio.h"
+#include "fsl_power.h"
+#include "fsl_iocon.h"
+#include "fsl_usart.h"
+
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+// IOCON pin mux
+#define IOCON_PIO_DIGITAL_EN 0x80u // Enables digital function
+#define IOCON_PIO_FUNC0 0x00u
+#define IOCON_PIO_FUNC1 0x01u // Selects pin function 1
+#define IOCON_PIO_FUNC7 0x07u // Selects pin function 7
+#define IOCON_PIO_INPFILT_OFF 0x0100u // Input filter disabled
+#define IOCON_PIO_INV_DI 0x00u // Input function is not inverted
+#define IOCON_PIO_MODE_INACT 0x00u // No addition pin function
+#define IOCON_PIO_MODE_PULLUP 0x10u
+#define IOCON_PIO_OPENDRAIN_DI 0x00u // Open drain is disabled
+#define IOCON_PIO_SLEW_STANDARD 0x00u // Standard mode, output slew rate control is enabled
+
+// Digital pin function n enabled
+#define IOCON_PIO_DIG_FUNC0_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC0)
+#define IOCON_PIO_DIG_FUNC1_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC1)
+#define IOCON_PIO_DIG_FUNC4_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC4)
+#define IOCON_PIO_DIG_FUNC7_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_INPFILT_OFF | IOCON_PIO_FUNC7)
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB1_IRQHandler(void)
+{
+ tud_int_handler(1);
+}
+
+/****************************************************************
+name: BOARD_BootClockFROHF96M
+outputs:
+- {id: SYSTICK_clock.outFreq, value: 96 MHz}
+- {id: System_clock.outFreq, value: 96 MHz}
+settings:
+- {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
+sources:
+- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
+******************************************************************/
+void BootClockFROHF96M(void)
+{
+ /*!< Set up the clock sources */
+ /*!< Set up FRO */
+ POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
+ CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
+ accidentally being below the voltage for current speed */
+ POWER_SetVoltageForFreq(96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
+ CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
+
+ CLOCK_SetupFROClocking(96000000U); /*!< Set up high frequency FRO output to selected frequency */
+
+ /*!< Set up dividers */
+ CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
+
+ /*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
+
+ /*!< Set SystemCoreClock variable. */
+ SystemCoreClock = 96000000U;
+}
+
+void board_init(void)
+{
+ // Enable IOCON clock
+ CLOCK_EnableClock(kCLOCK_Iocon);
+
+ // Init 96 MHz clock
+ BootClockFROHF96M();
+
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ // Init all GPIO ports 54114 only has 2 ports.
+ GPIO_PortInit(GPIO, LED_PORT);
+ GPIO_PortInit(GPIO, BUTTON_PORT);
+
+ // LED
+ IOCON_PinMuxSet(IOCON, LED_PORT, LED_PIN, IOCON_PIO_DIG_FUNC0_EN);
+ gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 0};
+ GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
+
+ board_led_write(0);
+
+ // Button
+ IOCON_PinMuxSet(IOCON, BUTTON_PORT, BUTTON_PIN, IOCON_PIO_DIG_FUNC0_EN | IOCON_PIO_MODE_PULLUP);
+ gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
+ GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
+
+#ifdef UART_DEV
+ // UART
+ IOCON_PinMuxSet(IOCON, UART_RX_PINMUX);
+ IOCON_PinMuxSet(IOCON, UART_TX_PINMUX);
+
+ // Enable UART when debug log is on
+ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);
+ usart_config_t uart_config;
+ USART_GetDefaultConfig(&uart_config);
+ uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
+ USART_Init(UART_DEV, &uart_config, 12000000);
+#endif
+
+ // USB
+ IOCON_PinMuxSet(IOCON, USB0_VBUS_PINMUX);
+
+#if defined(FSL_FEATURE_SOC_USBHSD_COUNT) && FSL_FEATURE_SOC_USBHSD_COUNT
+ // LPC546xx and LPC540xx has OTG 1 FS + 1 HS rhports
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ // Port0 is Full Speed
+ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*< Turn on USB Phy */
+ CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
+ CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
+
+ /*According to reference mannual, device mode setting has to be set by access usb host register */
+ CLOCK_EnableClock(kCLOCK_Usbhsl0); /* enable usb0 host clock */
+ USBFSH->PORTMODE |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
+ CLOCK_DisableClock(kCLOCK_Usbhsl0); /* disable usb0 host clock */
+
+ CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbSrcFro, CLOCK_GetFroHfFreq());
+ #endif
+
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ // Port1 is High Speed
+ POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY);
+
+ /*According to reference mannual, device mode setting has to be set by access usb host register */
+ CLOCK_EnableClock(kCLOCK_Usbh1); /* enable usb1 host clock */
+ USBHSH->PORTMODE |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
+ CLOCK_DisableClock(kCLOCK_Usbh1); /* enable usb1 host clock */
+
+ CLOCK_EnableUsbhs0DeviceClock(kCLOCK_UsbSrcUsbPll, 0U);
+ #endif
+
+#else
+ // LPC5411x series only has full speed device
+
+ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); // Turn on USB Phy
+ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return BUTTON_STATE_ACTIVE == GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ USART_WriteBlocking(UART_DEV, (uint8_t const *) buf, len);
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc54/family.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc54/family.mk
new file mode 100644
index 0000000..600df6f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc54/family.mk
@@ -0,0 +1,54 @@
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += $(SDK_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC54XXX \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+
+ifeq ($(PORT), 1)
+ $(info "PORT1 High Speed")
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+
+ # LPC55 Highspeed Port1 can only write to USB_SRAM region
+ CFLAGS += -DCFG_TUSB_MEM_SECTION='__attribute__((section("m_usb_global")))'
+else
+ $(info "PORT0 Full Speed")
+endif
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter
+
+MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/system_$(MCU_CORE).c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(MCU_DIR)/drivers/fsl_power.c \
+ $(MCU_DIR)/drivers/fsl_reset.c \
+ $(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
+ $(SDK_DIR)/drivers/flexcomm/fsl_usart.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/flexcomm \
+ $(TOP)/$(SDK_DIR)/drivers/lpc_iocon \
+ $(TOP)/$(SDK_DIR)/drivers/lpc_gpio
+
+SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_CORE).S
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/LPC55S69_cm33_core0_uf2.ld b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/LPC55S69_cm33_core0_uf2.ld
new file mode 100644
index 0000000..6b5d852
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/LPC55S69_cm33_core0_uf2.ld
@@ -0,0 +1,234 @@
+/*
+** ###################################################################
+** Processors: LPC55S69JBD100_cm33_core0
+** LPC55S69JBD64_cm33_core0
+** LPC55S69JEV98_cm33_core0
+**
+** Compiler: GNU C Compiler
+** Reference manual: LPC55S6x/LPC55S2x/LPC552x User manual(UM11126) Rev.1.3 16 May 2019
+** Version: rev. 1.1, 2019-05-16
+** Build: b191008
+**
+** Abstract:
+** Linker file for the GNU C Compiler
+**
+** Copyright 2016 Freescale Semiconductor, Inc.
+** Copyright 2016-2019 NXP
+** All rights reserved.
+**
+** SPDX-License-Identifier: BSD-3-Clause
+**
+** http: www.nxp.com
+** mail: support@nxp.com
+**
+** ###################################################################
+*/
+
+
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0800;
+RPMSG_SHMEM_SIZE = DEFINED(__use_shmem__) ? 0x1800 : 0;
+
+/* Specify the memory areas */
+MEMORY
+{
+ m_interrupts (RX) : ORIGIN = 0x00010000, LENGTH = 0x00000200
+ m_text (RX) : ORIGIN = 0x00010200, LENGTH = 0x0007FE00
+ m_core1_image (RX) : ORIGIN = 0x00090000, LENGTH = 0x00008000
+ m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00033000 - RPMSG_SHMEM_SIZE
+ rpmsg_sh_mem (RW) : ORIGIN = 0x20033000 - RPMSG_SHMEM_SIZE, LENGTH = RPMSG_SHMEM_SIZE
+ m_usb_sram (RW) : ORIGIN = 0x40100000, LENGTH = 0x00004000
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* section for storing the secondary core image */
+ .m0code :
+ {
+ . = ALIGN(4) ;
+ KEEP (*(.m0code))
+ *(.m0code*)
+ . = ALIGN(4) ;
+ } > m_core1_image
+
+ /* NOINIT section for rpmsg_sh_mem */
+ .noinit_rpmsg_sh_mem (NOLOAD) : ALIGN(4)
+ {
+ __RPMSG_SH_MEM_START__ = .;
+ *(.noinit.$rpmsg_sh_mem*)
+ . = ALIGN(4) ;
+ __RPMSG_SH_MEM_END__ = .;
+ } > rpmsg_sh_mem
+
+ /* The startup code goes first into internal flash */
+ .interrupts :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } > m_interrupts
+
+ /* The program code and other data goes into internal flash */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+ KEEP (*(.init))
+ KEEP (*(.fini))
+ . = ALIGN(4);
+ } > m_text
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > m_text
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } > m_text
+
+ .ctors :
+ {
+ __CTOR_LIST__ = .;
+ /* gcc uses crtbegin.o to find the start of
+ the constructors, so we make sure it is
+ first. Because this is a wildcard, it
+ doesn't matter if the user does not
+ actually link against crtbegin.o; the
+ linker won't look for a file to match a
+ wildcard. The wildcard also means that it
+ doesn't matter which directory crtbegin.o
+ is in. */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*crtbegin?.o(.ctors))
+ /* We don't want to include the .ctor section from
+ from the crtend.o file until after the sorted ctors.
+ The .ctor section from the crtend file contains the
+ end of ctors marker and it must be last */
+ KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ __CTOR_END__ = .;
+ } > m_text
+
+ .dtors :
+ {
+ __DTOR_LIST__ = .;
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*crtbegin?.o(.dtors))
+ KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ __DTOR_END__ = .;
+ } > m_text
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } > m_text
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } > m_text
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } > m_text
+
+ __etext = .; /* define a global symbol at end of code */
+ __DATA_ROM = .; /* Symbol is used by startup for data initialization */
+
+ .data : AT(__DATA_ROM)
+ {
+ . = ALIGN(4);
+ __DATA_RAM = .;
+ __data_start__ = .; /* create a global symbol at data start */
+ *(.ramfunc*) /* for functions in ram */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ __data_end__ = .; /* define a global symbol at data end */
+ } > m_data
+
+ __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
+ text_end = ORIGIN(m_text) + LENGTH(m_text);
+ ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
+
+ /* Uninitialized data section */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ . = ALIGN(4);
+ __START_BSS = .;
+ __bss_start__ = .;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ __END_BSS = .;
+ } > m_data
+
+ .heap :
+ {
+ . = ALIGN(8);
+ __end__ = .;
+ PROVIDE(end = .);
+ __HeapBase = .;
+ . += HEAP_SIZE;
+ __HeapLimit = .;
+ __heap_limit = .; /* Add for _sbrk */
+ } > m_data
+
+ .stack :
+ {
+ . = ALIGN(8);
+ . += STACK_SIZE;
+ } > m_data
+
+ m_usb_bdt (NOLOAD) :
+ {
+ . = ALIGN(512);
+ *(m_usb_bdt)
+ } > m_usb_sram
+
+ m_usb_global (NOLOAD) :
+ {
+ *(m_usb_global)
+ } > m_usb_sram
+
+ /* Initializes stack on the end of block */
+ __StackTop = ORIGIN(m_data) + LENGTH(m_data);
+ __StackLimit = __StackTop - STACK_SIZE;
+ PROVIDE(__stack = __StackTop);
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+
+ ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
+}
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.h
new file mode 100644
index 0000000..975e74e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.h
@@ -0,0 +1,63 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 0
+#define LED_PIN 1
+#define LED_STATE_ON 1
+
+// WAKE button
+#define BUTTON_PORT 0
+#define BUTTON_PIN 5
+#define BUTTON_STATE_ACTIVE 0
+
+// Number of neopixels
+#define NEOPIXEL_NUMBER 2
+#define NEOPIXEL_PORT 0
+#define NEOPIXEL_PIN 27
+#define NEOPIXEL_CH 6
+#define NEOPIXEL_TYPE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0U, 29U, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0U, 30U, IOCON_PIO_DIG_FUNC1_EN
+
+// XTAL
+#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.mk
new file mode 100644
index 0000000..d28700c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/double_m33_express/board.mk
@@ -0,0 +1,12 @@
+MCU_VARIANT = LPC55S69
+MCU_CORE = LPC55S69_cm33_core0
+PORT ?= 1
+
+CFLAGS += -DCPU_LPC55S69JBD100_cm33_core0
+LD_FILE = $(BOARD_PATH)/LPC55S69_cm33_core0_uf2.ld
+
+JLINK_DEVICE = LPC55S69
+PYOCD_TARGET = LPC55S69
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h
new file mode 100644
index 0000000..f85701b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 1
+#define LED_PIN 6
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 1
+#define BUTTON_PIN 18
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0, 29, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN
+
+// XTAL
+#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk
new file mode 100644
index 0000000..ec0828e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s28/board.mk
@@ -0,0 +1,11 @@
+MCU_VARIANT = LPC55S28
+MCU_CORE = LPC55S28
+PORT ?= 1
+
+CFLAGS += -DCPU_LPC55S28JBD100
+
+JLINK_DEVICE = LPC55S28
+PYOCD_TARGET = LPC55S28
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h
new file mode 100644
index 0000000..f85701b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 1
+#define LED_PIN 6
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 1
+#define BUTTON_PIN 18
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0, 29, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN
+
+// XTAL
+#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk
new file mode 100644
index 0000000..73edc88
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/lpcxpresso55s69/board.mk
@@ -0,0 +1,11 @@
+MCU_VARIANT = LPC55S69
+MCU_CORE = LPC55S69_cm33_core0
+PORT ?= 1
+
+CFLAGS += -DCPU_LPC55S69JBD100_cm33_core0
+
+JLINK_DEVICE = LPC55S69
+PYOCD_TARGET = LPC55S69
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.h b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.h
new file mode 100644
index 0000000..5e17cf9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT 0
+#define LED_PIN 5
+#define LED_STATE_ON 0
+
+// WAKE button (Dummy, use unused pin
+#define BUTTON_PORT 0
+#define BUTTON_PIN 30
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART0
+#define UART_RX_PINMUX 0, 24, IOCON_PIO_DIG_FUNC1_EN
+#define UART_TX_PINMUX 0, 25, IOCON_PIO_DIG_FUNC1_EN
+
+// XTAL
+#define XTAL0_CLK_HZ (16 * 1000 * 1000U)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.mk
new file mode 100644
index 0000000..ceb1d0e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/boards/mcu_link/board.mk
@@ -0,0 +1,11 @@
+MCU_VARIANT = LPC55S69
+MCU_CORE = LPC55S69_cm33_core0
+PORT ?= 1
+
+CFLAGS += -DCPU_LPC55S69JBD64_cm33_core0
+
+JLINK_DEVICE = LPC55S69
+PYOCD_TARGET = LPC55S69
+
+# flash using pyocd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/family.c b/circuitpython/lib/tinyusb/hw/bsp/lpc55/family.c
new file mode 100644
index 0000000..f037a9f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/family.c
@@ -0,0 +1,283 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+#include "fsl_device_registers.h"
+#include "fsl_gpio.h"
+#include "fsl_power.h"
+#include "fsl_iocon.h"
+#include "fsl_usart.h"
+#include "fsl_sctimer.h"
+#include "sct_neopixel.h"
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+// IOCON pin mux
+#define IOCON_PIO_DIGITAL_EN 0x0100u // Enables digital function
+#define IOCON_PIO_FUNC0 0x00u // Selects pin function 0
+#define IOCON_PIO_FUNC1 0x01u // Selects pin function 1
+#define IOCON_PIO_FUNC4 0x04u // Selects pin function 4
+#define IOCON_PIO_FUNC7 0x07u // Selects pin function 7
+#define IOCON_PIO_INV_DI 0x00u // Input function is not inverted
+#define IOCON_PIO_MODE_INACT 0x00u // No addition pin function
+#define IOCON_PIO_OPENDRAIN_DI 0x00u // Open drain is disabled
+#define IOCON_PIO_SLEW_STANDARD 0x00u // Standard mode, output slew rate control is enabled
+
+#define IOCON_PIO_DIG_FUNC0_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC0) // Digital pin function 0 enabled
+#define IOCON_PIO_DIG_FUNC1_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC1) // Digital pin function 1 enabled
+#define IOCON_PIO_DIG_FUNC4_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC4) // Digital pin function 2 enabled
+#define IOCON_PIO_DIG_FUNC7_EN (IOCON_PIO_DIGITAL_EN | IOCON_PIO_FUNC7) // Digital pin function 2 enabled
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB1_IRQHandler(void)
+{
+ tud_int_handler(1);
+}
+
+/****************************************************************
+name: BOARD_BootClockFROHF96M
+outputs:
+- {id: SYSTICK_clock.outFreq, value: 96 MHz}
+- {id: System_clock.outFreq, value: 96 MHz}
+settings:
+- {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
+sources:
+- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
+******************************************************************/
+void BootClockFROHF96M(void)
+{
+ /*!< Set up the clock sources */
+ /*!< Set up FRO */
+ POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
+ CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
+ CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
+ accidentally being below the voltage for current speed */
+
+ CLOCK_SetupFROClocking(96000000U); /*!< Set up high frequency FRO output to selected frequency */
+
+ POWER_SetVoltageForFreq(96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
+ CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
+
+ /*!< Set up dividers */
+ CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
+
+ /*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
+
+ /*!< Set SystemCoreClock variable. */
+ SystemCoreClock = 96000000U;
+}
+
+void board_init(void)
+{
+ // Enable IOCON clock
+ CLOCK_EnableClock(kCLOCK_Iocon);
+
+ // Init 96 MHz clock
+ BootClockFROHF96M();
+
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ // Init all GPIO ports
+ GPIO_PortInit(GPIO, 0);
+ GPIO_PortInit(GPIO, 1);
+
+ // LED
+ IOCON_PinMuxSet(IOCON, LED_PORT, LED_PIN, IOCON_PIO_DIG_FUNC0_EN);
+ gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 1};
+ GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
+
+ board_led_write(0);
+
+#ifdef NEOPIXEL_PIN
+ // Neopixel
+ static uint32_t pixelData[NEOPIXEL_NUMBER];
+ IOCON_PinMuxSet(IOCON, NEOPIXEL_PORT, NEOPIXEL_PIN, IOCON_PIO_DIG_FUNC4_EN);
+
+ sctpix_init(NEOPIXEL_TYPE);
+ sctpix_addCh(NEOPIXEL_CH, pixelData, NEOPIXEL_NUMBER);
+ sctpix_setPixel(NEOPIXEL_CH, 0, 0x100010);
+ sctpix_setPixel(NEOPIXEL_CH, 1, 0x100010);
+ sctpix_show();
+#endif
+
+ // Button
+ IOCON_PinMuxSet(IOCON, BUTTON_PORT, BUTTON_PIN, IOCON_PIO_DIG_FUNC0_EN);
+ gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
+ GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
+
+#ifdef UART_DEV
+ // UART
+ IOCON_PinMuxSet(IOCON, UART_RX_PINMUX);
+ IOCON_PinMuxSet(IOCON, UART_TX_PINMUX);
+
+ // Enable UART when debug log is on
+ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);
+ usart_config_t uart_config;
+ USART_GetDefaultConfig(&uart_config);
+ uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
+ USART_Init(UART_DEV, &uart_config, 12000000);
+#endif
+
+ // USB VBUS
+ /* PORT0 PIN22 configured as USB0_VBUS */
+ IOCON_PinMuxSet(IOCON, 0U, 22U, IOCON_PIO_DIG_FUNC7_EN);
+
+#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ // Port0 is Full Speed
+
+ /* Turn on USB0 Phy */
+ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY);
+
+ /* reset the IP to make sure it's in reset state. */
+ RESET_PeripheralReset(kUSB0D_RST_SHIFT_RSTn);
+ RESET_PeripheralReset(kUSB0HSL_RST_SHIFT_RSTn);
+ RESET_PeripheralReset(kUSB0HMR_RST_SHIFT_RSTn);
+
+ // Enable USB Clock Adjustments to trim the FRO for the full speed controller
+ ANACTRL->FRO192M_CTRL |= ANACTRL_FRO192M_CTRL_USBCLKADJ_MASK;
+ CLOCK_SetClkDiv(kCLOCK_DivUsb0Clk, 1, false);
+ CLOCK_AttachClk(kFRO_HF_to_USB0_CLK);
+
+ /*According to reference mannual, device mode setting has to be set by access usb host register */
+ CLOCK_EnableClock(kCLOCK_Usbhsl0); // enable usb0 host clock
+ USBFSH->PORTMODE |= USBFSH_PORTMODE_DEV_ENABLE_MASK;
+ CLOCK_DisableClock(kCLOCK_Usbhsl0); // disable usb0 host clock
+
+ /* enable USB Device clock */
+ CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf));
+#endif
+
+#if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ // Port1 is High Speed
+
+ /* Turn on USB1 Phy */
+ POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY);
+
+ /* reset the IP to make sure it's in reset state. */
+ RESET_PeripheralReset(kUSB1H_RST_SHIFT_RSTn);
+ RESET_PeripheralReset(kUSB1D_RST_SHIFT_RSTn);
+ RESET_PeripheralReset(kUSB1_RST_SHIFT_RSTn);
+ RESET_PeripheralReset(kUSB1RAM_RST_SHIFT_RSTn);
+
+ /* According to reference mannual, device mode setting has to be set by access usb host register */
+ CLOCK_EnableClock(kCLOCK_Usbh1); // enable usb0 host clock
+
+ USBHSH->PORTMODE = USBHSH_PORTMODE_SW_PDCOM_MASK; // Put PHY powerdown under software control
+ USBHSH->PORTMODE |= USBHSH_PORTMODE_DEV_ENABLE_MASK;
+
+ CLOCK_DisableClock(kCLOCK_Usbh1); // disable usb0 host clock
+
+ /* enable USB Device clock */
+ CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_UsbPhySrcExt, XTAL0_CLK_HZ);
+ CLOCK_EnableUsbhs0DeviceClock(kCLOCK_UsbSrcUnused, 0U);
+ CLOCK_EnableClock(kCLOCK_UsbRam1);
+
+ // Enable PHY support for Low speed device + LS via FS Hub
+ USBPHY->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK;
+
+ // Enable all power for normal operation
+ USBPHY->PWD = 0;
+
+ USBPHY->CTRL_SET = USBPHY_CTRL_SET_ENAUTOCLR_CLKGATE_MASK;
+ USBPHY->CTRL_SET = USBPHY_CTRL_SET_ENAUTOCLR_PHY_PWD_MASK;
+
+ // TX Timing
+// uint32_t phytx = USBPHY->TX;
+// phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK);
+// phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
+// USBPHY->TX = phytx;
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+
+#ifdef NEOPIXEL_PIN
+ if (state) {
+ sctpix_setPixel(NEOPIXEL_CH, 0, 0x100000);
+ sctpix_setPixel(NEOPIXEL_CH, 1, 0x101010);
+ } else {
+ sctpix_setPixel(NEOPIXEL_CH, 0, 0x001000);
+ sctpix_setPixel(NEOPIXEL_CH, 1, 0x000010);
+ }
+ sctpix_show();
+#endif
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return BUTTON_STATE_ACTIVE == GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ USART_WriteBlocking(UART_DEV, (uint8_t const *) buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpc55/family.mk b/circuitpython/lib/tinyusb/hw/bsp/lpc55/family.mk
new file mode 100644
index 0000000..4e8d65c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpc55/family.mk
@@ -0,0 +1,67 @@
+UF2_FAMILY_ID = 0x2abc77ec
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += lib/sct_neopixel $(SDK_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+# Default to Highspeed PORT1
+PORT ?= 1
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m33 \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-sp-d16 \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC55XX \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' \
+ -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
+
+ifeq ($(PORT), 1)
+ $(info "PORT1 High Speed")
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+
+ # LPC55 Highspeed Port1 can only write to USB_SRAM region
+ CFLAGS += -DCFG_TUSB_MEM_SECTION='__attribute__((section("m_usb_global")))'
+else
+ $(info "PORT0 Full Speed")
+endif
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal
+
+MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
+
+# All source paths should be relative to the top level.
+LD_FILE ?= $(MCU_DIR)/gcc/$(MCU_CORE)_flash.ld
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/system_$(MCU_CORE).c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(MCU_DIR)/drivers/fsl_power.c \
+ $(MCU_DIR)/drivers/fsl_reset.c \
+ $(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
+ $(SDK_DIR)/drivers/flexcomm/fsl_usart.c \
+ lib/sct_neopixel/sct_neopixel.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/sct_neopixel \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/flexcomm \
+ $(TOP)/$(SDK_DIR)/drivers/lpc_iocon \
+ $(TOP)/$(SDK_DIR)/drivers/lpc_gpio \
+ $(TOP)/$(SDK_DIR)/drivers/sctimer
+
+SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_CORE).S
+
+LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM33_NTZ/non_secure
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/board.mk
new file mode 100644
index 0000000..b736eeb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/board.mk
@@ -0,0 +1,46 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0 \
+ -nostdlib \
+ -DCORE_M0 \
+ -D__USE_LPCOPEN \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC11UXX \
+ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data.$$RAM2")))' \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc11uxx/lpc_chip_11uxx
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc11u37.ld
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc11xx.c \
+ $(MCU_DIR)/src/chip_11xx.c \
+ $(MCU_DIR)/src/clock_11xx.c \
+ $(MCU_DIR)/src/gpio_11xx_1.c \
+ $(MCU_DIR)/src/iocon_11xx.c \
+ $(MCU_DIR)/src/sysctl_11xx.c \
+ $(MCU_DIR)/src/sysinit_11xx.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = LPC11U37/401
+
+# flash using pyocd
+flash: $(BUILD)/$(PROJECT).hex
+ pyocd flash -t lpc11u37 $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpc11u37.ld b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpc11u37.ld
new file mode 100644
index 0000000..6a2dfb7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpc11u37.ld
@@ -0,0 +1,195 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * Copyright (c) 2008-2013 Code Red Technologies Ltd,
+ * Copyright 2015, 2018-2019 NXP
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC11U37/401
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v11.0.0 [Build 2516] [2019-06-05] on Sep 6, 2019 12:16:06 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash128 (rx) : ORIGIN = 0x0, LENGTH = 0x20000 /* 128K bytes (alias Flash) */
+ RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K bytes (alias RAM) */
+ RamUsb2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes (alias RAM2) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash128 = 0x0 ; /* MFlash128 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash128 = 0x0 + 0x20000 ; /* 128K bytes */
+ __top_Flash = 0x0 + 0x20000 ; /* 128K bytes */
+ __base_RamLoc8 = 0x10000000 ; /* RamLoc8 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc8 = 0x10000000 + 0x2000 ; /* 8K bytes */
+ __top_RAM = 0x10000000 + 0x2000 ; /* 8K bytes */
+ __base_RamUsb2 = 0x20004000 ; /* RamUsb2 */
+ __base_RAM2 = 0x20004000 ; /* RAM2 */
+ __top_RamUsb2 = 0x20004000 + 0x800 ; /* 2K bytes */
+ __top_RAM2 = 0x20004000 + 0x800 ; /* 2K bytes */
+
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash128
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash128
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash128
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash128
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamUsb2 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamUsb2)
+ *(.data.$RAM2)
+ *(.data.$RamUsb2)
+ *(.data.$RAM2.*)
+ *(.data.$RamUsb2.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamUsb2 AT>MFlash128
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc8
+
+ /* Main DATA section (RamLoc8) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc8 AT>MFlash128
+
+ /* BSS section for RamUsb2 */
+ .bss_RAM2 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2)
+ *(.bss.$RamUsb2)
+ *(.bss.$RAM2.*)
+ *(.bss.$RamUsb2.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamUsb2
+
+ /* MAIN BSS SECTION */
+ .bss :
+ {
+ . = ALIGN(4) ;
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc8
+
+ /* NOINIT section for RamUsb2 */
+ .noinit_RAM2 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM2)
+ *(.noinit.$RamUsb2)
+ *(.noinit.$RAM2.*)
+ *(.noinit.$RamUsb2.*)
+ . = ALIGN(4) ;
+ } > RamUsb2
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD):
+ {
+ . = ALIGN(4) ;
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc8
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc8 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (( DEFINED(NMI_Handler) ? NMI_Handler : M0_NMI_Handler ) + 1)
+ + (( DEFINED(HardFault_Handler) ? HardFault_Handler : M0_HardFault_Handler ) + 1)
+ )
+ );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c
new file mode 100644
index 0000000..11f1797
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u37/lpcxpresso11u37.c
@@ -0,0 +1,208 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//---------------------------------------------------------------- ----+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT 1
+#define LED_PIN 24
+#define LED_STATE_ON 0
+
+// Wake up Switch
+#define BUTTON_PORT 0
+#define BUTTON_PIN 16
+#define BUTTON_STATE_ACTIVE 0
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = 12000000;
+const uint32_t ExtRateIn = 0;
+
+/* Pin muxing table, only items that need changing from their default pin
+ state are in this table. Not every pin is mapped. */
+/* IOCON pin definitions for pin muxing */
+typedef struct {
+ uint32_t port : 8; /* Pin port */
+ uint32_t pin : 8; /* Pin number */
+ uint32_t modefunc : 16; /* Function and mode */
+} PINMUX_GRP_T;
+
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ {0, 3, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // USB VBUS
+ {0, 6, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_6 used for USB_CONNECT */
+
+ {0, 18, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // UART0 RX
+ {0, 19, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // UART0 TX
+};
+
+/* Setup system clocking */
+static void SystemSetupClocking(void)
+{
+ volatile int i;
+
+ /* Powerup main oscillator */
+ Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSOSC_PD);
+
+ /* Wait 200us for OSC to be stablized, no status
+ indication, dummy wait. */
+ for (i = 0; i < 0x100; i++) {}
+
+ /* Set system PLL input to main oscillator */
+ Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);
+
+ /* Power down PLL to change the PLL divider ratio */
+ Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_SYSPLL_PD);
+
+ /* Setup PLL for main oscillator rate (FCLKIN = 12MHz) * 4 = 48MHz
+ MSEL = 3 (this is pre-decremented), PSEL = 1 (for P = 2)
+ FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 4 = 48MHz
+ FCCO = FCLKOUT * 2 * P = 48MHz * 2 * 2 = 192MHz (within FCCO range) */
+ Chip_Clock_SetupSystemPLL(3, 1);
+
+ /* Powerup system PLL */
+ Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSPLL_PD);
+
+ /* Wait for PLL to lock */
+ while (!Chip_Clock_IsSystemPLLLocked()) {}
+
+ /* Set system clock divider to 1 */
+ Chip_Clock_SetSysClockDiv(1);
+
+ /* Setup FLASH access to 3 clocks */
+ Chip_FMC_SetFLASHAccess(FLASHTIM_50MHZ_CPU);
+
+ /* Set main clock source to the system PLL. This will drive 48MHz
+ for the main clock and 48MHz for the system clock */
+ Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_PLLOUT);
+
+ /* Set USB PLL input to main oscillator */
+ Chip_Clock_SetUSBPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);
+ /* Setup USB PLL (FCLKIN = 12MHz) * 4 = 48MHz
+ MSEL = 3 (this is pre-decremented), PSEL = 1 (for P = 2)
+ FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 4 = 48MHz
+ FCCO = FCLKOUT * 2 * P = 48MHz * 2 * 2 = 192MHz (within FCCO range) */
+ Chip_Clock_SetupUSBPLL(3, 1);
+
+ /* Powerup USB PLL */
+ Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPLL_PD);
+
+ /* Wait for PLL to lock */
+ while (!Chip_Clock_IsUSBPLLLocked()) {}
+}
+
+// Invoked by startup code
+void SystemInit(void)
+{
+ SystemSetupClocking();
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_RAM1);
+
+ /* Enable IOCON clock */
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
+ for (uint32_t i = 0; i < (sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); i++)
+ {
+ Chip_IOCON_PinMuxSet(LPC_IOCON, pinmuxing[i].port, pinmuxing[i].pin, pinmuxing[i].modefunc);
+ }
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+
+ // USB: Setup PLL clock, and power
+ /* enable USB main clock */
+ Chip_Clock_SetUSBClockSource(SYSCTL_USBCLKSRC_PLLOUT, 1);
+ /* Enable AHB clock to the USB block and USB RAM. */
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_USB);
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_USBRAM);
+ /* power UP USB Phy */
+ Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPAD_PD);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/board.mk
new file mode 100644
index 0000000..922414f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/board.mk
@@ -0,0 +1,42 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -nostdlib \
+ -DCORE_M0PLUS \
+ -D__VTOR_PRESENT=0 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC11UXX \
+ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data.$$RAM3")))' \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc11u6x/lpc_chip_11u6x
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc11u68.ld
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc11u6x.c \
+ $(MCU_DIR)/src/chip_11u6x.c \
+ $(MCU_DIR)/src/clock_11u6x.c \
+ $(MCU_DIR)/src/gpio_11u6x.c \
+ $(MCU_DIR)/src/iocon_11u6x.c \
+ $(MCU_DIR)/src/syscon_11u6x.c \
+ $(MCU_DIR)/src/sysinit_11u6x.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = LPC11U68
+
+# flash using pyocd
+flash: $(BUILD)/$(PROJECT).hex
+ pyocd flash -t lpc11u68 $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpc11u68.ld b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpc11u68.ld
new file mode 100644
index 0000000..56d9e4b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpc11u68.ld
@@ -0,0 +1,242 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC11U68
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 14, 2019 4:55:54 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash256 (rx) : ORIGIN = 0x0, LENGTH = 0x40000 /* 256K bytes (alias Flash) */
+ Ram0_32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ Ram1_2 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x800 /* 2K bytes (alias RAM2) */
+ Ram2USB_2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes (alias RAM3) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash256 = 0x0 ; /* MFlash256 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash256 = 0x0 + 0x40000 ; /* 256K bytes */
+ __top_Flash = 0x0 + 0x40000 ; /* 256K bytes */
+ __base_Ram0_32 = 0x10000000 ; /* Ram0_32 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_Ram0_32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __base_Ram1_2 = 0x20000000 ; /* Ram1_2 */
+ __base_RAM2 = 0x20000000 ; /* RAM2 */
+ __top_Ram1_2 = 0x20000000 + 0x800 ; /* 2K bytes */
+ __top_RAM2 = 0x20000000 + 0x800 ; /* 2K bytes */
+ __base_Ram2USB_2 = 0x20004000 ; /* Ram2USB_2 */
+ __base_RAM3 = 0x20004000 ; /* RAM3 */
+ __top_Ram2USB_2 = 0x20004000 + 0x800 ; /* 2K bytes */
+ __top_RAM3 = 0x20004000 + 0x800 ; /* 2K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash256
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash256
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash256
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash256
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* possible MTB section for Ram1_2 */
+ .mtb_buffer_RAM2 (NOLOAD) :
+ {
+ KEEP(*(.mtb.$RAM2*))
+ KEEP(*(.mtb.$Ram1_2*))
+ } > Ram1_2
+
+ /* DATA section for Ram1_2 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$Ram1_2)
+ *(.data.$RAM2*)
+ *(.data.$Ram1_2*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > Ram1_2 AT>MFlash256
+ /* possible MTB section for Ram2USB_2 */
+ .mtb_buffer_RAM3 (NOLOAD) :
+ {
+ KEEP(*(.mtb.$RAM3*))
+ KEEP(*(.mtb.$Ram2USB_2*))
+ } > Ram2USB_2
+
+ /* DATA section for Ram2USB_2 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$Ram2USB_2)
+ *(.data.$RAM3*)
+ *(.data.$Ram2USB_2*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ } > Ram2USB_2 AT>MFlash256
+ /* MAIN DATA SECTION */
+ /* Default MTB section */
+ .mtb_buffer_default (NOLOAD) :
+ {
+ KEEP(*(.mtb*))
+ } > Ram0_32
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > Ram0_32
+
+ /* Main DATA section (Ram0_32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > Ram0_32 AT>MFlash256
+
+ /* BSS section for Ram1_2 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$Ram1_2*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > Ram1_2
+
+ /* BSS section for Ram2USB_2 */
+ .bss_RAM3 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM3 = .) ;
+ *(.bss.$RAM3*)
+ *(.bss.$Ram2USB_2*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ } > Ram2USB_2
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > Ram0_32
+
+ /* NOINIT section for Ram1_2 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$Ram1_2*)
+ . = ALIGN(4) ;
+ } > Ram1_2
+
+ /* NOINIT section for Ram2USB_2 */
+ .noinit_RAM3 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM3*)
+ *(.noinit.$Ram2USB_2*)
+ . = ALIGN(4) ;
+ } > Ram2USB_2
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > Ram0_32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_Ram0_32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (( DEFINED(NMI_Handler) ? NMI_Handler : M0_NMI_Handler ) + 1)
+ + (( DEFINED(HardFault_Handler) ? HardFault_Handler : M0_HardFault_Handler ) + 1)
+ )
+ );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c
new file mode 100644
index 0000000..e33a5c6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso11u68/lpcxpresso11u68.c
@@ -0,0 +1,135 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT 2
+#define LED_PIN 17
+#define LED_STATE_ON 0
+
+// Wake up Switch
+#define BUTTON_PORT 0
+#define BUTTON_PIN 16
+#define BUTTON_STATE_ACTIVE 0
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = 12000000;
+const uint32_t RTCOscRateIn = 32768;
+
+/* Pin muxing table, only items that need changing from their default pin
+ state are in this table. Not every pin is mapped. */
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ {0, 3, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // USB VBUS
+ {0, 18, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // UART0 RX
+ {0, 19, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN)}, // UART0 TX
+ {2, 0, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // XTALIN
+ {2, 1, (IOCON_FUNC1 | IOCON_MODE_INACT)}, // XTALOUT
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+ /* Enable IOCON clock */
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+
+ // USB: Setup PLL clock, and power
+ Chip_USB_Init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/board.mk
new file mode 100644
index 0000000..62135c2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/board.mk
@@ -0,0 +1,45 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -nostdlib \
+ -DCORE_M3 \
+ -D__USE_LPCOPEN \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC13XX \
+ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data.$$RAM2")))' \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+
+# startup.c and lpc_types.h cause following errors
+CFLAGS += -Wno-error=strict-prototypes
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc13xx/lpc_chip_13xx
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc1347.ld
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc13xx.c \
+ $(MCU_DIR)/src/chip_13xx.c \
+ $(MCU_DIR)/src/clock_13xx.c \
+ $(MCU_DIR)/src/gpio_13xx_1.c \
+ $(MCU_DIR)/src/iocon_13xx.c \
+ $(MCU_DIR)/src/sysctl_13xx.c \
+ $(MCU_DIR)/src/sysinit_13xx.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# For flash-jlink target
+JLINK_DEVICE = LPC1347
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpc1347.ld b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpc1347.ld
new file mode 100644
index 0000000..42a4bb2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpc1347.ld
@@ -0,0 +1,225 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC1347
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 14, 2019 6:01:58 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash64 (rx) : ORIGIN = 0x0, LENGTH = 0x10000 /* 64K bytes (alias Flash) */
+ RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8K bytes (alias RAM) */
+ RamUsb2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes (alias RAM2) */
+ RamPeriph2 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x800 /* 2K bytes (alias RAM3) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash64 = 0x0 ; /* MFlash64 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash64 = 0x0 + 0x10000 ; /* 64K bytes */
+ __top_Flash = 0x0 + 0x10000 ; /* 64K bytes */
+ __base_RamLoc8 = 0x10000000 ; /* RamLoc8 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc8 = 0x10000000 + 0x2000 ; /* 8K bytes */
+ __top_RAM = 0x10000000 + 0x2000 ; /* 8K bytes */
+ __base_RamUsb2 = 0x20004000 ; /* RamUsb2 */
+ __base_RAM2 = 0x20004000 ; /* RAM2 */
+ __top_RamUsb2 = 0x20004000 + 0x800 ; /* 2K bytes */
+ __top_RAM2 = 0x20004000 + 0x800 ; /* 2K bytes */
+ __base_RamPeriph2 = 0x20000000 ; /* RamPeriph2 */
+ __base_RAM3 = 0x20000000 ; /* RAM3 */
+ __top_RamPeriph2 = 0x20000000 + 0x800 ; /* 2K bytes */
+ __top_RAM3 = 0x20000000 + 0x800 ; /* 2K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash64
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash64
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash64
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash64
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamUsb2 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamUsb2)
+ *(.data.$RAM2*)
+ *(.data.$RamUsb2*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamUsb2 AT>MFlash64
+ /* DATA section for RamPeriph2 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$RamPeriph2)
+ *(.data.$RAM3*)
+ *(.data.$RamPeriph2*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ } > RamPeriph2 AT>MFlash64
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc8
+
+ /* Main DATA section (RamLoc8) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc8 AT>MFlash64
+
+ /* BSS section for RamUsb2 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$RamUsb2*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamUsb2
+
+ /* BSS section for RamPeriph2 */
+ .bss_RAM3 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM3 = .) ;
+ *(.bss.$RAM3*)
+ *(.bss.$RamPeriph2*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ } > RamPeriph2
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc8
+
+ /* NOINIT section for RamUsb2 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$RamUsb2*)
+ . = ALIGN(4) ;
+ } > RamUsb2
+
+ /* NOINIT section for RamPeriph2 */
+ .noinit_RAM3 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM3*)
+ *(.noinit.$RamPeriph2*)
+ . = ALIGN(4) ;
+ } > RamPeriph2
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc8
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc8 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpcxpresso1347.c b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpcxpresso1347.c
new file mode 100644
index 0000000..a9a67ae
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1347/lpcxpresso1347.c
@@ -0,0 +1,152 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT 0
+#define LED_PIN 7
+
+// Joytick Down if connected to LPCXpresso Base board
+#define BUTTON_PORT 1
+#define BUTTON_PIN 20
+
+//static const struct {
+// uint8_t port;
+// uint8_t pin;
+//} buttons[] =
+//{
+// {1, 22 }, // Joystick up
+// {1, 20 }, // Joystick down
+// {1, 23 }, // Joystick left
+// {1, 21 }, // Joystick right
+// {1, 19 }, // Joystick press
+// {0, 1 }, // SW3
+//};
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = 12000000;
+const uint32_t ExtRateIn = 0;
+
+/* Pin muxing table, only items that need changing from their default pin
+ state are in this table. */
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ {0, 1, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_1 used for CLKOUT */
+ {0, 2, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_PULLUP)}, /* PIO0_2 used for SSEL */
+ {0, 3, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_3 used for USB_VBUS */
+ {0, 6, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_6 used for USB_CONNECT */
+ {0, 8, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_8 used for MISO0 */
+ {0, 9, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_9 used for MOSI0 */
+ {0, 11, (IOCON_FUNC2 | IOCON_ADMODE_EN | IOCON_FILT_DIS)}, /* PIO0_11 used for AD0 */
+ {0, 18, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_18 used for RXD */
+ {0, 19, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_19 used for TXD */
+ {1, 29, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO1_29 used for SCK0 */
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+ /* Enable IOCON clock */
+ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO_PORT);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
+
+ // USB: Setup PLL clock, and power
+ Chip_USB_Init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return Chip_GPIO_GetPinState(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/board.mk
new file mode 100644
index 0000000..34b4d6d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/board.mk
@@ -0,0 +1,43 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -nostdlib \
+ -DCORE_M3 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC175X_6X \
+ -DRTC_EV_SUPPORT=0
+
+# lpc_types.h cause following errors
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc175x_6x/lpc_chip_175x_6x
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc1769.ld
+
+SRC_C += \
+ src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc175x_6x.c \
+ $(MCU_DIR)/src/chip_17xx_40xx.c \
+ $(MCU_DIR)/src/clock_17xx_40xx.c \
+ $(MCU_DIR)/src/gpio_17xx_40xx.c \
+ $(MCU_DIR)/src/iocon_17xx_40xx.c \
+ $(MCU_DIR)/src/sysctl_17xx_40xx.c \
+ $(MCU_DIR)/src/sysinit_17xx_40xx.c \
+ $(MCU_DIR)/src/uart_17xx_40xx.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# For flash-jlink target
+JLINK_DEVICE = LPC1769
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpc1769.ld b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpc1769.ld
new file mode 100644
index 0000000..d1c83d8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpc1769.ld
@@ -0,0 +1,184 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC1769
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 14, 2019 6:39:29 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ RamAHB32 (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x8000 /* 32K bytes (alias RAM2) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash512 = 0x0 ; /* MFlash512 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash512 = 0x0 + 0x80000 ; /* 512K bytes */
+ __top_Flash = 0x0 + 0x80000 ; /* 512K bytes */
+ __base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __base_RamAHB32 = 0x2007c000 ; /* RamAHB32 */
+ __base_RAM2 = 0x2007c000 ; /* RAM2 */
+ __top_RamAHB32 = 0x2007c000 + 0x8000 ; /* 32K bytes */
+ __top_RAM2 = 0x2007c000 + 0x8000 ; /* 32K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash512
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash512
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamAHB32 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM2*)
+ *(.data.$RamAHB32*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamAHB32 AT>MFlash512
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc32
+
+ /* Main DATA section (RamLoc32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc32 AT>MFlash512
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$RamAHB32*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamAHB32
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc32
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$RamAHB32*)
+ . = ALIGN(4) ;
+ } > RamAHB32
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpcxpresso1769.c b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpcxpresso1769.c
new file mode 100644
index 0000000..b82e5ff
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso1769/lpcxpresso1769.c
@@ -0,0 +1,209 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT 0
+#define LED_PIN 22
+#define LED_STATE_ON 1
+
+// JOYSTICK_DOWN if using LPCXpresso Base Board
+#define BUTTON_PORT 0
+#define BUTTON_PIN 15
+#define BUTTON_STATE_ACTIVE 0
+
+#define BOARD_UART_PORT LPC_UART3
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = 12000000;
+const uint32_t RTCOscRateIn = 32768;
+
+/* Pin muxing configuration */
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ {0, 0, IOCON_MODE_INACT | IOCON_FUNC2}, /* TXD3 */
+ {0, 1, IOCON_MODE_INACT | IOCON_FUNC2}, /* RXD3 */
+ {LED_PORT, LED_PIN, IOCON_MODE_INACT | IOCON_FUNC0}, /* Led 0 */
+
+ /* Joystick buttons. */
+// {2, 3, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_UP */
+ {BUTTON_PORT, BUTTON_PIN, IOCON_FUNC0 | IOCON_MODE_PULLUP}, /* JOYSTICK_DOWN */
+// {2, 4, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_LEFT */
+// {0, 16, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_RIGHT */
+// {0, 17, IOCON_MODE_INACT | IOCON_FUNC0}, /* JOYSTICK_PRESS */
+};
+
+static const PINMUX_GRP_T pin_usb_mux[] =
+{
+ {0, 29, IOCON_MODE_INACT | IOCON_FUNC1}, // D+
+ {0, 30, IOCON_MODE_INACT | IOCON_FUNC1}, // D-
+ {2, 9, IOCON_MODE_INACT | IOCON_FUNC1}, // Soft Connect
+
+ {1, 19, IOCON_MODE_INACT | IOCON_FUNC2}, // USB_PPWR (Host mode)
+
+ // VBUS is not connected on this board, so leave the pin at default setting.
+ /// Chip_IOCON_PinMux(LPC_IOCON, 1, 30, IOCON_MODE_INACT, IOCON_FUNC2); // USB VBUS
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+#ifdef __USE_LPCOPEN
+ extern void (* const g_pfnVectors[])(void);
+ unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;
+ *pSCB_VTOR = (unsigned int) g_pfnVectors;
+#endif
+
+ Chip_IOCON_Init(LPC_IOCON);
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+ Chip_SetupXtalClocking();
+
+ Chip_SYSCTL_SetFLASHAccess(FLASHTIM_100MHZ_CPU);
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+
+#if 0
+ //------------- UART -------------//
+ PINSEL_CFG_Type PinCfg =
+ {
+ .Portnum = 0,
+ .Pinnum = 0, // TXD is P0.0
+ .Funcnum = 2,
+ .OpenDrain = 0,
+ .Pinmode = 0
+ };
+ PINSEL_ConfigPin(&PinCfg);
+
+ PinCfg.Portnum = 0;
+ PinCfg.Pinnum = 1; // RXD is P0.1
+ PINSEL_ConfigPin(&PinCfg);
+
+ UART_CFG_Type UARTConfigStruct;
+ UART_ConfigStructInit(&UARTConfigStruct);
+ UARTConfigStruct.Baud_rate = CFG_BOARD_UART_BAUDRATE;
+
+ UART_Init(BOARD_UART_PORT, &UARTConfigStruct);
+ UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART Transmit
+#endif
+
+ //------------- USB -------------//
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pin_usb_mux, sizeof(pin_usb_mux) / sizeof(PINMUX_GRP_T));
+ Chip_USB_Init();
+
+ enum {
+ USBCLK_DEVCIE = 0x12, // AHB + Device
+ USBCLK_HOST = 0x19, // AHB + Host + OTG
+// 0x1B // Host + Device + OTG + AHB
+ };
+
+ uint32_t const clk_en = CFG_TUD_ENABLED ? USBCLK_DEVCIE : USBCLK_HOST;
+
+ LPC_USB->OTGClkCtrl = clk_en;
+ while ( (LPC_USB->OTGClkSt & clk_en) != clk_en );
+
+#if CFG_TUH_ENABLED
+ // set portfunc to host !!!
+ LPC_USB->StCtrl = 0x3; // should be 1
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+// return UART_ReceiveByte(BOARD_UART_PORT);
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+// UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/board.mk b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/board.mk
new file mode 100644
index 0000000..98bef67
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/board.mk
@@ -0,0 +1,52 @@
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += $(SDK_DIR)
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -DCPU_LPC51U68JBD64 \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC51UXX \
+ -DCFG_TUSB_MEM_SECTION='__attribute__((section(".data")))' \
+ -DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))'
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter
+
+MCU_DIR = $(SDK_DIR)/devices/LPC51U68
+
+# All source paths should be relative to the top level.
+LD_FILE = $(MCU_DIR)/gcc/LPC51U68_flash.ld
+
+SRC_C += \
+ src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
+ $(MCU_DIR)/system_LPC51U68.c \
+ $(MCU_DIR)/drivers/fsl_clock.c \
+ $(MCU_DIR)/drivers/fsl_power.c \
+ $(MCU_DIR)/drivers/fsl_reset.c \
+ $(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
+ $(SDK_DIR)/drivers/flexcomm/fsl_usart.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/../../CMSIS/Include \
+ $(TOP)/$(MCU_DIR) \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/flexcomm \
+ $(TOP)/$(SDK_DIR)/drivers/lpc_iocon \
+ $(TOP)/$(SDK_DIR)/drivers/lpc_gpio
+
+SRC_S += $(MCU_DIR)/gcc/startup_LPC51U68.S
+
+LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower.a
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+JLINK_DEVICE = LPC51U68
+PYOCD_TARGET = LPC51U68
+
+# flash using pyocd (51u68 is not supported yet)
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c
new file mode 100644
index 0000000..6bade77
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/lpcxpresso51u68/lpcxpresso51u68.c
@@ -0,0 +1,179 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+#include "fsl_device_registers.h"
+#include "fsl_gpio.h"
+#include "fsl_power.h"
+#include "fsl_iocon.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT 0
+#define LED_PIN 29
+#define LED_STATE_ON 0
+
+// WAKE button
+#define BUTTON_PORT 0
+#define BUTTON_PIN 24
+
+// IOCON pin mux
+#define IOCON_PIO_DIGITAL_EN 0x80u /*!< Enables digital function */
+#define IOCON_PIO_FUNC1 0x01u /*!< Selects pin function 1 */
+#define IOCON_PIO_FUNC7 0x07u /*!< Selects pin function 7 */
+#define IOCON_PIO_INPFILT_OFF 0x0100u /*!< Input filter disabled */
+#define IOCON_PIO_INV_DI 0x00u /*!< Input function is not inverted */
+#define IOCON_PIO_MODE_INACT 0x00u /*!< No addition pin function */
+#define IOCON_PIO_OPENDRAIN_DI 0x00u /*!< Open drain is disabled */
+#define IOCON_PIO_SLEW_STANDARD 0x00u /*!< Standard mode, output slew rate control is enabled */
+
+/****************************************************************
+name: BOARD_BootClockFROHF96M
+outputs:
+- {id: SYSTICK_clock.outFreq, value: 96 MHz}
+- {id: System_clock.outFreq, value: 96 MHz}
+settings:
+- {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
+sources:
+- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
+******************************************************************/
+void BootClockFROHF96M(void)
+{
+ /*!< Set up the clock sources */
+ /*!< Set up FRO */
+ POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
+ CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without
+ accidentally being below the voltage for current speed */
+ POWER_SetVoltageForFreq(96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
+ CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
+
+ CLOCK_SetupFROClocking(96000000U); /*!< Set up high frequency FRO output to selected frequency */
+
+ /*!< Set up dividers */
+ CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
+ CLOCK_SetClkDiv(kCLOCK_DivSystickClk, 0U, true); /*!< Reset SYSTICKCLKDIV divider counter and halt it */
+ CLOCK_SetClkDiv(kCLOCK_DivSystickClk, 1U, false); /*!< Set SYSTICKCLKDIV divider to value 1 */
+
+ /*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
+ /*!< Set SystemCoreClock variable. */
+ SystemCoreClock = 96000000U;
+}
+
+void board_init(void)
+{
+ // Enable IOCON clock
+ CLOCK_EnableClock(kCLOCK_Iocon);
+
+ // Enable GPIO0 clock
+ CLOCK_EnableClock(kCLOCK_Gpio0);
+
+ // Init 96 MHz clock
+ BootClockFROHF96M();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_PortInit(GPIO, LED_PORT);
+ GPIO_PortInit(GPIO, BUTTON_PORT);
+
+ // LED
+ gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 0};
+ GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
+ board_led_write(true);
+
+ // Button
+ gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
+ GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
+
+ // USB
+ const uint32_t port1_pin6_config = (
+ IOCON_PIO_FUNC7 | /* Pin is configured as USB0_VBUS */
+ IOCON_PIO_MODE_INACT | /* No addition pin function */
+ IOCON_PIO_INV_DI | /* Input function is not inverted */
+ IOCON_PIO_DIGITAL_EN | /* Enables digital function */
+ IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
+ IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
+ );
+ IOCON_PinMuxSet(IOCON, 1, 6, port1_pin6_config); /* PORT1 PIN6 (coords: 26) is configured as USB0_VBUS */
+
+ POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
+ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcFro, CLOCK_GetFreq(kCLOCK_FroHf)); /* enable USB IP clock */
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ // active low
+ return 1-GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mbed1768/board.mk b/circuitpython/lib/tinyusb/hw/bsp/mbed1768/board.mk
new file mode 100644
index 0000000..b0d8858
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mbed1768/board.mk
@@ -0,0 +1,45 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -nostdlib \
+ -DCORE_M3 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC175X_6X \
+ -DRTC_EV_SUPPORT=0
+
+# startup.c and lpc_types.h cause following errors
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc175x_6x/lpc_chip_175x_6x
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/lpc1768.ld
+
+SRC_C += \
+ src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc175x_6x.c \
+ $(MCU_DIR)/src/chip_17xx_40xx.c \
+ $(MCU_DIR)/src/clock_17xx_40xx.c \
+ $(MCU_DIR)/src/gpio_17xx_40xx.c \
+ $(MCU_DIR)/src/iocon_17xx_40xx.c \
+ $(MCU_DIR)/src/sysctl_17xx_40xx.c \
+ $(MCU_DIR)/src/sysinit_17xx_40xx.c \
+ $(MCU_DIR)/src/uart_17xx_40xx.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# For flash-jlink target
+JLINK_DEVICE = LPC1768
+
+# flash using pyocd
+flash: $(BUILD)/$(PROJECT).hex
+ pyocd flash -t lpc1768 $<
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mbed1768/lpc1768.ld b/circuitpython/lib/tinyusb/hw/bsp/mbed1768/lpc1768.ld
new file mode 100644
index 0000000..d1c83d8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mbed1768/lpc1768.ld
@@ -0,0 +1,184 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * (c) Code Red Technologies Ltd, 2008-2013
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC1769
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] on May 14, 2019 6:39:29 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512K bytes (alias Flash) */
+ RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
+ RamAHB32 (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x8000 /* 32K bytes (alias RAM2) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_MFlash512 = 0x0 ; /* MFlash512 */
+ __base_Flash = 0x0 ; /* Flash */
+ __top_MFlash512 = 0x0 + 0x80000 ; /* 512K bytes */
+ __top_Flash = 0x0 + 0x80000 ; /* 512K bytes */
+ __base_RamLoc32 = 0x10000000 ; /* RamLoc32 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc32 = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM = 0x10000000 + 0x8000 ; /* 32K bytes */
+ __base_RamAHB32 = 0x2007c000 ; /* RamAHB32 */
+ __base_RAM2 = 0x2007c000 ; /* RAM2 */
+ __top_RamAHB32 = 0x2007c000 + 0x8000 ; /* 32K bytes */
+ __top_RAM2 = 0x2007c000 + 0x8000 ; /* 32K bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > MFlash512
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > MFlash512
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > MFlash512
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > MFlash512
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamAHB32 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM2*)
+ *(.data.$RamAHB32*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamAHB32 AT>MFlash512
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED : ALIGN(4)
+ {
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc32
+
+ /* Main DATA section (RamLoc32) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc32 AT>MFlash512
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM2 : ALIGN(4)
+ {
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2*)
+ *(.bss.$RamAHB32*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamAHB32
+
+ /* MAIN BSS SECTION */
+ .bss : ALIGN(4)
+ {
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc32
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM2 (NOLOAD) : ALIGN(4)
+ {
+ *(.noinit.$RAM2*)
+ *(.noinit.$RamAHB32*)
+ . = ALIGN(4) ;
+ } > RamAHB32
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD): ALIGN(4)
+ {
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc32
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mbed1768/mbed1768.c b/circuitpython/lib/tinyusb/hw/bsp/mbed1768/mbed1768.c
new file mode 100644
index 0000000..7c2b370
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mbed1768/mbed1768.c
@@ -0,0 +1,197 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+#define LED_PORT 1
+#define LED_PIN 18
+#define LED_STATE_ON 1
+
+// JOYSTICK_DOWN if using LPCXpresso Base Board
+#define BUTTON_PORT 0
+#define BUTTON_PIN 15
+#define BUTTON_STATE_ACTIVE 0
+
+#define BOARD_UART_PORT LPC_UART3
+
+/* System oscillator rate and RTC oscillator rate */
+const uint32_t OscRateIn = 10000000;
+const uint32_t RTCOscRateIn = 32768;
+
+/* Pin muxing configuration */
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ {LED_PORT, LED_PIN, IOCON_MODE_INACT | IOCON_FUNC0},
+ {BUTTON_PORT, BUTTON_PIN, IOCON_FUNC0 | IOCON_MODE_PULLUP},
+};
+
+static const PINMUX_GRP_T pin_usb_mux[] =
+{
+ {0, 29, IOCON_MODE_INACT | IOCON_FUNC1}, // D+
+ {0, 30, IOCON_MODE_INACT | IOCON_FUNC1}, // D-
+ {2, 9, IOCON_MODE_INACT | IOCON_FUNC1}, // Connect
+
+ {1, 19, IOCON_MODE_INACT | IOCON_FUNC2}, // USB_PPWR
+ {1, 22, IOCON_MODE_INACT | IOCON_FUNC2}, // USB_PWRD
+
+ /* VBUS is not connected on this board, so leave the pin at default setting. */
+ /*Chip_IOCON_PinMux(LPC_IOCON, 1, 30, IOCON_MODE_INACT, IOCON_FUNC2);*/ /* USB VBUS */
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+#ifdef __USE_LPCOPEN
+ extern void (* const g_pfnVectors[])(void);
+ unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;
+ *pSCB_VTOR = (unsigned int) g_pfnVectors;
+#endif
+
+ Chip_IOCON_Init(LPC_IOCON);
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+ Chip_SetupXtalClocking();
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+
+#if 0
+ //------------- UART -------------//
+ PINSEL_CFG_Type PinCfg =
+ {
+ .Portnum = 0,
+ .Pinnum = 0, // TXD is P0.0
+ .Funcnum = 2,
+ .OpenDrain = 0,
+ .Pinmode = 0
+ };
+ PINSEL_ConfigPin(&PinCfg);
+
+ PinCfg.Portnum = 0;
+ PinCfg.Pinnum = 1; // RXD is P0.1
+ PINSEL_ConfigPin(&PinCfg);
+
+ UART_CFG_Type UARTConfigStruct;
+ UART_ConfigStructInit(&UARTConfigStruct);
+ UARTConfigStruct.Baud_rate = CFG_BOARD_UART_BAUDRATE;
+
+ UART_Init(BOARD_UART_PORT, &UARTConfigStruct);
+ UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART Transmit
+#endif
+
+ //------------- USB -------------//
+ Chip_IOCON_SetPinMuxing(LPC_IOCON, pin_usb_mux, sizeof(pin_usb_mux) / sizeof(PINMUX_GRP_T));
+ Chip_USB_Init();
+
+ enum {
+ USBCLK_DEVCIE = 0x12, // AHB + Device
+ USBCLK_HOST = 0x19, // AHB + Host + OTG
+// 0x1B // Host + Device + OTG + AHB
+ };
+
+ uint32_t const clk_en = CFG_TUD_ENABLED ? USBCLK_DEVCIE : USBCLK_HOST;
+
+ LPC_USB->OTGClkCtrl = clk_en;
+ while ( (LPC_USB->OTGClkSt & clk_en) != clk_en );
+
+#if CFG_TUH_ENABLED
+ // set portfunc to host !!!
+ LPC_USB->StCtrl = 0x3; // should be 1
+#endif
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == Chip_GPIO_GetPinState(LPC_GPIO, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+// return UART_ReceiveByte(BOARD_UART_PORT);
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+// UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/board.mk b/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/board.mk
new file mode 100644
index 0000000..b766392
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/board.mk
@@ -0,0 +1,8 @@
+LD_FILE = $(BOARD_PATH)/flash.ld
+SRC_S += $(SDK_DIR)/mm32f327x/MM32F327x/Source/GCC_StartAsm/startup_mm32m3ux_u_gcc.S
+
+# For flash-jlink target
+#JLINK_DEVICE = stm32f411ve
+
+# flash target using on-board stlink
+#flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/flash.ld b/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/flash.ld
new file mode 100644
index 0000000..d96d6e4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/flash.ld
@@ -0,0 +1,163 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 MM32 SE TEAM
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x2001FFFF; /* end of RAM */
+
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/mm32f327x_mb39.c b/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/mm32f327x_mb39.c
new file mode 100644
index 0000000..cff7bc1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mm32/boards/mm32f327x_mb39/mm32f327x_mb39.c
@@ -0,0 +1,172 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 MM32 SE TEAM
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "mm32_device.h"
+#include "hal_conf.h"
+#include "tusb.h"
+#include "../board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void OTG_FS_IRQHandler (void)
+{
+ tud_int_handler(0);
+
+}
+void USB_DeviceClockInit (void)
+{
+ /* Select USBCLK source */
+ // RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1);
+ RCC->CFGR &= ~(0x3 << 22);
+ RCC->CFGR |= (0x1 << 22);
+
+ /* Enable USB clock */
+ RCC->AHB2ENR |= 0x1 << 7;
+}
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+// LED
+
+void board_led_write (bool state);
+extern u32 SystemCoreClock;
+const int baudrate = 115200;
+
+void board_init (void)
+{
+// usb clock
+ USB_DeviceClockInit();
+
+ if ( SysTick_Config(SystemCoreClock / 1000) )
+ {
+ while ( 1 )
+ ;
+ }
+ NVIC_SetPriority(SysTick_IRQn, 0x0);
+
+ // LED
+ GPIO_InitTypeDef GPIO_InitStruct;
+ RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE);
+ GPIO_StructInit(&GPIO_InitStruct);
+ GPIO_PinAFConfig(GPIOA, GPIO_PinSource15, GPIO_AF_15); //Disable JTDI AF to AF15
+
+ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15;
+ GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
+ GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ board_led_write(true);
+
+ // UART
+ UART_InitTypeDef UART_InitStruct;
+
+ RCC_APB2PeriphClockCmd(RCC_APB2ENR_UART1, ENABLE); //enableUART1,GPIOAclock
+ RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE); //
+ //UART initialset
+
+ GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_7);
+ GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_7);
+
+ UART_StructInit(&UART_InitStruct);
+ UART_InitStruct.UART_BaudRate = baudrate;
+ UART_InitStruct.UART_WordLength = UART_WordLength_8b;
+ UART_InitStruct.UART_StopBits = UART_StopBits_1; //one stopbit
+ UART_InitStruct.UART_Parity = UART_Parity_No; //none odd-even verify bit
+ UART_InitStruct.UART_HardwareFlowControl = UART_HardwareFlowControl_None; //No hardware flow control
+ UART_InitStruct.UART_Mode = UART_Mode_Rx | UART_Mode_Tx; // receive and sent mode
+
+ UART_Init(UART1, &UART_InitStruct); //initial uart 1
+ UART_Cmd(UART1, ENABLE); //enable uart 1
+
+ //UART1_TX GPIOA.9
+ GPIO_StructInit(&GPIO_InitStruct);
+ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9;
+ GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
+ GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ //UART1_RX GPIOA.10
+ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
+ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
+ GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write (bool state)
+{
+ state ? (GPIO_ResetBits(GPIOA, GPIO_Pin_15)) : (GPIO_SetBits(GPIOA, GPIO_Pin_15));
+}
+
+uint32_t board_button_read (void)
+{
+ return 0;
+}
+
+int board_uart_read (uint8_t *buf, int len)
+{
+ (void) buf;
+ (void) len;
+ return 0;
+}
+
+int board_uart_write (void const *buf, int len)
+{
+ const char *buff = buf;
+ while ( len )
+ {
+ while ( (UART1->CSR & UART_IT_TXIEN) == 0 )
+ ; //The loop is sent until it is finished
+ UART1->TDR = (*buff & 0xFF);
+ buff++;
+ len--;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis (void)
+{
+ return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/mm32/family.mk b/circuitpython/lib/tinyusb/hw/bsp/mm32/family.mk
new file mode 100644
index 0000000..1a9f511
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/mm32/family.mk
@@ -0,0 +1,36 @@
+UF2_FAMILY_ID = 0x0
+SDK_DIR = hw/mcu/mindmotion/mm32sdk
+DEPS_SUBMODULES += lib/CMSIS_5 $(SDK_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -mfloat-abi=soft \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_MM32F327X
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=maybe-uninitialized -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c \
+ $(SDK_DIR)/mm32f327x/MM32F327x/Source/system_mm32f327x.c \
+ $(SDK_DIR)/mm32f327x/MM32F327x/HAL_Lib/Src/hal_gpio.c \
+ $(SDK_DIR)/mm32f327x/MM32F327x/HAL_Lib/Src/hal_rcc.c \
+ $(SDK_DIR)/mm32f327x/MM32F327x/HAL_Lib/Src/hal_uart.c \
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(SDK_DIR)/mm32f327x/MM32F327x/Include \
+ $(TOP)/$(SDK_DIR)/mm32f327x/MM32F327x/HAL_Lib/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# flash target using on-board
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h b/circuitpython/lib/tinyusb/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h
new file mode 100644
index 0000000..ccfe321
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/msp430/boards/msp_exp430f5529lp/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT P1OUT
+#define LED_PIN BIT0
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT P1IN
+#define BUTTON_PIN BIT1
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/msp430/family.c b/circuitpython/lib/tinyusb/hw/bsp/msp430/family.c
new file mode 100644
index 0000000..4b8ae39
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/msp430/family.c
@@ -0,0 +1,218 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+#include "msp430.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+uint32_t cnt = 0;
+
+static void SystemClock_Config(void)
+{
+ WDTCTL = WDTPW + WDTHOLD; // Disable watchdog.
+
+ // Increase VCore to level 2- required for 16 MHz operation on this MCU.
+ PMMCTL0 = PMMPW + PMMCOREV_2;
+
+ UCSCTL3 = SELREF__XT2CLK; // FLL is fed by XT2.
+
+ // XT1 used for ACLK (default- not used in this demo)
+ P5SEL |= BIT4; // Required to enable XT1
+ // Loop until XT1 fault flag is cleared.
+ do
+ {
+ UCSCTL7 &= ~XT1LFOFFG;
+ }while(UCSCTL7 & XT1LFOFFG);
+
+ // XT2 is 4 MHz an external oscillator, use PLL to boost to 16 MHz.
+ P5SEL |= BIT2; // Required to enable XT2.
+ // Loop until XT2 fault flag is cleared
+ do
+ {
+ UCSCTL7 &= ~XT2OFFG;
+ }while(UCSCTL7 & XT2OFFG);
+
+ // Kickstart the DCO into the correct frequency range, otherwise a
+ // fault will occur.
+ // FIXME: DCORSEL_6 should work according to datasheet params, but generates
+ // a fault. I am not sure why it faults.
+ UCSCTL1 = DCORSEL_7;
+ UCSCTL2 = FLLD_2 + 3; // DCO freq = D * (N + 1) * (FLLREFCLK / n)
+ // DCOCLKDIV freq = (N + 1) * (FLLREFCLK / n)
+ // N = 3, D = 2, thus DCO freq = 32 MHz.
+
+ // MCLK configured for 16 MHz using XT2.
+ // SMCLK configured for 8 MHz using XT2.
+ UCSCTL4 |= SELM__DCOCLKDIV + SELS__DCOCLKDIV;
+ UCSCTL5 |= DIVM__16 + DIVS__2;
+
+ // Now wait till everything's stabilized.
+ do
+ {
+ UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
+ SFRIFG1 &= ~OFIFG;
+ }while(SFRIFG1 & OFIFG);
+
+ // Configure Timer A to use SMCLK as a source. Count 1000 ticks at 1 MHz.
+ TA0CCTL0 |= CCIE;
+ TA0CCR0 = 999; // 1000 ticks.
+ TA0CTL |= TASSEL_2 + ID_3 + MC__UP; // Use SMCLK, divide by 8, start timer.
+
+ // Initialize USB power and PLL.
+ USBKEYPID = USBKEY;
+
+ // VUSB enabled automatically.
+ // Wait two milliseconds to stabilize, per manual recommendation.
+ uint32_t ms_elapsed = board_millis();
+ do
+ {
+ while((board_millis() - ms_elapsed) < 2);
+ }while(!(USBPWRCTL & USBBGVBV));
+
+ // USB uses XT2 (4 MHz) directly. Enable the PLL.
+ USBPLLDIVB |= USBPLL_SETCLK_4_0;
+ USBPLLCTL |= (UPFDEN | UPLLEN);
+
+ // Wait until PLL locks. Check every 2ms, per manual.
+ ms_elapsed = board_millis();
+ do
+ {
+ USBPLLIR &= ~USBOOLIFG;
+ while((board_millis() - ms_elapsed) < 2);
+ }while(USBPLLIR & USBOOLIFG);
+
+ USBKEYPID = 0;
+}
+
+uint32_t wait = 0;
+
+void board_init(void)
+{
+ __bis_SR_register(GIE); // Enable interrupts.
+ SystemClock_Config();
+
+ // Enable basic I/O.
+ P1DIR |= LED_PIN; // LED output.
+ P1REN |= BUTTON_PIN; // Internal resistor enable.
+ P1OUT |= BUTTON_PIN; // Pullup.
+
+ // Enable the backchannel UART (115200)
+ P4DIR |= BIT5;
+ P4SEL |= (BIT5 | BIT4);
+
+ UCA1CTL1 |= (UCSSEL__SMCLK | UCSWRST); // Hold in reset, use SMCLK.
+ UCA1BRW = 4;
+ UCA1MCTL |= (UCBRF_3 | UCBRS_5 | UCOS16); // Overampling mode, 115200 baud.
+ // Copied from manual.
+ UCA1CTL1 &= ~UCSWRST;
+
+ // Set up USB pins.
+ USBKEYPID = USBKEY;
+ USBPHYCTL |= PUSEL; // Convert USB D+/D- pins to USB functionality.
+ USBKEYPID = 0;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ if(state)
+ {
+ LED_PORT |= LED_PIN;
+ }
+ else
+ {
+ LED_PORT &= ~LED_PIN;
+ }
+}
+
+uint32_t board_button_read(void)
+{
+ return ((P1IN & BIT1) >> 1) == BUTTON_STATE_ACTIVE;
+}
+
+int board_uart_read(uint8_t * buf, int len)
+{
+ for(int i = 0; i < len; i++)
+ {
+ // Wait until something to receive (cleared by reading buffer).
+ while(!(UCA1IFG & UCRXIFG));
+ buf[i] = UCA1RXBUF;
+ }
+
+ return len;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ const char * char_buf = (const char *) buf;
+
+ for(int i = 0; i < len; i++)
+ {
+ // Wait until TX buffer is empty (cleared by writing buffer).
+ while(!(UCA1IFG & UCTXIFG));
+ UCA1TXBUF = char_buf[i];
+ }
+
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TIMER0_A0_ISR (void)
+{
+ system_ticks++;
+ // TAxCCR0 CCIFG resets itself as soon as interrupt is invoked.
+}
+
+uint32_t board_millis(void)
+{
+ uint32_t systick_mirror;
+
+ // 32-bit update is not atomic on MSP430. We can read the bottom 16-bits,
+ // an interrupt occurs, updates _all_ 32 bits, and then we return a
+ // garbage value. And I've seen it happen!
+ TA0CCTL0 &= ~CCIE;
+ systick_mirror = system_ticks;
+ TA0CCTL0 |= CCIE;
+
+ return systick_mirror;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/msp430/family.mk b/circuitpython/lib/tinyusb/hw/bsp/msp430/family.mk
new file mode 100644
index 0000000..ceafa6e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/msp430/family.mk
@@ -0,0 +1,35 @@
+CROSS_COMPILE = msp430-elf-
+DEPS_SUBMODULES += hw/mcu/ti
+SKIP_NANOLIB = 1
+
+CFLAGS += \
+ -D__MSP430F5529__ \
+ -DCFG_TUSB_MCU=OPT_MCU_MSP430x5xx \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_TUD_ENDPOINT0_SIZE=8
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
+LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
+LDFLAGS += $(addprefix -L,$(LDINC))
+
+SRC_C += src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+
+INC += \
+ $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include \
+ $(TOP)/$(BOARD_PATH)
+
+# export for libmsp430.so to same installation
+ifneq ($(OS),Windows_NT)
+export LD_LIBRARY_PATH=$(dir $(shell which MSP430Flasher))
+endif
+
+# flash target using TI MSP430-Flasher
+# http://www.ti.com/tool/MSP430-FLASHER
+# Please add its installation dir to PATH
+flash: $(BUILD)/$(PROJECT).hex
+ MSP430Flasher -w $< -z [VCC]
+
+# flash target using mspdebug.
+flash-mspdebug: $(BUILD)/$(PROJECT).elf
+ $(MSPDEBUG) tilib "prog $<" --allow-fw-update
diff --git a/circuitpython/lib/tinyusb/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h b/circuitpython/lib/tinyusb/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h
new file mode 100644
index 0000000..3130d66
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/msp432e4/boards/msp_exp432e401y/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#define CLK_LED 12u
+#define GPIO_LED GPION
+#define GPIO_LED_PIN 1u
+
+#define CLK_BUTTON 8u
+#define GPIO_BUTTON GPIOJ
+#define GPIO_BUTTON_PIN 0u
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.c b/circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.c
new file mode 100644
index 0000000..3d2d408
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.c
@@ -0,0 +1,203 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+#include "msp.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+#if CFG_TUH_ENABLED
+ tuh_int_handler(0);
+#endif
+#if CFG_TUD_ENABLED
+ tud_int_handler(0);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+void board_init(void)
+{
+ unsigned bits;
+ /* Turn off power domains that unused peripherals belong to */
+ SYSCTL->PCCAN = 0u;
+#ifdef __MCU_HAS_LCD0__
+ SYSCTL->PCLCD = 0u;
+#endif
+ SYSCTL->PCEMAC = 0u;
+ SYSCTL->PCEPHY = 0u;
+ SYSCTL->PCCCM = 0u;
+
+ /* --- Setup system clock --- */
+ /* Start power-up process of the main oscillator */
+ SYSCTL->MOSCCTL = SYSCTL_MOSCCTL_OSCRNG;
+ while (!(SYSCTL->RIS & SYSCTL_RIS_MOSCPUPRIS)) ; /* Wait for completion */
+ SYSCTL->MISC = SYSCTL_MISC_MOSCPUPMIS; /* Clear the completion interrupt status */
+ /* Set the main oscillator to PLL reference clock */
+ SYSCTL->RSCLKCFG = SYSCTL_RSCLKCFG_PLLSRC_MOSC;
+ /* PLL freq. = (MOSC freq. / 10) * 96 = 240MHz */
+ SYSCTL->PLLFREQ1 = (4 << SYSCTL_PLLFREQ1_N_S) | (1 << SYSCTL_PLLFREQ1_Q_S);
+ SYSCTL->PLLFREQ0 = (96 << SYSCTL_PLLFREQ0_MINT_S) | SYSCTL_PLLFREQ0_PLLPWR;
+ /* Set BCHT=6, BCE=0, WS=5 for 120MHz system clock */
+ SYSCTL->MEMTIM0 = SYSCTL_MEMTIM0_EBCHT_3_5 | (5 << SYSCTL_MEMTIM0_EWS_S) |
+ SYSCTL_MEMTIM0_FBCHT_3_5 | (5 << SYSCTL_MEMTIM0_FWS_S) | SYSCTL_MEMTIM0_MB1;
+ /* Wait for completion of PLL power-up process */
+ while (!(SYSCTL->RIS & SYSCTL_RIS_PLLLRIS)) ;
+ SYSCTL->MISC = SYSCTL_MISC_PLLLMIS; /* Clear the completion interrupt status */
+ /* Switch the system clock to PLL/4 */
+ SYSCTL->RSCLKCFG = SYSCTL_RSCLKCFG_MEMTIMU | SYSCTL_RSCLKCFG_ACG |
+ SYSCTL_RSCLKCFG_USEPLL | SYSCTL_RSCLKCFG_PLLSRC_MOSC | (1 << SYSCTL_RSCLKCFG_PSYSDIV_S);
+
+ SystemCoreClockUpdate();
+#if CFG_TUSB_OS == OPT_OS_NONE
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ /* USR_LED1 ON1 */
+ bits = TU_BIT(CLK_LED);
+ SYSCTL->RCGCGPIO |= bits;
+ while (bits != (SYSCTL->RCGCGPIO & bits)) ;
+ GPIO_LED->DIR = TU_BIT(GPIO_LED_PIN);
+ GPIO_LED->DEN = TU_BIT(GPIO_LED_PIN);
+
+ /* USR_SW1 PJ0 */
+ bits = TU_BIT(CLK_BUTTON);
+ SYSCTL->RCGCGPIO |= bits;
+ while (bits != (SYSCTL->RCGCGPIO & bits)) ;
+ GPIO_BUTTON->PUR = TU_BIT(GPIO_BUTTON_PIN);
+ GPIO_BUTTON->DEN = TU_BIT(GPIO_BUTTON_PIN);
+
+ /* UART PA0,1 */
+ bits = TU_BIT(0);
+ SYSCTL->RCGCGPIO |= bits;
+ while (bits != (SYSCTL->RCGCGPIO & bits)) ;
+ GPIOA->AFSEL = 3u;
+ GPIOA->PCTL = 0x11u;
+ GPIOA->DEN = 3u;
+
+ SYSCTL->RCGCUART |= 1u << 0;
+ while (!(SYSCTL->PRUART & (1u << 0))) ;
+ UART0->CTL = 0;
+ UART0->IBRD = 8; /* 8.68056 = 16MHz / (16 * 115200) */
+ UART0->FBRD = 44; /* 0.6875 = 44/64 -> 115108bps (0.08%) */
+ UART0->LCRH = UART_LCRH_WLEN_8 | UART_LCRH_FEN;
+ UART0->CC = UART_CC_CS_PIOSC; /* Set the baud clock to PIOSC */
+ UART0->CTL = UART_CTL_RXE | UART_CTL_TXE | UART_CTL_UARTEN;
+
+ /* USB PB0(ID) PB1(VBUS) PL6,7(DP,DM) */
+ bits = TU_BIT(1) | TU_BIT(10);
+ SYSCTL->RCGCGPIO |= bits;
+ while (bits != (SYSCTL->RCGCGPIO & bits)) ;
+ GPIOB->AMSEL = TU_BIT(0) | TU_BIT(1);
+ GPIOL->AMSEL = TU_BIT(6) | TU_BIT(7);
+
+#if CFG_TUH_ENABLED
+ /* USB PD6(EPEN) */
+ bits = TU_BIT(3);
+ SYSCTL->RCGCGPIO |= bits;
+ while (bits != (SYSCTL->RCGCGPIO & bits)) ;
+ GPIOD->AFSEL = TU_BIT(6);
+ GPIOD->PCTL = 0x05000000u;
+ GPIOD->DEN = TU_BIT(6);
+#endif
+
+ SYSCTL->RCGCUSB = 1u; /* Open the clock gate for SYSCLK */
+ while (!(SYSCTL->PRUSB & (1u << 0))) ;
+ USB0->CC = USB_CC_CLKEN | (3u << USB_CC_CLKDIV_S); /* 60MHz = 240MHz / 4 */
+ __DMB(); /* Wait for completion of opening of the clock gate */
+
+ SYSCTL->SRUSB = 1u;
+ for (int i = 0; i < 16; ++i) __NOP();
+ SYSCTL->SRUSB = 0u;
+
+ USB0->CC = USB_CC_CLKEN | (3u << USB_CC_CLKDIV_S); /* 60MHz = 240MHz / 4 */
+ __DMB(); /* Wait for completion of opening of the clock gate */
+#if CFG_TUH_ENABLED
+ USB0->GPCS = USB_GPCS_DEVMOD_OTG;
+ USB0->EPC = USB_EPC_EPENDE | USB_EPC_EPEN_HIGH;
+#endif
+#if CFG_TUD_ENABLED
+ USB0->GPCS = USB_GPCS_DEVMOD_DEVVBUS;
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ if (state)
+ GPIO_LED->DATA |= TU_BIT(GPIO_LED_PIN);
+ else
+ GPIO_LED->DATA &= ~TU_BIT(GPIO_LED_PIN);
+}
+
+uint32_t board_button_read(void)
+{
+ return (GPIO_BUTTON->DATA & TU_BIT(GPIO_BUTTON_PIN)) ? 0u : 1u;
+}
+
+int board_uart_read(uint8_t * buf, int len)
+{
+ for (int i = 0; i < len; ++i) {
+ while (UART0->FR & UART_FR_RXFE) ;
+ *buf++ = UART0->DR;
+ }
+ return len;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ uint8_t const *p = (uint8_t const *)buf;
+ for (int i = 0; i < len; ++i) {
+ while (UART0->FR & UART_FR_TXFF) ;
+ UART0->DR = *p++;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0u;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.mk b/circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.mk
new file mode 100644
index 0000000..e3cb90a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/msp432e4/family.mk
@@ -0,0 +1,41 @@
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/ti
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mslow-flash-data \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -D__MSP432E401Y__ \
+ -DCFG_TUSB_MCU=OPT_MCU_MSP432E4
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=cast-qual -Wno-error=format=
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/mcu/ti/msp432e4/Source/msp432e401y.ld
+LDINC += $(TOP)/hw/mcu/ti/msp432e4/Include
+LDFLAGS += $(addprefix -L,$(LDINC))
+
+MCU_DIR = hw/mcu/ti/msp432e4
+
+SRC_C += \
+ src/portable/mentor/musb/dcd_musb.c \
+ src/portable/mentor/musb/hcd_musb.c \
+ $(MCU_DIR)/Source/system_msp432e401y.c
+
+INC += \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(MCU_DIR)/Include \
+ $(TOP)/$(BOARD_PATH)
+
+SRC_S += $(MCU_DIR)/Source/startup_msp432e411y_gcc.S
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = MSP432E401Y
+JLINK_IF = SWD
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ngx4330/board.mk b/circuitpython/lib/tinyusb/hw/bsp/ngx4330/board.mk
new file mode 100644
index 0000000..3e90156
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ngx4330/board.mk
@@ -0,0 +1,47 @@
+DEPS_SUBMODULES += hw/mcu/nxp/lpcopen
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib \
+ -DCORE_M4 \
+ -D__USE_LPCOPEN \
+ -DCFG_TUSB_MCU=OPT_MCU_LPC43XX
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter -Wno-error=cast-qual
+
+MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/ngx4330.ld
+
+SRC_C += \
+ src/portable/chipidea/ci_hs/dcd_ci_hs.c \
+ src/portable/chipidea/ci_hs/hcd_ci_hs.c \
+ src/portable/ehci/ehci.c \
+ $(MCU_DIR)/../gcc/cr_startup_lpc43xx.c \
+ $(MCU_DIR)/src/chip_18xx_43xx.c \
+ $(MCU_DIR)/src/clock_18xx_43xx.c \
+ $(MCU_DIR)/src/gpio_18xx_43xx.c \
+ $(MCU_DIR)/src/sysinit_18xx_43xx.c \
+ $(MCU_DIR)/src/uart_18xx_43xx.c \
+ $(MCU_DIR)/src/fpu_init.c
+
+INC += \
+ $(TOP)/$(MCU_DIR)/inc \
+ $(TOP)/$(MCU_DIR)/inc/config_43xx
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = LPC4330
+JLINK_IF = swd
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.c b/circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.c
new file mode 100644
index 0000000..b63f9b8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.c
@@ -0,0 +1,264 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "chip.h"
+#include "../board.h"
+
+#define LED_PORT 1
+#define LED_PIN 12
+#define LED_STATE_ON 0
+
+#define BUTTON_PORT 0
+#define BUTTON_PIN 7
+#define BUTTON_STATE_ACTIVE 0
+
+#define BOARD_UART_PORT LPC_USART0
+#define BOARD_UART_PIN_PORT 0x0f
+#define BOARD_UART_PIN_TX 10 // PF.10 : UART0_TXD
+#define BOARD_UART_PIN_RX 11 // PF.11 : UART0_RXD
+
+/*------------------------------------------------------------------*/
+/* BOARD API
+ *------------------------------------------------------------------*/
+
+/* System configuration variables used by chip driver */
+const uint32_t OscRateIn = 12000000;
+const uint32_t ExtRateIn = 0;
+
+static const PINMUX_GRP_T pinmuxing[] =
+{
+ // LED P2.12 as GPIO 1.12
+ {2, 11, (SCU_MODE_INBUFF_EN | SCU_MODE_PULLDOWN | SCU_MODE_FUNC0)},
+
+ // Button P2.7 as GPIO 0.7
+ {2, 7, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0)},
+
+ // USB
+ {2, 6, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4)}, // USB1_PWR_EN
+ {2, 5, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)}, // USB1_VBUS
+ {1, 7, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC4)}, // USB0_PWRN_EN
+
+ // SPIFI
+ {3, 3, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI CLK */
+ {3, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D3 */
+ {3, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D2 */
+ {3, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D1 */
+ {3, 7, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D0 */
+ {3, 8, (SCU_PINIO_FAST | SCU_MODE_FUNC3)} /* SPIFI CS/SSEL */
+};
+
+// Invoked by startup code
+void SystemInit(void)
+{
+#ifdef __USE_LPCOPEN
+ extern void (* const g_pfnVectors[])(void);
+ unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;
+ *pSCB_VTOR = (unsigned int) g_pfnVectors;
+
+#if __FPU_USED == 1
+ fpuInit();
+#endif
+#endif // __USE_LPCOPEN
+
+ // Set up pinmux
+ Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
+
+ //------------- Set up clock -------------//
+ Chip_Clock_SetBaseClock(CLK_BASE_SPIFI, CLKIN_IRC, true, false); // change SPIFI to IRC during clock programming
+ LPC_SPIFI->CTRL |= SPIFI_CTRL_FBCLK(1); // and set FBCLK in SPIFI controller
+
+ Chip_SetupCoreClock(CLKIN_CRYSTAL, MAX_CLOCK_FREQ, true);
+
+ /* Reset and enable 32Khz oscillator */
+ LPC_CREG->CREG0 &= ~((1 << 3) | (1 << 2));
+ LPC_CREG->CREG0 |= (1 << 1) | (1 << 0);
+
+ /* Setup a divider E for main PLL clock switch SPIFI clock to that divider.
+ Divide rate is based on CPU speed and speed of SPI FLASH part. */
+#if (MAX_CLOCK_FREQ > 180000000)
+ Chip_Clock_SetDivider(CLK_IDIV_E, CLKIN_MAINPLL, 5);
+#else
+ Chip_Clock_SetDivider(CLK_IDIV_E, CLKIN_MAINPLL, 4);
+#endif
+ Chip_Clock_SetBaseClock(CLK_BASE_SPIFI, CLKIN_IDIVE, true, false);
+
+ /* Setup system base clocks and initial states. This won't enable and
+ disable individual clocks, but sets up the base clock sources for
+ each individual peripheral clock. */
+ Chip_Clock_SetBaseClock(CLK_BASE_USB1, CLKIN_IDIVD, true, true);
+}
+
+void board_init(void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ //NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ Chip_GPIO_Init(LPC_GPIO_PORT);
+
+ // LED
+ Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED_PORT, LED_PIN);
+
+ // Button
+ Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
+
+#if 0
+ //------------- UART -------------//
+ scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_TX, MD_PDN, FUNC1);
+ scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_RX, MD_PLN | MD_EZI | MD_ZI, FUNC1);
+
+ UART_CFG_Type UARTConfigStruct;
+ UART_ConfigStructInit(&UARTConfigStruct);
+ UARTConfigStruct.Baud_rate = CFG_BOARD_UART_BAUDRATE;
+ UARTConfigStruct.Clock_Speed = 0;
+
+ UART_Init(BOARD_UART_PORT, &UARTConfigStruct);
+ UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART Transmit
+#endif
+
+ //------------- USB -------------//
+ enum {
+ USBMODE_DEVICE = 2,
+ USBMODE_HOST = 3
+ };
+
+ enum {
+ USBMODE_VBUS_LOW = 0,
+ USBMODE_VBUS_HIGH = 1
+ };
+
+ /* USB0
+ * For USB Device operation; insert jumpers in position 1-2 in JP17/JP18/JP19. GPIO28 controls USB
+ * connect functionality and LED32 lights when the USB Device is connected. SJ4 has pads 1-2 shorted
+ * by default. LED33 is controlled by GPIO27 and signals USB-up state. GPIO54 is used for VBUS
+ * sensing.
+ * For USB Host operation; insert jumpers in position 2-3 in JP17/JP18/JP19. USB Host power is
+ * controlled via distribution switch U20 (found in schematic page 11). Signal GPIO26 is active low and
+ * enables +5V on VBUS2. LED35 light whenever +5V is present on VBUS2. GPIO55 is connected to
+ * status feedback from the distribution switch. GPIO54 is used for VBUS sensing. 15Kohm pull-down
+ * resistors are always active
+ */
+#if CFG_TUSB_RHPORT0_MODE
+ Chip_USB0_Init();
+#endif
+
+ /* USB1
+ * When USB channel #1 is used as USB Host, 15Kohm pull-down resistors are needed on the USB data
+ * signals. These are activated inside the USB OTG chip (U31), and this has to be done via the I2C
+ * interface of GPIO52/GPIO53.
+ * J20 is the connector to use when USB Host is used. In order to provide +5V to the external USB
+ * device connected to this connector (J20), channel A of U20 must be enabled. It is enabled by default
+ * since SJ5 is normally connected between pin 1-2. LED34 lights green when +5V is available on J20.
+ * JP15 shall not be inserted. JP16 has no effect
+ *
+ * When USB channel #1 is used as USB Device, a 1.5Kohm pull-up resistor is needed on the USB DP
+ * data signal. There are two methods to create this. JP15 is inserted and the pull-up resistor is always
+ * enabled. Alternatively, the pull-up resistor is activated inside the USB OTG chip (U31), and this has to
+ * be done via the I2C interface of GPIO52/GPIO53. In the latter case, JP15 shall not be inserted.
+ * J19 is the connector to use when USB Device is used. Normally it should be a USB-B connector for
+ * creating a USB Device interface, but the mini-AB connector can also be used in this case. The status
+ * of VBUS can be read via U31.
+ * JP16 shall not be inserted.
+ */
+#if CFG_TUSB_RHPORT1_MODE
+ Chip_USB1_Init();
+
+// Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 6); /* GPIO5[6] = USB1_PWR_EN */
+// Chip_GPIO_SetPinState(LPC_GPIO_PORT, 5, 6, true); /* GPIO5[6] output high */
+#endif
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USB0_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
+ tuh_int_handler(0);
+ #endif
+
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+void USB1_IRQHandler(void)
+{
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST
+ tuh_int_handler(1);
+ #endif
+
+ #if CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE
+ tud_int_handler(1);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == Chip_GPIO_GetPinState(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ //return UART_ReceiveByte(BOARD_UART_PORT);
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ //UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.ld b/circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.ld
new file mode 100644
index 0000000..7bd363f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/ngx4330/ngx4330.ld
@@ -0,0 +1,343 @@
+/*
+ * GENERATED FILE - DO NOT EDIT
+ * Copyright (c) 2008-2013 Code Red Technologies Ltd,
+ * Copyright 2015, 2018-2019 NXP
+ * (c) NXP Semiconductors 2013-2019
+ * Generated linker script file for LPC4330
+ * Created from linkscript.ldt by FMCreateLinkLibraries
+ * Using Freemarker v2.3.23
+ * MCUXpresso IDE v11.0.0 [Build 2516] [2019-06-05] on Sep 9, 2019 12:09:49 PM
+ */
+
+MEMORY
+{
+ /* Define each memory region */
+ RamLoc128 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x20000 /* 128K bytes (alias RAM) */
+ RamLoc72 (rwx) : ORIGIN = 0x10080000, LENGTH = 0x12000 /* 72K bytes (alias RAM2) */
+ RamAHB32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM3) */
+ RamAHB16 (rwx) : ORIGIN = 0x20008000, LENGTH = 0x4000 /* 16K bytes (alias RAM4) */
+ RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */
+ SPIFI (rx) : ORIGIN = 0x14000000, LENGTH = 0x400000 /* 4M bytes (alias Flash) */
+}
+
+ /* Define a symbol for the top of each memory region */
+ __base_RamLoc128 = 0x10000000 ; /* RamLoc128 */
+ __base_RAM = 0x10000000 ; /* RAM */
+ __top_RamLoc128 = 0x10000000 + 0x20000 ; /* 128K bytes */
+ __top_RAM = 0x10000000 + 0x20000 ; /* 128K bytes */
+ __base_RamLoc72 = 0x10080000 ; /* RamLoc72 */
+ __base_RAM2 = 0x10080000 ; /* RAM2 */
+ __top_RamLoc72 = 0x10080000 + 0x12000 ; /* 72K bytes */
+ __top_RAM2 = 0x10080000 + 0x12000 ; /* 72K bytes */
+ __base_RamAHB32 = 0x20000000 ; /* RamAHB32 */
+ __base_RAM3 = 0x20000000 ; /* RAM3 */
+ __top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */
+ __top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */
+ __base_RamAHB16 = 0x20008000 ; /* RamAHB16 */
+ __base_RAM4 = 0x20008000 ; /* RAM4 */
+ __top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */
+ __top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */
+ __base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */
+ __base_RAM5 = 0x2000c000 ; /* RAM5 */
+ __top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+ __top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */
+ __base_SPIFI = 0x14000000 ; /* SPIFI */
+ __base_Flash = 0x14000000 ; /* Flash */
+ __top_SPIFI = 0x14000000 + 0x400000 ; /* 4M bytes */
+ __top_Flash = 0x14000000 + 0x400000 ; /* 4M bytes */
+
+ENTRY(ResetISR)
+
+SECTIONS
+{
+ /* MAIN TEXT SECTION */
+ .text : ALIGN(4)
+ {
+ FILL(0xff)
+ __vectors_start__ = ABSOLUTE(.) ;
+ KEEP(*(.isr_vector))
+ /* Global Section Table */
+ . = ALIGN(4) ;
+ __section_table_start = .;
+ __data_section_table = .;
+ LONG(LOADADDR(.data));
+ LONG( ADDR(.data));
+ LONG( SIZEOF(.data));
+ LONG(LOADADDR(.data_RAM2));
+ LONG( ADDR(.data_RAM2));
+ LONG( SIZEOF(.data_RAM2));
+ LONG(LOADADDR(.data_RAM3));
+ LONG( ADDR(.data_RAM3));
+ LONG( SIZEOF(.data_RAM3));
+ LONG(LOADADDR(.data_RAM4));
+ LONG( ADDR(.data_RAM4));
+ LONG( SIZEOF(.data_RAM4));
+ LONG(LOADADDR(.data_RAM5));
+ LONG( ADDR(.data_RAM5));
+ LONG( SIZEOF(.data_RAM5));
+ __data_section_table_end = .;
+ __bss_section_table = .;
+ LONG( ADDR(.bss));
+ LONG( SIZEOF(.bss));
+ LONG( ADDR(.bss_RAM2));
+ LONG( SIZEOF(.bss_RAM2));
+ LONG( ADDR(.bss_RAM3));
+ LONG( SIZEOF(.bss_RAM3));
+ LONG( ADDR(.bss_RAM4));
+ LONG( SIZEOF(.bss_RAM4));
+ LONG( ADDR(.bss_RAM5));
+ LONG( SIZEOF(.bss_RAM5));
+ __bss_section_table_end = .;
+ __section_table_end = . ;
+ /* End of Global Section Table */
+
+ *(.after_vectors*)
+
+ } > SPIFI
+
+ .text : ALIGN(4)
+ {
+ *(.text*)
+ *(.rodata .rodata.* .constdata .constdata.*)
+ . = ALIGN(4);
+ } > SPIFI
+ /*
+ * for exception handling/unwind - some Newlib functions (in common
+ * with C++ and STDC++) use this.
+ */
+ .ARM.extab : ALIGN(4)
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > SPIFI
+
+ __exidx_start = .;
+
+ .ARM.exidx : ALIGN(4)
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > SPIFI
+ __exidx_end = .;
+
+ _etext = .;
+
+ /* DATA section for RamLoc72 */
+
+ .data_RAM2 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM2 = .) ;
+ *(.ramfunc.$RAM2)
+ *(.ramfunc.$RamLoc72)
+ *(.data.$RAM2)
+ *(.data.$RamLoc72)
+ *(.data.$RAM2.*)
+ *(.data.$RamLoc72.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM2 = .) ;
+ } > RamLoc72 AT>SPIFI
+ /* DATA section for RamAHB32 */
+
+ .data_RAM3 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM3 = .) ;
+ *(.ramfunc.$RAM3)
+ *(.ramfunc.$RamAHB32)
+ *(.data.$RAM3)
+ *(.data.$RamAHB32)
+ *(.data.$RAM3.*)
+ *(.data.$RamAHB32.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM3 = .) ;
+ } > RamAHB32 AT>SPIFI
+ /* DATA section for RamAHB16 */
+
+ .data_RAM4 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM4 = .) ;
+ *(.ramfunc.$RAM4)
+ *(.ramfunc.$RamAHB16)
+ *(.data.$RAM4)
+ *(.data.$RamAHB16)
+ *(.data.$RAM4.*)
+ *(.data.$RamAHB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM4 = .) ;
+ } > RamAHB16 AT>SPIFI
+ /* DATA section for RamAHB_ETB16 */
+
+ .data_RAM5 : ALIGN(4)
+ {
+ FILL(0xff)
+ PROVIDE(__start_data_RAM5 = .) ;
+ *(.ramfunc.$RAM5)
+ *(.ramfunc.$RamAHB_ETB16)
+ *(.data.$RAM5)
+ *(.data.$RamAHB_ETB16)
+ *(.data.$RAM5.*)
+ *(.data.$RamAHB_ETB16.*)
+ . = ALIGN(4) ;
+ PROVIDE(__end_data_RAM5 = .) ;
+ } > RamAHB_ETB16 AT>SPIFI
+ /* MAIN DATA SECTION */
+ .uninit_RESERVED (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ KEEP(*(.bss.$RESERVED*))
+ . = ALIGN(4) ;
+ _end_uninit_RESERVED = .;
+ } > RamLoc128
+
+ /* Main DATA section (RamLoc128) */
+ .data : ALIGN(4)
+ {
+ FILL(0xff)
+ _data = . ;
+ *(vtable)
+ *(.ramfunc*)
+ *(.data*)
+ . = ALIGN(4) ;
+ _edata = . ;
+ } > RamLoc128 AT>SPIFI
+
+ /* BSS section for RamLoc72 */
+ .bss_RAM2 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM2 = .) ;
+ *(.bss.$RAM2)
+ *(.bss.$RamLoc72)
+ *(.bss.$RAM2.*)
+ *(.bss.$RamLoc72.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM2 = .) ;
+ } > RamLoc72
+
+ /* BSS section for RamAHB32 */
+ .bss_RAM3 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM3 = .) ;
+ *(.bss.$RAM3)
+ *(.bss.$RamAHB32)
+ *(.bss.$RAM3.*)
+ *(.bss.$RamAHB32.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM3 = .) ;
+ } > RamAHB32
+
+ /* BSS section for RamAHB16 */
+ .bss_RAM4 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM4 = .) ;
+ *(.bss.$RAM4)
+ *(.bss.$RamAHB16)
+ *(.bss.$RAM4.*)
+ *(.bss.$RamAHB16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM4 = .) ;
+ } > RamAHB16
+
+ /* BSS section for RamAHB_ETB16 */
+ .bss_RAM5 :
+ {
+ . = ALIGN(4) ;
+ PROVIDE(__start_bss_RAM5 = .) ;
+ *(.bss.$RAM5)
+ *(.bss.$RamAHB_ETB16)
+ *(.bss.$RAM5.*)
+ *(.bss.$RamAHB_ETB16.*)
+ . = ALIGN (. != 0 ? 4 : 1) ; /* avoid empty segment */
+ PROVIDE(__end_bss_RAM5 = .) ;
+ } > RamAHB_ETB16
+
+ /* MAIN BSS SECTION */
+ .bss :
+ {
+ . = ALIGN(4) ;
+ _bss = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4) ;
+ _ebss = .;
+ PROVIDE(end = .);
+ } > RamLoc128
+
+ /* NOINIT section for RamLoc72 */
+ .noinit_RAM2 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM2)
+ *(.noinit.$RamLoc72)
+ *(.noinit.$RAM2.*)
+ *(.noinit.$RamLoc72.*)
+ . = ALIGN(4) ;
+ } > RamLoc72
+
+ /* NOINIT section for RamAHB32 */
+ .noinit_RAM3 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM3)
+ *(.noinit.$RamAHB32)
+ *(.noinit.$RAM3.*)
+ *(.noinit.$RamAHB32.*)
+ . = ALIGN(4) ;
+ } > RamAHB32
+
+ /* NOINIT section for RamAHB16 */
+ .noinit_RAM4 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM4)
+ *(.noinit.$RamAHB16)
+ *(.noinit.$RAM4.*)
+ *(.noinit.$RamAHB16.*)
+ . = ALIGN(4) ;
+ } > RamAHB16
+
+ /* NOINIT section for RamAHB_ETB16 */
+ .noinit_RAM5 (NOLOAD) :
+ {
+ . = ALIGN(4) ;
+ *(.noinit.$RAM5)
+ *(.noinit.$RamAHB_ETB16)
+ *(.noinit.$RAM5.*)
+ *(.noinit.$RamAHB_ETB16.*)
+ . = ALIGN(4) ;
+ } > RamAHB_ETB16
+
+ /* DEFAULT NOINIT SECTION */
+ .noinit (NOLOAD):
+ {
+ . = ALIGN(4) ;
+ _noinit = .;
+ *(.noinit*)
+ . = ALIGN(4) ;
+ _end_noinit = .;
+ } > RamLoc128
+ PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+ PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc128 - 0);
+
+ /* ## Create checksum value (used in startup) ## */
+ PROVIDE(__valid_user_code_checksum = 0 -
+ (_vStackTop
+ + (ResetISR + 1)
+ + (NMI_Handler + 1)
+ + (HardFault_Handler + 1)
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ ) );
+
+ /* Provide basic symbols giving location and size of main text
+ * block, including initial values of RW data sections. Note that
+ * these will need extending to give a complete picture with
+ * complex images (e.g multiple Flash banks).
+ */
+ _image_start = LOADADDR(.text);
+ _image_end = LOADADDR(.data) + SIZEOF(.data);
+ _image_size = _image_end - _image_start;
+} \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.h
new file mode 100644
index 0000000..2c58e8f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(1, 1)
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN _PINNUM(1, 02)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.mk
new file mode 100644
index 0000000..f31899e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
+
+# flash using adafruit-nrfutil dfu
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/nrf52840_s140_v6.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/nrf52840_s140_v6.ld
new file mode 100755
index 0000000..5314a4e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/adafruit_clue/nrf52840_s140_v6.ld
@@ -0,0 +1,38 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
+
+ /* SRAM required by S132 depend on
+ * - Attribute Table Size
+ * - Vendor UUID count
+ * - Max ATT MTU
+ * - Concurrent connection peripheral + central + secure links
+ * - Event Len, HVN queue, Write CMD queue
+ */
+ RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
+}
+
+SECTIONS
+{
+ . = ALIGN(4);
+ .svc_data :
+ {
+ PROVIDE(__start_svc_data = .);
+ KEEP(*(.svc_data))
+ PROVIDE(__stop_svc_data = .);
+ } > RAM
+
+ .fs_data :
+ {
+ PROVIDE(__start_fs_data = .);
+ KEEP(*(.fs_data))
+ PROVIDE(__stop_fs_data = .);
+ } > RAM
+} INSERT AFTER .data;
+
+INCLUDE "nrf52_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
new file mode 100755
index 0000000..f570740
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
@@ -0,0 +1,32 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x10000, LENGTH = 0xf0000
+ RAM_NVIC (rwx) : ORIGIN = 0x20000000, LENGTH = 0x100
+ RAM_CRASH_DATA (rwx) : ORIGIN = (0x20000000 + 0x100), LENGTH = 0x100
+ RAM (rwx) : ORIGIN = ((0x20000000 + 0x100) + 0x100), LENGTH = (0x40000 - (0x100 + 0x100))
+}
+
+SECTIONS
+{
+ . = ALIGN(4);
+ .svc_data :
+ {
+ PROVIDE(__start_svc_data = .);
+ KEEP(*(.svc_data))
+ PROVIDE(__stop_svc_data = .);
+ } > RAM
+
+ .fs_data :
+ {
+ PROVIDE(__start_fs_data = .);
+ KEEP(*(.fs_data))
+ PROVIDE(__stop_fs_data = .);
+ } > RAM
+} INSERT AFTER .data;
+
+INCLUDE "nrf52_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.h
new file mode 100644
index 0000000..d548e01
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(0, 24)
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN _PINNUM(1, 11) // D2
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN _PINNUM(1, 10)
+#define UART_TX_PIN _PINNUM(1, 3)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk
new file mode 100644
index 0000000..94babd8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk
@@ -0,0 +1,13 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# flash using bossac (as part of Nano33 BSP tools)
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(PROJECT).bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i -e -w $^ -R
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.h
new file mode 100644
index 0000000..a86c9dc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(1, 14)
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN _PINNUM(1, 15)
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+#define UART_RX_PIN 30
+#define UART_TX_PIN 14
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk
new file mode 100644
index 0000000..f31899e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
+
+# flash using adafruit-nrfutil dfu
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld
new file mode 100755
index 0000000..5314a4e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld
@@ -0,0 +1,38 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
+
+ /* SRAM required by S132 depend on
+ * - Attribute Table Size
+ * - Vendor UUID count
+ * - Max ATT MTU
+ * - Concurrent connection peripheral + central + secure links
+ * - Event Len, HVN queue, Write CMD queue
+ */
+ RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
+}
+
+SECTIONS
+{
+ . = ALIGN(4);
+ .svc_data :
+ {
+ PROVIDE(__start_svc_data = .);
+ KEEP(*(.svc_data))
+ PROVIDE(__stop_svc_data = .);
+ } > RAM
+
+ .fs_data :
+ {
+ PROVIDE(__start_fs_data = .);
+ KEEP(*(.fs_data))
+ PROVIDE(__stop_fs_data = .);
+ } > RAM
+} INSERT AFTER .data;
+
+INCLUDE "nrf52_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.h
new file mode 100644
index 0000000..3208a94
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(1, 15)
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN _PINNUM(1, 02)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 24
+#define UART_TX_PIN 25
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk
new file mode 100644
index 0000000..f31899e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
+
+# flash using adafruit-nrfutil dfu
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/nrf52840_s140_v6.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/nrf52840_s140_v6.ld
new file mode 100644
index 0000000..5314a4e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_express/nrf52840_s140_v6.ld
@@ -0,0 +1,38 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
+
+ /* SRAM required by S132 depend on
+ * - Attribute Table Size
+ * - Vendor UUID count
+ * - Max ATT MTU
+ * - Concurrent connection peripheral + central + secure links
+ * - Event Len, HVN queue, Write CMD queue
+ */
+ RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
+}
+
+SECTIONS
+{
+ . = ALIGN(4);
+ .svc_data :
+ {
+ PROVIDE(__start_svc_data = .);
+ KEEP(*(.svc_data))
+ PROVIDE(__stop_svc_data = .);
+ } > RAM
+
+ .fs_data :
+ {
+ PROVIDE(__start_fs_data = .);
+ KEEP(*(.fs_data))
+ PROVIDE(__stop_fs_data = .);
+ } > RAM
+} INSERT AFTER .data;
+
+INCLUDE "nrf52_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h
new file mode 100644
index 0000000..ece6e34
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(1, 9)
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN _PINNUM(1, 02)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 24
+#define UART_TX_PIN 25
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk
new file mode 100644
index 0000000..f31899e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
+
+# flash using adafruit-nrfutil dfu
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/nrf52840_s140_v6.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/nrf52840_s140_v6.ld
new file mode 100644
index 0000000..5314a4e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/feather_nrf52840_sense/nrf52840_s140_v6.ld
@@ -0,0 +1,38 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
+
+ /* SRAM required by S132 depend on
+ * - Attribute Table Size
+ * - Vendor UUID count
+ * - Max ATT MTU
+ * - Concurrent connection peripheral + central + secure links
+ * - Event Len, HVN queue, Write CMD queue
+ */
+ RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
+}
+
+SECTIONS
+{
+ . = ALIGN(4);
+ .svc_data :
+ {
+ PROVIDE(__start_svc_data = .);
+ KEEP(*(.svc_data))
+ PROVIDE(__stop_svc_data = .);
+ } > RAM
+
+ .fs_data :
+ {
+ PROVIDE(__start_fs_data = .);
+ KEEP(*(.fs_data))
+ PROVIDE(__stop_fs_data = .);
+ } > RAM
+} INSERT AFTER .data;
+
+INCLUDE "nrf52_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h
new file mode 100644
index 0000000..132173a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(0, 6)
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN _PINNUM(0, 29)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 25
+#define UART_TX_PIN 24
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk
new file mode 100644
index 0000000..f31899e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk
@@ -0,0 +1,10 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
+
+# flash using adafruit-nrfutil dfu
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld
new file mode 100644
index 0000000..5314a4e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld
@@ -0,0 +1,38 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
+
+ /* SRAM required by S132 depend on
+ * - Attribute Table Size
+ * - Vendor UUID count
+ * - Max ATT MTU
+ * - Concurrent connection peripheral + central + secure links
+ * - Event Len, HVN queue, Write CMD queue
+ */
+ RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
+}
+
+SECTIONS
+{
+ . = ALIGN(4);
+ .svc_data :
+ {
+ PROVIDE(__start_svc_data = .);
+ KEEP(*(.svc_data))
+ PROVIDE(__stop_svc_data = .);
+ } > RAM
+
+ .fs_data :
+ {
+ PROVIDE(__start_fs_data = .);
+ KEEP(*(.fs_data))
+ PROVIDE(__stop_fs_data = .);
+ } > RAM
+} INSERT AFTER .data;
+
+INCLUDE "nrf52_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h
new file mode 100644
index 0000000..01dd1f2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(0, 23)
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN _PINNUM(0, 18)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 2
+#define UART_TX_PIN 3
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk
new file mode 100644
index 0000000..3afa234
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk
@@ -0,0 +1,15 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# flash using Nordic nrfutil (pip3 install nrfutil)
+# make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash
+NRFUTIL = nrfutil
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ $(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@
+
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200 \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld
new file mode 100644
index 0000000..78eddc9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld
@@ -0,0 +1,13 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xE0000-0x1000
+ RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8
+}
+
+
+INCLUDE "nrf_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.h
new file mode 100644
index 0000000..ab12d21
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 13
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN 11
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 8
+#define UART_TX_PIN 6
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.mk
new file mode 100644
index 0000000..be2ed33
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10056/board.mk
@@ -0,0 +1,7 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.h
new file mode 100644
index 0000000..0810be6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN 8
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN _PINNUM(1, 6)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 8
+#define UART_TX_PIN 6
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.mk
new file mode 100644
index 0000000..0b82ecd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/board.mk
@@ -0,0 +1,15 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# flash using Nordic nrfutil (pip2 install nrfutil)
+# make BOARD=pca10059 SERIAL=/dev/ttyACM0 all flash
+NRFUTIL = nrfutil
+
+$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
+ $(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@
+
+flash: $(BUILD)/$(PROJECT).zip
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/pca10059.ld b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/pca10059.ld
new file mode 100644
index 0000000..510bfdd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10059/pca10059.ld
@@ -0,0 +1,13 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lnosys)
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xff000
+ RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8
+}
+
+
+INCLUDE "nrf_common.ld"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.h
new file mode 100644
index 0000000..8811330
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN 13
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN 11
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 8
+#define UART_TX_PIN 6
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.mk
new file mode 100644
index 0000000..5fba269
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/pca10100/board.mk
@@ -0,0 +1,7 @@
+MCU_VARIANT = nrf52833
+CFLAGS += -DNRF52833_XXAA
+
+LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52833_xxaa.ld
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.h b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.h
new file mode 100644
index 0000000..dcf829d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN _PINNUM(1, 13)
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN _PINNUM(0, 15)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 25
+#define UART_TX_PIN 24
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk
new file mode 100644
index 0000000..be2ed33
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk
@@ -0,0 +1,7 @@
+MCU_VARIANT = nrf52840
+CFLAGS += -DNRF52840_XXAA
+
+LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/family.c b/circuitpython/lib/tinyusb/hw/bsp/nrf/family.c
new file mode 100644
index 0000000..a07332d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/family.c
@@ -0,0 +1,224 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "board.h"
+
+#include "nrfx.h"
+#include "nrfx/hal/nrf_gpio.h"
+#include "nrfx/drivers/include/nrfx_power.h"
+#include "nrfx/drivers/include/nrfx_uarte.h"
+
+#ifdef SOFTDEVICE_PRESENT
+#include "nrf_sdm.h"
+#include "nrf_soc.h"
+#endif
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USBD_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+/*------------------------------------------------------------------*/
+/* MACRO TYPEDEF CONSTANT ENUM
+ *------------------------------------------------------------------*/
+
+static nrfx_uarte_t _uart_id = NRFX_UARTE_INSTANCE(0);
+
+// tinyusb function that handles power event (detected, ready, removed)
+// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
+extern void tusb_hal_nrf_power_event(uint32_t event);
+
+
+// nrf power callback, could be unused if SD is enabled or usb is disabled (board_test example)
+TU_ATTR_UNUSED static void power_event_handler(nrfx_power_usb_evt_t event)
+{
+ tusb_hal_nrf_power_event((uint32_t) event);
+}
+
+void board_init(void)
+{
+ // stop LF clock just in case we jump from application without reset
+ NRF_CLOCK->TASKS_LFCLKSTOP = 1UL;
+
+ // Use Internal OSC to compatible with all boards
+ NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC;
+ NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
+
+ // LED
+ nrf_gpio_cfg_output(LED_PIN);
+ board_led_write(false);
+
+ // Button
+ nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP);
+
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock/1000);
+
+ // UART
+ nrfx_uarte_config_t uart_cfg =
+ {
+ .pseltxd = UART_TX_PIN,
+ .pselrxd = UART_RX_PIN,
+ .pselcts = NRF_UARTE_PSEL_DISCONNECTED,
+ .pselrts = NRF_UARTE_PSEL_DISCONNECTED,
+ .p_context = NULL,
+ .baudrate = NRF_UARTE_BAUDRATE_115200, // CFG_BOARD_UART_BAUDRATE
+ .interrupt_priority = 7,
+ .hal_cfg = {
+ .hwfc = NRF_UARTE_HWFC_DISABLED,
+ .parity = NRF_UARTE_PARITY_EXCLUDED,
+ }
+ };
+
+ nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler);
+
+ //------------- USB -------------//
+#if CFG_TUD_ENABLED
+ // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice
+ // 2 is highest for application
+ NVIC_SetPriority(USBD_IRQn, 2);
+
+ // USB power may already be ready at this time -> no event generated
+ // We need to invoke the handler based on the status initially
+ uint32_t usb_reg;
+
+#ifdef SOFTDEVICE_PRESENT
+ uint8_t sd_en = false;
+ sd_softdevice_is_enabled(&sd_en);
+
+ if ( sd_en ) {
+ sd_power_usbdetected_enable(true);
+ sd_power_usbpwrrdy_enable(true);
+ sd_power_usbremoved_enable(true);
+
+ sd_power_usbregstatus_get(&usb_reg);
+ }else
+#endif
+ {
+ // Power module init
+ const nrfx_power_config_t pwr_cfg = { 0 };
+ nrfx_power_init(&pwr_cfg);
+
+ // Register tusb function as USB power handler
+ // cause cast-function-type warning
+ const nrfx_power_usbevt_config_t config = { .handler = power_event_handler };
+ nrfx_power_usbevt_init(&config);
+
+ nrfx_power_usbevt_enable();
+
+ usb_reg = NRF_POWER->USBREGSTATUS;
+ }
+
+ if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED);
+ if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == nrf_gpio_pin_read(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+// return NRFX_SUCCESS == nrfx_uart_rx(&_uart_id, buf, (size_t) len) ? len : 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ return (NRFX_SUCCESS == nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len)) ? len : 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+#ifdef SOFTDEVICE_PRESENT
+// process SOC event from SD
+uint32_t proc_soc(void)
+{
+ uint32_t soc_evt;
+ uint32_t err = sd_evt_get(&soc_evt);
+
+ if (NRF_SUCCESS == err)
+ {
+ /*------------- usb power event handler -------------*/
+ int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED:
+ (soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY :
+ (soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1;
+
+ if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt);
+ }
+
+ return err;
+}
+
+uint32_t proc_ble(void)
+{
+ // do nothing with ble
+ return NRF_ERROR_NOT_FOUND;
+}
+
+void SD_EVT_IRQHandler(void)
+{
+ // process BLE and SOC until there is no more events
+ while( (NRF_ERROR_NOT_FOUND != proc_ble()) || (NRF_ERROR_NOT_FOUND != proc_soc()) )
+ {
+
+ }
+}
+
+void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info)
+{
+ (void) id;
+ (void) pc;
+ (void) info;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nrf/family.mk b/circuitpython/lib/tinyusb/hw/bsp/nrf/family.mk
new file mode 100644
index 0000000..d8283a9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nrf/family.mk
@@ -0,0 +1,48 @@
+UF2_FAMILY_ID = 0xADA52840
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/nordic/nrfx
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -DCFG_TUSB_MCU=OPT_MCU_NRF5X \
+ -DCONFIG_GPIO_AS_PINRESET
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual
+
+# All source paths should be relative to the top level.
+LD_FILE ?= hw/bsp/nrf/boards/$(BOARD)/nrf52840_s140_v6.ld
+
+LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk
+
+SRC_C += \
+ src/portable/nordic/nrf5x/dcd_nrf5x.c \
+ hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \
+ hw/mcu/nordic/nrfx/drivers/src/nrfx_uarte.c \
+ hw/mcu/nordic/nrfx/mdk/system_$(MCU_VARIANT).c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/hw/mcu/nordic \
+ $(TOP)/hw/mcu/nordic/nrfx \
+ $(TOP)/hw/mcu/nordic/nrfx/mdk \
+ $(TOP)/hw/mcu/nordic/nrfx/hal \
+ $(TOP)/hw/mcu/nordic/nrfx/drivers/include \
+ $(TOP)/hw/mcu/nordic/nrfx/drivers/src \
+
+SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_$(MCU_VARIANT).S
+
+ASFLAGS += -D__HEAP_SIZE=0
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = $(MCU_VARIANT)_xxaa
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/board.mk
new file mode 100644
index 0000000..ff1d5aa
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/board.mk
@@ -0,0 +1,43 @@
+DEPS_SUBMODULES += hw/mcu/nuvoton
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs-linux \
+ -mcpu=cortex-m0 \
+ -D__ARM_FEATURE_DSP=0 \
+ -DUSE_ASSERT=0 \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_NUC121
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/nuc121_flash.ld
+
+SRC_C += \
+ src/portable/nuvoton/nuc121/dcd_nuc121.c \
+ hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Source/system_NUC121.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/clk.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/fmc.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/gpio.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/sys.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/timer.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/uart.c
+
+SRC_S += \
+ hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Source/GCC/startup_NUC121.S
+
+INC += \
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Include \
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/StdDriver/inc \
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = NUC121SC2AE
+
+# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
+# Please compile and install it from github source
+flash: $(BUILD)/$(PROJECT).elf
+ openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nuc121_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nuc121_flash.ld
new file mode 100644
index 0000000..3966b27
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nuc121_flash.ld
@@ -0,0 +1,195 @@
+/* Linker script to configure memory regions. */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x8000 /* 32k */
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x2000 /* 8k */
+}
+
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __copy_table_start__
+ * __copy_table_end__
+ * __zero_table_start__
+ * __zero_table_end__
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __Vectors_End
+ * __Vectors_Size
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+ __end__ = .;
+
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c
new file mode 100644
index 0000000..7117a34
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c
@@ -0,0 +1,121 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "NuMicro.h"
+#include "clk.h"
+#include "sys.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USBD_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT PB
+#define LED_PIN 4
+#define LED_PIN_IO PB4
+#define LED_STATE_ON 0
+
+void board_init(void)
+{
+ /* Unlock protected registers */
+ SYS_UnlockReg();
+
+ /*---------------------------------------------------------------------------------------------------------*/
+ /* Init System Clock */
+ /*---------------------------------------------------------------------------------------------------------*/
+
+ /* Enable Internal HIRC 48 MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN);
+
+ /* Waiting for Internal RC clock ready */
+ CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
+
+ /* Switch HCLK clock source to Internal HIRC and HCLK source divide 1 */
+ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));
+
+ /* Enable module clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+ /* Select module clock source */
+ CLK_SetModuleClock(USBD_MODULE, CLK_CLKSEL3_USBDSEL_HIRC, CLK_CLKDIV0_USB(1));
+
+ /* Enable module clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(48000000 / 1000);
+#endif
+
+ // LED
+ GPIO_SetMode(LED_PORT, 1 << LED_PIN, GPIO_MODE_OUTPUT);
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ LED_PIN_IO = (state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/board.mk
new file mode 100644
index 0000000..bb56e42
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/board.mk
@@ -0,0 +1,39 @@
+DEPS_SUBMODULES += hw/mcu/nuvoton
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs-linux \
+ -mcpu=cortex-m0 \
+ -D__ARM_FEATURE_DSP=0 \
+ -DUSE_ASSERT=0 \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_NUC121
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/nuc125_flash.ld
+
+SRC_C += \
+ src/portable/nuvoton/nuc121/dcd_nuc121.c \
+ hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Source/system_NUC121.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/clk.c \
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/gpio.c
+
+SRC_S += \
+ hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Source/GCC/startup_NUC121.S
+
+INC += \
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Include \
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/StdDriver/inc \
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = NUC125SC2AE
+
+# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
+# Please compile and install it from github source
+flash: $(BUILD)/$(PROJECT).elf
+ openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nuc125_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nuc125_flash.ld
new file mode 100644
index 0000000..3966b27
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nuc125_flash.ld
@@ -0,0 +1,195 @@
+/* Linker script to configure memory regions. */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x8000 /* 32k */
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x2000 /* 8k */
+}
+
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __copy_table_start__
+ * __copy_table_end__
+ * __zero_table_start__
+ * __zero_table_end__
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __Vectors_End
+ * __Vectors_Size
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+ __end__ = .;
+
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c
new file mode 100644
index 0000000..7117a34
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c
@@ -0,0 +1,121 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "NuMicro.h"
+#include "clk.h"
+#include "sys.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USBD_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT PB
+#define LED_PIN 4
+#define LED_PIN_IO PB4
+#define LED_STATE_ON 0
+
+void board_init(void)
+{
+ /* Unlock protected registers */
+ SYS_UnlockReg();
+
+ /*---------------------------------------------------------------------------------------------------------*/
+ /* Init System Clock */
+ /*---------------------------------------------------------------------------------------------------------*/
+
+ /* Enable Internal HIRC 48 MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN);
+
+ /* Waiting for Internal RC clock ready */
+ CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
+
+ /* Switch HCLK clock source to Internal HIRC and HCLK source divide 1 */
+ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));
+
+ /* Enable module clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+ /* Select module clock source */
+ CLK_SetModuleClock(USBD_MODULE, CLK_CLKSEL3_USBDSEL_HIRC, CLK_CLKDIV0_USB(1));
+
+ /* Enable module clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(48000000 / 1000);
+#endif
+
+ // LED
+ GPIO_SetMode(LED_PORT, 1 << LED_PIN, GPIO_MODE_OUTPUT);
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ LED_PIN_IO = (state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/board.mk
new file mode 100644
index 0000000..4f0ebf2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/board.mk
@@ -0,0 +1,45 @@
+DEPS_SUBMODULES += hw/mcu/nuvoton
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs-linux \
+ -mcpu=cortex-m0 \
+ -D__ARM_FEATURE_DSP=0 \
+ -DUSE_ASSERT=0 \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+ -D__CORTEX_SC=0 \
+ -DCFG_TUSB_MCU=OPT_MCU_NUC126
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/nuc126_flash.ld
+
+SRC_C += \
+ src/portable/nuvoton/nuc121/dcd_nuc121.c \
+ hw/mcu/nuvoton/nuc126/Device/Nuvoton/NUC126/Source/system_NUC126.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/clk.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/crc.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/gpio.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/rtc.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/sys.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/timer.c \
+ hw/mcu/nuvoton/nuc126/StdDriver/src/uart.c
+
+SRC_S += \
+ hw/mcu/nuvoton/nuc126/Device/Nuvoton/NUC126/Source/GCC/startup_NUC126.S
+
+INC += \
+ $(TOP)/hw/mcu/nuvoton/nuc126/Device/Nuvoton/NUC126/Include \
+ $(TOP)/hw/mcu/nuvoton/nuc126/StdDriver/inc \
+ $(TOP)/hw/mcu/nuvoton/nuc126/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = NUC126VG4AE
+
+# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
+# Please compile and install it from github source
+flash: $(BUILD)/$(PROJECT).elf
+ openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nuc126_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nuc126_flash.ld
new file mode 100644
index 0000000..b23890b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nuc126_flash.ld
@@ -0,0 +1,195 @@
+/* Linker script to configure memory regions. */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 /* 256k */
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x5000 /* 20k */
+}
+
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __copy_table_start__
+ * __copy_table_end__
+ * __zero_table_start__
+ * __zero_table_end__
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __Vectors_End
+ * __Vectors_Size
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+ __end__ = .;
+
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c
new file mode 100644
index 0000000..da62e7b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c
@@ -0,0 +1,153 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "NuMicro.h"
+#include "clk.h"
+#include "sys.h"
+
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USBD_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT PC
+#define LED_PIN 9
+#define LED_PIN_IO PC9
+#define LED_STATE_ON 0
+
+#define CRYSTAL_LESS /* system will be 48MHz when defined, otherwise, system is 72MHz */
+#define HIRC48_AUTO_TRIM SYS_IRCTCTL1_REFCKSEL_Msk | (1UL << SYS_IRCTCTL1_LOOPSEL_Pos) | (2UL << SYS_IRCTCTL1_FREQSEL_Pos)
+#define TRIM_INIT (SYS_BASE+0x118)
+
+void board_init(void)
+{
+ /* Unlock protected registers */
+ SYS_UnlockReg();
+
+ /*---------------------------------------------------------------------------------------------------------*/
+ /* Init System Clock */
+ /*---------------------------------------------------------------------------------------------------------*/
+
+ /* Enable Internal RC 22.1184 MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
+
+ /* Waiting for Internal RC clock ready */
+ CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
+
+ /* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
+ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));
+
+#ifndef CRYSTAL_LESS
+ /* Enable external XTAL 12 MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);
+
+ /* Waiting for external XTAL clock ready */
+ CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);
+
+ /* Set core clock */
+ CLK_SetCoreClock(72000000);
+
+ /* Use HIRC as UART clock source */
+ CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UARTSEL_HIRC, CLK_CLKDIV0_UART(1));
+
+ /* Use PLL as USB clock source */
+ CLK_SetModuleClock(USBD_MODULE, CLK_CLKSEL3_USBDSEL_PLL, CLK_CLKDIV0_USB(3));
+
+#else
+ /* Enable Internal RC 48MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCTL_HIRC48EN_Msk);
+
+ /* Waiting for Internal RC clock ready */
+ CLK_WaitClockReady(CLK_STATUS_HIRC48STB_Msk);
+
+ /* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
+ CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC48, CLK_CLKDIV0_HCLK(1));
+
+ /* Use HIRC as UART clock source */
+ CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UARTSEL_HIRC, CLK_CLKDIV0_UART(1));
+
+ /* Use HIRC48 as USB clock source */
+ CLK_SetModuleClock(USBD_MODULE, CLK_CLKSEL3_USBDSEL_HIRC48, CLK_CLKDIV0_USB(1));
+#endif
+
+ /* Enable module clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(48000000 / 1000);
+#endif
+
+ // LED
+ GPIO_SetMode(LED_PORT, 1 << LED_PIN, GPIO_MODE_OUTPUT);
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ LED_PIN_IO = (state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/board.mk
new file mode 100644
index 0000000..4d7aac7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/board.mk
@@ -0,0 +1,41 @@
+DEPS_SUBMODULES += hw/mcu/nuvoton
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs-linux \
+ -mcpu=cortex-m0 \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_NUC120
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld
+
+SRC_C += \
+ src/portable/nuvoton/nuc120/dcd_nuc120.c \
+ hw/mcu/nuvoton/nuc100_120/Device/Nuvoton/NUC100Series/Source/system_NUC100Series.c \
+ hw/mcu/nuvoton/nuc100_120/StdDriver/src/clk.c \
+ hw/mcu/nuvoton/nuc100_120/StdDriver/src/gpio.c \
+ hw/mcu/nuvoton/nuc100_120/StdDriver/src/sys.c \
+ hw/mcu/nuvoton/nuc100_120/StdDriver/src/timer.c \
+ hw/mcu/nuvoton/nuc100_120/StdDriver/src/uart.c
+
+SRC_S += \
+ hw/mcu/nuvoton/nuc100_120/Device/Nuvoton/NUC100Series/Source/GCC/startup_NUC100Series.S
+
+INC += \
+ $(TOP)/hw/mcu/nuvoton/nuc100_120/Device/Nuvoton/NUC100Series/Include \
+ $(TOP)/hw/mcu/nuvoton/nuc100_120/StdDriver/inc \
+ $(TOP)/hw/mcu/nuvoton/nuc100_120/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = NUC120LE3
+
+# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
+# Please compile and install it from github source
+flash: $(BUILD)/$(PROJECT).elf
+ openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld
new file mode 100644
index 0000000..cab12c8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld
@@ -0,0 +1,195 @@
+/* Linker script to configure memory regions. */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x20000 /* 128k */
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 /* 16k */
+}
+
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __copy_table_start__
+ * __copy_table_end__
+ * __zero_table_start__
+ * __zero_table_end__
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __Vectors_End
+ * __Vectors_Size
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .text :
+ {
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+ __end__ = .;
+
+ *(.text*)
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c
new file mode 100644
index 0000000..0d78116
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c
@@ -0,0 +1,133 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "NUC100Series.h"
+#include "clk.h"
+#include "sys.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USBD_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT PB
+#define LED_PIN 0
+#define LED_PIN_IO PB0
+#define LED_STATE_ON 0
+
+void board_init(void)
+{
+ SYS_UnlockReg();
+
+ /* Enable Internal RC 22.1184 MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk);
+
+ /* Waiting for Internal RC clock ready */
+ CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk);
+
+ /* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
+ CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1));
+
+ /* Enable external XTAL 12 MHz clock */
+ CLK_EnableXtalRC(CLK_PWRCON_XTL12M_EN_Msk);
+
+ /* Waiting for external XTAL clock ready */
+ CLK_WaitClockReady(CLK_CLKSTATUS_XTL12M_STB_Msk);
+
+ /* Set core clock */
+ CLK_SetCoreClock(48000000);
+
+ /* Enable module clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+ /* Select module clock source */
+ CLK_SetModuleClock(USBD_MODULE, 0, CLK_CLKDIV_USB(1));
+
+ SYS_LockReg();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(48000000 / 1000);
+#endif
+
+ GPIO_SetMode(LED_PORT, 1UL << LED_PIN, GPIO_PMD_OUTPUT);
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+#if 0
+ /* this would be the simplest solution... *IF* the part supported the pin data interface */
+ LED_PIN_IO = (state) ? LED_STATE_ON : (1-LED_STATE_ON);
+#else
+ /* if the part's *PDIO pin data registers don't work, a more elaborate approach is needed */
+ uint32_t irq_state = __get_PRIMASK();
+ __disable_irq();
+ uint32_t current = LED_PORT->DOUT & ~(1UL << LED_PIN);
+ LED_PORT->DOUT = current | (((state) ? LED_STATE_ON : (1UL-LED_STATE_ON)) << LED_PIN);
+ __set_PRIMASK(irq_state);
+#endif
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/board.mk b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/board.mk
new file mode 100644
index 0000000..e851434
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/board.mk
@@ -0,0 +1,60 @@
+DEPS_SUBMODULES += hw/mcu/nuvoton
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs-linux \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -DCFG_TUSB_MCU=OPT_MCU_NUC505
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/nuc505_flashtoram.ld
+
+SRC_C += \
+ src/portable/nuvoton/nuc505/dcd_nuc505.c \
+ hw/mcu/nuvoton/nuc505/Device/Nuvoton/NUC505Series/Source/system_NUC505Series.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/adc.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/clk.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/gpio.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/i2c.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/i2s.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/pwm.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/rtc.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/spi.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/spim.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/sys.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/timer.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/uart.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/wdt.c \
+ hw/mcu/nuvoton/nuc505/StdDriver/src/wwdt.c
+
+SRC_S += \
+ hw/mcu/nuvoton/nuc505/Device/Nuvoton/NUC505Series/Source/GCC/startup_NUC505Series.S
+
+INC += \
+ $(TOP)/hw/mcu/nuvoton/nuc505/Device/Nuvoton/NUC505Series/Include \
+ $(TOP)/hw/mcu/nuvoton/nuc505/StdDriver/inc \
+ $(TOP)/hw/mcu/nuvoton/nuc505/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = NUC505YO13Y
+
+# Note
+# To be able to program the SPI flash, it need to boot with ICP mode "1011".
+# However, in ICP mode, opencod cannot establish connection to the mcu.
+# Therefore, there is no easy command line flash for NUC505
+# It is probably better to just use Nuvoton NuMicro ICP programming on windows to program the board
+# - 1111 "SPI" (run from internal flash)
+# - 1110 "USB" (mass storage emulator that accepts a .bin file)
+# - 0111 "ICE-SPI" (allow external debugger access, but may not be programmable)
+# - 1011 ICP mode (programmable via NuMicro ICP programming tool)
+
+# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
+# Please compile and install it from github source
+flash: $(BUILD)/$(PROJECT).elf
+ openocd -f interface/nulink.cfg -f target/numicroM4.cfg -c "program $< reset exit"
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld
new file mode 100644
index 0000000..53d385c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld
@@ -0,0 +1,199 @@
+/* Linker script to configure memory regions. */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000 /* 512k */
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 /* 128k */
+}
+
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __copy_table_start__
+ * __copy_table_end__
+ * __zero_table_start__
+ * __zero_table_end__
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ * __Vectors_End
+ * __Vectors_Size
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+ .startup :
+ {
+ KEEP(*(.vectors))
+ __Vectors_End = .;
+ __Vectors_Size = __Vectors_End - __Vectors;
+ __end__ = .;
+
+ KEEP(*(.preinit))
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > FLASH
+ __exidx_end = .;
+
+ /* To copy multiple ROM to RAM sections,
+ * uncomment .copy.table section and,
+ * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .copy.table :
+ {
+ . = ALIGN(4);
+ __copy_table_start__ = .;
+ LONG (__etext)
+ LONG (__data_start__)
+ LONG (__data_end__ - __data_start__)
+ LONG (__etext2)
+ LONG (__data2_start__)
+ LONG (__data2_end__ - __data2_start__)
+ __copy_table_end__ = .;
+ } > FLASH
+ */
+
+ /* To clear multiple BSS sections,
+ * uncomment .zero.table section and,
+ * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
+ /*
+ .zero.table :
+ {
+ . = ALIGN(4);
+ __zero_table_start__ = .;
+ LONG (__bss_start__)
+ LONG (__bss_end__ - __bss_start__)
+ LONG (__bss2_start__)
+ LONG (__bss2_end__ - __bss2_start__)
+ __zero_table_end__ = .;
+ } > FLASH
+ */
+
+ __etext = .;
+
+ .data : AT (__etext)
+ {
+ __data_start__ = .;
+
+ *(.text*)
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ *(.rodata*)
+
+ KEEP(*(.eh_frame*))
+
+ *(vtable)
+ *(.data*)
+
+ . = ALIGN(4);
+ /* preinit data */
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP(*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+
+ . = ALIGN(4);
+ /* init data */
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+
+
+ . = ALIGN(4);
+ /* finit data */
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+
+ KEEP(*(.jcr*))
+ . = ALIGN(4);
+ /* All data end */
+ __data_end__ = .;
+
+ } > RAM
+
+ .bss :
+ {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+ } > RAM
+
+ .heap (COPY):
+ {
+ __HeapBase = .;
+ __end__ = .;
+ end = __end__;
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ } > RAM
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ KEEP(*(.stack*))
+ } > RAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c
new file mode 100644
index 0000000..49e66d2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c
@@ -0,0 +1,129 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "bsp/board.h"
+#include "NUC505Series.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USBD_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT PC
+#define LED_PIN 3
+#define LED_STATE_ON 0
+
+void board_init(void)
+{
+ /* Enable XTAL */
+ CLK->PWRCTL |= CLK_PWRCTL_HXTEN_Msk;
+
+ CLK_SetCoreClock(96000000);
+
+ /* Set PCLK divider */
+ CLK_SetModuleClock(PCLK_MODULE, 0, 1);
+
+ /* Update System Core Clock */
+ SystemCoreClockUpdate();
+
+ /* Enable USB IP clock */
+ CLK_EnableModuleClock(USBD_MODULE);
+
+ /* Select USB IP clock source */
+ CLK_SetModuleClock(USBD_MODULE, CLK_USBD_SRC_EXT, 0);
+
+ CLK_SetModuleClock(PCLK_MODULE, 0, 1);
+
+ /* Enable PHY */
+ USBD_ENABLE_PHY();
+ /* wait PHY clock ready */
+ while (1) {
+ USBD->EP[EPA].EPMPS = 0x20;
+ if (USBD->EP[EPA].EPMPS == 0x20)
+ break;
+ }
+
+ /* Force SE0, and then clear it to connect*/
+ USBD_SET_SE0();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(96000000 / 1000);
+#endif
+
+ GPIO_SetMode(LED_PORT, 1UL << LED_PIN, GPIO_MODE_OUTPUT);
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ uint32_t current = (state) ? LED_STATE_ON : (1-LED_STATE_ON);
+ current <<= LED_PIN;
+ uint32_t irq_state = __get_PRIMASK();
+ __disable_irq();
+ current |= LED_PORT->DOUT & ~(1UL << LED_PIN);
+ LED_PORT->DOUT = current;
+ __set_PRIMASK(irq_state);
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/board.mk b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/board.mk
new file mode 100644
index 0000000..3df5ed9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/board.mk
@@ -0,0 +1,5 @@
+JLINK_DEVICE=PIC32MZ2048EFH064
+JLINK_IF=ICSP
+
+CFLAGS += \
+ -mprocessor=32MZ2048EFH064 \
diff --git a/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/olimex_emz64.c b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/olimex_emz64.c
new file mode 100644
index 0000000..e47ec5f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_emz64/olimex_emz64.c
@@ -0,0 +1,144 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2022 Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <xc.h>
+#include "tusb.h"
+
+/* JTAG on, WDT off */
+#pragma config FDMTEN=0, FSOSCEN=0, DMTCNT=1
+#pragma config DEBUG=ON
+#pragma config JTAGEN=ON
+#pragma config FSLEEP=OFF
+#pragma config TRCEN=OFF
+#pragma config ICESEL=ICS_PGx2
+
+#pragma config POSCMOD = EC
+#pragma config FNOSC = SPLL
+/* 24MHz posc input to pll, div by 3, multiply by 50, div by 2 -> 200mhz*/
+#pragma config FPLLICLK=0, FPLLIDIV=DIV_3, FPLLRNG=RANGE_5_10_MHZ, FPLLMULT=MUL_50, FPLLODIV=DIV_2
+#pragma config FUSBIDIO=1
+#pragma config WINDIS=NORMAL
+#pragma config WDTSPGM=1
+#pragma config WDTPS=15
+#pragma config FWDTEN=OFF
+
+void button_init(void)
+{
+ // RB12 - button
+ // ANSELB B12 not analog
+ ANSELBCLR = TU_BIT(12);
+ // TRISB B12 input
+ TRISBSET = TU_BIT(12);
+ // Pull-up
+ CNPUBSET = TU_BIT(12);
+}
+
+void led_init(void)
+{
+ // RB8 - LED
+ // ANASELB RB8 not analog
+ ANSELBCLR = TU_BIT(8);
+ // TRISH RH2 output
+ TRISBCLR = TU_BIT(8);
+ // Initial value 0, LED off
+ LATBCLR = TU_BIT(8);
+}
+
+void uart_init(void)
+{
+ // RD4/RD0 Uart4 TX/RX
+ // ANSELD - not present on 64 pin device
+
+ /* Unlock system for PPS configuration */
+ SYSKEY = 0x00000000;
+ SYSKEY = 0xAA996655;
+ SYSKEY = 0x556699AA;
+ CFGCONbits.IOLOCK = 0;
+
+ // PPS Input Remapping
+ // U4RX -> RD0
+ U4RXR = 3;
+
+ // PPS Output Remapping
+ // RD4 -> U4TX
+ RPD4R = 2;
+
+ // Lock back the system after PPS configuration
+ CFGCONbits.IOLOCK = 1;
+ SYSKEY = 0x00000000;
+
+ // UART4
+ // High speed mode
+ // 8 bits, no parity, no RTS/CTS, no flow control
+ U4MODE = 0x0;
+
+ // Enable UART2 Receiver and Transmitter
+ U4STASET = (_U4STA_UTXEN_MASK | _U4STA_URXEN_MASK | _U4STA_UTXISEL1_MASK);
+
+ // BAUD Rate register Setup
+ U4BRG = 100000000 / (16 * 115200) + 1;
+
+ // Disable Interrupts
+ IEC4CLR = _IEC5_U4EIE_MASK | _IEC5_U4RXIE_MASK | _IEC5_U4TXIE_MASK;
+
+ // Turn ON UART2
+ U4MODESET = _U4MODE_ON_MASK;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ if (state)
+ {
+ LATBSET = TU_BIT(8);
+ }
+ else
+ {
+ LATBCLR = TU_BIT(8);
+ }
+}
+
+uint32_t board_button_read(void)
+{
+ return ((PORTB >> 12) & 1) == 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ int i = len;
+ uint8_t const * data = buf;
+ while (i--)
+ {
+ while (U4STAbits.UTXBF) ;
+ U4TXREG = *data++;
+ }
+ return len;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/board.mk b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/board.mk
new file mode 100644
index 0000000..a43b62d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/board.mk
@@ -0,0 +1,5 @@
+JLINK_DEVICE=PIC32MZ2048EFM144
+JLINK_IF=ICSP
+
+CFLAGS += \
+ -mprocessor=32MZ2048EFM144 \
diff --git a/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/olimex_hmz144.c b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/olimex_hmz144.c
new file mode 100644
index 0000000..93a8da5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/boards/olimex_hmz144/olimex_hmz144.c
@@ -0,0 +1,142 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2022 Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <xc.h>
+#include "tusb.h"
+
+/* JTAG on, WDT off */
+#pragma config FDMTEN=0, FSOSCEN=0, DMTCNT=1
+#pragma config DEBUG=ON
+#pragma config JTAGEN=ON
+#pragma config FSLEEP=OFF
+#pragma config TRCEN=OFF
+#pragma config ICESEL=ICS_PGx2
+
+#pragma config POSCMOD = HS
+#pragma config FNOSC = SPLL
+/* 24MHz posc input to pll, div by 3, multiply by 50, div by 2 -> 200mhz*/
+#pragma config FPLLICLK=0, FPLLIDIV=DIV_3, FPLLRNG=RANGE_5_10_MHZ, FPLLMULT=MUL_50, FPLLODIV=DIV_2
+#pragma config FUSBIDIO=1
+#pragma config WINDIS=NORMAL
+#pragma config WDTSPGM=1
+#pragma config WDTPS=15
+#pragma config FWDTEN=OFF
+
+void button_init(void)
+{
+ // RB12 - button
+ // ANSELB B12 not analog
+ ANSELBCLR = TU_BIT(12);
+ // TRISB B12 input
+ TRISBSET = TU_BIT(12);
+}
+
+void led_init(void)
+{
+ // RH2 - LED
+ // ANASELH no analog function on RH2
+ // TRISH RH2 output
+ TRISHCLR = TU_BIT(2);
+ // Initial value 0, LED off
+ LATHCLR = TU_BIT(2);
+}
+
+void uart_init(void)
+{
+ // RE8/RE9 Uart2 TX/RX
+ // ANSELE - TX/RX not analog
+ ANSELECLR = TU_BIT(8) | TU_BIT(9);
+
+ /* Unlock system for PPS configuration */
+ SYSKEY = 0x00000000;
+ SYSKEY = 0xAA996655;
+ SYSKEY = 0x556699AA;
+ CFGCONbits.IOLOCK = 0;
+
+ // PPS Input Remapping
+ // U2RX -> RE9
+ U2RXR = 13;
+
+ // PPS Output Remapping
+ // RE8 -> U2TX
+ RPE8R = 2;
+
+ // Lock back the system after PPS configuration
+ CFGCONbits.IOLOCK = 1;
+ SYSKEY = 0x00000000;
+
+ // UART2
+ // High speed mode
+ // 8 bits, no parity, no RTS/CTS, no flow control
+ U2MODE = 0x0;
+
+ // Enable UART2 Receiver and Transmitter
+ U2STASET = (_U2STA_UTXEN_MASK | _U2STA_URXEN_MASK | _U2STA_UTXISEL1_MASK);
+
+ // BAUD Rate register Setup
+ U2BRG = 100000000 / (16 * 115200) + 1;
+
+ // Disable Interrupts
+ IEC4CLR = _IEC4_U2EIE_MASK | _IEC4_U2RXIE_MASK | _IEC4_U2TXIE_MASK;
+
+ // Turn ON UART2
+ U2MODESET = _U2MODE_ON_MASK;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ if (state)
+ {
+ LATHSET = TU_BIT(2);
+ }
+ else
+ {
+ LATHCLR = TU_BIT(2);
+ }
+}
+
+uint32_t board_button_read(void)
+{
+ return ((PORTB >> 12) & 1) == 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ int i = len;
+ uint8_t const * data = buf;
+ while (i--)
+ {
+ while (U2STAbits.UTXBF) ;
+ U2TXREG = *data++;
+ }
+ return len;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.c b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.c
new file mode 100644
index 0000000..786f049
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.c
@@ -0,0 +1,110 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2022 Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <xc.h>
+#include "tusb.h"
+
+void __attribute__((interrupt(IPL2AUTO), vector(_USB_VECTOR), no_fpu))
+USBD_IRQHandler(void)
+{
+ IFS4CLR = _IFS4_USBIF_MASK;
+ tud_int_handler(0);
+}
+
+TU_ATTR_WEAK void button_init(void)
+{
+}
+
+TU_ATTR_WEAK void led_init(void)
+{
+}
+
+TU_ATTR_WEAK void uart_init(void)
+{
+}
+
+void board_init(void)
+{
+ button_init();
+ led_init();
+ uart_init();
+
+ // Force device mode by overriding USB ID and settings it to 1
+ USBCRCONbits.PHYIDEN = 0;
+ USBCRCONbits.USBIDVAL = 1;
+ USBCRCONbits.USBIDOVEN = 1;
+
+ // set interrupt priority (must much IPL2AUTO)
+ IPC33CLR = _IPC33_USBIP_MASK;
+ IPC33SET = (2 << _IPC33_USBIP_POSITION);
+ // set interrupt subpriority
+ IPC33CLR = _IPC33_USBIS_MASK;
+ IPC33SET = (0 << _IPC33_USBIS_POSITION);
+
+ USBCRCONbits.USBIE = 0;
+ IFS4CLR = _IFS4_USBIF_MASK;
+ IEC4SET = _IEC4_USBIE_MASK;
+
+ __builtin_enable_interrupts();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+TU_ATTR_WEAK void board_led_write(bool state)
+{
+ (void) state;
+}
+
+TU_ATTR_WEAK uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+TU_ATTR_WEAK int board_uart_read(uint8_t * buf, int len)
+{
+ (void) buf;
+ (void) len;
+
+ return 0;
+}
+
+TU_ATTR_WEAK int board_uart_write(void const * buf, int len)
+{
+ (void) buf;
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+uint32_t board_millis(void)
+{
+ // COUNTER is system clock (200MHz / 2 = 100MHz) convert to ms)
+ return _CP0_GET_COUNT() / (100000000 / 1000);
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.mk b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.mk
new file mode 100644
index 0000000..48e0868
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/pic32mz/family.mk
@@ -0,0 +1,20 @@
+CROSS_COMPILE = xc32-
+CFLAGS_OPTIMIZED = -O2
+LIBS_GCC = -lgcc -lm
+SKIP_NANOLIB = 1
+
+CFLAGS = \
+ -std=c99 \
+ -DCFG_TUSB_MCU=OPT_MCU_PIC32MZ
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+SRC_C += \
+ src/portable/microchip/pic32mz/dcd_pic32mz.c \
+
+INC += \
+ $(TOP)/hw/mcu/microchip/pic32mz \
+ $(TOP)/$(BOARD_PATH) \
+
+# flash target using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/board.h b/circuitpython/lib/tinyusb/hw/bsp/rp2040/board.h
new file mode 100644
index 0000000..237f29d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/board.h
@@ -0,0 +1,53 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef PICO_DEFAULT_LED_PIN
+#define LED_PIN PICO_DEFAULT_LED_PIN
+#define LED_STATE_ON (!(PICO_DEFAULT_LED_PIN_INVERTED))
+#endif
+
+// Button pin is BOOTSEL which is flash CS pin
+#define BUTTON_BOOTSEL
+#define BUTTON_STATE_ACTIVE 0
+
+#if defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && defined(PICO_DEFAULT_UART)
+#define UART_DEV PICO_DEFAULT_UART
+#define UART_TX_PIN PICO_DEFAULT_UART_TX_PIN
+#define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake
new file mode 100644
index 0000000..e527a8c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_feather_rp2040/board.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD adafruit_feather_rp2040) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake
new file mode 100644
index 0000000..3fd2dd0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_itsybitsy_rp2040/board.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD adafruit_itsybitsy_rp2040) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake
new file mode 100644
index 0000000..469929c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/adafruit_qtpy_rp2040/board.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD adafruit_qtpy_rp2040) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/pico_sdk/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/pico_sdk/board.cmake
new file mode 100644
index 0000000..d57cbe5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/pico_sdk/board.cmake
@@ -0,0 +1 @@
+# This builds with settings based purely on the current PICO_BOARD set via the SDK
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake
new file mode 100644
index 0000000..8280c83
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/boards/raspberry_pi_pico/board.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD pico) \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.c b/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.c
new file mode 100644
index 0000000..fa63dad
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.c
@@ -0,0 +1,199 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "pico/stdlib.h"
+#include "pico/binary_info.h"
+#include "hardware/gpio.h"
+#include "hardware/sync.h"
+#include "hardware/structs/ioqspi.h"
+#include "hardware/structs/sio.h"
+
+#include "bsp/board.h"
+#include "board.h"
+
+#ifdef BUTTON_BOOTSEL
+// This example blinks the Picoboard LED when the BOOTSEL button is pressed.
+//
+// Picoboard has a button attached to the flash CS pin, which the bootrom
+// checks, and jumps straight to the USB bootcode if the button is pressed
+// (pulling flash CS low). We can check this pin in by jumping to some code in
+// SRAM (so that the XIP interface is not required), floating the flash CS
+// pin, and observing whether it is pulled low.
+//
+// This doesn't work if others are trying to access flash at the same time,
+// e.g. XIP streamer, or the other core.
+bool __no_inline_not_in_flash_func(get_bootsel_button)() {
+ const uint CS_PIN_INDEX = 1;
+
+ // Must disable interrupts, as interrupt handlers may be in flash, and we
+ // are about to temporarily disable flash access!
+ uint32_t flags = save_and_disable_interrupts();
+
+ // Set chip select to Hi-Z
+ hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,
+ GPIO_OVERRIDE_LOW << IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_LSB,
+ IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_BITS);
+
+ // Note we can't call into any sleep functions in flash right now
+ for (volatile int i = 0; i < 1000; ++i);
+
+ // The HI GPIO registers in SIO can observe and control the 6 QSPI pins.
+ // Note the button pulls the pin *low* when pressed.
+ bool button_state = (sio_hw->gpio_hi_in & (1u << CS_PIN_INDEX));
+
+ // Need to restore the state of chip select, else we are going to have a
+ // bad time when we return to code in flash!
+ hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,
+ GPIO_OVERRIDE_NORMAL << IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_LSB,
+ IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_BITS);
+
+ restore_interrupts(flags);
+
+ return button_state;
+}
+#endif
+
+//------------- Segger RTT retarget -------------//
+#if defined(LOGGER_RTT)
+
+// Logging with RTT
+// - If RTT Control Block is not found by 'Auto Detection` try to use 'Search Range` with '0x20000000 0x10000'
+// - SWD speed is rather slow around 1000Khz
+
+#include "pico/stdio/driver.h"
+#include "SEGGER_RTT.h"
+
+static void stdio_rtt_write (const char *buf, int length)
+{
+ SEGGER_RTT_Write(0, buf, length);
+}
+
+static int stdio_rtt_read (char *buf, int len)
+{
+ return SEGGER_RTT_Read(0, buf, len);
+}
+
+static stdio_driver_t stdio_rtt =
+{
+ .out_chars = stdio_rtt_write,
+ .out_flush = NULL,
+ .in_chars = stdio_rtt_read
+};
+
+void stdio_rtt_init(void)
+{
+ stdio_set_driver_enabled(&stdio_rtt, true);
+}
+
+#endif
+
+#ifdef UART_DEV
+static uart_inst_t *uart_inst;
+#endif
+
+void board_init(void)
+{
+#ifdef LED_PIN
+ bi_decl(bi_1pin_with_name(LED_PIN, "LED"));
+ gpio_init(LED_PIN);
+ gpio_set_dir(LED_PIN, GPIO_OUT);
+#endif
+
+ // Button
+#ifndef BUTTON_BOOTSEL
+#endif
+
+#if defined(UART_DEV) && defined(LIB_PICO_STDIO_UART)
+ bi_decl(bi_2pins_with_func(UART_TX_PIN, UART_TX_PIN, GPIO_FUNC_UART));
+ uart_inst = uart_get_instance(UART_DEV);
+ stdio_uart_init_full(uart_inst, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN);
+#endif
+
+#if defined(LOGGER_RTT)
+ stdio_rtt_init();
+#endif
+
+ // todo probably set up device mode?
+#if CFG_TUD_ENABLED
+
+#endif
+
+#if CFG_TUH_ENABLED
+ // set portfunc to host !!!
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+#ifdef LED_PIN
+ gpio_put(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+#endif
+}
+
+uint32_t board_button_read(void)
+{
+#ifdef BUTTON_BOOTSEL
+ return BUTTON_STATE_ACTIVE == get_bootsel_button();
+#else
+ return 0;
+#endif
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+#ifdef UART_DEV
+ for(int i=0;i<len;i++) {
+ buf[i] = uart_getc(uart_inst);
+ }
+ return len;
+#else
+ return 0;
+#endif
+}
+
+int board_uart_write(void const * buf, int len)
+{
+#ifdef UART_DEV
+ char const* bufch = (char const*) buf;
+ for(int i=0;i<len;i++) {
+ uart_putc(uart_inst, bufch[i]);
+ }
+ return len;
+#else
+ return 0;
+#endif
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+// rp2040 implementation will install approriate handler when initializing
+// tinyusb. There is no need to forward IRQ from application
+//--------------------------------------------------------------------+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.cmake
new file mode 100644
index 0000000..1aa180e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.cmake
@@ -0,0 +1,179 @@
+cmake_minimum_required(VERSION 3.13)
+if (NOT TARGET _rp2040_family_inclusion_marker)
+ add_library(_rp2040_family_inclusion_marker INTERFACE)
+
+ if (NOT BOARD)
+ message("BOARD not specified, defaulting to pico_sdk")
+ set(BOARD pico_sdk)
+ endif()
+
+ # add the SDK in case we are standalone tinyusb example (noop if already present)
+ include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake)
+
+ # include basic family CMake functionality
+ set(FAMILY_MCUS RP2040)
+
+ include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+ # TOP is absolute path to root directory of TinyUSB git repo
+ set(TOP "${CMAKE_CURRENT_LIST_DIR}/../../..")
+ get_filename_component(TOP "${TOP}" REALPATH)
+
+ if (NOT PICO_TINYUSB_PATH)
+ set(PICO_TINYUSB_PATH ${TOP})
+ endif()
+
+ # Base config for both device and host; wrapped by SDK's tinyusb_common
+ add_library(tinyusb_common_base INTERFACE)
+
+ target_sources(tinyusb_common_base INTERFACE
+ ${TOP}/src/tusb.c
+ ${TOP}/src/common/tusb_fifo.c
+ )
+
+ target_include_directories(tinyusb_common_base INTERFACE
+ ${TOP}/src
+ ${TOP}/src/common
+ ${TOP}/hw
+ )
+
+ target_link_libraries(tinyusb_common_base INTERFACE
+ hardware_structs
+ hardware_irq
+ hardware_resets
+ pico_sync
+ )
+
+ set(TINYUSB_DEBUG_LEVEL 0)
+ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ message("Compiling TinyUSB with CFG_TUSB_DEBUG=1")
+ set(TINYUSB_DEBUG_LEVEL 1)
+ endif ()
+
+ target_compile_definitions(tinyusb_common_base INTERFACE
+ CFG_TUSB_MCU=OPT_MCU_RP2040
+ CFG_TUSB_OS=OPT_OS_PICO
+ CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
+ )
+
+ # Base config for device mode; wrapped by SDK's tinyusb_device
+ add_library(tinyusb_device_base INTERFACE)
+ target_sources(tinyusb_device_base INTERFACE
+ ${TOP}/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+ ${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.c
+ ${TOP}/src/device/usbd.c
+ ${TOP}/src/device/usbd_control.c
+ ${TOP}/src/class/audio/audio_device.c
+ ${TOP}/src/class/cdc/cdc_device.c
+ ${TOP}/src/class/dfu/dfu_device.c
+ ${TOP}/src/class/dfu/dfu_rt_device.c
+ ${TOP}/src/class/hid/hid_device.c
+ ${TOP}/src/class/midi/midi_device.c
+ ${TOP}/src/class/msc/msc_device.c
+ ${TOP}/src/class/net/ecm_rndis_device.c
+ ${TOP}/src/class/net/ncm_device.c
+ ${TOP}/src/class/usbtmc/usbtmc_device.c
+ ${TOP}/src/class/vendor/vendor_device.c
+ ${TOP}/src/class/video/video_device.c
+ )
+
+ # Base config for host mode; wrapped by SDK's tinyusb_host
+ add_library(tinyusb_host_base INTERFACE)
+ target_sources(tinyusb_host_base INTERFACE
+ ${TOP}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
+ ${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.c
+ ${TOP}/src/host/usbh.c
+ ${TOP}/src/host/usbh_control.c
+ ${TOP}/src/host/hub.c
+ ${TOP}/src/class/cdc/cdc_host.c
+ ${TOP}/src/class/hid/hid_host.c
+ ${TOP}/src/class/msc/msc_host.c
+ ${TOP}/src/class/vendor/vendor_host.c
+ )
+
+ # Sometimes have to do host specific actions in mostly
+ # common functions
+ target_compile_definitions(tinyusb_host_base INTERFACE
+ RP2040_USB_HOST_MODE=1
+ )
+
+ add_library(tinyusb_bsp INTERFACE)
+ target_sources(tinyusb_bsp INTERFACE
+ ${TOP}/hw/bsp/rp2040/family.c
+ )
+# target_include_directories(tinyusb_bsp INTERFACE
+# ${TOP}/hw/bsp/rp2040)
+
+ # tinyusb_additions will hold our extra settings for examples
+ add_library(tinyusb_additions INTERFACE)
+
+ target_compile_definitions(tinyusb_additions INTERFACE
+ PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
+ )
+
+ if(DEFINED LOG)
+ target_compile_definitions(tinyusb_additions INTERFACE CFG_TUSB_DEBUG=${LOG} )
+ endif()
+
+ if(LOGGER STREQUAL "rtt")
+ target_compile_definitions(tinyusb_additions INTERFACE
+ LOGGER_RTT
+ SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
+ )
+
+ target_sources(tinyusb_additions INTERFACE
+ ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
+ )
+
+ target_include_directories(tinyusb_additions INTERFACE
+ ${TOP}/lib/SEGGER_RTT/RTT
+ )
+ endif()
+
+ function(family_configure_target TARGET)
+ pico_add_extra_outputs(${TARGET})
+ pico_enable_stdio_uart(${TARGET} 1)
+ target_link_libraries(${TARGET} PUBLIC pico_stdlib pico_bootsel_via_double_reset tinyusb_board tinyusb_additions)
+ endfunction()
+
+ function(family_configure_device_example TARGET)
+ family_configure_target(${TARGET})
+ target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device)
+ endfunction()
+
+ function(family_configure_host_example TARGET)
+ family_configure_target(${TARGET})
+ target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_host)
+ endfunction()
+
+ function(family_initialize_project PROJECT DIR)
+ # call the original version of this function from family_common.cmake
+ _family_initialize_project(${PROJECT} ${DIR})
+ enable_language(C CXX ASM)
+ pico_sdk_init()
+ endfunction()
+
+ # This method must be called from the project scope to suppress known warnings in TinyUSB source files
+ function(suppress_tinyusb_warnings)
+ set_source_files_properties(
+ ${PICO_TINYUSB_PATH}/src/tusb.c
+ PROPERTIES
+ COMPILE_FLAGS "-Wno-conversion")
+ set_source_files_properties(
+ ${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
+ PROPERTIES
+ COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual")
+ set_source_files_properties(
+ ${PICO_TINYUSB_PATH}/src/device/usbd.c
+ PROPERTIES
+ COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual -Wno-null-dereference")
+ set_source_files_properties(
+ ${PICO_TINYUSB_PATH}/src/device/usbd_control.c
+ PROPERTIES
+ COMPILE_FLAGS "-Wno-conversion")
+ set_source_files_properties(
+ ${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
+ PROPERTIES
+ COMPILE_FLAGS "-Wno-conversion")
+ endfunction()
+endif()
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.mk b/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.mk
new file mode 100644
index 0000000..5db784b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/family.mk
@@ -0,0 +1,19 @@
+JLINK_DEVICE = rp2040_m0_0
+PYOCD_TARGET = rp2040
+
+ifeq ($(DEBUG), 1)
+CMAKE_DEFSYM += -DCMAKE_BUILD_TYPE=Debug
+endif
+
+$(BUILD):
+ cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) -DPICO_BUILD_DOCS=0 $(CMAKE_DEFSYM)
+
+all: $(BUILD)
+ $(MAKE) -C $(BUILD)
+
+clean:
+ $(RM) -rf $(BUILD)
+
+flash: flash-pyocd
+flash-uf2:
+ @$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rp2040/pico_sdk_import.cmake b/circuitpython/lib/tinyusb/hw/bsp/rp2040/pico_sdk_import.cmake
new file mode 100644
index 0000000..28efe9e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rp2040/pico_sdk_import.cmake
@@ -0,0 +1,62 @@
+# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
+
+# This can be dropped into an external project to help locate this SDK
+# It should be include()ed prior to project()
+
+if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
+ set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
+ message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
+endif ()
+
+if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
+ set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
+ message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
+endif ()
+
+if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
+ set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
+ message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
+endif ()
+
+set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
+set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
+set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
+
+if (NOT PICO_SDK_PATH)
+ if (PICO_SDK_FETCH_FROM_GIT)
+ include(FetchContent)
+ set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
+ if (PICO_SDK_FETCH_FROM_GIT_PATH)
+ get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
+ endif ()
+ FetchContent_Declare(
+ pico_sdk
+ GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
+ GIT_TAG master
+ )
+ if (NOT pico_sdk)
+ message("Downloading Raspberry Pi Pico SDK")
+ FetchContent_Populate(pico_sdk)
+ set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
+ endif ()
+ set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
+ else ()
+ message(FATAL_ERROR
+ "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
+ )
+ endif ()
+endif ()
+
+get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
+if (NOT EXISTS ${PICO_SDK_PATH})
+ message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
+endif ()
+
+set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
+if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
+ message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
+endif ()
+
+set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
+
+include(${PICO_SDK_INIT_CMAKE_FILE})
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/board.mk b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/board.mk
new file mode 100644
index 0000000..0eba946
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/board.mk
@@ -0,0 +1,24 @@
+DEPS_SUBMODULES += hw/mcu/renesas/rx
+
+CFLAGS += \
+ -mcpu=rx610 \
+ -misa=v1 \
+ -DCFG_TUSB_MCU=OPT_MCU_RX63X
+
+MCU_DIR = hw/mcu/renesas/rx/rx63n
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/r5f5631fd.ld
+
+# For freeRTOS port source
+FREERTOS_PORT = RX600
+
+# For flash-jlink target
+JLINK_DEVICE = R5F5631F
+JLINK_IF = JTAG
+
+# For flash-pyocd target
+PYOCD_TARGET =
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/gr_citrus.c b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/gr_citrus.c
new file mode 100644
index 0000000..633ddad
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/gr_citrus.c
@@ -0,0 +1,275 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Koji Kitayama
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+/* How to connect JLink and GR-CITRUS
+ *
+ * GR-CITRUS needs to solder some pads to enable JTAG interface.
+ * - Short the following pads individually with solder.
+ * - J4
+ * - J5
+ * - Short EMLE pad and 3.3V(GR-CITRUS pin name) with a wire.
+ *
+ * The pads are [the back side of GR-CITRUS](https://www.slideshare.net/MinaoYamamoto/grcitrusrx631/2).
+ *
+ * Connect the pins between GR-CITRUS and JLink as follows.
+ *
+ * | Function | GR-CITRUS pin | JLink pin No.| note |
+ * |:---------:|:-------------:|:------------:|:--------:|
+ * | VTref | 3.3V | 1 | |
+ * | TRST | 5 | 3 | |
+ * | GND | GND | 4 | |
+ * | TDI | 3 | 5 | |
+ * | TMS | 2 | 7 | |
+ * | TCK/FINEC | 14 | 9 | short J4 |
+ * | TDO | 9 | 13 | short J5 |
+ * | nRES | RST | 15 | |
+ *
+ * JLink firmware needs to update to V6.96 or newer version to avoid
+ * [a bug](https://forum.segger.com/index.php/Thread/7758-SOLVED-Bug-in-JLink-from-V6-88b-regarding-RX65N)
+ * regarding downloading.
+ */
+
+#include "../board.h"
+#include "iodefine.h"
+#include "interrupt_handlers.h"
+
+#define IRQ_PRIORITY_CMT0 5
+#define IRQ_PRIORITY_USBI0 6
+#define IRQ_PRIORITY_SCI0 5
+
+#define SYSTEM_PRCR_PRC1 (1<<1)
+#define SYSTEM_PRCR_PRKEY (0xA5u<<8)
+
+#define CMT_PCLK 48000000
+#define CMT_CMCR_CKS_DIV_128 2
+#define CMT_CMCR_CMIE (1<<6)
+#define MPC_PFS_ISEL (1<<6)
+
+#define SCI_PCLK 48000000
+#define SCI_SSR_FER (1<<4)
+#define SCI_SSR_ORER (1<<5)
+
+#define SCI_SCR_TEIE (1u<<2)
+#define SCI_SCR_RE (1u<<4)
+#define SCI_SCR_TE (1u<<5)
+#define SCI_SCR_RIE (1u<<6)
+#define SCI_SCR_TIE (1u<<7)
+
+//--------------------------------------------------------------------+
+// SCI0 handling
+//--------------------------------------------------------------------+
+typedef struct {
+ uint8_t *buf;
+ uint32_t cnt;
+} sci_buf_t;
+static volatile sci_buf_t sci0_buf[2];
+
+void INT_Excep_SCI0_TXI0(void)
+{
+ uint8_t *buf = sci0_buf[0].buf;
+ uint32_t cnt = sci0_buf[0].cnt;
+
+ if (!buf || !cnt) {
+ SCI0.SCR.BYTE &= ~(SCI_SCR_TEIE | SCI_SCR_TE | SCI_SCR_TIE);
+ return;
+ }
+ SCI0.TDR = *buf;
+ if (--cnt) {
+ ++buf;
+ } else {
+ buf = NULL;
+ SCI0.SCR.BIT.TIE = 0;
+ SCI0.SCR.BIT.TEIE = 1;
+ }
+ sci0_buf[0].buf = buf;
+ sci0_buf[0].cnt = cnt;
+}
+
+void INT_Excep_SCI0_TEI0(void)
+{
+ SCI0.SCR.BYTE &= ~(SCI_SCR_TEIE | SCI_SCR_TE | SCI_SCR_TIE);
+}
+
+void INT_Excep_SCI0_RXI0(void)
+{
+ uint8_t *buf = sci0_buf[1].buf;
+ uint32_t cnt = sci0_buf[1].cnt;
+
+ if (!buf || !cnt ||
+ (SCI0.SSR.BYTE & (SCI_SSR_FER | SCI_SSR_ORER))) {
+ sci0_buf[1].buf = NULL;
+ SCI0.SSR.BYTE = 0;
+ SCI0.SCR.BYTE &= ~(SCI_SCR_RE | SCI_SCR_RIE);
+ return;
+ }
+ *buf = SCI0.RDR;
+ if (--cnt) {
+ ++buf;
+ } else {
+ buf = NULL;
+ SCI0.SCR.BYTE &= ~(SCI_SCR_RE | SCI_SCR_RIE);
+ }
+ sci0_buf[1].buf = buf;
+ sci0_buf[1].cnt = cnt;
+}
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void INT_Excep_USB0_USBI0(void)
+{
+ tud_int_handler(0);
+}
+
+void board_init(void)
+{
+#if CFG_TUSB_OS == OPT_OS_NONE
+ /* Enable CMT0 */
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
+ MSTP(CMT0) = 0;
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
+ /* Setup 1ms tick timer */
+ CMT0.CMCNT = 0;
+ CMT0.CMCOR = CMT_PCLK / 1000 / 128;
+ CMT0.CMCR.WORD = CMT_CMCR_CMIE | CMT_CMCR_CKS_DIV_128;
+ IR(CMT0, CMI0) = 0;
+ IPR(CMT0, CMI0) = IRQ_PRIORITY_CMT0;
+ IEN(CMT0, CMI0) = 1;
+ CMT.CMSTR0.BIT.STR0 = 1;
+#endif
+
+ /* Unlock MPC registers */
+ MPC.PWPR.BIT.B0WI = 0;
+ MPC.PWPR.BIT.PFSWE = 1;
+ /* LED PA0 */
+ PORTA.PMR.BIT.B0 = 0U;
+ PORTA.PODR.BIT.B0 = 0U;
+ PORTA.PDR.BIT.B0 = 1U;
+ /* UART TXD0 => P20, RXD0 => P21 */
+ PORT2.PMR.BIT.B0 = 1U;
+ PORT2.PCR.BIT.B0 = 1U;
+ MPC.P20PFS.BYTE = 0b01010;
+ PORT2.PMR.BIT.B1 = 1U;
+ MPC.P21PFS.BYTE = 0b01010;
+ /* USB VBUS -> P16 DPUPE -> P14 */
+ PORT1.PMR.BIT.B4 = 1U;
+ PORT1.PMR.BIT.B6 = 1U;
+ MPC.P14PFS.BYTE = 0b10001;
+ MPC.P16PFS.BYTE = MPC_PFS_ISEL | 0b10001;
+ MPC.PFUSB0.BIT.PUPHZS = 1;
+ /* Lock MPC registers */
+ MPC.PWPR.BIT.PFSWE = 0;
+ MPC.PWPR.BIT.B0WI = 1;
+
+ IR(USB0, USBI0) = 0;
+ IPR(USB0, USBI0) = IRQ_PRIORITY_USBI0;
+
+ /* Enable SCI0 */
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
+ MSTP(SCI0) = 0;
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
+ SCI0.BRR = (SCI_PCLK / (32 * 115200)) - 1;
+ IR(SCI0, RXI0) = 0;
+ IR(SCI0, TXI0) = 0;
+ IR(SCI0, TEI0) = 0;
+ IPR(SCI0, RXI0) = IRQ_PRIORITY_SCI0;
+ IPR(SCI0, TXI0) = IRQ_PRIORITY_SCI0;
+ IPR(SCI0, TEI0) = IRQ_PRIORITY_SCI0;
+ IEN(SCI0, RXI0) = 1;
+ IEN(SCI0, TXI0) = 1;
+ IEN(SCI0, TEI0) = 1;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ PORTA.PODR.BIT.B0 = state ? 1 : 0;
+}
+
+uint32_t board_button_read(void)
+{
+ return 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ sci0_buf[1].buf = buf;
+ sci0_buf[1].cnt = len;
+ SCI0.SCR.BYTE |= SCI_SCR_RE | SCI_SCR_RIE;
+ while (SCI0.SCR.BIT.RE) ;
+ return len - sci0_buf[1].cnt;
+}
+
+int board_uart_write(void const *buf, int len)
+{
+ sci0_buf[0].buf = (uint8_t*)(uintptr_t) buf;
+ sci0_buf[0].cnt = len;
+ SCI0.SCR.BYTE |= SCI_SCR_TE | SCI_SCR_TIE;
+ while (SCI0.SCR.BIT.TE) ;
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void INT_Excep_CMT0_CMI0(void)
+{
+ ++system_ticks;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#else
+uint32_t SystemCoreClock = 96000000;
+#endif
+
+int close(int fd)
+{
+ (void)fd;
+ return -1;
+}
+int fstat(int fd, void *pstat)
+{
+ (void)fd;
+ (void)pstat;
+ return 0;
+}
+off_t lseek(int fd, off_t pos, int whence)
+{
+ (void)fd;
+ (void)pos;
+ (void)whence;
+ return 0;
+}
+int isatty(int fd)
+{
+ (void)fd;
+ return 1;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/hwinit.c b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/hwinit.c
new file mode 100644
index 0000000..8245d77
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/hwinit.c
@@ -0,0 +1,31 @@
+/************************************************************************/
+/* File Version: V1.00 */
+/* Date Generated: 08/07/2013 */
+/************************************************************************/
+
+#include "iodefine.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void HardwareSetup(void);
+#ifdef __cplusplus
+}
+#endif
+
+void HardwareSetup(void)
+{
+ SYSTEM.PRCR.WORD = 0xA503u;
+ SYSTEM.SOSCCR.BYTE = 0x01u;
+ SYSTEM.MOSCWTCR.BYTE = 0x0Du;
+ SYSTEM.PLLWTCR.BYTE = 0x0Eu;
+ SYSTEM.PLLCR.WORD = 0x0F00u;
+ SYSTEM.MOSCCR.BYTE = 0x00u;
+ SYSTEM.PLLCR2.BYTE = 0x00u;
+ for (unsigned i = 0; i < 2075u; ++i) __asm("nop");
+ SYSTEM.SCKCR.LONG = 0x21021211u;
+ SYSTEM.SCKCR2.WORD = 0x0033u;
+ SYSTEM.SCKCR3.WORD = 0x0400u;
+ SYSTEM.SYSCR0.WORD = 0x5A01;
+ SYSTEM.MSTPCRB.BIT.MSTPB15 = 0;
+ SYSTEM.PRCR.WORD = 0xA500u;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/r5f5631fd.ld b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/r5f5631fd.ld
new file mode 100644
index 0000000..bb9c297
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/gr_citrus/r5f5631fd.ld
@@ -0,0 +1,127 @@
+__USTACK_SIZE = 0x00000400;
+__ISTACK_SIZE = 0x00000400;
+
+MEMORY
+{
+ RAM : ORIGIN = 0x4, LENGTH = 0x3fffc
+ ROM : ORIGIN = 0xFFE00000, LENGTH = 0x200000
+}
+SECTIONS
+{
+ .fvectors 0xFFFFFF80: AT(0xFFFFFF80)
+ {
+ KEEP(*(.fvectors))
+ } > ROM
+ .text 0xFFE00000: AT(0xFFE00000)
+ {
+ *(.text)
+ *(.text.*)
+ *(P)
+ etext = .;
+ } > ROM
+ .rvectors ALIGN(4):
+ {
+ _rvectors_start = .;
+ KEEP(*(.rvectors))
+ _rvectors_end = .;
+ } > ROM
+ .init :
+ {
+ KEEP(*(.init))
+ __preinit_array_start = .;
+ KEEP(*(.preinit_array))
+ __preinit_array_end = .;
+ __init_array_start = (. + 3) & ~ 3;
+ KEEP(*(.init_array))
+ KEEP(*(SORT(.init_array.*)))
+ __init_array_end = .;
+ __fini_array_start = .;
+ KEEP(*(.fini_array))
+ KEEP(*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+ } > ROM
+ .fini :
+ {
+ KEEP(*(.fini))
+ } > ROM
+ .got :
+ {
+ *(.got)
+ *(.got.plt)
+ } > ROM
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata.*)
+ *(C_1)
+ *(C_2)
+ *(C)
+ _erodata = .;
+ } > ROM
+ .eh_frame_hdr :
+ {
+ *(.eh_frame_hdr)
+ } > ROM
+ .eh_frame :
+ {
+ *(.eh_frame)
+ } > ROM
+ .jcr :
+ {
+ *(.jcr)
+ } > ROM
+ .tors :
+ {
+ __CTOR_LIST__ = .;
+ . = ALIGN(2);
+ ___ctors = .;
+ *(.ctors)
+ ___ctors_end = .;
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ ___dtors = .;
+ *(.dtors)
+ ___dtors_end = .;
+ __DTOR_END__ = .;
+ . = ALIGN(2);
+ _mdata = .;
+ } > ROM
+ .data : AT(_mdata)
+ {
+ _data = .;
+ *(.data)
+ *(.data.*)
+ *(D)
+ *(D_1)
+ *(D_2)
+ _edata = .;
+ } > RAM
+ .gcc_exc :
+ {
+ *(.gcc_exc)
+ } > RAM
+ .bss :
+ {
+ _bss = .;
+ *(.bss)
+ *(.bss.**)
+ *(COMMON)
+ *(B)
+ *(B_1)
+ *(B_2)
+ _ebss = .;
+ _end = .;
+ } > RAM
+ .ustack :
+ {
+ . = ALIGN(8);
+ . = . + __USTACK_SIZE;
+ PROVIDE(_ustack = .);
+ } > RAM
+ .istack :
+ {
+ . = ALIGN(8);
+ . = . + __ISTACK_SIZE;
+ PROVIDE(_istack = .);
+ } > RAM
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/board.mk b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/board.mk
new file mode 100644
index 0000000..fc76d79
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/board.mk
@@ -0,0 +1,25 @@
+CFLAGS += \
+ -mcpu=rx64m \
+ -misa=v2 \
+ -DCFG_TUSB_MCU=OPT_MCU_RX65X \
+ -DIR_USB0_USBI0=IR_PERIB_INTB185 \
+ -DIER_USB0_USBI0=IER_PERIB_INTB185 \
+ -DIEN_USB0_USBI0=IEN_PERIB_INTB185
+
+MCU_DIR = hw/mcu/renesas/rx/rx65n
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/r5f565ne.ld
+
+# For freeRTOS port source
+FREERTOS_PORT = RX600
+
+# For flash-jlink target
+JLINK_DEVICE = R5F565NE
+JLINK_IF = JTAG
+
+# For flash-pyocd target
+PYOCD_TARGET =
+
+# flash using rfp-cli
+flash: flash-rfp
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/r5f565ne.ld b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/r5f565ne.ld
new file mode 100644
index 0000000..27914e6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/r5f565ne.ld
@@ -0,0 +1,168 @@
+__USTACK_SIZE = 0x00000800;
+__ISTACK_SIZE = 0x00000800;
+
+MEMORY
+{
+ RAM : ORIGIN = 0x4, LENGTH = 0x3fffc
+ RAM2 : ORIGIN = 0x00800000, LENGTH = 0x60000
+ OFS : ORIGIN = 0xFE7F5D00, LENGTH = 128
+ ROM : ORIGIN = 0xFFE00000, LENGTH = 0x200000
+}
+SECTIONS
+{
+ .exvectors 0xFFFFFF80: AT(0xFFFFFF80)
+ {
+ "_exvectors_start" = .;
+ KEEP(*(.exvectors))
+ "_exvectors_end" = .;
+ } >ROM
+ .fvectors 0xFFFFFFFC: AT(0xFFFFFFFC)
+ {
+ KEEP(*(.fvectors))
+ } > ROM
+ .text 0xFFE00000: AT(0xFFE00000)
+ {
+ *(.text)
+ *(.text.*)
+ *(P)
+ KEEP(*(.text.*_isr))
+ etext = .;
+ } > ROM
+ .rvectors ALIGN(4):
+ {
+ _rvectors_start = .;
+ KEEP(*(.rvectors))
+ _rvectors_end = .;
+ } > ROM
+ .init :
+ {
+ KEEP(*(.init))
+ __preinit_array_start = .;
+ KEEP(*(.preinit_array))
+ __preinit_array_end = .;
+ __init_array_start = (. + 3) & ~ 3;
+ KEEP(*(.init_array))
+ KEEP(*(SORT(.init_array.*)))
+ __init_array_end = .;
+ __fini_array_start = .;
+ KEEP(*(.fini_array))
+ KEEP(*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+ } > ROM
+ .fini :
+ {
+ KEEP(*(.fini))
+ } > ROM
+ .got :
+ {
+ *(.got)
+ *(.got.plt)
+ } > ROM
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata.*)
+ *(C_1)
+ *(C_2)
+ *(C)
+ _erodata = .;
+ } > ROM
+ .eh_frame_hdr :
+ {
+ *(.eh_frame_hdr)
+ } > ROM
+ .eh_frame :
+ {
+ *(.eh_frame)
+ } > ROM
+ .jcr :
+ {
+ *(.jcr)
+ } > ROM
+ .tors :
+ {
+ __CTOR_LIST__ = .;
+ . = ALIGN(2);
+ ___ctors = .;
+ *(.ctors)
+ ___ctors_end = .;
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ ___dtors = .;
+ *(.dtors)
+ ___dtors_end = .;
+ __DTOR_END__ = .;
+ . = ALIGN(2);
+ _mdata = .;
+ } > ROM
+ .data : AT(_mdata)
+ {
+ _data = .;
+ *(.data)
+ *(.data.*)
+ *(D)
+ *(D_1)
+ *(D_2)
+ _edata = .;
+ } > RAM
+ .gcc_exc :
+ {
+ *(.gcc_exc)
+ } > RAM
+ .bss :
+ {
+ _bss = .;
+ *(.bss)
+ *(.bss.**)
+ *(COMMON)
+ *(B)
+ *(B_1)
+ *(B_2)
+ _ebss = .;
+ _end = .;
+ } > RAM
+ .ustack :
+ {
+ . = ALIGN(8);
+ . = . + __USTACK_SIZE;
+ PROVIDE(_ustack = .);
+ } > RAM
+ .istack :
+ {
+ . = ALIGN(8);
+ . = . + __ISTACK_SIZE;
+ PROVIDE(_istack = .);
+ } > RAM
+ .ofs1 0xFE7F5D00: AT(0xFE7F5D00)
+ {
+ KEEP(*(.ofs1))
+ } > OFS
+ .ofs2 0xFE7F5D10: AT(0xFE7F5D10)
+ {
+ KEEP(*(.ofs2))
+ } > OFS
+ .ofs3 0xFE7F5D20: AT(0xFE7F5D20)
+ {
+ KEEP(*(.ofs3))
+ } > OFS
+ .ofs4 0xFE7F5D40: AT(0xFE7F5D40)
+ {
+ KEEP(*(.ofs4))
+ } > OFS
+ .ofs5 0xFE7F5D48: AT(0xFE7F5D48)
+ {
+ KEEP(*(.ofs5))
+ } > OFS
+ .ofs6 0xFE7F5D50: AT(0xFE7F5D50)
+ {
+ KEEP(*(.ofs6))
+ } > OFS
+ .ofs7 0xFE7F5D64: AT(0xFE7F5D64)
+ {
+ KEEP(*(.ofs7))
+ } > OFS
+ .ofs8 0xFE7F5D70: AT(0xFE7F5D70)
+ {
+ KEEP(*(.ofs8))
+ } > OFS
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/rx65n_target.c b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/rx65n_target.c
new file mode 100644
index 0000000..f189e40
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/boards/rx65n_target/rx65n_target.c
@@ -0,0 +1,325 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Koji Kitayama
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+/* How to connect JLink and RX65n Target and option board
+ * (For original comment https://github.com/hathach/tinyusb/pull/922#issuecomment-869786131)
+ *
+ * To enable JTAG, RX65N requires following connections on main board.
+ * - short EJ2 jumper header, to disable onboard E2L.
+ * - short EMLE(J1-2) and 3V3(J1-14 or J2-10), to enable In-Circuit Emulator.
+ *
+ * Note: For RX65N-Cloud-Kit, the option board's JTAG pins to some switches or floating.
+ * To use JLink with the option board, I think some further modifications will be necessary.
+ *
+ * | Function | RX65N pin | main board | option board | JLink connector |
+ * |:---------:|:----------:|:----------:|:------------:|:---------------:|
+ * | 3V3 | VCC | J1-14 | CN5-6 | 1 |
+ * | TRST | P34 | J1-16 | CN5-7 | 3 |
+ * | GND | VSS | J1-12 | CN5-5 | 4 |
+ * | TDI | P30 | J1-20 | CN5-10 | 5 |
+ * | TMS | P31 | J1-19 | USER_SW | 7 |
+ * | TCK/FINEC | P27 | J1-21 | N/A | 9 |
+ * | TDO | P26 | J1-22 | CN5-9 | 13 |
+ * | nRES | RES# | J1-10 | RESET_SW | 15 |
+ *
+ * JLink firmware needs to update to V6.96 or newer version to avoid
+ * [a bug](https://forum.segger.com/index.php/Thread/7758-SOLVED-Bug-in-JLink-from-V6-88b-regarding-RX65N)
+ * regarding downloading.
+ */
+
+#include "bsp/board.h"
+#include "iodefine.h"
+#include "interrupt_handlers.h"
+
+#define IRQ_PRIORITY_CMT0 5
+#define IRQ_PRIORITY_USBI0 6
+#define IRQ_PRIORITY_SCI5 5
+
+#define SYSTEM_PRCR_PRC1 (1<<1)
+#define SYSTEM_PRCR_PRKEY (0xA5u<<8)
+
+#define CMT_PCLK 60000000
+#define CMT_CMCR_CKS_DIV_128 2
+#define CMT_CMCR_CMIE (1<<6)
+#define MPC_PFS_ISEL (1<<6)
+
+#define SCI_PCLK 60000000
+#define SCI_SSR_FER (1<<4)
+#define SCI_SSR_ORER (1<<5)
+
+#define SCI_SCR_TEIE (1u<<2)
+#define SCI_SCR_RE (1u<<4)
+#define SCI_SCR_TE (1u<<5)
+#define SCI_SCR_RIE (1u<<6)
+#define SCI_SCR_TIE (1u<<7)
+#define INT_Excep_SCI5_TEI5 INT_Excep_ICU_GROUPBL0
+
+#define IRQ_USB0_USBI0 62
+#define SLIBR_USBI0 SLIBR185
+#define IPR_USB0_USBI0 IPR_PERIB_INTB185
+#define INT_Excep_USB0_USBI0 INT_Excep_PERIB_INTB185
+
+void HardwareSetup(void)
+{
+ FLASH.ROMCIV.WORD = 1;
+ while (FLASH.ROMCIV.WORD) ;
+ FLASH.ROMCE.WORD = 1;
+ while (!FLASH.ROMCE.WORD) ;
+
+ SYSTEM.PRCR.WORD = 0xA503u;
+ if (!SYSTEM.RSTSR1.BYTE) {
+ RTC.RCR4.BYTE = 0;
+ RTC.RCR3.BYTE = 12;
+ while (12 != RTC.RCR3.BYTE) ;
+ }
+ SYSTEM.SOSCCR.BYTE = 1;
+
+ if (SYSTEM.HOCOCR.BYTE) {
+ SYSTEM.HOCOCR.BYTE = 0;
+ while (!SYSTEM.OSCOVFSR.BIT.HCOVF) ;
+ }
+ SYSTEM.PLLCR.WORD = 0x1D10u; /* HOCO x 15 */
+ SYSTEM.PLLCR2.BYTE = 0;
+ while (!SYSTEM.OSCOVFSR.BIT.PLOVF) ;
+
+ SYSTEM.SCKCR.LONG = 0x21C11222u;
+ SYSTEM.SCKCR2.WORD = 0x0041u;
+ SYSTEM.ROMWT.BYTE = 0x02u;
+ while (0x02u != SYSTEM.ROMWT.BYTE) ;
+ SYSTEM.SCKCR3.WORD = 0x400u;
+ SYSTEM.PRCR.WORD = 0xA500u;
+}
+
+//--------------------------------------------------------------------+
+// SCI handling
+//--------------------------------------------------------------------+
+typedef struct {
+ uint8_t *buf;
+ uint32_t cnt;
+} sci_buf_t;
+static volatile sci_buf_t sci_buf[2];
+
+void INT_Excep_SCI5_TXI5(void)
+{
+ uint8_t *buf = sci_buf[0].buf;
+ uint32_t cnt = sci_buf[0].cnt;
+
+ if (!buf || !cnt) {
+ SCI5.SCR.BYTE &= ~(SCI_SCR_TEIE | SCI_SCR_TE | SCI_SCR_TIE);
+ return;
+ }
+ SCI5.TDR = *buf;
+ if (--cnt) {
+ ++buf;
+ } else {
+ buf = NULL;
+ SCI5.SCR.BIT.TIE = 0;
+ SCI5.SCR.BIT.TEIE = 1;
+ }
+ sci_buf[0].buf = buf;
+ sci_buf[0].cnt = cnt;
+}
+
+void INT_Excep_SCI5_TEI5(void)
+{
+ SCI5.SCR.BYTE &= ~(SCI_SCR_TEIE | SCI_SCR_TE | SCI_SCR_TIE);
+}
+
+void INT_Excep_SCI5_RXI5(void)
+{
+ uint8_t *buf = sci_buf[1].buf;
+ uint32_t cnt = sci_buf[1].cnt;
+
+ if (!buf || !cnt ||
+ (SCI5.SSR.BYTE & (SCI_SSR_FER | SCI_SSR_ORER))) {
+ sci_buf[1].buf = NULL;
+ SCI5.SSR.BYTE = 0;
+ SCI5.SCR.BYTE &= ~(SCI_SCR_RE | SCI_SCR_RIE);
+ return;
+ }
+ *buf = SCI5.RDR;
+ if (--cnt) {
+ ++buf;
+ } else {
+ buf = NULL;
+ SCI5.SCR.BYTE &= ~(SCI_SCR_RE | SCI_SCR_RIE);
+ }
+ sci_buf[1].buf = buf;
+ sci_buf[1].cnt = cnt;
+}
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void INT_Excep_USB0_USBI0(void)
+{
+#if CFG_TUH_ENABLED
+ tuh_int_handler(0);
+#endif
+#if CFG_TUD_ENABLED
+ tud_int_handler(0);
+#endif
+}
+
+void board_init(void)
+{
+ /* setup software configurable interrupts */
+ ICU.SLIBR_USBI0.BYTE = IRQ_USB0_USBI0;
+ ICU.SLIPRCR.BYTE = 1;
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ /* Enable CMT0 */
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
+ MSTP(CMT0) = 0;
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
+ /* Setup 1ms tick timer */
+ CMT0.CMCNT = 0;
+ CMT0.CMCOR = CMT_PCLK / 1000 / 128;
+ CMT0.CMCR.WORD = CMT_CMCR_CMIE | CMT_CMCR_CKS_DIV_128;
+ IR(CMT0, CMI0) = 0;
+ IPR(CMT0, CMI0) = IRQ_PRIORITY_CMT0;
+ IEN(CMT0, CMI0) = 1;
+ CMT.CMSTR0.BIT.STR0 = 1;
+#endif
+
+ /* Unlock MPC registers */
+ MPC.PWPR.BIT.B0WI = 0;
+ MPC.PWPR.BIT.PFSWE = 1;
+ // SW PB1
+ PORTB.PMR.BIT.B1 = 0U;
+ PORTB.PDR.BIT.B1 = 0U;
+ // LED PD6
+ PORTD.PODR.BIT.B6 = 1U;
+ PORTD.ODR1.BIT.B4 = 1U;
+ PORTD.PMR.BIT.B6 = 0U;
+ PORTD.PDR.BIT.B6 = 1U;
+ /* UART TXD5 => PA4, RXD5 => PA3 */
+ PORTA.PMR.BIT.B4 = 1U;
+ PORTA.PCR.BIT.B4 = 1U;
+ MPC.PA4PFS.BYTE = 0b01010;
+ PORTA.PMR.BIT.B3 = 1U;
+ MPC.PA5PFS.BYTE = 0b01010;
+ /* USB VBUS -> P16 */
+ PORT1.PMR.BIT.B6 = 1U;
+ MPC.P16PFS.BYTE = MPC_PFS_ISEL | 0b10001;
+ /* Lock MPC registers */
+ MPC.PWPR.BIT.PFSWE = 0;
+ MPC.PWPR.BIT.B0WI = 1;
+
+ /* Enable SCI5 */
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
+ MSTP(SCI5) = 0;
+ SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
+ SCI5.SEMR.BIT.ABCS = 1;
+ SCI5.SEMR.BIT.BGDM = 1;
+ SCI5.BRR = (SCI_PCLK / (8 * 115200)) - 1;
+ IR(SCI5, RXI5) = 0;
+ IR(SCI5, TXI5) = 0;
+ IS(SCI5, TEI5) = 0;
+ IR(ICU, GROUPBL0) = 0;
+ IPR(SCI5, RXI5) = IRQ_PRIORITY_SCI5;
+ IPR(SCI5, TXI5) = IRQ_PRIORITY_SCI5;
+ IPR(ICU,GROUPBL0) = IRQ_PRIORITY_SCI5;
+ IEN(SCI5, RXI5) = 1;
+ IEN(SCI5, TXI5) = 1;
+ IEN(ICU,GROUPBL0) = 1;
+ EN(SCI5, TEI5) = 1;
+
+ /* setup USBI0 interrupt. */
+ IR(USB0, USBI0) = 0;
+ IPR(USB0, USBI0) = IRQ_PRIORITY_USBI0;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ PORTD.PODR.BIT.B6 = state ? 0 : 1;
+}
+
+uint32_t board_button_read(void)
+{
+ return PORTB.PIDR.BIT.B1 ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ sci_buf[1].buf = buf;
+ sci_buf[1].cnt = len;
+ SCI5.SCR.BYTE |= SCI_SCR_RE | SCI_SCR_RIE;
+ while (SCI5.SCR.BIT.RE) ;
+ return len - sci_buf[1].cnt;
+}
+
+int board_uart_write(void const *buf, int len)
+{
+ sci_buf[0].buf = (uint8_t*)(uintptr_t) buf;
+ sci_buf[0].cnt = len;
+ SCI5.SCR.BYTE |= SCI_SCR_TE | SCI_SCR_TIE;
+ while (SCI5.SCR.BIT.TE) ;
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void INT_Excep_CMT0_CMI0(void)
+{
+ ++system_ticks;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#else
+uint32_t SystemCoreClock = 120000000;
+#endif
+
+int close(int fd)
+{
+ (void)fd;
+ return -1;
+}
+int fstat(int fd, void *pstat)
+{
+ (void)fd;
+ (void)pstat;
+ return 0;
+}
+off_t lseek(int fd, off_t pos, int whence)
+{
+ (void)fd;
+ (void)pos;
+ (void)whence;
+ return 0;
+}
+int isatty(int fd)
+{
+ (void)fd;
+ return 1;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/rx/family.mk b/circuitpython/lib/tinyusb/hw/bsp/rx/family.mk
new file mode 100644
index 0000000..aba0581
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/rx/family.mk
@@ -0,0 +1,33 @@
+DEPS_SUBMODULES += hw/mcu/renesas/rx
+
+# Cross Compiler for RX
+CROSS_COMPILE = rx-elf-
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -nostartfiles \
+ -ffunction-sections \
+ -fdata-sections \
+ -fshort-enums \
+ -mlittle-endian-data \
+ -DSSIZE_MAX=__INT_MAX__
+
+SRC_C += \
+ src/portable/renesas/usba/dcd_usba.c \
+ src/portable/renesas/usba/hcd_usba.c \
+ $(MCU_DIR)/vects.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)
+
+SRC_S += $(MCU_DIR)/start.S
+
+$(BUILD)/$(PROJECT).mot: $(BUILD)/$(PROJECT).elf
+ @echo CREATE $@
+ $(OBJCOPY) -O srec -I elf32-rx-be-ns $^ $@
+
+# flash using rfp-cli
+flash-rfp: $(BUILD)/$(PROJECT).mot
+ rfp-cli -device rx65x -tool e2l -if fine -fo id FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -auth id FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -auto $^
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.h
new file mode 100644
index 0000000..1bda929
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN PIN_PA27 // pin PA22
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN PIN_PA16 // pin PB22
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.mk
new file mode 100644
index 0000000..ad9cfb2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -D__SAMD11D14AM__
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/samd11d14am_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD11D14
+
+# flash using dfu-util
+flash: $(BUILD)/$(PROJECT).bin
+ dfu-util -a 0 -d 1d50:615c -D $< || dfu-util -a 0 -d 16d0:05a5 -D $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld
new file mode 100644
index 0000000..cb633c1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/luna_d11/samd11d14am_flash.ld
@@ -0,0 +1,144 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD11D14AM
+ *
+ * Copyright (c) 2018 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 4K, LENGTH = 0x00004000 - 4K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00001000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x400;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.h
new file mode 100644
index 0000000..cfeac67
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN PIN_PA16 // pin PA22
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN PIN_PA14 // pin PB22
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.mk
new file mode 100644
index 0000000..e351cf0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -D__SAMD11D14AM__
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/samd11d14am_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD11D14
+
+# flash using edbg
+flash: $(BUILD)/$(PROJECT).bin
+ edbg -b -t samd11 -e -pv -f $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld
new file mode 100644
index 0000000..8b3124c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld
@@ -0,0 +1,144 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD11D14AM
+ *
+ * Copyright (c) 2018 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00004000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00001000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x400;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/family.c b/circuitpython/lib/tinyusb/hw/bsp/samd11/family.c
new file mode 100644
index 0000000..8d96339
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/family.c
@@ -0,0 +1,150 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+#include "board.h"
+
+#include "hal/include/hal_gpio.h"
+#include "hal/include/hal_init.h"
+#include "hri/hri_nvmctrl_d11.h"
+
+#include "hpl/gclk/hpl_gclk_base.h"
+#include "hpl_pm_config.h"
+#include "hpl/pm/hpl_pm_base.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+/* Referenced GCLKs, should be initialized firstly */
+#define _GCLK_INIT_1ST (1 << 0 | 1 << 1)
+
+/* Not referenced GCLKs, initialized last */
+#define _GCLK_INIT_LAST (~_GCLK_INIT_1ST)
+
+void board_init(void)
+{
+ // Clock init ( follow hpl_init.c )
+ hri_nvmctrl_set_CTRLB_RWS_bf(NVMCTRL, 2);
+
+ _pm_init();
+ _sysctrl_init_sources();
+#if _GCLK_INIT_1ST
+ _gclk_init_generators_by_fref(_GCLK_INIT_1ST);
+#endif
+ _sysctrl_init_referenced_generators();
+ _gclk_init_generators_by_fref(_GCLK_INIT_LAST);
+
+ // 1ms tick timer (samd SystemCoreClock may not correct)
+ SystemCoreClock = CONF_CPU_FREQUENCY;
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+
+ // Led init
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(LED_PIN, 0);
+
+ // Button init
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+
+ /* USB Clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation. */
+ _pm_enable_bus_clock(PM_BUS_APBB, USB);
+ _pm_enable_bus_clock(PM_BUS_AHB, USB);
+ _gclk_enable_channel(USB_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
+
+ // USB Pin Init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24G_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25G_USB_DP);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+
+void _init(void)
+{
+ // This _init() standin makes certain GCC environments happier.
+ // They expect the main binary to have a constructor called _init; but don't provide a weak default.
+ // Providing an empty constructor satisfies this odd case, and doesn't harm anything.
+}
+
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd11/family.mk b/circuitpython/lib/tinyusb/hw/bsp/samd11/family.mk
new file mode 100644
index 0000000..ae55be7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd11/family.mk
@@ -0,0 +1,40 @@
+DEPS_SUBMODULES += hw/mcu/microchip
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -nostdlib -nostartfiles \
+ -DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
+ -DOSC32K_OVERWRITE_CALIBRATION=0 \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMD11
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/microchip/samd/dcd_samd.c \
+ hw/mcu/microchip/samd11/gcc/gcc/startup_samd11.c \
+ hw/mcu/microchip/samd11/gcc/system_samd11.c \
+ hw/mcu/microchip/samd11/hpl/gclk/hpl_gclk.c \
+ hw/mcu/microchip/samd11/hpl/pm/hpl_pm.c \
+ hw/mcu/microchip/samd11/hpl/sysctrl/hpl_sysctrl.c \
+ hw/mcu/microchip/samd11/hal/src/hal_atomic.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/hw/mcu/microchip/samd11/ \
+ $(TOP)/hw/mcu/microchip/samd11/config \
+ $(TOP)/hw/mcu/microchip/samd11/include \
+ $(TOP)/hw/mcu/microchip/samd11/hal/include \
+ $(TOP)/hw/mcu/microchip/samd11/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/samd11/hpl/pm/ \
+ $(TOP)/hw/mcu/microchip/samd11/hpl/port \
+ $(TOP)/hw/mcu/microchip/samd11/hri \
+ $(TOP)/hw/mcu/microchip/samd11/CMSIS/Include \
+ $(TOP)/hw/mcu/microchip/samd11/CMSIS/Core/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.h
new file mode 100644
index 0000000..a3e0399
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN (32 + 30) // PB30
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN (0 + 15) // PA15
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.mk
new file mode 100644
index 0000000..4be547a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/board.mk
@@ -0,0 +1,10 @@
+CFLAGS += -D__SAMD21J18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/samd21j18a_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21J18
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld
new file mode 100644
index 0000000..e2f9341
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld
@@ -0,0 +1,144 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21J18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.h
new file mode 100644
index 0000000..2d7da1c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 17
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 28
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.mk
new file mode 100644
index 0000000..d6c9150
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld
new file mode 100644
index 0000000..f0c9334
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.h
new file mode 100644
index 0000000..67924d8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN (32 + 10) // PB10
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN (0 + 11) // PB11
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 31 // CDC5_RX
+#define UART_TX_PIN 37 // CDC5_TX
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.mk
new file mode 100644
index 0000000..112fb69
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/board.mk
@@ -0,0 +1,14 @@
+CFLAGS += -D__SAMD21G17A__ -DCFG_EXAMPLE_MSC_READONLY -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/samd21g17a_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = atsamd21g17a
+
+# flash using jlink (options are: jlink/cmsisdap/stlink/dfu)
+#flash: flash-jlink
+
+PYOCD_TARGET = atsamd21g17a
+PYOCD_OPTION = -O dap_protocol=swd
+flash: flash-pyocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld
new file mode 100644
index 0000000..153f0cb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld
@@ -0,0 +1,144 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G17A/D
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00020000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00004000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.h
new file mode 100644
index 0000000..b9292b9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 17
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 15
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.mk
new file mode 100644
index 0000000..d6c9150
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
new file mode 100644
index 0000000..f0c9334
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.h
new file mode 100644
index 0000000..177fb69
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 17
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 21
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.mk
new file mode 100644
index 0000000..d6c9150
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld
new file mode 100644
index 0000000..f0c9334
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.h
new file mode 100644
index 0000000..2e0a2a6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN PIN_PA22
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN PIN_PB22
+#define BUTTON_STATE_ACTIVE 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.mk
new file mode 100644
index 0000000..27a634e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+LD_FILE = $(BOARD_PATH)/samd21g18a_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+# flash using dfu-util
+flash: $(BUILD)/$(PROJECT).bin
+ dfu-util -a 0 -d 1d50:615c -D $< || dfu-util -a 0 -d 16d0:05a5 -D $<
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld
new file mode 100644
index 0000000..1585930
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/luna_d21/samd21g18a_flash.ld
@@ -0,0 +1,144 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 4K, LENGTH = 0x00040000 - 4K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.h
new file mode 100644
index 0000000..13b7556
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 17
+#define LED_STATE_ON 1
+
+// Button: D5
+#define BUTTON_PIN 15
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.mk
new file mode 100644
index 0000000..d6c9150
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld
new file mode 100644
index 0000000..f0c9334
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.h
new file mode 100644
index 0000000..6f8325e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.h
@@ -0,0 +1,46 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED is neopixel, leave unset for now
+
+// Button is wired to reset
+
+// UART
+#define UART_RX_PIN 8
+#define UART_TX_PIN 7
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.mk
new file mode 100644
index 0000000..6cefa84
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/board.mk
@@ -0,0 +1,11 @@
+# For Adafruit QT Py board
+
+CFLAGS += -D__SAMD21E18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21E18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/qtpy.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/qtpy.ld
new file mode 100644
index 0000000..f0c9334
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/qtpy/qtpy.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.h
new file mode 100644
index 0000000..0d1e9ce
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 17
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN 9 // PA4 pin D1 on seed input
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.mk
new file mode 100644
index 0000000..1c888da
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld
new file mode 100644
index 0000000..cf11c4c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K /* 8K offset to preserve bootloader */
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.h
new file mode 100644
index 0000000..c8692e6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.h
@@ -0,0 +1,34 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021 Jean Gressmann <jean@0x42.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#pragma once
+
+// LED
+#define LED_PIN 10 // PA10
+#define LED_STATE_ON 1
+
+// UART
+#define UART_SERCOM 0
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.mk
new file mode 100644
index 0000000..803ffe8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/board.mk
@@ -0,0 +1,5 @@
+CFLAGS += -D__SAMD21E18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/trinket_m0.ld
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld
new file mode 100644
index 0000000..f0c9334
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 0x00040000 - 8K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/family.c b/circuitpython/lib/tinyusb/hw/bsp/samd21/family.c
new file mode 100644
index 0000000..494dc39
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/family.c
@@ -0,0 +1,249 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+#include "board.h"
+
+#include "hal/include/hal_gpio.h"
+#include "hal/include/hal_init.h"
+#include "hri/hri_nvmctrl_d21.h"
+
+#include "hpl/gclk/hpl_gclk_base.h"
+#include "hpl_pm_config.h"
+#include "hpl/pm/hpl_pm_base.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// UART support
+//--------------------------------------------------------------------+
+static void uart_init(void);
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+/* Referenced GCLKs, should be initialized firstly */
+#define _GCLK_INIT_1ST (1 << 0 | 1 << 1)
+
+/* Not referenced GCLKs, initialized last */
+#define _GCLK_INIT_LAST (~_GCLK_INIT_1ST)
+
+void board_init(void)
+{
+ // Clock init ( follow hpl_init.c )
+ hri_nvmctrl_set_CTRLB_RWS_bf(NVMCTRL, 2);
+
+ _pm_init();
+ _sysctrl_init_sources();
+#if _GCLK_INIT_1ST
+ _gclk_init_generators_by_fref(_GCLK_INIT_1ST);
+#endif
+ _sysctrl_init_referenced_generators();
+ _gclk_init_generators_by_fref(_GCLK_INIT_LAST);
+
+ // Update SystemCoreClock since it is hard coded with asf4 and not correct
+ // Init 1ms tick timer (samd SystemCoreClock may not correct)
+ SystemCoreClock = CONF_CPU_FREQUENCY;
+#if CFG_TUSB_OS == OPT_OS_NONE
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ // Led init
+#ifdef LED_PIN
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ board_led_write(false);
+#endif
+
+ // Button init
+#ifdef BUTTON_PIN
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULL_DOWN : GPIO_PULL_UP);
+#endif
+
+ uart_init();
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+ /* USB Clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation. */
+ _pm_enable_bus_clock(PM_BUS_APBB, USB);
+ _pm_enable_bus_clock(PM_BUS_AHB, USB);
+ _gclk_enable_channel(USB_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
+
+ // USB Pin Init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24G_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25G_USB_DP);
+
+ // Output 500hz PWM on D12 (PA19 - TCC0 WO[3]) so we can validate the GCLK0 clock speed with a Saleae.
+ _pm_enable_bus_clock(PM_BUS_APBC, TCC0);
+ TCC0->PER.bit.PER = 48000000 / 1000;
+ TCC0->CC[3].bit.CC = 48000000 / 2000;
+ TCC0->CTRLA.bit.ENABLE = true;
+
+ gpio_set_pin_function(PIN_PA19, PINMUX_PA19F_TCC0_WO3);
+ _gclk_enable_channel(TCC0_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ (void)state;
+#ifdef LED_PIN
+ gpio_set_pin_level(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+#endif
+}
+
+uint32_t board_button_read(void)
+{
+#ifdef BUTTON_PIN
+ return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+#else
+ return 0;
+#endif
+}
+
+#if defined(UART_SERCOM)
+
+#define BOARD_SERCOM2(n) SERCOM ## n
+#define BOARD_SERCOM(n) BOARD_SERCOM2(n)
+
+static void uart_init(void)
+{
+#if UART_SERCOM == 0
+ gpio_set_pin_function(PIN_PA06, PINMUX_PA06D_SERCOM0_PAD2);
+ gpio_set_pin_function(PIN_PA07, PINMUX_PA07D_SERCOM0_PAD3);
+
+ // setup clock (48MHz)
+ _pm_enable_bus_clock(PM_BUS_APBC, SERCOM0);
+ _gclk_enable_channel(SERCOM0_GCLK_ID_CORE, GCLK_CLKCTRL_GEN_GCLK0_Val);
+
+ SERCOM0->USART.CTRLA.bit.SWRST = 1; /* reset SERCOM & enable config */
+ while(SERCOM0->USART.SYNCBUSY.bit.SWRST);
+
+ SERCOM0->USART.CTRLA.reg = /* CMODE = 0 -> async, SAMPA = 0, FORM = 0 -> USART frame, SMPR = 0 -> arithmetic baud rate */
+ SERCOM_USART_CTRLA_SAMPR(1) | /* 0 = 16x / arithmetic baud rate, 1 = 16x / fractional baud rate */
+// SERCOM_USART_CTRLA_FORM(0) | /* 0 = USART Frame, 2 = LIN Master */
+ SERCOM_USART_CTRLA_DORD | /* LSB first */
+ SERCOM_USART_CTRLA_MODE(1) | /* 0 = Asynchronous, 1 = USART with internal clock */
+ SERCOM_USART_CTRLA_RXPO(3) | /* pad 3 */
+ SERCOM_USART_CTRLA_TXPO(1); /* pad 2 */
+
+ SERCOM0->USART.CTRLB.reg =
+ SERCOM_USART_CTRLB_TXEN | /* tx enabled */
+ SERCOM_USART_CTRLB_RXEN; /* rx enabled */
+
+ SERCOM0->USART.BAUD.reg = SERCOM_USART_BAUD_FRAC_FP(0) | SERCOM_USART_BAUD_FRAC_BAUD(26);
+
+ SERCOM0->USART.CTRLA.bit.ENABLE = 1; /* activate SERCOM */
+ while(SERCOM0->USART.SYNCBUSY.bit.ENABLE); /* wait for SERCOM to be ready */
+#endif
+}
+
+static inline void uart_send_buffer(uint8_t const *text, size_t len)
+{
+ for (size_t i = 0; i < len; ++i) {
+ BOARD_SERCOM(UART_SERCOM)->USART.DATA.reg = text[i];
+ while((BOARD_SERCOM(UART_SERCOM)->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_TXC) == 0);
+ }
+}
+
+static inline void uart_send_str(const char* text)
+{
+ while (*text) {
+ BOARD_SERCOM(UART_SERCOM)->USART.DATA.reg = *text++;
+ while((BOARD_SERCOM(UART_SERCOM)->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_TXC) == 0);
+ }
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ if (len < 0) {
+ uart_send_str(buf);
+ } else {
+ uart_send_buffer(buf, len);
+ }
+ return len;
+}
+
+#else // ! defined(UART_SERCOM)
+static void uart_init(void)
+{
+
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+#endif
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd21/family.mk b/circuitpython/lib/tinyusb/hw/bsp/samd21/family.mk
new file mode 100644
index 0000000..208f237
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd21/family.mk
@@ -0,0 +1,49 @@
+UF2_FAMILY_ID = 0x68ed2b88
+DEPS_SUBMODULES += hw/mcu/microchip
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -nostdlib -nostartfiles \
+ -DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMD21
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/microchip/samd/dcd_samd.c \
+ hw/mcu/microchip/samd21/gcc/gcc/startup_samd21.c \
+ hw/mcu/microchip/samd21/gcc/system_samd21.c \
+ hw/mcu/microchip/samd21/hpl/gclk/hpl_gclk.c \
+ hw/mcu/microchip/samd21/hpl/pm/hpl_pm.c \
+ hw/mcu/microchip/samd21/hpl/sysctrl/hpl_sysctrl.c \
+ hw/mcu/microchip/samd21/hal/src/hal_atomic.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/hw/mcu/microchip/samd21/ \
+ $(TOP)/hw/mcu/microchip/samd21/config \
+ $(TOP)/hw/mcu/microchip/samd21/include \
+ $(TOP)/hw/mcu/microchip/samd21/hal/include \
+ $(TOP)/hw/mcu/microchip/samd21/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/samd21/hpl/pm/ \
+ $(TOP)/hw/mcu/microchip/samd21/hpl/port \
+ $(TOP)/hw/mcu/microchip/samd21/hri \
+ $(TOP)/hw/mcu/microchip/samd21/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash-bossac: $(BUILD)/$(PROJECT).bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.h
new file mode 100644
index 0000000..1d5ed80
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 23
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 16 // D5
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_TX_PIN (32 + 17)
+#define UART_RX_PIN (32 + 16)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.mk
new file mode 100644
index 0000000..a8a98a9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/board.mk
@@ -0,0 +1,8 @@
+CFLAGS += -D__SAMD51J19A__
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD51J19
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld
new file mode 100644
index 0000000..f1a021d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld
@@ -0,0 +1,166 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD51G19A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 0x00080000 - 16K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.h
new file mode 100644
index 0000000..0760d42
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 22
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 18 // D5
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_TX_PIN 16
+#define UART_RX_PIN 17
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.mk
new file mode 100644
index 0000000..57a680e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -D__SAMD51J19A__
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD51J19
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld
new file mode 100644
index 0000000..f1a021d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld
@@ -0,0 +1,166 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD51G19A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 0x00080000 - 16K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.h
new file mode 100644
index 0000000..ab10ae4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 16
+#define LED_STATE_ON 1
+
+// Button: D5
+#define BUTTON_PIN (32+14)
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_TX_PIN 23
+#define UART_RX_PIN 22
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.mk
new file mode 100644
index 0000000..d7953cc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/board.mk
@@ -0,0 +1,10 @@
+CFLAGS += -D__SAMD51J19A__
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD51J19
+
+flash: flash-bossac
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld
new file mode 100644
index 0000000..f1a021d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld
@@ -0,0 +1,166 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD51G19A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 0x00080000 - 16K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.h
new file mode 100644
index 0000000..1d5ed80
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 23
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 16 // D5
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_TX_PIN (32 + 17)
+#define UART_RX_PIN (32 + 16)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.mk
new file mode 100644
index 0000000..a8a98a9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/board.mk
@@ -0,0 +1,8 @@
+CFLAGS += -D__SAMD51J19A__
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD51J19
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/pybadge.ld b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/pybadge.ld
new file mode 100644
index 0000000..f1a021d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pybadge/pybadge.ld
@@ -0,0 +1,166 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD51G19A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 0x00080000 - 16K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.h b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.h
new file mode 100644
index 0000000..9e51ded
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN (32+23)
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN (32+22) // D2
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_TX_PIN (32 + 13)
+#define UART_RX_PIN (32 + 12)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.mk
new file mode 100644
index 0000000..a8a98a9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/board.mk
@@ -0,0 +1,8 @@
+CFLAGS += -D__SAMD51J19A__
+
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD51J19
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/pyportal.ld b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/pyportal.ld
new file mode 100644
index 0000000..f1a021d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/boards/pyportal/pyportal.ld
@@ -0,0 +1,166 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD51G19A
+ *
+ * Copyright (c) 2017 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 0x00080000 - 16K
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00030000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/family.c b/circuitpython/lib/tinyusb/hw/bsp/samd51/family.c
new file mode 100644
index 0000000..020e638
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/family.c
@@ -0,0 +1,162 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+#include "board.h"
+
+#include "hal/include/hal_gpio.h"
+#include "hal/include/hal_init.h"
+#include "hpl/gclk/hpl_gclk_base.h"
+#include "hpl_mclk_config.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_0_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+void USB_1_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+void USB_2_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+void USB_3_Handler (void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+/* Referenced GCLKs, should be initialized firstly */
+#define _GCLK_INIT_1ST 0xFFFFFFFF
+
+/* Not referenced GCLKs, initialized last */
+#define _GCLK_INIT_LAST (~_GCLK_INIT_1ST)
+
+void board_init(void)
+{
+ // Clock init ( follow hpl_init.c )
+ hri_nvmctrl_set_CTRLA_RWS_bf(NVMCTRL, 0);
+
+ _osc32kctrl_init_sources();
+ _oscctrl_init_sources();
+ _mclk_init();
+#if _GCLK_INIT_1ST
+ _gclk_init_generators_by_fref(_GCLK_INIT_1ST);
+#endif
+ _oscctrl_init_referenced_generators();
+ _gclk_init_generators_by_fref(_GCLK_INIT_LAST);
+
+ // Update SystemCoreClock since it is hard coded with asf4 and not correct
+ // Init 1ms tick timer (samd SystemCoreClock may not correct)
+ SystemCoreClock = CONF_CPU_FREQUENCY;
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+
+ // Led init
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(LED_PIN, 0);
+
+ // Button init
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_3_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+ /* USB Clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation. */
+ hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+ hri_mclk_set_AHBMASK_USB_bit(MCLK);
+ hri_mclk_set_APBBMASK_USB_bit(MCLK);
+
+ // USB Pin Init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24H_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25H_USB_DP);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // button is active low
+ return gpio_get_pin_level(BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samd51/family.mk b/circuitpython/lib/tinyusb/hw/bsp/samd51/family.mk
new file mode 100644
index 0000000..783bed8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samd51/family.mk
@@ -0,0 +1,50 @@
+UF2_FAMILY_ID = 0x55114460
+DEPS_SUBMODULES += hw/mcu/microchip
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMD51
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/microchip/samd/dcd_samd.c \
+ hw/mcu/microchip/samd51/gcc/gcc/startup_samd51.c \
+ hw/mcu/microchip/samd51/gcc/system_samd51.c \
+ hw/mcu/microchip/samd51/hpl/gclk/hpl_gclk.c \
+ hw/mcu/microchip/samd51/hpl/mclk/hpl_mclk.c \
+ hw/mcu/microchip/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c \
+ hw/mcu/microchip/samd51/hpl/oscctrl/hpl_oscctrl.c \
+ hw/mcu/microchip/samd51/hal/src/hal_atomic.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/hw/mcu/microchip/samd51/ \
+ $(TOP)/hw/mcu/microchip/samd51/config \
+ $(TOP)/hw/mcu/microchip/samd51/include \
+ $(TOP)/hw/mcu/microchip/samd51/hal/include \
+ $(TOP)/hw/mcu/microchip/samd51/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/samd51/hpl/port \
+ $(TOP)/hw/mcu/microchip/samd51/hri \
+ $(TOP)/hw/mcu/microchip/samd51/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash-bossac: $(BUILD)/$(PROJECT).bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x4000 -e -w $^ -R
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/board.mk b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/board.mk
new file mode 100644
index 0000000..2d0d928
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/board.mk
@@ -0,0 +1,48 @@
+DEPS_SUBMODULES += hw/mcu/microchip
+
+CONF_CPU_FREQUENCY ?= 48000000
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mlong-calls \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -D__SAME54P20A__ \
+ -DCONF_CPU_FREQUENCY=$(CONF_CPU_FREQUENCY) \
+ -DCFG_TUSB_MCU=OPT_MCU_SAME5X \
+ -DBOARD_NAME="\"Microchip SAM E54 Xplained Pro\""
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-qual
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/same54p20a_flash.ld
+
+SRC_C += \
+ src/portable/microchip/samd/dcd_samd.c \
+ hw/mcu/microchip/same54/gcc/gcc/startup_same54.c \
+ hw/mcu/microchip/same54/gcc/system_same54.c \
+ hw/mcu/microchip/same54/hal/utils/src/utils_syscalls.c
+
+INC += \
+ $(TOP)/hw/mcu/microchip/same54/ \
+ $(TOP)/hw/mcu/microchip/same54/config \
+ $(TOP)/hw/mcu/microchip/same54/include \
+ $(TOP)/hw/mcu/microchip/same54/hal/include \
+ $(TOP)/hw/mcu/microchip/same54/hal/utils/include \
+ $(TOP)/hw/mcu/microchip/same54/hpl/port \
+ $(TOP)/hw/mcu/microchip/same54/hri \
+ $(TOP)/hw/mcu/microchip/same54/CMSIS/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAME54P20
+
+# flash using edbg from https://github.com/ataradov/edbg
+flash: $(BUILD)/$(PROJECT).bin
+ edbg --verbose -t same54 -pv -f $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_flash.ld
new file mode 100644
index 0000000..97072bf
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_flash.ld
@@ -0,0 +1,163 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAME54P20A
+ *
+ * Copyright (c) 2019 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00100000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_sram.ld b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_sram.ld
new file mode 100644
index 0000000..6219f4a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54p20a_sram.ld
@@ -0,0 +1,162 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal SRAM on the SAME54P20A
+ *
+ * Copyright (c) 2019 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000
+ bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
+ qspi (rwx) : ORIGIN = 0x04000000, LENGTH = 0x01000000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > ram
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > ram
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .bkupram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sbkupram = .;
+ *(.bkupram .bkupram.*);
+ . = ALIGN(8);
+ _ebkupram = .;
+ } > bkupram
+
+ .qspi (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sqspi = .;
+ *(.qspi .qspi.*);
+ . = ALIGN(8);
+ _eqspi = .;
+ } > qspi
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54xplainedpro.c b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54xplainedpro.c
new file mode 100644
index 0000000..ba1eec3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same54xplainedpro/same54xplainedpro.c
@@ -0,0 +1,306 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021 Jean Gressmann <jean@0x42.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include <sam.h>
+#include "bsp/board.h"
+
+#include <hal/include/hal_gpio.h>
+
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_0_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB_1_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB_2_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB_3_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+#define LED_PIN PIN_PC18
+#define BUTTON_PIN PIN_PB31
+#define BOARD_SERCOM SERCOM2
+
+/** Initializes the clocks from the external 12 MHz crystal
+ *
+ * The goal of this setup is to preserve the second PLL
+ * for the application code while still having a reasonable
+ * 48 MHz clock for USB / UART.
+ *
+ * GCLK0: CONF_CPU_FREQUENCY (default 120 MHz) from PLL0
+ * GCLK1: unused
+ * GCLK2: 12 MHz from XOSC1
+ * DFLL48M: closed loop from GLCK2
+ * GCLK3: 48 MHz
+ */
+static inline void init_clock_xtal(void)
+{
+ /* configure for a 12MHz crystal connected to XIN1/XOUT1 */
+ OSCCTRL->XOSCCTRL[1].reg =
+ OSCCTRL_XOSCCTRL_STARTUP(6) | // 1.953 ms
+ OSCCTRL_XOSCCTRL_RUNSTDBY |
+ OSCCTRL_XOSCCTRL_ENALC |
+ OSCCTRL_XOSCCTRL_IMULT(4) | OSCCTRL_XOSCCTRL_IPTAT(3) | // 8MHz to 16MHz
+ OSCCTRL_XOSCCTRL_XTALEN |
+ OSCCTRL_XOSCCTRL_ENABLE;
+ while(0 == OSCCTRL->STATUS.bit.XOSCRDY1);
+
+ OSCCTRL->Dpll[0].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_DIV(2) | OSCCTRL_DPLLCTRLB_REFCLK_XOSC1; /* 12MHz / 6 = 2Mhz, input = XOSC1 */
+ OSCCTRL->Dpll[0].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0x0) | OSCCTRL_DPLLRATIO_LDR((CONF_CPU_FREQUENCY / 1000000 / 2) - 1); /* multiply to get CONF_CPU_FREQUENCY (default = 120MHz) */
+ OSCCTRL->Dpll[0].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_RUNSTDBY | OSCCTRL_DPLLCTRLA_ENABLE;
+ while(0 == OSCCTRL->Dpll[0].DPLLSTATUS.bit.CLKRDY); /* wait for the PLL0 to be ready */
+
+ /* configure clock-generator 0 to use DPLL0 as source -> GCLK0 is used for the core */
+ GCLK->GENCTRL[0].reg =
+ GCLK_GENCTRL_DIV(0) |
+ GCLK_GENCTRL_RUNSTDBY |
+ GCLK_GENCTRL_GENEN |
+ GCLK_GENCTRL_SRC_DPLL0 |
+ GCLK_GENCTRL_IDC;
+ while(1 == GCLK->SYNCBUSY.bit.GENCTRL0); /* wait for the synchronization between clock domains to be complete */
+
+ // configure GCLK2 for 12MHz from XOSC1
+ GCLK->GENCTRL[2].reg =
+ GCLK_GENCTRL_DIV(0) |
+ GCLK_GENCTRL_RUNSTDBY |
+ GCLK_GENCTRL_GENEN |
+ GCLK_GENCTRL_SRC_XOSC1 |
+ GCLK_GENCTRL_IDC;
+ while(1 == GCLK->SYNCBUSY.bit.GENCTRL2); /* wait for the synchronization between clock domains to be complete */
+
+ /* setup DFLL48M to use GLCK2 */
+ GCLK->PCHCTRL[OSCCTRL_GCLK_ID_DFLL48].reg = GCLK_PCHCTRL_GEN_GCLK2 | GCLK_PCHCTRL_CHEN;
+
+ OSCCTRL->DFLLCTRLA.reg = 0;
+ while(1 == OSCCTRL->DFLLSYNC.bit.ENABLE);
+
+ OSCCTRL->DFLLCTRLB.reg = OSCCTRL_DFLLCTRLB_MODE | OSCCTRL_DFLLCTRLB_WAITLOCK;
+ OSCCTRL->DFLLMUL.bit.MUL = 4; // 4 * 12MHz -> 48MHz
+
+ OSCCTRL->DFLLCTRLA.reg =
+ OSCCTRL_DFLLCTRLA_ENABLE |
+ OSCCTRL_DFLLCTRLA_RUNSTDBY;
+ while(1 == OSCCTRL->DFLLSYNC.bit.ENABLE);
+
+ // setup 48 MHz GCLK3 from DFLL48M
+ GCLK->GENCTRL[3].reg =
+ GCLK_GENCTRL_DIV(0) |
+ GCLK_GENCTRL_RUNSTDBY |
+ GCLK_GENCTRL_GENEN |
+ GCLK_GENCTRL_SRC_DFLL |
+ GCLK_GENCTRL_IDC;
+ while(1 == GCLK->SYNCBUSY.bit.GENCTRL3);
+}
+
+/* Initialize SERCOM2 for 115200 bps 8N1 using a 48 MHz clock */
+static inline void uart_init(void)
+{
+ gpio_set_pin_function(PIN_PB24, PINMUX_PB24D_SERCOM2_PAD1);
+ gpio_set_pin_function(PIN_PB25, PINMUX_PB25D_SERCOM2_PAD0);
+
+ MCLK->APBBMASK.bit.SERCOM2_ = 1;
+ GCLK->PCHCTRL[SERCOM2_GCLK_ID_CORE].reg = GCLK_PCHCTRL_GEN_GCLK0 | GCLK_PCHCTRL_CHEN;
+
+ BOARD_SERCOM->USART.CTRLA.bit.SWRST = 1; /* reset and disable SERCOM -> enable configuration */
+ while (BOARD_SERCOM->USART.SYNCBUSY.bit.SWRST);
+
+ BOARD_SERCOM->USART.CTRLA.reg =
+ SERCOM_USART_CTRLA_SAMPR(0) | /* 0 = 16x / arithmetic baud rate, 1 = 16x / fractional baud rate */
+ SERCOM_USART_CTRLA_SAMPA(0) | /* 16x over sampling */
+ SERCOM_USART_CTRLA_FORM(0) | /* 0x0 USART frame, 0x1 USART frame with parity, ... */
+ SERCOM_USART_CTRLA_DORD | /* LSB first */
+ SERCOM_USART_CTRLA_MODE(1) | /* 0x0 USART with external clock, 0x1 USART with internal clock */
+ SERCOM_USART_CTRLA_RXPO(1) | /* SERCOM PAD[1] is used for data reception */
+ SERCOM_USART_CTRLA_TXPO(0); /* SERCOM PAD[0] is used for data transmission */
+
+ BOARD_SERCOM->USART.CTRLB.reg = /* RXEM = 0 -> receiver disabled, LINCMD = 0 -> normal USART transmission, SFDE = 0 -> start-of-frame detection disabled, SBMODE = 0 -> one stop bit, CHSIZE = 0 -> 8 bits */
+ SERCOM_USART_CTRLB_TXEN | /* transmitter enabled */
+ SERCOM_USART_CTRLB_RXEN; /* receiver enabled */
+ // BOARD_SERCOM->USART.BAUD.reg = SERCOM_USART_BAUD_FRAC_FP(0) | SERCOM_USART_BAUD_FRAC_BAUD(26); /* 48000000/(16*115200) = 26.041666667 */
+ BOARD_SERCOM->USART.BAUD.reg = SERCOM_USART_BAUD_BAUD(63019); /* 65536*(1−16*115200/48000000) */
+
+ BOARD_SERCOM->USART.CTRLA.bit.ENABLE = 1; /* activate SERCOM */
+ while (BOARD_SERCOM->USART.SYNCBUSY.bit.ENABLE); /* wait for SERCOM to be ready */
+}
+
+static inline void uart_send_buffer(uint8_t const *text, size_t len)
+{
+ for (size_t i = 0; i < len; ++i) {
+ BOARD_SERCOM->USART.DATA.reg = text[i];
+ while((BOARD_SERCOM->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_TXC) == 0);
+ }
+}
+
+static inline void uart_send_str(const char* text)
+{
+ while (*text) {
+ BOARD_SERCOM->USART.DATA.reg = *text++;
+ while((BOARD_SERCOM->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_TXC) == 0);
+ }
+}
+
+
+void board_init(void)
+{
+ // Uncomment this line and change the GCLK for UART/USB to run off the XTAL.
+ // init_clock_xtal();
+
+ SystemCoreClock = CONF_CPU_FREQUENCY;
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ uart_init();
+
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " UART initialized\n");
+ tu_printf(BOARD_NAME " reset cause %#02x\n", RSTC->RCAUSE.reg);
+#endif
+
+ // LED0 init
+ gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ board_led_write(0);
+
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " LED pin configured\n");
+#endif
+
+ // BTN0 init
+ gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " Button pin configured\n");
+#endif
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_3_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+
+#if CFG_TUD_ENABLED
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " USB device enabled\n");
+#endif
+
+ /* USB clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation.
+ */
+ hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK0_Val | GCLK_PCHCTRL_CHEN);
+ hri_mclk_set_AHBMASK_USB_bit(MCLK);
+ hri_mclk_set_APBBMASK_USB_bit(MCLK);
+
+ // USB pin init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24H_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25H_USB_DP);
+
+
+#if CFG_TUSB_DEBUG >= 2
+ uart_send_str(BOARD_NAME " USB device configured\n");
+#endif
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, !state);
+}
+
+uint32_t board_button_read(void)
+{
+ return (PORT->Group[1].IN.reg & 0x80000000) != 0x80000000;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ if (len < 0) {
+ uart_send_str(buf);
+ } else {
+ uart_send_buffer(buf, len);
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/board.mk b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/board.mk
new file mode 100644
index 0000000..ba7088e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/board.mk
@@ -0,0 +1,56 @@
+DEPS_SUBMODULES += hw/mcu/microchip
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -D__SAME70N19B__ \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMX7X
+
+# suppress following warnings from mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual
+
+ASF_DIR = hw/mcu/microchip/same70
+
+# All source paths should be relative to the top level.
+LD_FILE = $(ASF_DIR)/same70b/gcc/gcc/same70q21b_flash.ld
+
+SRC_C += \
+ src/portable/microchip/samx7x/dcd_samx7x.c \
+ $(ASF_DIR)/same70b/gcc/gcc/startup_same70q21b.c \
+ $(ASF_DIR)/same70b/gcc/system_same70q21b.c \
+ $(ASF_DIR)/hpl/core/hpl_init.c \
+ $(ASF_DIR)/hpl/usart/hpl_usart.c \
+ $(ASF_DIR)/hpl/pmc/hpl_pmc.c \
+ $(ASF_DIR)/hal/src/hal_usart_async.c \
+ $(ASF_DIR)/hal/src/hal_io.c \
+ $(ASF_DIR)/hal/src/hal_atomic.c \
+ $(ASF_DIR)/hal/utils/src/utils_ringbuffer.c
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(ASF_DIR) \
+ $(TOP)/$(ASF_DIR)/config \
+ $(TOP)/$(ASF_DIR)/same70b/include \
+ $(TOP)/$(ASF_DIR)/hal/include \
+ $(TOP)/$(ASF_DIR)/hal/utils/include \
+ $(TOP)/$(ASF_DIR)/hpl/core \
+ $(TOP)/$(ASF_DIR)/hpl/pio \
+ $(TOP)/$(ASF_DIR)/hpl/pmc \
+ $(TOP)/$(ASF_DIR)/hri \
+ $(TOP)/$(ASF_DIR)/CMSIS/Core/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM7
+
+# For flash-jlink target
+JLINK_DEVICE = SAME70N19B
+
+# flash using edbg from https://github.com/ataradov/edbg
+# Note: SAME70's GPNVM1 must be set to 1 to boot from flash with
+# edbg -t same70 -F w0,1,1
+flash: $(BUILD)/$(PROJECT).bin
+ edbg --verbose -t same70 -pv -f $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_pmc_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_pmc_config.h
new file mode 100644
index 0000000..387aaa5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_pmc_config.h
@@ -0,0 +1,1053 @@
+/* Auto-generated config file hpl_pmc_config.h */
+#ifndef HPL_PMC_CONFIG_H
+#define HPL_PMC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include <peripheral_clk_config.h>
+
+#define CLK_SRC_OPTION_OSC32K 0
+#define CLK_SRC_OPTION_XOSC32K 1
+#define CLK_SRC_OPTION_OSC12M 2
+#define CLK_SRC_OPTION_XOSC20M 3
+
+#define CLK_SRC_OPTION_SLCK 0
+#define CLK_SRC_OPTION_MAINCK 1
+#define CLK_SRC_OPTION_PLLACK 2
+#define CLK_SRC_OPTION_UPLLCKDIV 3
+#define CLK_SRC_OPTION_MCK 4
+
+#define CLK_SRC_OPTION_UPLLCK 3
+
+#define CONF_RC_4M 0
+#define CONF_RC_8M 1
+#define CONF_RC_12M 2
+
+#define CONF_XOSC32K_NO_BYPASS 0
+#define CONF_XOSC32K_BYPASS 1
+
+#define CONF_XOSC20M_NO_BYPASS 0
+#define CONF_XOSC20M_BYPASS 1
+
+// <e> Clock_SLCK configuration
+// <i> Indicates whether SLCK configuration is enabled or not
+// <id> enable_clk_gen_slck
+#ifndef CONF_CLK_SLCK_CONFIG
+#define CONF_CLK_SLCK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator SLCK source
+
+// <CLK_SRC_OPTION_OSC32K"> 32kHz High Accuracy Internal Oscillator (OSC32K)
+
+// <CLK_SRC_OPTION_XOSC32K"> 32kHz External Crystal Oscillator (XOSC32K)
+
+// <i> This defines the clock source for SLCK
+// <id> clk_gen_slck_oscillator
+#ifndef CONF_CLK_GEN_SLCK_SRC
+#define CONF_CLK_GEN_SLCK_SRC CLK_SRC_OPTION_OSC32K
+#endif
+
+// <q> Enable Clock_SLCK
+// <i> Indicates whether SLCK is enabled or disable
+// <id> clk_gen_slck_arch_enable
+#ifndef CONF_CLK_SLCK_ENABLE
+#define CONF_CLK_SLCK_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_MAINCK configuration
+// <i> Indicates whether MAINCK configuration is enabled or not
+// <id> enable_clk_gen_mainck
+#ifndef CONF_CLK_MAINCK_CONFIG
+#define CONF_CLK_MAINCK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator MAINCK source
+
+// <CLK_SRC_OPTION_OSC12M"> Embedded 4/8/12MHz RC Oscillator (OSC12M)
+
+// <CLK_SRC_OPTION_XOSC20M"> External 3-20MHz Oscillator (XOSC20M)
+
+// <i> This defines the clock source for MAINCK
+// <id> clk_gen_mainck_oscillator
+#ifndef CONF_CLK_GEN_MAINCK_SRC
+#define CONF_CLK_GEN_MAINCK_SRC CLK_SRC_OPTION_XOSC20M
+#endif
+
+// <q> Enable Clock_MAINCK
+// <i> Indicates whether MAINCK is enabled or disable
+// <id> clk_gen_mainck_arch_enable
+#ifndef CONF_CLK_MAINCK_ENABLE
+#define CONF_CLK_MAINCK_ENABLE 1
+#endif
+
+// <q> Enable Main Clock Failure Detection
+// <i> Indicates whether Main Clock Failure Detection is enabled or disable.
+// <i> The 4/8/12 MHz RC oscillator must be selected as the source of MAINCK.
+// <id> clk_gen_cfden_enable
+#ifndef CONF_CLK_CFDEN_ENABLE
+#define CONF_CLK_CFDEN_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_MCKR configuration
+// <i> Indicates whether MCKR configuration is enabled or not
+// <id> enable_clk_gen_mckr
+#ifndef CONF_CLK_MCKR_CONFIG
+#define CONF_CLK_MCKR_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator MCKR source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <i> This defines the clock source for MCKR
+// <id> clk_gen_mckr_oscillator
+#ifndef CONF_CLK_GEN_MCKR_SRC
+#define CONF_CLK_GEN_MCKR_SRC CLK_SRC_OPTION_PLLACK
+#endif
+
+// <q> Enable Clock_MCKR
+// <i> Indicates whether MCKR is enabled or disable
+// <id> clk_gen_mckr_arch_enable
+#ifndef CONF_CLK_MCKR_ENABLE
+#define CONF_CLK_MCKR_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Master Clock Prescaler
+// <0=> 1
+// <1=> 2
+// <2=> 4
+// <3=> 8
+// <4=> 16
+// <5=> 32
+// <6=> 64
+// <7=> 3
+// <i> Select the clock prescaler.
+// <id> mckr_presc
+#ifndef CONF_MCKR_PRESC
+#define CONF_MCKR_PRESC 0
+#endif
+
+// </h>
+// </e>// <e> Clock_MCK configuration
+// <i> Indicates whether MCK configuration is enabled or not
+// <id> enable_clk_gen_mck
+#ifndef CONF_CLK_MCK_CONFIG
+#define CONF_CLK_MCK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator MCK source
+
+// <CLK_SRC_OPTION_MCKR"> Master Clock Controller (PMC_MCKR)
+
+// <i> This defines the clock source for MCK
+// <id> clk_gen_mck_oscillator
+#ifndef CONF_CLK_GEN_MCK_SRC
+#define CONF_CLK_GEN_MCK_SRC CLK_SRC_OPTION_MCKR
+#endif
+
+// </h>
+
+// <h>
+
+//<o> Master Clock Controller Divider MCK divider
+// <0=> 1
+// <1=> 2
+// <3=> 3
+// <2=> 4
+// <i> Select the master clock divider.
+// <id> mck_div
+#ifndef CONF_MCK_DIV
+#define CONF_MCK_DIV 1
+#endif
+
+// </h>
+// </e>// <e> Clock_SYSTICK configuration
+// <i> Indicates whether SYSTICK configuration is enabled or not
+// <id> enable_clk_gen_systick
+#ifndef CONF_CLK_SYSTICK_CONFIG
+#define CONF_CLK_SYSTICK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator SYSTICK source
+
+// <CLK_SRC_OPTION_MCKR"> Master Clock Controller (PMC_MCKR)
+
+// <i> This defines the clock source for SYSTICK
+// <id> clk_gen_systick_oscillator
+#ifndef CONF_CLK_GEN_SYSTICK_SRC
+#define CONF_CLK_GEN_SYSTICK_SRC CLK_SRC_OPTION_MCKR
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Systick clock divider
+// <8=> 8
+// <i> Select systick clock divider
+// <id> systick_clock_div
+#ifndef CONF_SYSTICK_DIV
+#define CONF_SYSTICK_DIV 8
+#endif
+
+// </h>
+// </e>// <e> Clock_FCLK configuration
+// <i> Indicates whether FCLK configuration is enabled or not
+// <id> enable_clk_gen_fclk
+#ifndef CONF_CLK_FCLK_CONFIG
+#define CONF_CLK_FCLK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator FCLK source
+
+// <CLK_SRC_OPTION_MCKR"> Master Clock Controller (PMC_MCKR)
+
+// <i> This defines the clock source for FCLK
+// <id> clk_gen_fclk_oscillator
+#ifndef CONF_CLK_GEN_FCLK_SRC
+#define CONF_CLK_GEN_FCLK_SRC CLK_SRC_OPTION_MCKR
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_GCLK0 configuration
+// <i> Indicates whether GCLK0 configuration is enabled or not
+// <id> enable_clk_gen_gclk0
+#ifndef CONF_CLK_GCLK0_CONFIG
+#define CONF_CLK_GCLK0_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator GCLK0 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCK"> USB 480M Clock (UPLLCK)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for GCLK0
+// <id> clk_gen_gclk0_oscillator
+#ifndef CONF_CLK_GEN_GCLK0_SRC
+#define CONF_CLK_GEN_GCLK0_SRC CLK_SRC_OPTION_MCK
+#endif
+
+// <q> Enable Clock_GCLK0
+// <i> Indicates whether GCLK0 is enabled or disable
+// <id> clk_gen_gclk0_arch_enable
+#ifndef CONF_CLK_GCLK0_ENABLE
+#define CONF_CLK_GCLK0_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+// <q> Enable GCLK0 GCLKEN
+// <i> Indicates whether GCLK0 GCLKEN is enabled or disable
+// <id> gclk0_gclken_enable
+#ifndef CONF_GCLK0_GCLKEN_ENABLE
+#define CONF_GCLK0_GCLKEN_ENABLE 0
+#endif
+
+// <o> Generic Clock GCLK0 divider <1-256>
+// <i> Select the clock divider (divider = GCLKDIV + 1).
+// <id> gclk0_div
+#ifndef CONF_GCLK0_DIV
+#define CONF_GCLK0_DIV 2
+#endif
+
+// </h>
+// </e>// <e> Clock_GCLK1 configuration
+// <i> Indicates whether GCLK1 configuration is enabled or not
+// <id> enable_clk_gen_gclk1
+#ifndef CONF_CLK_GCLK1_CONFIG
+#define CONF_CLK_GCLK1_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator GCLK1 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCK"> USB 480M Clock (UPLLCK)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for GCLK1
+// <id> clk_gen_gclk1_oscillator
+#ifndef CONF_CLK_GEN_GCLK1_SRC
+#define CONF_CLK_GEN_GCLK1_SRC CLK_SRC_OPTION_PLLACK
+#endif
+
+// <q> Enable Clock_GCLK1
+// <i> Indicates whether GCLK1 is enabled or disable
+// <id> clk_gen_gclk1_arch_enable
+#ifndef CONF_CLK_GCLK1_ENABLE
+#define CONF_CLK_GCLK1_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+// <q> Enable GCLK1 GCLKEN
+// <i> Indicates whether GCLK1 GCLKEN is enabled or disable
+// <id> gclk1_gclken_enable
+#ifndef CONF_GCLK1_GCLKEN_ENABLE
+#define CONF_GCLK1_GCLKEN_ENABLE 0
+#endif
+
+// <o> Generic Clock GCLK1 divider <1-256>
+// <i> Select the clock divider (divider = GCLKDIV + 1).
+// <id> gclk1_div
+#ifndef CONF_GCLK1_DIV
+#define CONF_GCLK1_DIV 3
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK0 configuration
+// <i> Indicates whether PCK0 configuration is enabled or not
+// <id> enable_clk_gen_pck0
+#ifndef CONF_CLK_PCK0_CONFIG
+#define CONF_CLK_PCK0_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK0 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK0
+// <id> clk_gen_pck0_oscillator
+#ifndef CONF_CLK_GEN_PCK0_SRC
+#define CONF_CLK_GEN_PCK0_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK0
+// <i> Indicates whether PCK0 is enabled or disable
+// <id> clk_gen_pck0_arch_enable
+#ifndef CONF_CLK_PCK0_ENABLE
+#define CONF_CLK_PCK0_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck0_presc
+#ifndef CONF_PCK0_PRESC
+#define CONF_PCK0_PRESC 1
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK1 configuration
+// <i> Indicates whether PCK1 configuration is enabled or not
+// <id> enable_clk_gen_pck1
+#ifndef CONF_CLK_PCK1_CONFIG
+#define CONF_CLK_PCK1_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK1 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK1
+// <id> clk_gen_pck1_oscillator
+#ifndef CONF_CLK_GEN_PCK1_SRC
+#define CONF_CLK_GEN_PCK1_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK1
+// <i> Indicates whether PCK1 is enabled or disable
+// <id> clk_gen_pck1_arch_enable
+#ifndef CONF_CLK_PCK1_ENABLE
+#define CONF_CLK_PCK1_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck1_presc
+#ifndef CONF_PCK1_PRESC
+#define CONF_PCK1_PRESC 2
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK2 configuration
+// <i> Indicates whether PCK2 configuration is enabled or not
+// <id> enable_clk_gen_pck2
+#ifndef CONF_CLK_PCK2_CONFIG
+#define CONF_CLK_PCK2_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK2 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK2
+// <id> clk_gen_pck2_oscillator
+#ifndef CONF_CLK_GEN_PCK2_SRC
+#define CONF_CLK_GEN_PCK2_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK2
+// <i> Indicates whether PCK2 is enabled or disable
+// <id> clk_gen_pck2_arch_enable
+#ifndef CONF_CLK_PCK2_ENABLE
+#define CONF_CLK_PCK2_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck2_presc
+#ifndef CONF_PCK2_PRESC
+#define CONF_PCK2_PRESC 3
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK3 configuration
+// <i> Indicates whether PCK3 configuration is enabled or not
+// <id> enable_clk_gen_pck3
+#ifndef CONF_CLK_PCK3_CONFIG
+#define CONF_CLK_PCK3_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK3 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK3
+// <id> clk_gen_pck3_oscillator
+#ifndef CONF_CLK_GEN_PCK3_SRC
+#define CONF_CLK_GEN_PCK3_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK3
+// <i> Indicates whether PCK3 is enabled or disable
+// <id> clk_gen_pck3_arch_enable
+#ifndef CONF_CLK_PCK3_ENABLE
+#define CONF_CLK_PCK3_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck3_presc
+#ifndef CONF_PCK3_PRESC
+#define CONF_PCK3_PRESC 4
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK4 configuration
+// <i> Indicates whether PCK4 configuration is enabled or not
+// <id> enable_clk_gen_pck4
+#ifndef CONF_CLK_PCK4_CONFIG
+#define CONF_CLK_PCK4_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK4 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK4
+// <id> clk_gen_pck4_oscillator
+#ifndef CONF_CLK_GEN_PCK4_SRC
+#define CONF_CLK_GEN_PCK4_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK4
+// <i> Indicates whether PCK4 is enabled or disable
+// <id> clk_gen_pck4_arch_enable
+#ifndef CONF_CLK_PCK4_ENABLE
+#define CONF_CLK_PCK4_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck4_presc
+#ifndef CONF_PCK4_PRESC
+#define CONF_PCK4_PRESC 5
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK5 configuration
+// <i> Indicates whether PCK5 configuration is enabled or not
+// <id> enable_clk_gen_pck5
+#ifndef CONF_CLK_PCK5_CONFIG
+#define CONF_CLK_PCK5_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK5 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK5
+// <id> clk_gen_pck5_oscillator
+#ifndef CONF_CLK_GEN_PCK5_SRC
+#define CONF_CLK_GEN_PCK5_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK5
+// <i> Indicates whether PCK5 is enabled or disable
+// <id> clk_gen_pck5_arch_enable
+#ifndef CONF_CLK_PCK5_ENABLE
+#define CONF_CLK_PCK5_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck5_presc
+#ifndef CONF_PCK5_PRESC
+#define CONF_PCK5_PRESC 6
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK6 configuration
+// <i> Indicates whether PCK6 configuration is enabled or not
+// <id> enable_clk_gen_pck6
+#ifndef CONF_CLK_PCK6_CONFIG
+#define CONF_CLK_PCK6_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK6 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK6
+// <id> clk_gen_pck6_oscillator
+#ifndef CONF_CLK_GEN_PCK6_SRC
+#define CONF_CLK_GEN_PCK6_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK6
+// <i> Indicates whether PCK6 is enabled or disable
+// <id> clk_gen_pck6_arch_enable
+#ifndef CONF_CLK_PCK6_ENABLE
+#define CONF_CLK_PCK6_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck6_presc
+#ifndef CONF_PCK6_PRESC
+#define CONF_PCK6_PRESC 7
+#endif
+
+// </h>
+// </e>// <e> Clock_USB_480M configuration
+// <i> Indicates whether USB_480M configuration is enabled or not
+// <id> enable_clk_gen_usb_480m
+#ifndef CONF_CLK_USB_480M_CONFIG
+#define CONF_CLK_USB_480M_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator USB_480M source
+
+// <CLK_SRC_OPTION_UPLLCK"> USB 480M Clock (UPLLCK)
+
+// <i> This defines the clock source for USB_480M
+// <id> clk_gen_usb_480m_oscillator
+#ifndef CONF_CLK_GEN_USB_480M_SRC
+#define CONF_CLK_GEN_USB_480M_SRC CLK_SRC_OPTION_UPLLCK
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_USB_48M configuration
+// <i> Indicates whether USB_48M configuration is enabled or not
+// <id> enable_clk_gen_usb_48m
+#ifndef CONF_CLK_USB_48M_CONFIG
+#define CONF_CLK_USB_48M_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator USB_48M source
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <i> This defines the clock source for USB_48M
+// <id> clk_gen_usb_48m_oscillator
+#ifndef CONF_CLK_GEN_USB_48M_SRC
+#define CONF_CLK_GEN_USB_48M_SRC CLK_SRC_OPTION_UPLLCKDIV
+#endif
+
+// <q> Enable Clock_USB_48M
+// <i> Indicates whether USB_48M is enabled or disable
+// <id> clk_gen_usb_48m_arch_enable
+#ifndef CONF_CLK_USB_48M_ENABLE
+#define CONF_CLK_USB_48M_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+
+// <o> USB Clock Controller Divider <1-16>
+// <i> Select the USB clock divider (divider = USBDIV + 1).
+// <id> usb_48m_div
+#ifndef CONF_USB_48M_DIV
+#define CONF_USB_48M_DIV 5
+#endif
+
+// </h>
+// </e>// <e> Clock_SLCK2 configuration
+// <i> Indicates whether SLCK2 configuration is enabled or not
+// <id> enable_clk_gen_slck2
+#ifndef CONF_CLK_SLCK2_CONFIG
+#define CONF_CLK_SLCK2_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator SLCK2 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <i> This defines the clock source for SLCK2
+// <id> clk_gen_slck2_oscillator
+#ifndef CONF_CLK_GEN_SLCK2_SRC
+#define CONF_CLK_GEN_SLCK2_SRC CLK_SRC_OPTION_SLCK
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>
+
+// <e> System Configuration
+// <i> Indicates whether configuration for system is enabled or not
+// <id> enable_hclk_clock
+#ifndef CONF_SYSTEM_CONFIG
+#define CONF_SYSTEM_CONFIG 1
+#endif
+
+// <h> Processor Clock Settings
+// <y> Processor Clock source
+// <MCKR"> Master Clock Controller (PMC_MCKR)
+// <i> This defines the clock source for the HCLK (Processor clock)
+// <id> hclk_clock_source
+#ifndef CONF_HCLK_SRC
+#define CONF_HCLK_SRC MCKR
+#endif
+
+// <o> Flash Wait State
+// <0=> 1 cycle
+// <1=> 2 cycles
+// <2=> 3 cycles
+// <3=> 4 cycles
+// <4=> 5 cycles
+// <5=> 6 cycles
+// <6=> 7 cycles
+// <i> This field defines the number of wait states for read and write operations.
+// <id> efc_fws
+#ifndef CONF_EFC_WAIT_STATE
+#define CONF_EFC_WAIT_STATE 5
+#endif
+
+// </h>
+// </e>
+
+// <e> SysTick Clock
+// <id> enable_systick_clk_clock
+#ifndef CONF_SYSTICK_CLK_CONFIG
+#define CONF_SYSTICK_CLK_CONFIG 1
+#endif
+
+// <y> SysTick Clock source
+// <MCKR"> Master Clock Controller (PMC_MCKR)
+// <i> This defines the clock source for the SysTick Clock
+// <id> systick_clk_clock_source
+#ifndef CONF_SYSTICK_CLK_SRC
+#define CONF_SYSTICK_CLK_SRC MCKR
+#endif
+
+// <o> SysTick Clock Divider
+// <8=> 8
+// <i> Fixed to 8 if Systick is not using Processor clock
+// <id> systick_clk_clock_div
+#ifndef CONF_SYSTICK_CLK_DIV
+#define CONF_SYSTICK_CLK_DIV 8
+#endif
+
+// </e>
+
+// <e> OSC32K Oscillator Configuration
+// <i> Indicates whether configuration for OSC32K is enabled or not
+// <id> enable_osc32k
+#ifndef CONF_OSC32K_CONFIG
+#define CONF_OSC32K_CONFIG 1
+#endif
+
+// <h> OSC32K Oscillator Control
+// <q> OSC32K Oscillator Enable
+// <i> Indicates whether OSC32K Oscillator is enabled or not
+// <id> osc32k_arch_enable
+#ifndef CONF_OSC32K_ENABLE
+#define CONF_OSC32K_ENABLE 0
+#endif
+// </h>
+// </e>
+
+// <e> XOSC32K Oscillator Configuration
+// <i> Indicates whether configuration for XOSC32K is enabled or not
+// <id> enable_xosc32k
+#ifndef CONF_XOSC32K_CONFIG
+#define CONF_XOSC32K_CONFIG 0
+#endif
+
+// <h> XOSC32K Oscillator Control
+// <y> Oscillator Bypass Select
+// <CONF_XOSC32K_NO_BYPASS"> The 32kHz crystal oscillator is not bypassed.
+// <CONF_XOSC32K_BYPASS"> The 32kHz crystal oscillator is bypassed.
+// <i> Indicates whether XOSC32K is bypassed.
+// <id> xosc32k_bypass
+#ifndef CONF_XOSC32K
+#define CONF_XOSC32K CONF_XOSC32K_NO_BYPASS
+#endif
+
+// <q> XOSC32K Oscillator Enable
+// <i> Indicates whether XOSC32K Oscillator is enabled or not
+// <id> xosc32k_arch_enable
+#ifndef CONF_XOSC32K_ENABLE
+#define CONF_XOSC32K_ENABLE 0
+#endif
+// </h>
+// </e>
+
+// <e> OSC12M Oscillator Configuration
+// <i> Indicates whether configuration for OSC12M is enabled or not
+// <id> enable_osc12m
+#ifndef CONF_OSC12M_CONFIG
+#define CONF_OSC12M_CONFIG 0
+#endif
+
+// <h> OSC12M Oscillator Control
+// <q> OSC12M Oscillator Enable
+// <i> Indicates whether OSC12M Oscillator is enabled or not.
+// <id> osc12m_arch_enable
+#ifndef CONF_OSC12M_ENABLE
+#define CONF_OSC12M_ENABLE 0
+#endif
+
+// <o> OSC12M selector
+// <0=> 4000000
+// <1=> 8000000
+// <2=> 12000000
+// <i> Select the frequency of embedded fast RC oscillator.
+// <id> osc12m_selector
+#ifndef CONF_OSC12M_SELECTOR
+#define CONF_OSC12M_SELECTOR 2
+#endif
+// </h>
+// </e>
+
+// <e> XOSC20M Oscillator Configuration
+// <i> Indicates whether configuration for XOSC20M is enabled or not.
+// <id> enable_xosc20m
+#ifndef CONF_XOSC20M_CONFIG
+#define CONF_XOSC20M_CONFIG 1
+#endif
+
+// <h> XOSC20M Oscillator Control
+// <o> XOSC20M selector <3000000-20000000>
+// <i> Select the frequency of crystal or ceramic resonator oscillator.
+// <id> xosc20m_selector
+#ifndef CONF_XOSC20M_SELECTOR
+#define CONF_XOSC20M_SELECTOR 12000000
+#endif
+
+// <o> Start up time for the external oscillator (ms): <0-256>
+// <i> Select start-up time.
+// <id> xosc20m_startup_time
+#ifndef CONF_XOSC20M_STARTUP_TIME
+#define CONF_XOSC20M_STARTUP_TIME 62
+#endif
+
+// <y> Oscillator Bypass Select
+// <CONF_XOSC20M_NO_BYPASS"> The external crystal oscillator is not bypassed.
+// <CONF_XOSC20M_BYPASS"> The external crystal oscillator is bypassed.
+// <i> Indicates whether XOSC20M is bypassed.
+// <id> xosc20m_bypass
+#ifndef CONF_XOSC20M
+#define CONF_XOSC20M CONF_XOSC20M_NO_BYPASS
+#endif
+
+// <q> XOSC20M Oscillator Enable
+// <i> Indicates whether XOSC20M Oscillator is enabled or not
+// <id> xosc20m_arch_enable
+#ifndef CONF_XOSC20M_ENABLE
+#define CONF_XOSC20M_ENABLE 1
+#endif
+// </h>
+// </e>
+
+// <e> PLLACK Oscillator Configuration
+// <i> Indicates whether configuration for PLLACK is enabled or not
+// <id> enable_pllack
+#ifndef CONF_PLLACK_CONFIG
+#define CONF_PLLACK_CONFIG 1
+#endif
+
+// <y> PLLACK Reference Clock Source
+// <MAINCK"> Main Clock (MAINCK)
+// <i> Select the clock source.
+// <id> pllack_ref_clock
+#ifndef CONF_PLLACK_CLK
+#define CONF_PLLACK_CLK MAINCK
+#endif
+
+// <h> PLLACK Oscillator Control
+// <q> PLLACK Oscillator Enable
+// <i> Indicates whether PLLACK Oscillator is enabled or not
+// <id> pllack_arch_enable
+#ifndef CONF_PLLACK_ENABLE
+#define CONF_PLLACK_ENABLE 1
+#endif
+
+// <o> PLLA Frontend Divider (DIVA) <1-255>
+// <i> Select the clock divider
+// <id> pllack_div
+#ifndef CONF_PLLACK_DIV
+#define CONF_PLLACK_DIV 1
+#endif
+
+// <o> PLLACK Muliplier <1-62>
+// <i> Indicates PLLA multiplier (multiplier = MULA + 1).
+// <id> pllack_mul
+#ifndef CONF_PLLACK_MUL
+#define CONF_PLLACK_MUL 25
+#endif
+// </h>
+// </e>
+
+// <e> UPLLCK Oscillator Configuration
+// <i> Indicates whether configuration for UPLLCK is enabled or not
+// <id> enable_upllck
+#ifndef CONF_UPLLCK_CONFIG
+#define CONF_UPLLCK_CONFIG 1
+#endif
+
+// <y> UPLLCK Reference Clock Source
+// <XOSC20M"> External 3-20MHz Oscillator (XOSC20M)
+// <i> Select the clock source,only when the input frequency is 12M or 16M, the upllck output is 480M.
+// <id> upllck_ref_clock
+#ifndef CONF_UPLLCK_CLK
+#define CONF_UPLLCK_CLK XOSC20M
+#endif
+
+// <h> UPLLCK Oscillator Control
+// <q> UPLLCK Oscillator Enable
+// <i> Indicates whether UPLLCK Oscillator is enabled or not
+// <id> upllck_arch_enable
+#ifndef CONF_UPLLCK_ENABLE
+#define CONF_UPLLCK_ENABLE 1
+#endif
+// </h>
+// </e>
+
+// <e> UPLLCKDIV Oscillator Configuration
+// <i> Indicates whether configuration for UPLLCKDIV is enabled or not
+// <id> enable_upllckdiv
+#ifndef CONF_UPLLCKDIV_CONFIG
+#define CONF_UPLLCKDIV_CONFIG 1
+#endif
+
+// <y> UPLLCKDIV Reference Clock Source
+// <UPLLCK"> USB 480M Clock (UPLLCK)
+// <i> Select the clock source.
+// <id> upllckdiv_ref_clock
+#ifndef CONF_UPLLCKDIV_CLK
+#define CONF_UPLLCKDIV_CLK UPLLCK
+#endif
+
+// <h> UPLLCKDIV Oscillator Control
+// <o> UPLLCKDIV Clock Divider
+// <0=> 1
+// <1=> 2
+// <i> Select the clock divider.
+// <id> upllckdiv_div
+#ifndef CONF_UPLLCKDIV_DIV
+#define CONF_UPLLCKDIV_DIV 1
+#endif
+// </h>
+// </e>
+
+// <e> MCK/8
+// <id> enable_mck_div_8
+#ifndef CONF_MCK_DIV_8_CONFIG
+#define CONF_MCK_DIV_8_CONFIG 0
+#endif
+
+// <o> MCK/8 Source
+// <0=> Master Clock (MCK)
+// <id> mck_div_8_src
+#ifndef CONF_MCK_DIV_8_SRC
+#define CONF_MCK_DIV_8_SRC 0
+#endif
+// </e>
+
+// <e> External Clock Input Configuration
+// <id> enable_dummy_ext
+#ifndef CONF_DUMMY_EXT_CONFIG
+#define CONF_DUMMY_EXT_CONFIG 1
+#endif
+
+// <o> External Clock Input Source
+// <i> All here are dummy values
+// <i> Refer to the peripherals settings for actual input information
+// <0=> Specific clock input from specific pin
+// <id> dummy_ext_src
+#ifndef CONF_DUMMY_EXT_SRC
+#define CONF_DUMMY_EXT_SRC 0
+#endif
+// </e>
+
+// <e> External Clock Configuration
+// <id> enable_dummy_ext_clk
+#ifndef CONF_DUMMY_EXT_CLK_CONFIG
+#define CONF_DUMMY_EXT_CLK_CONFIG 1
+#endif
+
+// <o> External Clock Source
+// <i> All here are dummy values
+// <i> Refer to the peripherals settings for actual input information
+// <0=> External Clock Input
+// <id> dummy_ext_clk_src
+#ifndef CONF_DUMMY_EXT_CLK_SRC
+#define CONF_DUMMY_EXT_CLK_SRC 0
+#endif
+// </e>
+
+// <<< end of configuration section >>>
+
+#endif // HPL_PMC_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_usart_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_usart_config.h
new file mode 100644
index 0000000..50ca3f1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_usart_config.h
@@ -0,0 +1,215 @@
+/* Auto-generated config file hpl_usart_config.h */
+#ifndef HPL_USART_CONFIG_H
+#define HPL_USART_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_USART_1_ENABLE
+#define CONF_USART_1_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <o> Frame parity
+// <0x0=>Even parity
+// <0x1=>Odd parity
+// <0x2=>Parity forced to 0
+// <0x3=>Parity forced to 1
+// <0x4=>No parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_USART_1_PARITY
+#define CONF_USART_1_PARITY 0x4
+#endif
+
+// <o> Character Size
+// <0x0=>5 bits
+// <0x1=>6 bits
+// <0x2=>7 bits
+// <0x3=>8 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_USART_1_CHSIZE
+#define CONF_USART_1_CHSIZE 0x3
+#endif
+
+// <o> Stop Bit
+// <0=>1 stop bit
+// <1=>1.5 stop bits
+// <2=>2 stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_USART_1_SBMODE
+#define CONF_USART_1_SBMODE 0
+#endif
+
+// <o> Clock Output Select
+// <0=>The USART does not drive the SCK pin
+// <1=>The USART drives the SCK pin if USCLKS does not select the external clock SCK
+// <i> Clock Output Select in USART sck, if in usrt master mode, please drive SCK.
+// <id> usart_clock_output_select
+#ifndef CONF_USART_1_CLKO
+#define CONF_USART_1_CLKO 0
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_USART_1_BAUD
+#define CONF_USART_1_BAUD 9600
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_USART_1_ADVANCED_CONFIG
+#define CONF_USART_1_ADVANCED_CONFIG 0
+#endif
+
+// <o> Channel Mode
+// <0=>Normal Mode
+// <1=>Automatic Echo
+// <2=>Local Loopback
+// <3=>Remote Loopback
+// <i> Channel mode in USART frame
+// <id> usart_channel_mode
+#ifndef CONF_USART_1_CHMODE
+#define CONF_USART_1_CHMODE 0
+#endif
+
+// <q> 9 bits character enable
+// <i> Enable 9 bits character, this has high priority than 5/6/7/8 bits.
+// <id> usart_9bits_enable
+#ifndef CONF_USART_1_MODE9
+#define CONF_USART_1_MODE9 0
+#endif
+
+// <o> Variable Sync
+// <0=>User defined configuration
+// <1=>sync field is updated when a character is written into US_THR
+// <i> Variable Synchronization of Command/Data Sync Start Frarm Delimiter
+// <id> variable_sync
+#ifndef CONF_USART_1_VAR_SYNC
+#define CONF_USART_1_VAR_SYNC 0
+#endif
+
+// <o> Oversampling Mode
+// <0=>16 Oversampling
+// <1=>8 Oversampling
+// <i> Oversampling Mode in UART mode
+// <id> usart__oversampling_mode
+#ifndef CONF_USART_1_OVER
+#define CONF_USART_1_OVER 0
+#endif
+
+// <o> Inhibit Non Ack
+// <0=>The NACK is generated
+// <1=>The NACK is not generated
+// <i> Inhibit Non Acknowledge
+// <id> usart__inack
+#ifndef CONF_USART_1_INACK
+#define CONF_USART_1_INACK 1
+#endif
+
+// <o> Disable Successive NACK
+// <0=>NACK is sent on the ISO line as soon as a parity error occurs
+// <1=>Many parity errors generate a NACK on the ISO line
+// <i> Disable Successive NACK
+// <id> usart_dsnack
+#ifndef CONF_USART_1_DSNACK
+#define CONF_USART_1_DSNACK 0
+#endif
+
+// <o> Inverted Data
+// <0=>Data isn't inverted, nomal mode
+// <1=>Data is inverted
+// <i> Inverted Data
+// <id> usart_invdata
+#ifndef CONF_USART_1_INVDATA
+#define CONF_USART_1_INVDATA 0
+#endif
+
+// <o> Maximum Number of Automatic Iteration <0-7>
+// <i> Defines the maximum number of iterations in mode ISO7816, protocol T = 0.
+// <id> usart_max_iteration
+#ifndef CONF_USART_1_MAX_ITERATION
+#define CONF_USART_1_MAX_ITERATION 0
+#endif
+
+// <q> Receive Line Filter enable
+// <i> whether the USART filters the receive line using a three-sample filter
+// <id> usart_receive_filter_enable
+#ifndef CONF_USART_1_FILTER
+#define CONF_USART_1_FILTER 0
+#endif
+
+// <q> Manchester Encoder/Decoder Enable
+// <i> whether the USART Manchester Encoder/Decoder
+// <id> usart_manchester_filter_enable
+#ifndef CONF_USART_1_MAN
+#define CONF_USART_1_MAN 0
+#endif
+
+// <o> Manchester Synchronization Mode
+// <0=>The Manchester start bit is a 0 to 1 transition
+// <1=>The Manchester start bit is a 1 to 0 transition
+// <i> Manchester Synchronization Mode
+// <id> usart_manchester_synchronization_mode
+#ifndef CONF_USART_1_MODSYNC
+#define CONF_USART_1_MODSYNC 0
+#endif
+
+// <o> Start Frame Delimiter Selector
+// <0=>Start frame delimiter is COMMAND or DATA SYNC
+// <1=>Start frame delimiter is one bit
+// <i> Start Frame Delimiter Selector
+// <id> usart_start_frame_delimiter
+#ifndef CONF_USART_1_ONEBIT
+#define CONF_USART_1_ONEBIT 0
+#endif
+
+// <o> Fractional Part <0-7>
+// <i> Fractional part of the baud rate if baud rate generator is in fractional mode
+// <id> usart_arch_fractional
+#ifndef CONF_USART_1_FRACTIONAL
+#define CONF_USART_1_FRACTIONAL 0x0
+#endif
+
+// <o> Data Order
+// <0=>LSB is transmitted first
+// <1=>MSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_msbf
+#ifndef CONF_USART_1_MSBF
+#define CONF_USART_1_MSBF 0
+#endif
+
+// </e>
+
+#define CONF_USART_1_MODE 0x0
+
+// Calculate BAUD register value in UART mode
+#if CONF_USART1_CK_SRC < 3
+#ifndef CONF_USART_1_BAUD_CD
+#define CONF_USART_1_BAUD_CD ((CONF_USART1_FREQUENCY) / CONF_USART_1_BAUD / 8 / (2 - CONF_USART_1_OVER))
+#endif
+#ifndef CONF_USART_1_BAUD_FP
+#define CONF_USART_1_BAUD_FP \
+ ((CONF_USART1_FREQUENCY) / CONF_USART_1_BAUD / (2 - CONF_USART_1_OVER) - 8 * CONF_USART_1_BAUD_CD)
+#endif
+#elif CONF_USART1_CK_SRC == 3
+// No division is active. The value written in US_BRGR has no effect.
+#ifndef CONF_USART_1_BAUD_CD
+#define CONF_USART_1_BAUD_CD 1
+#endif
+#ifndef CONF_USART_1_BAUD_FP
+#define CONF_USART_1_BAUD_FP 1
+#endif
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // HPL_USART_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_xdmac_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_xdmac_config.h
new file mode 100644
index 0000000..a3d62c6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/hpl_xdmac_config.h
@@ -0,0 +1,4400 @@
+/* Auto-generated config file hpl_xdmac_config.h */
+#ifndef HPL_XDMAC_CONFIG_H
+#define HPL_XDMAC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// <e> XDMAC enable
+// <i> Indicates whether xdmac is enabled or not
+// <id> xdmac_enable
+#ifndef CONF_DMA_ENABLE
+#define CONF_DMA_ENABLE 0
+#endif
+
+// <e> Channel 0 settings
+// <id> dmac_channel_0_settings
+#ifndef CONF_DMAC_CHANNEL_0_SETTINGS
+#define CONF_DMAC_CHANNEL_0_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_0
+#ifndef CONF_DMAC_BURSTSIZE_0
+#define CONF_DMAC_BURSTSIZE_0 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_0
+#ifndef CONF_DMAC_CHUNKSIZE_0
+#define CONF_DMAC_CHUNKSIZE_0 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_0
+#ifndef CONF_DMAC_BEATSIZE_0
+#define CONF_DMAC_BEATSIZE_0 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_0
+#ifndef CONF_DMAC_SRC_INTERFACE_0
+#define CONF_DMAC_SRC_INTERFACE_0 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_0
+#ifndef CONF_DMAC_DES_INTERFACE_0
+#define CONF_DMAC_DES_INTERFACE_0 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_0
+#ifndef CONF_DMAC_SRCINC_0
+#define CONF_DMAC_SRCINC_0 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_0
+#ifndef CONF_DMAC_DSTINC_0
+#define CONF_DMAC_DSTINC_0 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_0
+#ifndef CONF_DMAC_TRANS_TYPE_0
+#define CONF_DMAC_TRANS_TYPE_0 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_0
+#ifndef CONF_DMAC_TRIGSRC_0
+#define CONF_DMAC_TRIGSRC_0 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_0 == 0
+#define CONF_DMAC_TYPE_0 0
+#define CONF_DMAC_DSYNC_0 0
+#elif CONF_DMAC_TRANS_TYPE_0 == 1
+#define CONF_DMAC_TYPE_0 1
+#define CONF_DMAC_DSYNC_0 0
+#elif CONF_DMAC_TRANS_TYPE_0 == 2
+#define CONF_DMAC_TYPE_0 1
+#define CONF_DMAC_DSYNC_0 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_0 == 0xFF
+#define CONF_DMAC_SWREQ_0 1
+#else
+#define CONF_DMAC_SWREQ_0 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_0_SETTINGS == 1 && CONF_DMAC_BEATSIZE_0 != 2 && ((!CONF_DMAC_SRCINC_0) || (!CONF_DMAC_DSTINC_0)))
+#if (!CONF_DMAC_SRCINC_0)
+#define CONF_DMAC_SRC_STRIDE_0 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_0)
+#define CONF_DMAC_DES_STRIDE_0 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_0
+#define CONF_DMAC_SRC_STRIDE_0 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_0
+#define CONF_DMAC_DES_STRIDE_0 0
+#endif
+
+// <e> Channel 1 settings
+// <id> dmac_channel_1_settings
+#ifndef CONF_DMAC_CHANNEL_1_SETTINGS
+#define CONF_DMAC_CHANNEL_1_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_1
+#ifndef CONF_DMAC_BURSTSIZE_1
+#define CONF_DMAC_BURSTSIZE_1 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_1
+#ifndef CONF_DMAC_CHUNKSIZE_1
+#define CONF_DMAC_CHUNKSIZE_1 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_1
+#ifndef CONF_DMAC_BEATSIZE_1
+#define CONF_DMAC_BEATSIZE_1 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_1
+#ifndef CONF_DMAC_SRC_INTERFACE_1
+#define CONF_DMAC_SRC_INTERFACE_1 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_1
+#ifndef CONF_DMAC_DES_INTERFACE_1
+#define CONF_DMAC_DES_INTERFACE_1 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_1
+#ifndef CONF_DMAC_SRCINC_1
+#define CONF_DMAC_SRCINC_1 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_1
+#ifndef CONF_DMAC_DSTINC_1
+#define CONF_DMAC_DSTINC_1 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_1
+#ifndef CONF_DMAC_TRANS_TYPE_1
+#define CONF_DMAC_TRANS_TYPE_1 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_1
+#ifndef CONF_DMAC_TRIGSRC_1
+#define CONF_DMAC_TRIGSRC_1 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_1 == 0
+#define CONF_DMAC_TYPE_1 0
+#define CONF_DMAC_DSYNC_1 0
+#elif CONF_DMAC_TRANS_TYPE_1 == 1
+#define CONF_DMAC_TYPE_1 1
+#define CONF_DMAC_DSYNC_1 0
+#elif CONF_DMAC_TRANS_TYPE_1 == 2
+#define CONF_DMAC_TYPE_1 1
+#define CONF_DMAC_DSYNC_1 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_1 == 0xFF
+#define CONF_DMAC_SWREQ_1 1
+#else
+#define CONF_DMAC_SWREQ_1 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_1_SETTINGS == 1 && CONF_DMAC_BEATSIZE_1 != 2 && ((!CONF_DMAC_SRCINC_1) || (!CONF_DMAC_DSTINC_1)))
+#if (!CONF_DMAC_SRCINC_1)
+#define CONF_DMAC_SRC_STRIDE_1 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_1)
+#define CONF_DMAC_DES_STRIDE_1 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_1
+#define CONF_DMAC_SRC_STRIDE_1 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_1
+#define CONF_DMAC_DES_STRIDE_1 0
+#endif
+
+// <e> Channel 2 settings
+// <id> dmac_channel_2_settings
+#ifndef CONF_DMAC_CHANNEL_2_SETTINGS
+#define CONF_DMAC_CHANNEL_2_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_2
+#ifndef CONF_DMAC_BURSTSIZE_2
+#define CONF_DMAC_BURSTSIZE_2 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_2
+#ifndef CONF_DMAC_CHUNKSIZE_2
+#define CONF_DMAC_CHUNKSIZE_2 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_2
+#ifndef CONF_DMAC_BEATSIZE_2
+#define CONF_DMAC_BEATSIZE_2 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_2
+#ifndef CONF_DMAC_SRC_INTERFACE_2
+#define CONF_DMAC_SRC_INTERFACE_2 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_2
+#ifndef CONF_DMAC_DES_INTERFACE_2
+#define CONF_DMAC_DES_INTERFACE_2 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_2
+#ifndef CONF_DMAC_SRCINC_2
+#define CONF_DMAC_SRCINC_2 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_2
+#ifndef CONF_DMAC_DSTINC_2
+#define CONF_DMAC_DSTINC_2 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_2
+#ifndef CONF_DMAC_TRANS_TYPE_2
+#define CONF_DMAC_TRANS_TYPE_2 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_2
+#ifndef CONF_DMAC_TRIGSRC_2
+#define CONF_DMAC_TRIGSRC_2 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_2 == 0
+#define CONF_DMAC_TYPE_2 0
+#define CONF_DMAC_DSYNC_2 0
+#elif CONF_DMAC_TRANS_TYPE_2 == 1
+#define CONF_DMAC_TYPE_2 1
+#define CONF_DMAC_DSYNC_2 0
+#elif CONF_DMAC_TRANS_TYPE_2 == 2
+#define CONF_DMAC_TYPE_2 1
+#define CONF_DMAC_DSYNC_2 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_2 == 0xFF
+#define CONF_DMAC_SWREQ_2 1
+#else
+#define CONF_DMAC_SWREQ_2 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_2_SETTINGS == 1 && CONF_DMAC_BEATSIZE_2 != 2 && ((!CONF_DMAC_SRCINC_2) || (!CONF_DMAC_DSTINC_2)))
+#if (!CONF_DMAC_SRCINC_2)
+#define CONF_DMAC_SRC_STRIDE_2 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_2)
+#define CONF_DMAC_DES_STRIDE_2 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_2
+#define CONF_DMAC_SRC_STRIDE_2 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_2
+#define CONF_DMAC_DES_STRIDE_2 0
+#endif
+
+// <e> Channel 3 settings
+// <id> dmac_channel_3_settings
+#ifndef CONF_DMAC_CHANNEL_3_SETTINGS
+#define CONF_DMAC_CHANNEL_3_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_3
+#ifndef CONF_DMAC_BURSTSIZE_3
+#define CONF_DMAC_BURSTSIZE_3 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_3
+#ifndef CONF_DMAC_CHUNKSIZE_3
+#define CONF_DMAC_CHUNKSIZE_3 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_3
+#ifndef CONF_DMAC_BEATSIZE_3
+#define CONF_DMAC_BEATSIZE_3 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_3
+#ifndef CONF_DMAC_SRC_INTERFACE_3
+#define CONF_DMAC_SRC_INTERFACE_3 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_3
+#ifndef CONF_DMAC_DES_INTERFACE_3
+#define CONF_DMAC_DES_INTERFACE_3 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_3
+#ifndef CONF_DMAC_SRCINC_3
+#define CONF_DMAC_SRCINC_3 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_3
+#ifndef CONF_DMAC_DSTINC_3
+#define CONF_DMAC_DSTINC_3 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_3
+#ifndef CONF_DMAC_TRANS_TYPE_3
+#define CONF_DMAC_TRANS_TYPE_3 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_3
+#ifndef CONF_DMAC_TRIGSRC_3
+#define CONF_DMAC_TRIGSRC_3 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_3 == 0
+#define CONF_DMAC_TYPE_3 0
+#define CONF_DMAC_DSYNC_3 0
+#elif CONF_DMAC_TRANS_TYPE_3 == 1
+#define CONF_DMAC_TYPE_3 1
+#define CONF_DMAC_DSYNC_3 0
+#elif CONF_DMAC_TRANS_TYPE_3 == 2
+#define CONF_DMAC_TYPE_3 1
+#define CONF_DMAC_DSYNC_3 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_3 == 0xFF
+#define CONF_DMAC_SWREQ_3 1
+#else
+#define CONF_DMAC_SWREQ_3 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_3_SETTINGS == 1 && CONF_DMAC_BEATSIZE_3 != 2 && ((!CONF_DMAC_SRCINC_3) || (!CONF_DMAC_DSTINC_3)))
+#if (!CONF_DMAC_SRCINC_3)
+#define CONF_DMAC_SRC_STRIDE_3 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_3)
+#define CONF_DMAC_DES_STRIDE_3 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_3
+#define CONF_DMAC_SRC_STRIDE_3 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_3
+#define CONF_DMAC_DES_STRIDE_3 0
+#endif
+
+// <e> Channel 4 settings
+// <id> dmac_channel_4_settings
+#ifndef CONF_DMAC_CHANNEL_4_SETTINGS
+#define CONF_DMAC_CHANNEL_4_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_4
+#ifndef CONF_DMAC_BURSTSIZE_4
+#define CONF_DMAC_BURSTSIZE_4 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_4
+#ifndef CONF_DMAC_CHUNKSIZE_4
+#define CONF_DMAC_CHUNKSIZE_4 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_4
+#ifndef CONF_DMAC_BEATSIZE_4
+#define CONF_DMAC_BEATSIZE_4 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_4
+#ifndef CONF_DMAC_SRC_INTERFACE_4
+#define CONF_DMAC_SRC_INTERFACE_4 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_4
+#ifndef CONF_DMAC_DES_INTERFACE_4
+#define CONF_DMAC_DES_INTERFACE_4 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_4
+#ifndef CONF_DMAC_SRCINC_4
+#define CONF_DMAC_SRCINC_4 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_4
+#ifndef CONF_DMAC_DSTINC_4
+#define CONF_DMAC_DSTINC_4 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_4
+#ifndef CONF_DMAC_TRANS_TYPE_4
+#define CONF_DMAC_TRANS_TYPE_4 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_4
+#ifndef CONF_DMAC_TRIGSRC_4
+#define CONF_DMAC_TRIGSRC_4 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_4 == 0
+#define CONF_DMAC_TYPE_4 0
+#define CONF_DMAC_DSYNC_4 0
+#elif CONF_DMAC_TRANS_TYPE_4 == 1
+#define CONF_DMAC_TYPE_4 1
+#define CONF_DMAC_DSYNC_4 0
+#elif CONF_DMAC_TRANS_TYPE_4 == 2
+#define CONF_DMAC_TYPE_4 1
+#define CONF_DMAC_DSYNC_4 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_4 == 0xFF
+#define CONF_DMAC_SWREQ_4 1
+#else
+#define CONF_DMAC_SWREQ_4 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_4_SETTINGS == 1 && CONF_DMAC_BEATSIZE_4 != 2 && ((!CONF_DMAC_SRCINC_4) || (!CONF_DMAC_DSTINC_4)))
+#if (!CONF_DMAC_SRCINC_4)
+#define CONF_DMAC_SRC_STRIDE_4 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_4)
+#define CONF_DMAC_DES_STRIDE_4 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_4
+#define CONF_DMAC_SRC_STRIDE_4 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_4
+#define CONF_DMAC_DES_STRIDE_4 0
+#endif
+
+// <e> Channel 5 settings
+// <id> dmac_channel_5_settings
+#ifndef CONF_DMAC_CHANNEL_5_SETTINGS
+#define CONF_DMAC_CHANNEL_5_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_5
+#ifndef CONF_DMAC_BURSTSIZE_5
+#define CONF_DMAC_BURSTSIZE_5 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_5
+#ifndef CONF_DMAC_CHUNKSIZE_5
+#define CONF_DMAC_CHUNKSIZE_5 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_5
+#ifndef CONF_DMAC_BEATSIZE_5
+#define CONF_DMAC_BEATSIZE_5 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_5
+#ifndef CONF_DMAC_SRC_INTERFACE_5
+#define CONF_DMAC_SRC_INTERFACE_5 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_5
+#ifndef CONF_DMAC_DES_INTERFACE_5
+#define CONF_DMAC_DES_INTERFACE_5 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_5
+#ifndef CONF_DMAC_SRCINC_5
+#define CONF_DMAC_SRCINC_5 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_5
+#ifndef CONF_DMAC_DSTINC_5
+#define CONF_DMAC_DSTINC_5 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_5
+#ifndef CONF_DMAC_TRANS_TYPE_5
+#define CONF_DMAC_TRANS_TYPE_5 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_5
+#ifndef CONF_DMAC_TRIGSRC_5
+#define CONF_DMAC_TRIGSRC_5 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_5 == 0
+#define CONF_DMAC_TYPE_5 0
+#define CONF_DMAC_DSYNC_5 0
+#elif CONF_DMAC_TRANS_TYPE_5 == 1
+#define CONF_DMAC_TYPE_5 1
+#define CONF_DMAC_DSYNC_5 0
+#elif CONF_DMAC_TRANS_TYPE_5 == 2
+#define CONF_DMAC_TYPE_5 1
+#define CONF_DMAC_DSYNC_5 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_5 == 0xFF
+#define CONF_DMAC_SWREQ_5 1
+#else
+#define CONF_DMAC_SWREQ_5 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_5_SETTINGS == 1 && CONF_DMAC_BEATSIZE_5 != 2 && ((!CONF_DMAC_SRCINC_5) || (!CONF_DMAC_DSTINC_5)))
+#if (!CONF_DMAC_SRCINC_5)
+#define CONF_DMAC_SRC_STRIDE_5 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_5)
+#define CONF_DMAC_DES_STRIDE_5 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_5
+#define CONF_DMAC_SRC_STRIDE_5 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_5
+#define CONF_DMAC_DES_STRIDE_5 0
+#endif
+
+// <e> Channel 6 settings
+// <id> dmac_channel_6_settings
+#ifndef CONF_DMAC_CHANNEL_6_SETTINGS
+#define CONF_DMAC_CHANNEL_6_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_6
+#ifndef CONF_DMAC_BURSTSIZE_6
+#define CONF_DMAC_BURSTSIZE_6 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_6
+#ifndef CONF_DMAC_CHUNKSIZE_6
+#define CONF_DMAC_CHUNKSIZE_6 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_6
+#ifndef CONF_DMAC_BEATSIZE_6
+#define CONF_DMAC_BEATSIZE_6 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_6
+#ifndef CONF_DMAC_SRC_INTERFACE_6
+#define CONF_DMAC_SRC_INTERFACE_6 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_6
+#ifndef CONF_DMAC_DES_INTERFACE_6
+#define CONF_DMAC_DES_INTERFACE_6 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_6
+#ifndef CONF_DMAC_SRCINC_6
+#define CONF_DMAC_SRCINC_6 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_6
+#ifndef CONF_DMAC_DSTINC_6
+#define CONF_DMAC_DSTINC_6 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_6
+#ifndef CONF_DMAC_TRANS_TYPE_6
+#define CONF_DMAC_TRANS_TYPE_6 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_6
+#ifndef CONF_DMAC_TRIGSRC_6
+#define CONF_DMAC_TRIGSRC_6 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_6 == 0
+#define CONF_DMAC_TYPE_6 0
+#define CONF_DMAC_DSYNC_6 0
+#elif CONF_DMAC_TRANS_TYPE_6 == 1
+#define CONF_DMAC_TYPE_6 1
+#define CONF_DMAC_DSYNC_6 0
+#elif CONF_DMAC_TRANS_TYPE_6 == 2
+#define CONF_DMAC_TYPE_6 1
+#define CONF_DMAC_DSYNC_6 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_6 == 0xFF
+#define CONF_DMAC_SWREQ_6 1
+#else
+#define CONF_DMAC_SWREQ_6 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_6_SETTINGS == 1 && CONF_DMAC_BEATSIZE_6 != 2 && ((!CONF_DMAC_SRCINC_6) || (!CONF_DMAC_DSTINC_6)))
+#if (!CONF_DMAC_SRCINC_6)
+#define CONF_DMAC_SRC_STRIDE_6 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_6)
+#define CONF_DMAC_DES_STRIDE_6 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_6
+#define CONF_DMAC_SRC_STRIDE_6 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_6
+#define CONF_DMAC_DES_STRIDE_6 0
+#endif
+
+// <e> Channel 7 settings
+// <id> dmac_channel_7_settings
+#ifndef CONF_DMAC_CHANNEL_7_SETTINGS
+#define CONF_DMAC_CHANNEL_7_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_7
+#ifndef CONF_DMAC_BURSTSIZE_7
+#define CONF_DMAC_BURSTSIZE_7 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_7
+#ifndef CONF_DMAC_CHUNKSIZE_7
+#define CONF_DMAC_CHUNKSIZE_7 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_7
+#ifndef CONF_DMAC_BEATSIZE_7
+#define CONF_DMAC_BEATSIZE_7 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_7
+#ifndef CONF_DMAC_SRC_INTERFACE_7
+#define CONF_DMAC_SRC_INTERFACE_7 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_7
+#ifndef CONF_DMAC_DES_INTERFACE_7
+#define CONF_DMAC_DES_INTERFACE_7 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_7
+#ifndef CONF_DMAC_SRCINC_7
+#define CONF_DMAC_SRCINC_7 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_7
+#ifndef CONF_DMAC_DSTINC_7
+#define CONF_DMAC_DSTINC_7 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_7
+#ifndef CONF_DMAC_TRANS_TYPE_7
+#define CONF_DMAC_TRANS_TYPE_7 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_7
+#ifndef CONF_DMAC_TRIGSRC_7
+#define CONF_DMAC_TRIGSRC_7 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_7 == 0
+#define CONF_DMAC_TYPE_7 0
+#define CONF_DMAC_DSYNC_7 0
+#elif CONF_DMAC_TRANS_TYPE_7 == 1
+#define CONF_DMAC_TYPE_7 1
+#define CONF_DMAC_DSYNC_7 0
+#elif CONF_DMAC_TRANS_TYPE_7 == 2
+#define CONF_DMAC_TYPE_7 1
+#define CONF_DMAC_DSYNC_7 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_7 == 0xFF
+#define CONF_DMAC_SWREQ_7 1
+#else
+#define CONF_DMAC_SWREQ_7 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_7_SETTINGS == 1 && CONF_DMAC_BEATSIZE_7 != 2 && ((!CONF_DMAC_SRCINC_7) || (!CONF_DMAC_DSTINC_7)))
+#if (!CONF_DMAC_SRCINC_7)
+#define CONF_DMAC_SRC_STRIDE_7 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_7)
+#define CONF_DMAC_DES_STRIDE_7 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_7
+#define CONF_DMAC_SRC_STRIDE_7 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_7
+#define CONF_DMAC_DES_STRIDE_7 0
+#endif
+
+// <e> Channel 8 settings
+// <id> dmac_channel_8_settings
+#ifndef CONF_DMAC_CHANNEL_8_SETTINGS
+#define CONF_DMAC_CHANNEL_8_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_8
+#ifndef CONF_DMAC_BURSTSIZE_8
+#define CONF_DMAC_BURSTSIZE_8 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_8
+#ifndef CONF_DMAC_CHUNKSIZE_8
+#define CONF_DMAC_CHUNKSIZE_8 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_8
+#ifndef CONF_DMAC_BEATSIZE_8
+#define CONF_DMAC_BEATSIZE_8 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_8
+#ifndef CONF_DMAC_SRC_INTERFACE_8
+#define CONF_DMAC_SRC_INTERFACE_8 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_8
+#ifndef CONF_DMAC_DES_INTERFACE_8
+#define CONF_DMAC_DES_INTERFACE_8 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_8
+#ifndef CONF_DMAC_SRCINC_8
+#define CONF_DMAC_SRCINC_8 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_8
+#ifndef CONF_DMAC_DSTINC_8
+#define CONF_DMAC_DSTINC_8 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_8
+#ifndef CONF_DMAC_TRANS_TYPE_8
+#define CONF_DMAC_TRANS_TYPE_8 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_8
+#ifndef CONF_DMAC_TRIGSRC_8
+#define CONF_DMAC_TRIGSRC_8 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_8 == 0
+#define CONF_DMAC_TYPE_8 0
+#define CONF_DMAC_DSYNC_8 0
+#elif CONF_DMAC_TRANS_TYPE_8 == 1
+#define CONF_DMAC_TYPE_8 1
+#define CONF_DMAC_DSYNC_8 0
+#elif CONF_DMAC_TRANS_TYPE_8 == 2
+#define CONF_DMAC_TYPE_8 1
+#define CONF_DMAC_DSYNC_8 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_8 == 0xFF
+#define CONF_DMAC_SWREQ_8 1
+#else
+#define CONF_DMAC_SWREQ_8 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_8_SETTINGS == 1 && CONF_DMAC_BEATSIZE_8 != 2 && ((!CONF_DMAC_SRCINC_8) || (!CONF_DMAC_DSTINC_8)))
+#if (!CONF_DMAC_SRCINC_8)
+#define CONF_DMAC_SRC_STRIDE_8 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_8)
+#define CONF_DMAC_DES_STRIDE_8 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_8
+#define CONF_DMAC_SRC_STRIDE_8 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_8
+#define CONF_DMAC_DES_STRIDE_8 0
+#endif
+
+// <e> Channel 9 settings
+// <id> dmac_channel_9_settings
+#ifndef CONF_DMAC_CHANNEL_9_SETTINGS
+#define CONF_DMAC_CHANNEL_9_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_9
+#ifndef CONF_DMAC_BURSTSIZE_9
+#define CONF_DMAC_BURSTSIZE_9 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_9
+#ifndef CONF_DMAC_CHUNKSIZE_9
+#define CONF_DMAC_CHUNKSIZE_9 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_9
+#ifndef CONF_DMAC_BEATSIZE_9
+#define CONF_DMAC_BEATSIZE_9 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_9
+#ifndef CONF_DMAC_SRC_INTERFACE_9
+#define CONF_DMAC_SRC_INTERFACE_9 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_9
+#ifndef CONF_DMAC_DES_INTERFACE_9
+#define CONF_DMAC_DES_INTERFACE_9 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_9
+#ifndef CONF_DMAC_SRCINC_9
+#define CONF_DMAC_SRCINC_9 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_9
+#ifndef CONF_DMAC_DSTINC_9
+#define CONF_DMAC_DSTINC_9 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_9
+#ifndef CONF_DMAC_TRANS_TYPE_9
+#define CONF_DMAC_TRANS_TYPE_9 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_9
+#ifndef CONF_DMAC_TRIGSRC_9
+#define CONF_DMAC_TRIGSRC_9 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_9 == 0
+#define CONF_DMAC_TYPE_9 0
+#define CONF_DMAC_DSYNC_9 0
+#elif CONF_DMAC_TRANS_TYPE_9 == 1
+#define CONF_DMAC_TYPE_9 1
+#define CONF_DMAC_DSYNC_9 0
+#elif CONF_DMAC_TRANS_TYPE_9 == 2
+#define CONF_DMAC_TYPE_9 1
+#define CONF_DMAC_DSYNC_9 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_9 == 0xFF
+#define CONF_DMAC_SWREQ_9 1
+#else
+#define CONF_DMAC_SWREQ_9 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_9_SETTINGS == 1 && CONF_DMAC_BEATSIZE_9 != 2 && ((!CONF_DMAC_SRCINC_9) || (!CONF_DMAC_DSTINC_9)))
+#if (!CONF_DMAC_SRCINC_9)
+#define CONF_DMAC_SRC_STRIDE_9 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_9)
+#define CONF_DMAC_DES_STRIDE_9 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_9
+#define CONF_DMAC_SRC_STRIDE_9 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_9
+#define CONF_DMAC_DES_STRIDE_9 0
+#endif
+
+// <e> Channel 10 settings
+// <id> dmac_channel_10_settings
+#ifndef CONF_DMAC_CHANNEL_10_SETTINGS
+#define CONF_DMAC_CHANNEL_10_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_10
+#ifndef CONF_DMAC_BURSTSIZE_10
+#define CONF_DMAC_BURSTSIZE_10 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_10
+#ifndef CONF_DMAC_CHUNKSIZE_10
+#define CONF_DMAC_CHUNKSIZE_10 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_10
+#ifndef CONF_DMAC_BEATSIZE_10
+#define CONF_DMAC_BEATSIZE_10 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_10
+#ifndef CONF_DMAC_SRC_INTERFACE_10
+#define CONF_DMAC_SRC_INTERFACE_10 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_10
+#ifndef CONF_DMAC_DES_INTERFACE_10
+#define CONF_DMAC_DES_INTERFACE_10 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_10
+#ifndef CONF_DMAC_SRCINC_10
+#define CONF_DMAC_SRCINC_10 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_10
+#ifndef CONF_DMAC_DSTINC_10
+#define CONF_DMAC_DSTINC_10 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_10
+#ifndef CONF_DMAC_TRANS_TYPE_10
+#define CONF_DMAC_TRANS_TYPE_10 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_10
+#ifndef CONF_DMAC_TRIGSRC_10
+#define CONF_DMAC_TRIGSRC_10 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_10 == 0
+#define CONF_DMAC_TYPE_10 0
+#define CONF_DMAC_DSYNC_10 0
+#elif CONF_DMAC_TRANS_TYPE_10 == 1
+#define CONF_DMAC_TYPE_10 1
+#define CONF_DMAC_DSYNC_10 0
+#elif CONF_DMAC_TRANS_TYPE_10 == 2
+#define CONF_DMAC_TYPE_10 1
+#define CONF_DMAC_DSYNC_10 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_10 == 0xFF
+#define CONF_DMAC_SWREQ_10 1
+#else
+#define CONF_DMAC_SWREQ_10 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_10_SETTINGS == 1 && CONF_DMAC_BEATSIZE_10 != 2 \
+ && ((!CONF_DMAC_SRCINC_10) || (!CONF_DMAC_DSTINC_10)))
+#if (!CONF_DMAC_SRCINC_10)
+#define CONF_DMAC_SRC_STRIDE_10 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_10)
+#define CONF_DMAC_DES_STRIDE_10 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_10
+#define CONF_DMAC_SRC_STRIDE_10 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_10
+#define CONF_DMAC_DES_STRIDE_10 0
+#endif
+
+// <e> Channel 11 settings
+// <id> dmac_channel_11_settings
+#ifndef CONF_DMAC_CHANNEL_11_SETTINGS
+#define CONF_DMAC_CHANNEL_11_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_11
+#ifndef CONF_DMAC_BURSTSIZE_11
+#define CONF_DMAC_BURSTSIZE_11 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_11
+#ifndef CONF_DMAC_CHUNKSIZE_11
+#define CONF_DMAC_CHUNKSIZE_11 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_11
+#ifndef CONF_DMAC_BEATSIZE_11
+#define CONF_DMAC_BEATSIZE_11 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_11
+#ifndef CONF_DMAC_SRC_INTERFACE_11
+#define CONF_DMAC_SRC_INTERFACE_11 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_11
+#ifndef CONF_DMAC_DES_INTERFACE_11
+#define CONF_DMAC_DES_INTERFACE_11 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_11
+#ifndef CONF_DMAC_SRCINC_11
+#define CONF_DMAC_SRCINC_11 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_11
+#ifndef CONF_DMAC_DSTINC_11
+#define CONF_DMAC_DSTINC_11 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_11
+#ifndef CONF_DMAC_TRANS_TYPE_11
+#define CONF_DMAC_TRANS_TYPE_11 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_11
+#ifndef CONF_DMAC_TRIGSRC_11
+#define CONF_DMAC_TRIGSRC_11 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_11 == 0
+#define CONF_DMAC_TYPE_11 0
+#define CONF_DMAC_DSYNC_11 0
+#elif CONF_DMAC_TRANS_TYPE_11 == 1
+#define CONF_DMAC_TYPE_11 1
+#define CONF_DMAC_DSYNC_11 0
+#elif CONF_DMAC_TRANS_TYPE_11 == 2
+#define CONF_DMAC_TYPE_11 1
+#define CONF_DMAC_DSYNC_11 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_11 == 0xFF
+#define CONF_DMAC_SWREQ_11 1
+#else
+#define CONF_DMAC_SWREQ_11 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_11_SETTINGS == 1 && CONF_DMAC_BEATSIZE_11 != 2 \
+ && ((!CONF_DMAC_SRCINC_11) || (!CONF_DMAC_DSTINC_11)))
+#if (!CONF_DMAC_SRCINC_11)
+#define CONF_DMAC_SRC_STRIDE_11 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_11)
+#define CONF_DMAC_DES_STRIDE_11 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_11
+#define CONF_DMAC_SRC_STRIDE_11 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_11
+#define CONF_DMAC_DES_STRIDE_11 0
+#endif
+
+// <e> Channel 12 settings
+// <id> dmac_channel_12_settings
+#ifndef CONF_DMAC_CHANNEL_12_SETTINGS
+#define CONF_DMAC_CHANNEL_12_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_12
+#ifndef CONF_DMAC_BURSTSIZE_12
+#define CONF_DMAC_BURSTSIZE_12 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_12
+#ifndef CONF_DMAC_CHUNKSIZE_12
+#define CONF_DMAC_CHUNKSIZE_12 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_12
+#ifndef CONF_DMAC_BEATSIZE_12
+#define CONF_DMAC_BEATSIZE_12 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_12
+#ifndef CONF_DMAC_SRC_INTERFACE_12
+#define CONF_DMAC_SRC_INTERFACE_12 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_12
+#ifndef CONF_DMAC_DES_INTERFACE_12
+#define CONF_DMAC_DES_INTERFACE_12 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_12
+#ifndef CONF_DMAC_SRCINC_12
+#define CONF_DMAC_SRCINC_12 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_12
+#ifndef CONF_DMAC_DSTINC_12
+#define CONF_DMAC_DSTINC_12 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_12
+#ifndef CONF_DMAC_TRANS_TYPE_12
+#define CONF_DMAC_TRANS_TYPE_12 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_12
+#ifndef CONF_DMAC_TRIGSRC_12
+#define CONF_DMAC_TRIGSRC_12 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_12 == 0
+#define CONF_DMAC_TYPE_12 0
+#define CONF_DMAC_DSYNC_12 0
+#elif CONF_DMAC_TRANS_TYPE_12 == 1
+#define CONF_DMAC_TYPE_12 1
+#define CONF_DMAC_DSYNC_12 0
+#elif CONF_DMAC_TRANS_TYPE_12 == 2
+#define CONF_DMAC_TYPE_12 1
+#define CONF_DMAC_DSYNC_12 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_12 == 0xFF
+#define CONF_DMAC_SWREQ_12 1
+#else
+#define CONF_DMAC_SWREQ_12 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_12_SETTINGS == 1 && CONF_DMAC_BEATSIZE_12 != 2 \
+ && ((!CONF_DMAC_SRCINC_12) || (!CONF_DMAC_DSTINC_12)))
+#if (!CONF_DMAC_SRCINC_12)
+#define CONF_DMAC_SRC_STRIDE_12 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_12)
+#define CONF_DMAC_DES_STRIDE_12 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_12
+#define CONF_DMAC_SRC_STRIDE_12 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_12
+#define CONF_DMAC_DES_STRIDE_12 0
+#endif
+
+// <e> Channel 13 settings
+// <id> dmac_channel_13_settings
+#ifndef CONF_DMAC_CHANNEL_13_SETTINGS
+#define CONF_DMAC_CHANNEL_13_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_13
+#ifndef CONF_DMAC_BURSTSIZE_13
+#define CONF_DMAC_BURSTSIZE_13 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_13
+#ifndef CONF_DMAC_CHUNKSIZE_13
+#define CONF_DMAC_CHUNKSIZE_13 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_13
+#ifndef CONF_DMAC_BEATSIZE_13
+#define CONF_DMAC_BEATSIZE_13 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_13
+#ifndef CONF_DMAC_SRC_INTERFACE_13
+#define CONF_DMAC_SRC_INTERFACE_13 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_13
+#ifndef CONF_DMAC_DES_INTERFACE_13
+#define CONF_DMAC_DES_INTERFACE_13 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_13
+#ifndef CONF_DMAC_SRCINC_13
+#define CONF_DMAC_SRCINC_13 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_13
+#ifndef CONF_DMAC_DSTINC_13
+#define CONF_DMAC_DSTINC_13 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_13
+#ifndef CONF_DMAC_TRANS_TYPE_13
+#define CONF_DMAC_TRANS_TYPE_13 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_13
+#ifndef CONF_DMAC_TRIGSRC_13
+#define CONF_DMAC_TRIGSRC_13 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_13 == 0
+#define CONF_DMAC_TYPE_13 0
+#define CONF_DMAC_DSYNC_13 0
+#elif CONF_DMAC_TRANS_TYPE_13 == 1
+#define CONF_DMAC_TYPE_13 1
+#define CONF_DMAC_DSYNC_13 0
+#elif CONF_DMAC_TRANS_TYPE_13 == 2
+#define CONF_DMAC_TYPE_13 1
+#define CONF_DMAC_DSYNC_13 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_13 == 0xFF
+#define CONF_DMAC_SWREQ_13 1
+#else
+#define CONF_DMAC_SWREQ_13 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_13_SETTINGS == 1 && CONF_DMAC_BEATSIZE_13 != 2 \
+ && ((!CONF_DMAC_SRCINC_13) || (!CONF_DMAC_DSTINC_13)))
+#if (!CONF_DMAC_SRCINC_13)
+#define CONF_DMAC_SRC_STRIDE_13 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_13)
+#define CONF_DMAC_DES_STRIDE_13 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_13
+#define CONF_DMAC_SRC_STRIDE_13 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_13
+#define CONF_DMAC_DES_STRIDE_13 0
+#endif
+
+// <e> Channel 14 settings
+// <id> dmac_channel_14_settings
+#ifndef CONF_DMAC_CHANNEL_14_SETTINGS
+#define CONF_DMAC_CHANNEL_14_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_14
+#ifndef CONF_DMAC_BURSTSIZE_14
+#define CONF_DMAC_BURSTSIZE_14 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_14
+#ifndef CONF_DMAC_CHUNKSIZE_14
+#define CONF_DMAC_CHUNKSIZE_14 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_14
+#ifndef CONF_DMAC_BEATSIZE_14
+#define CONF_DMAC_BEATSIZE_14 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_14
+#ifndef CONF_DMAC_SRC_INTERFACE_14
+#define CONF_DMAC_SRC_INTERFACE_14 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_14
+#ifndef CONF_DMAC_DES_INTERFACE_14
+#define CONF_DMAC_DES_INTERFACE_14 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_14
+#ifndef CONF_DMAC_SRCINC_14
+#define CONF_DMAC_SRCINC_14 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_14
+#ifndef CONF_DMAC_DSTINC_14
+#define CONF_DMAC_DSTINC_14 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_14
+#ifndef CONF_DMAC_TRANS_TYPE_14
+#define CONF_DMAC_TRANS_TYPE_14 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_14
+#ifndef CONF_DMAC_TRIGSRC_14
+#define CONF_DMAC_TRIGSRC_14 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_14 == 0
+#define CONF_DMAC_TYPE_14 0
+#define CONF_DMAC_DSYNC_14 0
+#elif CONF_DMAC_TRANS_TYPE_14 == 1
+#define CONF_DMAC_TYPE_14 1
+#define CONF_DMAC_DSYNC_14 0
+#elif CONF_DMAC_TRANS_TYPE_14 == 2
+#define CONF_DMAC_TYPE_14 1
+#define CONF_DMAC_DSYNC_14 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_14 == 0xFF
+#define CONF_DMAC_SWREQ_14 1
+#else
+#define CONF_DMAC_SWREQ_14 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_14_SETTINGS == 1 && CONF_DMAC_BEATSIZE_14 != 2 \
+ && ((!CONF_DMAC_SRCINC_14) || (!CONF_DMAC_DSTINC_14)))
+#if (!CONF_DMAC_SRCINC_14)
+#define CONF_DMAC_SRC_STRIDE_14 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_14)
+#define CONF_DMAC_DES_STRIDE_14 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_14
+#define CONF_DMAC_SRC_STRIDE_14 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_14
+#define CONF_DMAC_DES_STRIDE_14 0
+#endif
+
+// <e> Channel 15 settings
+// <id> dmac_channel_15_settings
+#ifndef CONF_DMAC_CHANNEL_15_SETTINGS
+#define CONF_DMAC_CHANNEL_15_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_15
+#ifndef CONF_DMAC_BURSTSIZE_15
+#define CONF_DMAC_BURSTSIZE_15 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_15
+#ifndef CONF_DMAC_CHUNKSIZE_15
+#define CONF_DMAC_CHUNKSIZE_15 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_15
+#ifndef CONF_DMAC_BEATSIZE_15
+#define CONF_DMAC_BEATSIZE_15 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_15
+#ifndef CONF_DMAC_SRC_INTERFACE_15
+#define CONF_DMAC_SRC_INTERFACE_15 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_15
+#ifndef CONF_DMAC_DES_INTERFACE_15
+#define CONF_DMAC_DES_INTERFACE_15 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_15
+#ifndef CONF_DMAC_SRCINC_15
+#define CONF_DMAC_SRCINC_15 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_15
+#ifndef CONF_DMAC_DSTINC_15
+#define CONF_DMAC_DSTINC_15 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_15
+#ifndef CONF_DMAC_TRANS_TYPE_15
+#define CONF_DMAC_TRANS_TYPE_15 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_15
+#ifndef CONF_DMAC_TRIGSRC_15
+#define CONF_DMAC_TRIGSRC_15 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_15 == 0
+#define CONF_DMAC_TYPE_15 0
+#define CONF_DMAC_DSYNC_15 0
+#elif CONF_DMAC_TRANS_TYPE_15 == 1
+#define CONF_DMAC_TYPE_15 1
+#define CONF_DMAC_DSYNC_15 0
+#elif CONF_DMAC_TRANS_TYPE_15 == 2
+#define CONF_DMAC_TYPE_15 1
+#define CONF_DMAC_DSYNC_15 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_15 == 0xFF
+#define CONF_DMAC_SWREQ_15 1
+#else
+#define CONF_DMAC_SWREQ_15 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_15_SETTINGS == 1 && CONF_DMAC_BEATSIZE_15 != 2 \
+ && ((!CONF_DMAC_SRCINC_15) || (!CONF_DMAC_DSTINC_15)))
+#if (!CONF_DMAC_SRCINC_15)
+#define CONF_DMAC_SRC_STRIDE_15 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_15)
+#define CONF_DMAC_DES_STRIDE_15 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_15
+#define CONF_DMAC_SRC_STRIDE_15 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_15
+#define CONF_DMAC_DES_STRIDE_15 0
+#endif
+
+// <e> Channel 16 settings
+// <id> dmac_channel_16_settings
+#ifndef CONF_DMAC_CHANNEL_16_SETTINGS
+#define CONF_DMAC_CHANNEL_16_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_16
+#ifndef CONF_DMAC_BURSTSIZE_16
+#define CONF_DMAC_BURSTSIZE_16 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_16
+#ifndef CONF_DMAC_CHUNKSIZE_16
+#define CONF_DMAC_CHUNKSIZE_16 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_16
+#ifndef CONF_DMAC_BEATSIZE_16
+#define CONF_DMAC_BEATSIZE_16 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_16
+#ifndef CONF_DMAC_SRC_INTERFACE_16
+#define CONF_DMAC_SRC_INTERFACE_16 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_16
+#ifndef CONF_DMAC_DES_INTERFACE_16
+#define CONF_DMAC_DES_INTERFACE_16 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_16
+#ifndef CONF_DMAC_SRCINC_16
+#define CONF_DMAC_SRCINC_16 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_16
+#ifndef CONF_DMAC_DSTINC_16
+#define CONF_DMAC_DSTINC_16 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_16
+#ifndef CONF_DMAC_TRANS_TYPE_16
+#define CONF_DMAC_TRANS_TYPE_16 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_16
+#ifndef CONF_DMAC_TRIGSRC_16
+#define CONF_DMAC_TRIGSRC_16 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_16 == 0
+#define CONF_DMAC_TYPE_16 0
+#define CONF_DMAC_DSYNC_16 0
+#elif CONF_DMAC_TRANS_TYPE_16 == 1
+#define CONF_DMAC_TYPE_16 1
+#define CONF_DMAC_DSYNC_16 0
+#elif CONF_DMAC_TRANS_TYPE_16 == 2
+#define CONF_DMAC_TYPE_16 1
+#define CONF_DMAC_DSYNC_16 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_16 == 0xFF
+#define CONF_DMAC_SWREQ_16 1
+#else
+#define CONF_DMAC_SWREQ_16 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_16_SETTINGS == 1 && CONF_DMAC_BEATSIZE_16 != 2 \
+ && ((!CONF_DMAC_SRCINC_16) || (!CONF_DMAC_DSTINC_16)))
+#if (!CONF_DMAC_SRCINC_16)
+#define CONF_DMAC_SRC_STRIDE_16 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_16)
+#define CONF_DMAC_DES_STRIDE_16 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_16
+#define CONF_DMAC_SRC_STRIDE_16 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_16
+#define CONF_DMAC_DES_STRIDE_16 0
+#endif
+
+// <e> Channel 17 settings
+// <id> dmac_channel_17_settings
+#ifndef CONF_DMAC_CHANNEL_17_SETTINGS
+#define CONF_DMAC_CHANNEL_17_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_17
+#ifndef CONF_DMAC_BURSTSIZE_17
+#define CONF_DMAC_BURSTSIZE_17 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_17
+#ifndef CONF_DMAC_CHUNKSIZE_17
+#define CONF_DMAC_CHUNKSIZE_17 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_17
+#ifndef CONF_DMAC_BEATSIZE_17
+#define CONF_DMAC_BEATSIZE_17 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_17
+#ifndef CONF_DMAC_SRC_INTERFACE_17
+#define CONF_DMAC_SRC_INTERFACE_17 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_17
+#ifndef CONF_DMAC_DES_INTERFACE_17
+#define CONF_DMAC_DES_INTERFACE_17 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_17
+#ifndef CONF_DMAC_SRCINC_17
+#define CONF_DMAC_SRCINC_17 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_17
+#ifndef CONF_DMAC_DSTINC_17
+#define CONF_DMAC_DSTINC_17 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_17
+#ifndef CONF_DMAC_TRANS_TYPE_17
+#define CONF_DMAC_TRANS_TYPE_17 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_17
+#ifndef CONF_DMAC_TRIGSRC_17
+#define CONF_DMAC_TRIGSRC_17 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_17 == 0
+#define CONF_DMAC_TYPE_17 0
+#define CONF_DMAC_DSYNC_17 0
+#elif CONF_DMAC_TRANS_TYPE_17 == 1
+#define CONF_DMAC_TYPE_17 1
+#define CONF_DMAC_DSYNC_17 0
+#elif CONF_DMAC_TRANS_TYPE_17 == 2
+#define CONF_DMAC_TYPE_17 1
+#define CONF_DMAC_DSYNC_17 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_17 == 0xFF
+#define CONF_DMAC_SWREQ_17 1
+#else
+#define CONF_DMAC_SWREQ_17 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_17_SETTINGS == 1 && CONF_DMAC_BEATSIZE_17 != 2 \
+ && ((!CONF_DMAC_SRCINC_17) || (!CONF_DMAC_DSTINC_17)))
+#if (!CONF_DMAC_SRCINC_17)
+#define CONF_DMAC_SRC_STRIDE_17 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_17)
+#define CONF_DMAC_DES_STRIDE_17 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_17
+#define CONF_DMAC_SRC_STRIDE_17 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_17
+#define CONF_DMAC_DES_STRIDE_17 0
+#endif
+
+// <e> Channel 18 settings
+// <id> dmac_channel_18_settings
+#ifndef CONF_DMAC_CHANNEL_18_SETTINGS
+#define CONF_DMAC_CHANNEL_18_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_18
+#ifndef CONF_DMAC_BURSTSIZE_18
+#define CONF_DMAC_BURSTSIZE_18 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_18
+#ifndef CONF_DMAC_CHUNKSIZE_18
+#define CONF_DMAC_CHUNKSIZE_18 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_18
+#ifndef CONF_DMAC_BEATSIZE_18
+#define CONF_DMAC_BEATSIZE_18 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_18
+#ifndef CONF_DMAC_SRC_INTERFACE_18
+#define CONF_DMAC_SRC_INTERFACE_18 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_18
+#ifndef CONF_DMAC_DES_INTERFACE_18
+#define CONF_DMAC_DES_INTERFACE_18 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_18
+#ifndef CONF_DMAC_SRCINC_18
+#define CONF_DMAC_SRCINC_18 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_18
+#ifndef CONF_DMAC_DSTINC_18
+#define CONF_DMAC_DSTINC_18 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_18
+#ifndef CONF_DMAC_TRANS_TYPE_18
+#define CONF_DMAC_TRANS_TYPE_18 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_18
+#ifndef CONF_DMAC_TRIGSRC_18
+#define CONF_DMAC_TRIGSRC_18 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_18 == 0
+#define CONF_DMAC_TYPE_18 0
+#define CONF_DMAC_DSYNC_18 0
+#elif CONF_DMAC_TRANS_TYPE_18 == 1
+#define CONF_DMAC_TYPE_18 1
+#define CONF_DMAC_DSYNC_18 0
+#elif CONF_DMAC_TRANS_TYPE_18 == 2
+#define CONF_DMAC_TYPE_18 1
+#define CONF_DMAC_DSYNC_18 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_18 == 0xFF
+#define CONF_DMAC_SWREQ_18 1
+#else
+#define CONF_DMAC_SWREQ_18 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_18_SETTINGS == 1 && CONF_DMAC_BEATSIZE_18 != 2 \
+ && ((!CONF_DMAC_SRCINC_18) || (!CONF_DMAC_DSTINC_18)))
+#if (!CONF_DMAC_SRCINC_18)
+#define CONF_DMAC_SRC_STRIDE_18 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_18)
+#define CONF_DMAC_DES_STRIDE_18 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_18
+#define CONF_DMAC_SRC_STRIDE_18 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_18
+#define CONF_DMAC_DES_STRIDE_18 0
+#endif
+
+// <e> Channel 19 settings
+// <id> dmac_channel_19_settings
+#ifndef CONF_DMAC_CHANNEL_19_SETTINGS
+#define CONF_DMAC_CHANNEL_19_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_19
+#ifndef CONF_DMAC_BURSTSIZE_19
+#define CONF_DMAC_BURSTSIZE_19 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_19
+#ifndef CONF_DMAC_CHUNKSIZE_19
+#define CONF_DMAC_CHUNKSIZE_19 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_19
+#ifndef CONF_DMAC_BEATSIZE_19
+#define CONF_DMAC_BEATSIZE_19 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_19
+#ifndef CONF_DMAC_SRC_INTERFACE_19
+#define CONF_DMAC_SRC_INTERFACE_19 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_19
+#ifndef CONF_DMAC_DES_INTERFACE_19
+#define CONF_DMAC_DES_INTERFACE_19 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_19
+#ifndef CONF_DMAC_SRCINC_19
+#define CONF_DMAC_SRCINC_19 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_19
+#ifndef CONF_DMAC_DSTINC_19
+#define CONF_DMAC_DSTINC_19 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_19
+#ifndef CONF_DMAC_TRANS_TYPE_19
+#define CONF_DMAC_TRANS_TYPE_19 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_19
+#ifndef CONF_DMAC_TRIGSRC_19
+#define CONF_DMAC_TRIGSRC_19 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_19 == 0
+#define CONF_DMAC_TYPE_19 0
+#define CONF_DMAC_DSYNC_19 0
+#elif CONF_DMAC_TRANS_TYPE_19 == 1
+#define CONF_DMAC_TYPE_19 1
+#define CONF_DMAC_DSYNC_19 0
+#elif CONF_DMAC_TRANS_TYPE_19 == 2
+#define CONF_DMAC_TYPE_19 1
+#define CONF_DMAC_DSYNC_19 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_19 == 0xFF
+#define CONF_DMAC_SWREQ_19 1
+#else
+#define CONF_DMAC_SWREQ_19 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_19_SETTINGS == 1 && CONF_DMAC_BEATSIZE_19 != 2 \
+ && ((!CONF_DMAC_SRCINC_19) || (!CONF_DMAC_DSTINC_19)))
+#if (!CONF_DMAC_SRCINC_19)
+#define CONF_DMAC_SRC_STRIDE_19 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_19)
+#define CONF_DMAC_DES_STRIDE_19 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_19
+#define CONF_DMAC_SRC_STRIDE_19 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_19
+#define CONF_DMAC_DES_STRIDE_19 0
+#endif
+
+// <e> Channel 20 settings
+// <id> dmac_channel_20_settings
+#ifndef CONF_DMAC_CHANNEL_20_SETTINGS
+#define CONF_DMAC_CHANNEL_20_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_20
+#ifndef CONF_DMAC_BURSTSIZE_20
+#define CONF_DMAC_BURSTSIZE_20 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_20
+#ifndef CONF_DMAC_CHUNKSIZE_20
+#define CONF_DMAC_CHUNKSIZE_20 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_20
+#ifndef CONF_DMAC_BEATSIZE_20
+#define CONF_DMAC_BEATSIZE_20 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_20
+#ifndef CONF_DMAC_SRC_INTERFACE_20
+#define CONF_DMAC_SRC_INTERFACE_20 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_20
+#ifndef CONF_DMAC_DES_INTERFACE_20
+#define CONF_DMAC_DES_INTERFACE_20 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_20
+#ifndef CONF_DMAC_SRCINC_20
+#define CONF_DMAC_SRCINC_20 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_20
+#ifndef CONF_DMAC_DSTINC_20
+#define CONF_DMAC_DSTINC_20 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_20
+#ifndef CONF_DMAC_TRANS_TYPE_20
+#define CONF_DMAC_TRANS_TYPE_20 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_20
+#ifndef CONF_DMAC_TRIGSRC_20
+#define CONF_DMAC_TRIGSRC_20 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_20 == 0
+#define CONF_DMAC_TYPE_20 0
+#define CONF_DMAC_DSYNC_20 0
+#elif CONF_DMAC_TRANS_TYPE_20 == 1
+#define CONF_DMAC_TYPE_20 1
+#define CONF_DMAC_DSYNC_20 0
+#elif CONF_DMAC_TRANS_TYPE_20 == 2
+#define CONF_DMAC_TYPE_20 1
+#define CONF_DMAC_DSYNC_20 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_20 == 0xFF
+#define CONF_DMAC_SWREQ_20 1
+#else
+#define CONF_DMAC_SWREQ_20 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_20_SETTINGS == 1 && CONF_DMAC_BEATSIZE_20 != 2 \
+ && ((!CONF_DMAC_SRCINC_20) || (!CONF_DMAC_DSTINC_20)))
+#if (!CONF_DMAC_SRCINC_20)
+#define CONF_DMAC_SRC_STRIDE_20 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_20)
+#define CONF_DMAC_DES_STRIDE_20 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_20
+#define CONF_DMAC_SRC_STRIDE_20 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_20
+#define CONF_DMAC_DES_STRIDE_20 0
+#endif
+
+// <e> Channel 21 settings
+// <id> dmac_channel_21_settings
+#ifndef CONF_DMAC_CHANNEL_21_SETTINGS
+#define CONF_DMAC_CHANNEL_21_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_21
+#ifndef CONF_DMAC_BURSTSIZE_21
+#define CONF_DMAC_BURSTSIZE_21 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_21
+#ifndef CONF_DMAC_CHUNKSIZE_21
+#define CONF_DMAC_CHUNKSIZE_21 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_21
+#ifndef CONF_DMAC_BEATSIZE_21
+#define CONF_DMAC_BEATSIZE_21 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_21
+#ifndef CONF_DMAC_SRC_INTERFACE_21
+#define CONF_DMAC_SRC_INTERFACE_21 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_21
+#ifndef CONF_DMAC_DES_INTERFACE_21
+#define CONF_DMAC_DES_INTERFACE_21 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_21
+#ifndef CONF_DMAC_SRCINC_21
+#define CONF_DMAC_SRCINC_21 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_21
+#ifndef CONF_DMAC_DSTINC_21
+#define CONF_DMAC_DSTINC_21 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_21
+#ifndef CONF_DMAC_TRANS_TYPE_21
+#define CONF_DMAC_TRANS_TYPE_21 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_21
+#ifndef CONF_DMAC_TRIGSRC_21
+#define CONF_DMAC_TRIGSRC_21 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_21 == 0
+#define CONF_DMAC_TYPE_21 0
+#define CONF_DMAC_DSYNC_21 0
+#elif CONF_DMAC_TRANS_TYPE_21 == 1
+#define CONF_DMAC_TYPE_21 1
+#define CONF_DMAC_DSYNC_21 0
+#elif CONF_DMAC_TRANS_TYPE_21 == 2
+#define CONF_DMAC_TYPE_21 1
+#define CONF_DMAC_DSYNC_21 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_21 == 0xFF
+#define CONF_DMAC_SWREQ_21 1
+#else
+#define CONF_DMAC_SWREQ_21 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_21_SETTINGS == 1 && CONF_DMAC_BEATSIZE_21 != 2 \
+ && ((!CONF_DMAC_SRCINC_21) || (!CONF_DMAC_DSTINC_21)))
+#if (!CONF_DMAC_SRCINC_21)
+#define CONF_DMAC_SRC_STRIDE_21 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_21)
+#define CONF_DMAC_DES_STRIDE_21 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_21
+#define CONF_DMAC_SRC_STRIDE_21 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_21
+#define CONF_DMAC_DES_STRIDE_21 0
+#endif
+
+// <e> Channel 22 settings
+// <id> dmac_channel_22_settings
+#ifndef CONF_DMAC_CHANNEL_22_SETTINGS
+#define CONF_DMAC_CHANNEL_22_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_22
+#ifndef CONF_DMAC_BURSTSIZE_22
+#define CONF_DMAC_BURSTSIZE_22 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_22
+#ifndef CONF_DMAC_CHUNKSIZE_22
+#define CONF_DMAC_CHUNKSIZE_22 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_22
+#ifndef CONF_DMAC_BEATSIZE_22
+#define CONF_DMAC_BEATSIZE_22 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_22
+#ifndef CONF_DMAC_SRC_INTERFACE_22
+#define CONF_DMAC_SRC_INTERFACE_22 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_22
+#ifndef CONF_DMAC_DES_INTERFACE_22
+#define CONF_DMAC_DES_INTERFACE_22 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_22
+#ifndef CONF_DMAC_SRCINC_22
+#define CONF_DMAC_SRCINC_22 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_22
+#ifndef CONF_DMAC_DSTINC_22
+#define CONF_DMAC_DSTINC_22 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_22
+#ifndef CONF_DMAC_TRANS_TYPE_22
+#define CONF_DMAC_TRANS_TYPE_22 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_22
+#ifndef CONF_DMAC_TRIGSRC_22
+#define CONF_DMAC_TRIGSRC_22 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_22 == 0
+#define CONF_DMAC_TYPE_22 0
+#define CONF_DMAC_DSYNC_22 0
+#elif CONF_DMAC_TRANS_TYPE_22 == 1
+#define CONF_DMAC_TYPE_22 1
+#define CONF_DMAC_DSYNC_22 0
+#elif CONF_DMAC_TRANS_TYPE_22 == 2
+#define CONF_DMAC_TYPE_22 1
+#define CONF_DMAC_DSYNC_22 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_22 == 0xFF
+#define CONF_DMAC_SWREQ_22 1
+#else
+#define CONF_DMAC_SWREQ_22 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_22_SETTINGS == 1 && CONF_DMAC_BEATSIZE_22 != 2 \
+ && ((!CONF_DMAC_SRCINC_22) || (!CONF_DMAC_DSTINC_22)))
+#if (!CONF_DMAC_SRCINC_22)
+#define CONF_DMAC_SRC_STRIDE_22 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_22)
+#define CONF_DMAC_DES_STRIDE_22 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_22
+#define CONF_DMAC_SRC_STRIDE_22 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_22
+#define CONF_DMAC_DES_STRIDE_22 0
+#endif
+
+// <e> Channel 23 settings
+// <id> dmac_channel_23_settings
+#ifndef CONF_DMAC_CHANNEL_23_SETTINGS
+#define CONF_DMAC_CHANNEL_23_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_23
+#ifndef CONF_DMAC_BURSTSIZE_23
+#define CONF_DMAC_BURSTSIZE_23 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_23
+#ifndef CONF_DMAC_CHUNKSIZE_23
+#define CONF_DMAC_CHUNKSIZE_23 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_23
+#ifndef CONF_DMAC_BEATSIZE_23
+#define CONF_DMAC_BEATSIZE_23 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_23
+#ifndef CONF_DMAC_SRC_INTERFACE_23
+#define CONF_DMAC_SRC_INTERFACE_23 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_23
+#ifndef CONF_DMAC_DES_INTERFACE_23
+#define CONF_DMAC_DES_INTERFACE_23 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_23
+#ifndef CONF_DMAC_SRCINC_23
+#define CONF_DMAC_SRCINC_23 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_23
+#ifndef CONF_DMAC_DSTINC_23
+#define CONF_DMAC_DSTINC_23 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_23
+#ifndef CONF_DMAC_TRANS_TYPE_23
+#define CONF_DMAC_TRANS_TYPE_23 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_23
+#ifndef CONF_DMAC_TRIGSRC_23
+#define CONF_DMAC_TRIGSRC_23 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_23 == 0
+#define CONF_DMAC_TYPE_23 0
+#define CONF_DMAC_DSYNC_23 0
+#elif CONF_DMAC_TRANS_TYPE_23 == 1
+#define CONF_DMAC_TYPE_23 1
+#define CONF_DMAC_DSYNC_23 0
+#elif CONF_DMAC_TRANS_TYPE_23 == 2
+#define CONF_DMAC_TYPE_23 1
+#define CONF_DMAC_DSYNC_23 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_23 == 0xFF
+#define CONF_DMAC_SWREQ_23 1
+#else
+#define CONF_DMAC_SWREQ_23 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_23_SETTINGS == 1 && CONF_DMAC_BEATSIZE_23 != 2 \
+ && ((!CONF_DMAC_SRCINC_23) || (!CONF_DMAC_DSTINC_23)))
+#if (!CONF_DMAC_SRCINC_23)
+#define CONF_DMAC_SRC_STRIDE_23 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_23)
+#define CONF_DMAC_DES_STRIDE_23 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_23
+#define CONF_DMAC_SRC_STRIDE_23 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_23
+#define CONF_DMAC_DES_STRIDE_23 0
+#endif
+
+// </e>
+
+// <<< end of configuration section >>>
+
+#endif // HPL_XDMAC_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/peripheral_clk_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/peripheral_clk_config.h
new file mode 100644
index 0000000..84756f5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/peripheral_clk_config.h
@@ -0,0 +1,126 @@
+/* Auto-generated config file peripheral_clk_config.h */
+#ifndef PERIPHERAL_CLK_CONFIG_H
+#define PERIPHERAL_CLK_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+/**
+ * \def CONF_HCLK_FREQUENCY
+ * \brief HCLK's Clock frequency
+ */
+#ifndef CONF_HCLK_FREQUENCY
+#define CONF_HCLK_FREQUENCY 300000000
+#endif
+
+/**
+ * \def CONF_FCLK_FREQUENCY
+ * \brief FCLK's Clock frequency
+ */
+#ifndef CONF_FCLK_FREQUENCY
+#define CONF_FCLK_FREQUENCY 300000000
+#endif
+
+/**
+ * \def CONF_CPU_FREQUENCY
+ * \brief CPU's Clock frequency
+ */
+#ifndef CONF_CPU_FREQUENCY
+#define CONF_CPU_FREQUENCY 300000000
+#endif
+
+/**
+ * \def CONF_SLCK_FREQUENCY
+ * \brief Slow Clock frequency
+ */
+#define CONF_SLCK_FREQUENCY 0
+
+/**
+ * \def CONF_MCK_FREQUENCY
+ * \brief Master Clock frequency
+ */
+#define CONF_MCK_FREQUENCY 150000000
+
+/**
+ * \def CONF_PCK6_FREQUENCY
+ * \brief Programmable Clock Controller 6 frequency
+ */
+#define CONF_PCK6_FREQUENCY 1714285
+
+// <h> USART Clock Settings
+// <o> USART Clock source
+
+// <0=> Master Clock (MCK)
+// <1=> MCK / 8 for USART
+// <2=> Programmable Clock Controller 4 (PMC_PCK4)
+// <3=> External Clock
+// <i> This defines the clock source for the USART
+// <id> usart_clock_source
+#ifndef CONF_USART1_CK_SRC
+#define CONF_USART1_CK_SRC 0
+#endif
+
+// <o> USART External Clock Input on SCK <1-4294967295>
+// <i> Inputs the external clock frequency on SCK
+// <id> usart_clock_freq
+#ifndef CONF_USART1_SCK_FREQ
+#define CONF_USART1_SCK_FREQ 10000000
+#endif
+
+// </h>
+
+/**
+ * \def USART FREQUENCY
+ * \brief USART's Clock frequency
+ */
+#ifndef CONF_USART1_FREQUENCY
+#define CONF_USART1_FREQUENCY 150000000
+#endif
+
+#ifndef CONF_SRC_USB_480M
+#define CONF_SRC_USB_480M 0
+#endif
+
+#ifndef CONF_SRC_USB_48M
+#define CONF_SRC_USB_48M 1
+#endif
+
+// <y> USB Full/Low Speed Clock
+// <CONF_SRC_USB_48M"> USB Clock Controller (USB_48M)
+// <id> usb_fsls_clock_source
+// <i> 48MHz clock source for low speed and full speed.
+// <i> It must be available when low speed is supported by host driver.
+// <i> It must be available when low power mode is selected.
+#ifndef CONF_USBHS_FSLS_SRC
+#define CONF_USBHS_FSLS_SRC CONF_SRC_USB_48M
+#endif
+
+// <y> USB Clock Source(Normal/Low-power Mode Selection)
+// <CONF_SRC_USB_480M"> USB High Speed Clock (USB_480M)
+// <CONF_SRC_USB_48M"> USB Clock Controller (USB_48M)
+// <id> usb_clock_source
+// <i> Select the clock source for USB.
+// <i> In normal mode, use "USB High Speed Clock (USB_480M)".
+// <i> In low-power mode, use "USB Clock Controller (USB_48M)".
+#ifndef CONF_USBHS_SRC
+#define CONF_USBHS_SRC CONF_SRC_USB_480M
+#endif
+
+/**
+ * \def CONF_USBHS_FSLS_FREQUENCY
+ * \brief USBHS's Full/Low Speed Clock Source frequency
+ */
+#ifndef CONF_USBHS_FSLS_FREQUENCY
+#define CONF_USBHS_FSLS_FREQUENCY 48000000
+#endif
+
+/**
+ * \def CONF_USBHS_FREQUENCY
+ * \brief USBHS's Selected Clock Source frequency
+ */
+#ifndef CONF_USBHS_FREQUENCY
+#define CONF_USBHS_FREQUENCY 480000000
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // PERIPHERAL_CLK_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/same70_qmtech.c b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/same70_qmtech.c
new file mode 100644
index 0000000..6e6ad06
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_qmtech/same70_qmtech.c
@@ -0,0 +1,159 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+
+#include "peripheral_clk_config.h"
+#include "hpl/usart/hpl_usart_base.h"
+#include "hpl/pmc/hpl_pmc.h"
+#include "hal/include/hal_init.h"
+#include "hal/include/hal_usart_async.h"
+#include "hal/include/hal_gpio.h"
+
+
+// You can get the board here:
+// https://www.aliexpress.com/item/1005003173783268.html
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+#define LED_PIN GPIO(GPIO_PORTA, 15)
+
+#define BUTTON_PIN GPIO(GPIO_PORTA, 21)
+#define BUTTON_STATE_ACTIVE 0
+
+#define UART_TX_PIN GPIO(GPIO_PORTB, 1)
+#define UART_RX_PIN GPIO(GPIO_PORTB, 0)
+
+static struct usart_async_descriptor edbg_com;
+static uint8_t edbg_com_buffer[64];
+static volatile bool uart_busy = false;
+
+static void tx_cb_EDBG_COM(const struct usart_async_descriptor *const io_descr)
+{
+ (void) io_descr;
+ uart_busy = false;
+}
+
+//------------- IMPLEMENTATION -------------//
+void board_init(void)
+{
+ init_mcu();
+
+ /* Disable Watchdog */
+ hri_wdt_set_MR_WDDIS_bit(WDT);
+
+ // LED
+ _pmc_enable_periph_clock(ID_PIOB);
+ gpio_set_pin_level(LED_PIN, false);
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
+
+ // Button
+ _pmc_enable_periph_clock(ID_PIOA);
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+ gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
+
+ // Uart via EDBG Com
+ _pmc_enable_periph_clock(ID_USART1);
+ gpio_set_pin_function(UART_RX_PIN, MUX_PA21A_USART1_RXD1);
+ gpio_set_pin_function(UART_TX_PIN, MUX_PB4D_USART1_TXD1);
+
+ usart_async_init(&edbg_com, USART1, edbg_com_buffer, sizeof(edbg_com_buffer), _usart_get_usart_async());
+ usart_async_set_baud_rate(&edbg_com, CFG_BOARD_UART_BAUDRATE);
+ usart_async_register_callback(&edbg_com, USART_ASYNC_TXC_CB, tx_cb_EDBG_COM);
+ usart_async_enable(&edbg_com);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer (samd SystemCoreClock may not correct)
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ // Enable USB clock
+ _pmc_enable_periph_clock(ID_USBHS);
+
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USBHS_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ // while until previous transfer is complete
+ while(uart_busy) {}
+ uart_busy = true;
+
+ io_write(&edbg_com.io, buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/board.mk b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/board.mk
new file mode 100644
index 0000000..cb2decf
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/board.mk
@@ -0,0 +1,56 @@
+DEPS_SUBMODULES += hw/mcu/microchip
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -D__SAME70Q21B__ \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMX7X
+
+# suppress following warnings from mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual
+
+ASF_DIR = hw/mcu/microchip/same70
+
+# All source paths should be relative to the top level.
+LD_FILE = $(ASF_DIR)/same70b/gcc/gcc/same70q21b_flash.ld
+
+SRC_C += \
+ src/portable/microchip/samx7x/dcd_samx7x.c \
+ $(ASF_DIR)/same70b/gcc/gcc/startup_same70q21b.c \
+ $(ASF_DIR)/same70b/gcc/system_same70q21b.c \
+ $(ASF_DIR)/hpl/core/hpl_init.c \
+ $(ASF_DIR)/hpl/usart/hpl_usart.c \
+ $(ASF_DIR)/hpl/pmc/hpl_pmc.c \
+ $(ASF_DIR)/hal/src/hal_usart_async.c \
+ $(ASF_DIR)/hal/src/hal_io.c \
+ $(ASF_DIR)/hal/src/hal_atomic.c \
+ $(ASF_DIR)/hal/utils/src/utils_ringbuffer.c
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(ASF_DIR) \
+ $(TOP)/$(ASF_DIR)/config \
+ $(TOP)/$(ASF_DIR)/same70b/include \
+ $(TOP)/$(ASF_DIR)/hal/include \
+ $(TOP)/$(ASF_DIR)/hal/utils/include \
+ $(TOP)/$(ASF_DIR)/hpl/core \
+ $(TOP)/$(ASF_DIR)/hpl/pio \
+ $(TOP)/$(ASF_DIR)/hpl/pmc \
+ $(TOP)/$(ASF_DIR)/hri \
+ $(TOP)/$(ASF_DIR)/CMSIS/Core/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM7
+
+# For flash-jlink target
+JLINK_DEVICE = SAME70Q21B
+
+# flash using edbg from https://github.com/ataradov/edbg
+# Note: SAME70's GPNVM1 must be set to 1 to boot from flash with
+# edbg -t same70 -F w0,1,1
+flash: $(BUILD)/$(PROJECT).bin
+ edbg --verbose -t same70 -pv -f $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_pmc_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_pmc_config.h
new file mode 100644
index 0000000..387aaa5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_pmc_config.h
@@ -0,0 +1,1053 @@
+/* Auto-generated config file hpl_pmc_config.h */
+#ifndef HPL_PMC_CONFIG_H
+#define HPL_PMC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include <peripheral_clk_config.h>
+
+#define CLK_SRC_OPTION_OSC32K 0
+#define CLK_SRC_OPTION_XOSC32K 1
+#define CLK_SRC_OPTION_OSC12M 2
+#define CLK_SRC_OPTION_XOSC20M 3
+
+#define CLK_SRC_OPTION_SLCK 0
+#define CLK_SRC_OPTION_MAINCK 1
+#define CLK_SRC_OPTION_PLLACK 2
+#define CLK_SRC_OPTION_UPLLCKDIV 3
+#define CLK_SRC_OPTION_MCK 4
+
+#define CLK_SRC_OPTION_UPLLCK 3
+
+#define CONF_RC_4M 0
+#define CONF_RC_8M 1
+#define CONF_RC_12M 2
+
+#define CONF_XOSC32K_NO_BYPASS 0
+#define CONF_XOSC32K_BYPASS 1
+
+#define CONF_XOSC20M_NO_BYPASS 0
+#define CONF_XOSC20M_BYPASS 1
+
+// <e> Clock_SLCK configuration
+// <i> Indicates whether SLCK configuration is enabled or not
+// <id> enable_clk_gen_slck
+#ifndef CONF_CLK_SLCK_CONFIG
+#define CONF_CLK_SLCK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator SLCK source
+
+// <CLK_SRC_OPTION_OSC32K"> 32kHz High Accuracy Internal Oscillator (OSC32K)
+
+// <CLK_SRC_OPTION_XOSC32K"> 32kHz External Crystal Oscillator (XOSC32K)
+
+// <i> This defines the clock source for SLCK
+// <id> clk_gen_slck_oscillator
+#ifndef CONF_CLK_GEN_SLCK_SRC
+#define CONF_CLK_GEN_SLCK_SRC CLK_SRC_OPTION_OSC32K
+#endif
+
+// <q> Enable Clock_SLCK
+// <i> Indicates whether SLCK is enabled or disable
+// <id> clk_gen_slck_arch_enable
+#ifndef CONF_CLK_SLCK_ENABLE
+#define CONF_CLK_SLCK_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_MAINCK configuration
+// <i> Indicates whether MAINCK configuration is enabled or not
+// <id> enable_clk_gen_mainck
+#ifndef CONF_CLK_MAINCK_CONFIG
+#define CONF_CLK_MAINCK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator MAINCK source
+
+// <CLK_SRC_OPTION_OSC12M"> Embedded 4/8/12MHz RC Oscillator (OSC12M)
+
+// <CLK_SRC_OPTION_XOSC20M"> External 3-20MHz Oscillator (XOSC20M)
+
+// <i> This defines the clock source for MAINCK
+// <id> clk_gen_mainck_oscillator
+#ifndef CONF_CLK_GEN_MAINCK_SRC
+#define CONF_CLK_GEN_MAINCK_SRC CLK_SRC_OPTION_XOSC20M
+#endif
+
+// <q> Enable Clock_MAINCK
+// <i> Indicates whether MAINCK is enabled or disable
+// <id> clk_gen_mainck_arch_enable
+#ifndef CONF_CLK_MAINCK_ENABLE
+#define CONF_CLK_MAINCK_ENABLE 1
+#endif
+
+// <q> Enable Main Clock Failure Detection
+// <i> Indicates whether Main Clock Failure Detection is enabled or disable.
+// <i> The 4/8/12 MHz RC oscillator must be selected as the source of MAINCK.
+// <id> clk_gen_cfden_enable
+#ifndef CONF_CLK_CFDEN_ENABLE
+#define CONF_CLK_CFDEN_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_MCKR configuration
+// <i> Indicates whether MCKR configuration is enabled or not
+// <id> enable_clk_gen_mckr
+#ifndef CONF_CLK_MCKR_CONFIG
+#define CONF_CLK_MCKR_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator MCKR source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <i> This defines the clock source for MCKR
+// <id> clk_gen_mckr_oscillator
+#ifndef CONF_CLK_GEN_MCKR_SRC
+#define CONF_CLK_GEN_MCKR_SRC CLK_SRC_OPTION_PLLACK
+#endif
+
+// <q> Enable Clock_MCKR
+// <i> Indicates whether MCKR is enabled or disable
+// <id> clk_gen_mckr_arch_enable
+#ifndef CONF_CLK_MCKR_ENABLE
+#define CONF_CLK_MCKR_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Master Clock Prescaler
+// <0=> 1
+// <1=> 2
+// <2=> 4
+// <3=> 8
+// <4=> 16
+// <5=> 32
+// <6=> 64
+// <7=> 3
+// <i> Select the clock prescaler.
+// <id> mckr_presc
+#ifndef CONF_MCKR_PRESC
+#define CONF_MCKR_PRESC 0
+#endif
+
+// </h>
+// </e>// <e> Clock_MCK configuration
+// <i> Indicates whether MCK configuration is enabled or not
+// <id> enable_clk_gen_mck
+#ifndef CONF_CLK_MCK_CONFIG
+#define CONF_CLK_MCK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator MCK source
+
+// <CLK_SRC_OPTION_MCKR"> Master Clock Controller (PMC_MCKR)
+
+// <i> This defines the clock source for MCK
+// <id> clk_gen_mck_oscillator
+#ifndef CONF_CLK_GEN_MCK_SRC
+#define CONF_CLK_GEN_MCK_SRC CLK_SRC_OPTION_MCKR
+#endif
+
+// </h>
+
+// <h>
+
+//<o> Master Clock Controller Divider MCK divider
+// <0=> 1
+// <1=> 2
+// <3=> 3
+// <2=> 4
+// <i> Select the master clock divider.
+// <id> mck_div
+#ifndef CONF_MCK_DIV
+#define CONF_MCK_DIV 1
+#endif
+
+// </h>
+// </e>// <e> Clock_SYSTICK configuration
+// <i> Indicates whether SYSTICK configuration is enabled or not
+// <id> enable_clk_gen_systick
+#ifndef CONF_CLK_SYSTICK_CONFIG
+#define CONF_CLK_SYSTICK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator SYSTICK source
+
+// <CLK_SRC_OPTION_MCKR"> Master Clock Controller (PMC_MCKR)
+
+// <i> This defines the clock source for SYSTICK
+// <id> clk_gen_systick_oscillator
+#ifndef CONF_CLK_GEN_SYSTICK_SRC
+#define CONF_CLK_GEN_SYSTICK_SRC CLK_SRC_OPTION_MCKR
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Systick clock divider
+// <8=> 8
+// <i> Select systick clock divider
+// <id> systick_clock_div
+#ifndef CONF_SYSTICK_DIV
+#define CONF_SYSTICK_DIV 8
+#endif
+
+// </h>
+// </e>// <e> Clock_FCLK configuration
+// <i> Indicates whether FCLK configuration is enabled or not
+// <id> enable_clk_gen_fclk
+#ifndef CONF_CLK_FCLK_CONFIG
+#define CONF_CLK_FCLK_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator FCLK source
+
+// <CLK_SRC_OPTION_MCKR"> Master Clock Controller (PMC_MCKR)
+
+// <i> This defines the clock source for FCLK
+// <id> clk_gen_fclk_oscillator
+#ifndef CONF_CLK_GEN_FCLK_SRC
+#define CONF_CLK_GEN_FCLK_SRC CLK_SRC_OPTION_MCKR
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_GCLK0 configuration
+// <i> Indicates whether GCLK0 configuration is enabled or not
+// <id> enable_clk_gen_gclk0
+#ifndef CONF_CLK_GCLK0_CONFIG
+#define CONF_CLK_GCLK0_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator GCLK0 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCK"> USB 480M Clock (UPLLCK)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for GCLK0
+// <id> clk_gen_gclk0_oscillator
+#ifndef CONF_CLK_GEN_GCLK0_SRC
+#define CONF_CLK_GEN_GCLK0_SRC CLK_SRC_OPTION_MCK
+#endif
+
+// <q> Enable Clock_GCLK0
+// <i> Indicates whether GCLK0 is enabled or disable
+// <id> clk_gen_gclk0_arch_enable
+#ifndef CONF_CLK_GCLK0_ENABLE
+#define CONF_CLK_GCLK0_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+// <q> Enable GCLK0 GCLKEN
+// <i> Indicates whether GCLK0 GCLKEN is enabled or disable
+// <id> gclk0_gclken_enable
+#ifndef CONF_GCLK0_GCLKEN_ENABLE
+#define CONF_GCLK0_GCLKEN_ENABLE 0
+#endif
+
+// <o> Generic Clock GCLK0 divider <1-256>
+// <i> Select the clock divider (divider = GCLKDIV + 1).
+// <id> gclk0_div
+#ifndef CONF_GCLK0_DIV
+#define CONF_GCLK0_DIV 2
+#endif
+
+// </h>
+// </e>// <e> Clock_GCLK1 configuration
+// <i> Indicates whether GCLK1 configuration is enabled or not
+// <id> enable_clk_gen_gclk1
+#ifndef CONF_CLK_GCLK1_CONFIG
+#define CONF_CLK_GCLK1_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator GCLK1 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCK"> USB 480M Clock (UPLLCK)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for GCLK1
+// <id> clk_gen_gclk1_oscillator
+#ifndef CONF_CLK_GEN_GCLK1_SRC
+#define CONF_CLK_GEN_GCLK1_SRC CLK_SRC_OPTION_PLLACK
+#endif
+
+// <q> Enable Clock_GCLK1
+// <i> Indicates whether GCLK1 is enabled or disable
+// <id> clk_gen_gclk1_arch_enable
+#ifndef CONF_CLK_GCLK1_ENABLE
+#define CONF_CLK_GCLK1_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+// <q> Enable GCLK1 GCLKEN
+// <i> Indicates whether GCLK1 GCLKEN is enabled or disable
+// <id> gclk1_gclken_enable
+#ifndef CONF_GCLK1_GCLKEN_ENABLE
+#define CONF_GCLK1_GCLKEN_ENABLE 0
+#endif
+
+// <o> Generic Clock GCLK1 divider <1-256>
+// <i> Select the clock divider (divider = GCLKDIV + 1).
+// <id> gclk1_div
+#ifndef CONF_GCLK1_DIV
+#define CONF_GCLK1_DIV 3
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK0 configuration
+// <i> Indicates whether PCK0 configuration is enabled or not
+// <id> enable_clk_gen_pck0
+#ifndef CONF_CLK_PCK0_CONFIG
+#define CONF_CLK_PCK0_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK0 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK0
+// <id> clk_gen_pck0_oscillator
+#ifndef CONF_CLK_GEN_PCK0_SRC
+#define CONF_CLK_GEN_PCK0_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK0
+// <i> Indicates whether PCK0 is enabled or disable
+// <id> clk_gen_pck0_arch_enable
+#ifndef CONF_CLK_PCK0_ENABLE
+#define CONF_CLK_PCK0_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck0_presc
+#ifndef CONF_PCK0_PRESC
+#define CONF_PCK0_PRESC 1
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK1 configuration
+// <i> Indicates whether PCK1 configuration is enabled or not
+// <id> enable_clk_gen_pck1
+#ifndef CONF_CLK_PCK1_CONFIG
+#define CONF_CLK_PCK1_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK1 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK1
+// <id> clk_gen_pck1_oscillator
+#ifndef CONF_CLK_GEN_PCK1_SRC
+#define CONF_CLK_GEN_PCK1_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK1
+// <i> Indicates whether PCK1 is enabled or disable
+// <id> clk_gen_pck1_arch_enable
+#ifndef CONF_CLK_PCK1_ENABLE
+#define CONF_CLK_PCK1_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck1_presc
+#ifndef CONF_PCK1_PRESC
+#define CONF_PCK1_PRESC 2
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK2 configuration
+// <i> Indicates whether PCK2 configuration is enabled or not
+// <id> enable_clk_gen_pck2
+#ifndef CONF_CLK_PCK2_CONFIG
+#define CONF_CLK_PCK2_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK2 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK2
+// <id> clk_gen_pck2_oscillator
+#ifndef CONF_CLK_GEN_PCK2_SRC
+#define CONF_CLK_GEN_PCK2_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK2
+// <i> Indicates whether PCK2 is enabled or disable
+// <id> clk_gen_pck2_arch_enable
+#ifndef CONF_CLK_PCK2_ENABLE
+#define CONF_CLK_PCK2_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck2_presc
+#ifndef CONF_PCK2_PRESC
+#define CONF_PCK2_PRESC 3
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK3 configuration
+// <i> Indicates whether PCK3 configuration is enabled or not
+// <id> enable_clk_gen_pck3
+#ifndef CONF_CLK_PCK3_CONFIG
+#define CONF_CLK_PCK3_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK3 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK3
+// <id> clk_gen_pck3_oscillator
+#ifndef CONF_CLK_GEN_PCK3_SRC
+#define CONF_CLK_GEN_PCK3_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK3
+// <i> Indicates whether PCK3 is enabled or disable
+// <id> clk_gen_pck3_arch_enable
+#ifndef CONF_CLK_PCK3_ENABLE
+#define CONF_CLK_PCK3_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck3_presc
+#ifndef CONF_PCK3_PRESC
+#define CONF_PCK3_PRESC 4
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK4 configuration
+// <i> Indicates whether PCK4 configuration is enabled or not
+// <id> enable_clk_gen_pck4
+#ifndef CONF_CLK_PCK4_CONFIG
+#define CONF_CLK_PCK4_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK4 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK4
+// <id> clk_gen_pck4_oscillator
+#ifndef CONF_CLK_GEN_PCK4_SRC
+#define CONF_CLK_GEN_PCK4_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK4
+// <i> Indicates whether PCK4 is enabled or disable
+// <id> clk_gen_pck4_arch_enable
+#ifndef CONF_CLK_PCK4_ENABLE
+#define CONF_CLK_PCK4_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck4_presc
+#ifndef CONF_PCK4_PRESC
+#define CONF_PCK4_PRESC 5
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK5 configuration
+// <i> Indicates whether PCK5 configuration is enabled or not
+// <id> enable_clk_gen_pck5
+#ifndef CONF_CLK_PCK5_CONFIG
+#define CONF_CLK_PCK5_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK5 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK5
+// <id> clk_gen_pck5_oscillator
+#ifndef CONF_CLK_GEN_PCK5_SRC
+#define CONF_CLK_GEN_PCK5_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK5
+// <i> Indicates whether PCK5 is enabled or disable
+// <id> clk_gen_pck5_arch_enable
+#ifndef CONF_CLK_PCK5_ENABLE
+#define CONF_CLK_PCK5_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck5_presc
+#ifndef CONF_PCK5_PRESC
+#define CONF_PCK5_PRESC 6
+#endif
+
+// </h>
+// </e>// <e> Clock_PCK6 configuration
+// <i> Indicates whether PCK6 configuration is enabled or not
+// <id> enable_clk_gen_pck6
+#ifndef CONF_CLK_PCK6_CONFIG
+#define CONF_CLK_PCK6_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator PCK6 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <CLK_SRC_OPTION_MAINCK"> Main Clock (MAINCK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_MCK"> Master Clock (MCK)
+
+// <i> This defines the clock source for PCK6
+// <id> clk_gen_pck6_oscillator
+#ifndef CONF_CLK_GEN_PCK6_SRC
+#define CONF_CLK_GEN_PCK6_SRC CLK_SRC_OPTION_MAINCK
+#endif
+
+// <q> Enable Clock_PCK6
+// <i> Indicates whether PCK6 is enabled or disable
+// <id> clk_gen_pck6_arch_enable
+#ifndef CONF_CLK_PCK6_ENABLE
+#define CONF_CLK_PCK6_ENABLE 0
+#endif
+
+// </h>
+
+// <h>
+
+// <o> Programmable Clock Controller Prescaler <1-256>
+// <i> Select the clock prescaler (prescaler = PRESC + 1).
+// <id> pck6_presc
+#ifndef CONF_PCK6_PRESC
+#define CONF_PCK6_PRESC 7
+#endif
+
+// </h>
+// </e>// <e> Clock_USB_480M configuration
+// <i> Indicates whether USB_480M configuration is enabled or not
+// <id> enable_clk_gen_usb_480m
+#ifndef CONF_CLK_USB_480M_CONFIG
+#define CONF_CLK_USB_480M_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator USB_480M source
+
+// <CLK_SRC_OPTION_UPLLCK"> USB 480M Clock (UPLLCK)
+
+// <i> This defines the clock source for USB_480M
+// <id> clk_gen_usb_480m_oscillator
+#ifndef CONF_CLK_GEN_USB_480M_SRC
+#define CONF_CLK_GEN_USB_480M_SRC CLK_SRC_OPTION_UPLLCK
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>// <e> Clock_USB_48M configuration
+// <i> Indicates whether USB_48M configuration is enabled or not
+// <id> enable_clk_gen_usb_48m
+#ifndef CONF_CLK_USB_48M_CONFIG
+#define CONF_CLK_USB_48M_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator USB_48M source
+
+// <CLK_SRC_OPTION_PLLACK"> PLLA Clock (PLLACK)
+
+// <CLK_SRC_OPTION_UPLLCKDIV"> UDPLL with Divider (MCKR UPLLDIV2)
+
+// <i> This defines the clock source for USB_48M
+// <id> clk_gen_usb_48m_oscillator
+#ifndef CONF_CLK_GEN_USB_48M_SRC
+#define CONF_CLK_GEN_USB_48M_SRC CLK_SRC_OPTION_UPLLCKDIV
+#endif
+
+// <q> Enable Clock_USB_48M
+// <i> Indicates whether USB_48M is enabled or disable
+// <id> clk_gen_usb_48m_arch_enable
+#ifndef CONF_CLK_USB_48M_ENABLE
+#define CONF_CLK_USB_48M_ENABLE 1
+#endif
+
+// </h>
+
+// <h>
+
+// <o> USB Clock Controller Divider <1-16>
+// <i> Select the USB clock divider (divider = USBDIV + 1).
+// <id> usb_48m_div
+#ifndef CONF_USB_48M_DIV
+#define CONF_USB_48M_DIV 5
+#endif
+
+// </h>
+// </e>// <e> Clock_SLCK2 configuration
+// <i> Indicates whether SLCK2 configuration is enabled or not
+// <id> enable_clk_gen_slck2
+#ifndef CONF_CLK_SLCK2_CONFIG
+#define CONF_CLK_SLCK2_CONFIG 1
+#endif
+
+//<h> Clock Generator
+// <y> clock generator SLCK2 source
+
+// <CLK_SRC_OPTION_SLCK"> Slow Clock (SLCK)
+
+// <i> This defines the clock source for SLCK2
+// <id> clk_gen_slck2_oscillator
+#ifndef CONF_CLK_GEN_SLCK2_SRC
+#define CONF_CLK_GEN_SLCK2_SRC CLK_SRC_OPTION_SLCK
+#endif
+
+// </h>
+
+// <h>
+
+// </h>
+// </e>
+
+// <e> System Configuration
+// <i> Indicates whether configuration for system is enabled or not
+// <id> enable_hclk_clock
+#ifndef CONF_SYSTEM_CONFIG
+#define CONF_SYSTEM_CONFIG 1
+#endif
+
+// <h> Processor Clock Settings
+// <y> Processor Clock source
+// <MCKR"> Master Clock Controller (PMC_MCKR)
+// <i> This defines the clock source for the HCLK (Processor clock)
+// <id> hclk_clock_source
+#ifndef CONF_HCLK_SRC
+#define CONF_HCLK_SRC MCKR
+#endif
+
+// <o> Flash Wait State
+// <0=> 1 cycle
+// <1=> 2 cycles
+// <2=> 3 cycles
+// <3=> 4 cycles
+// <4=> 5 cycles
+// <5=> 6 cycles
+// <6=> 7 cycles
+// <i> This field defines the number of wait states for read and write operations.
+// <id> efc_fws
+#ifndef CONF_EFC_WAIT_STATE
+#define CONF_EFC_WAIT_STATE 5
+#endif
+
+// </h>
+// </e>
+
+// <e> SysTick Clock
+// <id> enable_systick_clk_clock
+#ifndef CONF_SYSTICK_CLK_CONFIG
+#define CONF_SYSTICK_CLK_CONFIG 1
+#endif
+
+// <y> SysTick Clock source
+// <MCKR"> Master Clock Controller (PMC_MCKR)
+// <i> This defines the clock source for the SysTick Clock
+// <id> systick_clk_clock_source
+#ifndef CONF_SYSTICK_CLK_SRC
+#define CONF_SYSTICK_CLK_SRC MCKR
+#endif
+
+// <o> SysTick Clock Divider
+// <8=> 8
+// <i> Fixed to 8 if Systick is not using Processor clock
+// <id> systick_clk_clock_div
+#ifndef CONF_SYSTICK_CLK_DIV
+#define CONF_SYSTICK_CLK_DIV 8
+#endif
+
+// </e>
+
+// <e> OSC32K Oscillator Configuration
+// <i> Indicates whether configuration for OSC32K is enabled or not
+// <id> enable_osc32k
+#ifndef CONF_OSC32K_CONFIG
+#define CONF_OSC32K_CONFIG 1
+#endif
+
+// <h> OSC32K Oscillator Control
+// <q> OSC32K Oscillator Enable
+// <i> Indicates whether OSC32K Oscillator is enabled or not
+// <id> osc32k_arch_enable
+#ifndef CONF_OSC32K_ENABLE
+#define CONF_OSC32K_ENABLE 0
+#endif
+// </h>
+// </e>
+
+// <e> XOSC32K Oscillator Configuration
+// <i> Indicates whether configuration for XOSC32K is enabled or not
+// <id> enable_xosc32k
+#ifndef CONF_XOSC32K_CONFIG
+#define CONF_XOSC32K_CONFIG 0
+#endif
+
+// <h> XOSC32K Oscillator Control
+// <y> Oscillator Bypass Select
+// <CONF_XOSC32K_NO_BYPASS"> The 32kHz crystal oscillator is not bypassed.
+// <CONF_XOSC32K_BYPASS"> The 32kHz crystal oscillator is bypassed.
+// <i> Indicates whether XOSC32K is bypassed.
+// <id> xosc32k_bypass
+#ifndef CONF_XOSC32K
+#define CONF_XOSC32K CONF_XOSC32K_NO_BYPASS
+#endif
+
+// <q> XOSC32K Oscillator Enable
+// <i> Indicates whether XOSC32K Oscillator is enabled or not
+// <id> xosc32k_arch_enable
+#ifndef CONF_XOSC32K_ENABLE
+#define CONF_XOSC32K_ENABLE 0
+#endif
+// </h>
+// </e>
+
+// <e> OSC12M Oscillator Configuration
+// <i> Indicates whether configuration for OSC12M is enabled or not
+// <id> enable_osc12m
+#ifndef CONF_OSC12M_CONFIG
+#define CONF_OSC12M_CONFIG 0
+#endif
+
+// <h> OSC12M Oscillator Control
+// <q> OSC12M Oscillator Enable
+// <i> Indicates whether OSC12M Oscillator is enabled or not.
+// <id> osc12m_arch_enable
+#ifndef CONF_OSC12M_ENABLE
+#define CONF_OSC12M_ENABLE 0
+#endif
+
+// <o> OSC12M selector
+// <0=> 4000000
+// <1=> 8000000
+// <2=> 12000000
+// <i> Select the frequency of embedded fast RC oscillator.
+// <id> osc12m_selector
+#ifndef CONF_OSC12M_SELECTOR
+#define CONF_OSC12M_SELECTOR 2
+#endif
+// </h>
+// </e>
+
+// <e> XOSC20M Oscillator Configuration
+// <i> Indicates whether configuration for XOSC20M is enabled or not.
+// <id> enable_xosc20m
+#ifndef CONF_XOSC20M_CONFIG
+#define CONF_XOSC20M_CONFIG 1
+#endif
+
+// <h> XOSC20M Oscillator Control
+// <o> XOSC20M selector <3000000-20000000>
+// <i> Select the frequency of crystal or ceramic resonator oscillator.
+// <id> xosc20m_selector
+#ifndef CONF_XOSC20M_SELECTOR
+#define CONF_XOSC20M_SELECTOR 12000000
+#endif
+
+// <o> Start up time for the external oscillator (ms): <0-256>
+// <i> Select start-up time.
+// <id> xosc20m_startup_time
+#ifndef CONF_XOSC20M_STARTUP_TIME
+#define CONF_XOSC20M_STARTUP_TIME 62
+#endif
+
+// <y> Oscillator Bypass Select
+// <CONF_XOSC20M_NO_BYPASS"> The external crystal oscillator is not bypassed.
+// <CONF_XOSC20M_BYPASS"> The external crystal oscillator is bypassed.
+// <i> Indicates whether XOSC20M is bypassed.
+// <id> xosc20m_bypass
+#ifndef CONF_XOSC20M
+#define CONF_XOSC20M CONF_XOSC20M_NO_BYPASS
+#endif
+
+// <q> XOSC20M Oscillator Enable
+// <i> Indicates whether XOSC20M Oscillator is enabled or not
+// <id> xosc20m_arch_enable
+#ifndef CONF_XOSC20M_ENABLE
+#define CONF_XOSC20M_ENABLE 1
+#endif
+// </h>
+// </e>
+
+// <e> PLLACK Oscillator Configuration
+// <i> Indicates whether configuration for PLLACK is enabled or not
+// <id> enable_pllack
+#ifndef CONF_PLLACK_CONFIG
+#define CONF_PLLACK_CONFIG 1
+#endif
+
+// <y> PLLACK Reference Clock Source
+// <MAINCK"> Main Clock (MAINCK)
+// <i> Select the clock source.
+// <id> pllack_ref_clock
+#ifndef CONF_PLLACK_CLK
+#define CONF_PLLACK_CLK MAINCK
+#endif
+
+// <h> PLLACK Oscillator Control
+// <q> PLLACK Oscillator Enable
+// <i> Indicates whether PLLACK Oscillator is enabled or not
+// <id> pllack_arch_enable
+#ifndef CONF_PLLACK_ENABLE
+#define CONF_PLLACK_ENABLE 1
+#endif
+
+// <o> PLLA Frontend Divider (DIVA) <1-255>
+// <i> Select the clock divider
+// <id> pllack_div
+#ifndef CONF_PLLACK_DIV
+#define CONF_PLLACK_DIV 1
+#endif
+
+// <o> PLLACK Muliplier <1-62>
+// <i> Indicates PLLA multiplier (multiplier = MULA + 1).
+// <id> pllack_mul
+#ifndef CONF_PLLACK_MUL
+#define CONF_PLLACK_MUL 25
+#endif
+// </h>
+// </e>
+
+// <e> UPLLCK Oscillator Configuration
+// <i> Indicates whether configuration for UPLLCK is enabled or not
+// <id> enable_upllck
+#ifndef CONF_UPLLCK_CONFIG
+#define CONF_UPLLCK_CONFIG 1
+#endif
+
+// <y> UPLLCK Reference Clock Source
+// <XOSC20M"> External 3-20MHz Oscillator (XOSC20M)
+// <i> Select the clock source,only when the input frequency is 12M or 16M, the upllck output is 480M.
+// <id> upllck_ref_clock
+#ifndef CONF_UPLLCK_CLK
+#define CONF_UPLLCK_CLK XOSC20M
+#endif
+
+// <h> UPLLCK Oscillator Control
+// <q> UPLLCK Oscillator Enable
+// <i> Indicates whether UPLLCK Oscillator is enabled or not
+// <id> upllck_arch_enable
+#ifndef CONF_UPLLCK_ENABLE
+#define CONF_UPLLCK_ENABLE 1
+#endif
+// </h>
+// </e>
+
+// <e> UPLLCKDIV Oscillator Configuration
+// <i> Indicates whether configuration for UPLLCKDIV is enabled or not
+// <id> enable_upllckdiv
+#ifndef CONF_UPLLCKDIV_CONFIG
+#define CONF_UPLLCKDIV_CONFIG 1
+#endif
+
+// <y> UPLLCKDIV Reference Clock Source
+// <UPLLCK"> USB 480M Clock (UPLLCK)
+// <i> Select the clock source.
+// <id> upllckdiv_ref_clock
+#ifndef CONF_UPLLCKDIV_CLK
+#define CONF_UPLLCKDIV_CLK UPLLCK
+#endif
+
+// <h> UPLLCKDIV Oscillator Control
+// <o> UPLLCKDIV Clock Divider
+// <0=> 1
+// <1=> 2
+// <i> Select the clock divider.
+// <id> upllckdiv_div
+#ifndef CONF_UPLLCKDIV_DIV
+#define CONF_UPLLCKDIV_DIV 1
+#endif
+// </h>
+// </e>
+
+// <e> MCK/8
+// <id> enable_mck_div_8
+#ifndef CONF_MCK_DIV_8_CONFIG
+#define CONF_MCK_DIV_8_CONFIG 0
+#endif
+
+// <o> MCK/8 Source
+// <0=> Master Clock (MCK)
+// <id> mck_div_8_src
+#ifndef CONF_MCK_DIV_8_SRC
+#define CONF_MCK_DIV_8_SRC 0
+#endif
+// </e>
+
+// <e> External Clock Input Configuration
+// <id> enable_dummy_ext
+#ifndef CONF_DUMMY_EXT_CONFIG
+#define CONF_DUMMY_EXT_CONFIG 1
+#endif
+
+// <o> External Clock Input Source
+// <i> All here are dummy values
+// <i> Refer to the peripherals settings for actual input information
+// <0=> Specific clock input from specific pin
+// <id> dummy_ext_src
+#ifndef CONF_DUMMY_EXT_SRC
+#define CONF_DUMMY_EXT_SRC 0
+#endif
+// </e>
+
+// <e> External Clock Configuration
+// <id> enable_dummy_ext_clk
+#ifndef CONF_DUMMY_EXT_CLK_CONFIG
+#define CONF_DUMMY_EXT_CLK_CONFIG 1
+#endif
+
+// <o> External Clock Source
+// <i> All here are dummy values
+// <i> Refer to the peripherals settings for actual input information
+// <0=> External Clock Input
+// <id> dummy_ext_clk_src
+#ifndef CONF_DUMMY_EXT_CLK_SRC
+#define CONF_DUMMY_EXT_CLK_SRC 0
+#endif
+// </e>
+
+// <<< end of configuration section >>>
+
+#endif // HPL_PMC_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_usart_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_usart_config.h
new file mode 100644
index 0000000..50ca3f1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_usart_config.h
@@ -0,0 +1,215 @@
+/* Auto-generated config file hpl_usart_config.h */
+#ifndef HPL_USART_CONFIG_H
+#define HPL_USART_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_USART_1_ENABLE
+#define CONF_USART_1_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <o> Frame parity
+// <0x0=>Even parity
+// <0x1=>Odd parity
+// <0x2=>Parity forced to 0
+// <0x3=>Parity forced to 1
+// <0x4=>No parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_USART_1_PARITY
+#define CONF_USART_1_PARITY 0x4
+#endif
+
+// <o> Character Size
+// <0x0=>5 bits
+// <0x1=>6 bits
+// <0x2=>7 bits
+// <0x3=>8 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_USART_1_CHSIZE
+#define CONF_USART_1_CHSIZE 0x3
+#endif
+
+// <o> Stop Bit
+// <0=>1 stop bit
+// <1=>1.5 stop bits
+// <2=>2 stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_USART_1_SBMODE
+#define CONF_USART_1_SBMODE 0
+#endif
+
+// <o> Clock Output Select
+// <0=>The USART does not drive the SCK pin
+// <1=>The USART drives the SCK pin if USCLKS does not select the external clock SCK
+// <i> Clock Output Select in USART sck, if in usrt master mode, please drive SCK.
+// <id> usart_clock_output_select
+#ifndef CONF_USART_1_CLKO
+#define CONF_USART_1_CLKO 0
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_USART_1_BAUD
+#define CONF_USART_1_BAUD 9600
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_USART_1_ADVANCED_CONFIG
+#define CONF_USART_1_ADVANCED_CONFIG 0
+#endif
+
+// <o> Channel Mode
+// <0=>Normal Mode
+// <1=>Automatic Echo
+// <2=>Local Loopback
+// <3=>Remote Loopback
+// <i> Channel mode in USART frame
+// <id> usart_channel_mode
+#ifndef CONF_USART_1_CHMODE
+#define CONF_USART_1_CHMODE 0
+#endif
+
+// <q> 9 bits character enable
+// <i> Enable 9 bits character, this has high priority than 5/6/7/8 bits.
+// <id> usart_9bits_enable
+#ifndef CONF_USART_1_MODE9
+#define CONF_USART_1_MODE9 0
+#endif
+
+// <o> Variable Sync
+// <0=>User defined configuration
+// <1=>sync field is updated when a character is written into US_THR
+// <i> Variable Synchronization of Command/Data Sync Start Frarm Delimiter
+// <id> variable_sync
+#ifndef CONF_USART_1_VAR_SYNC
+#define CONF_USART_1_VAR_SYNC 0
+#endif
+
+// <o> Oversampling Mode
+// <0=>16 Oversampling
+// <1=>8 Oversampling
+// <i> Oversampling Mode in UART mode
+// <id> usart__oversampling_mode
+#ifndef CONF_USART_1_OVER
+#define CONF_USART_1_OVER 0
+#endif
+
+// <o> Inhibit Non Ack
+// <0=>The NACK is generated
+// <1=>The NACK is not generated
+// <i> Inhibit Non Acknowledge
+// <id> usart__inack
+#ifndef CONF_USART_1_INACK
+#define CONF_USART_1_INACK 1
+#endif
+
+// <o> Disable Successive NACK
+// <0=>NACK is sent on the ISO line as soon as a parity error occurs
+// <1=>Many parity errors generate a NACK on the ISO line
+// <i> Disable Successive NACK
+// <id> usart_dsnack
+#ifndef CONF_USART_1_DSNACK
+#define CONF_USART_1_DSNACK 0
+#endif
+
+// <o> Inverted Data
+// <0=>Data isn't inverted, nomal mode
+// <1=>Data is inverted
+// <i> Inverted Data
+// <id> usart_invdata
+#ifndef CONF_USART_1_INVDATA
+#define CONF_USART_1_INVDATA 0
+#endif
+
+// <o> Maximum Number of Automatic Iteration <0-7>
+// <i> Defines the maximum number of iterations in mode ISO7816, protocol T = 0.
+// <id> usart_max_iteration
+#ifndef CONF_USART_1_MAX_ITERATION
+#define CONF_USART_1_MAX_ITERATION 0
+#endif
+
+// <q> Receive Line Filter enable
+// <i> whether the USART filters the receive line using a three-sample filter
+// <id> usart_receive_filter_enable
+#ifndef CONF_USART_1_FILTER
+#define CONF_USART_1_FILTER 0
+#endif
+
+// <q> Manchester Encoder/Decoder Enable
+// <i> whether the USART Manchester Encoder/Decoder
+// <id> usart_manchester_filter_enable
+#ifndef CONF_USART_1_MAN
+#define CONF_USART_1_MAN 0
+#endif
+
+// <o> Manchester Synchronization Mode
+// <0=>The Manchester start bit is a 0 to 1 transition
+// <1=>The Manchester start bit is a 1 to 0 transition
+// <i> Manchester Synchronization Mode
+// <id> usart_manchester_synchronization_mode
+#ifndef CONF_USART_1_MODSYNC
+#define CONF_USART_1_MODSYNC 0
+#endif
+
+// <o> Start Frame Delimiter Selector
+// <0=>Start frame delimiter is COMMAND or DATA SYNC
+// <1=>Start frame delimiter is one bit
+// <i> Start Frame Delimiter Selector
+// <id> usart_start_frame_delimiter
+#ifndef CONF_USART_1_ONEBIT
+#define CONF_USART_1_ONEBIT 0
+#endif
+
+// <o> Fractional Part <0-7>
+// <i> Fractional part of the baud rate if baud rate generator is in fractional mode
+// <id> usart_arch_fractional
+#ifndef CONF_USART_1_FRACTIONAL
+#define CONF_USART_1_FRACTIONAL 0x0
+#endif
+
+// <o> Data Order
+// <0=>LSB is transmitted first
+// <1=>MSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_msbf
+#ifndef CONF_USART_1_MSBF
+#define CONF_USART_1_MSBF 0
+#endif
+
+// </e>
+
+#define CONF_USART_1_MODE 0x0
+
+// Calculate BAUD register value in UART mode
+#if CONF_USART1_CK_SRC < 3
+#ifndef CONF_USART_1_BAUD_CD
+#define CONF_USART_1_BAUD_CD ((CONF_USART1_FREQUENCY) / CONF_USART_1_BAUD / 8 / (2 - CONF_USART_1_OVER))
+#endif
+#ifndef CONF_USART_1_BAUD_FP
+#define CONF_USART_1_BAUD_FP \
+ ((CONF_USART1_FREQUENCY) / CONF_USART_1_BAUD / (2 - CONF_USART_1_OVER) - 8 * CONF_USART_1_BAUD_CD)
+#endif
+#elif CONF_USART1_CK_SRC == 3
+// No division is active. The value written in US_BRGR has no effect.
+#ifndef CONF_USART_1_BAUD_CD
+#define CONF_USART_1_BAUD_CD 1
+#endif
+#ifndef CONF_USART_1_BAUD_FP
+#define CONF_USART_1_BAUD_FP 1
+#endif
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // HPL_USART_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_xdmac_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_xdmac_config.h
new file mode 100644
index 0000000..a3d62c6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/hpl_xdmac_config.h
@@ -0,0 +1,4400 @@
+/* Auto-generated config file hpl_xdmac_config.h */
+#ifndef HPL_XDMAC_CONFIG_H
+#define HPL_XDMAC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// <e> XDMAC enable
+// <i> Indicates whether xdmac is enabled or not
+// <id> xdmac_enable
+#ifndef CONF_DMA_ENABLE
+#define CONF_DMA_ENABLE 0
+#endif
+
+// <e> Channel 0 settings
+// <id> dmac_channel_0_settings
+#ifndef CONF_DMAC_CHANNEL_0_SETTINGS
+#define CONF_DMAC_CHANNEL_0_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_0
+#ifndef CONF_DMAC_BURSTSIZE_0
+#define CONF_DMAC_BURSTSIZE_0 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_0
+#ifndef CONF_DMAC_CHUNKSIZE_0
+#define CONF_DMAC_CHUNKSIZE_0 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_0
+#ifndef CONF_DMAC_BEATSIZE_0
+#define CONF_DMAC_BEATSIZE_0 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_0
+#ifndef CONF_DMAC_SRC_INTERFACE_0
+#define CONF_DMAC_SRC_INTERFACE_0 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_0
+#ifndef CONF_DMAC_DES_INTERFACE_0
+#define CONF_DMAC_DES_INTERFACE_0 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_0
+#ifndef CONF_DMAC_SRCINC_0
+#define CONF_DMAC_SRCINC_0 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_0
+#ifndef CONF_DMAC_DSTINC_0
+#define CONF_DMAC_DSTINC_0 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_0
+#ifndef CONF_DMAC_TRANS_TYPE_0
+#define CONF_DMAC_TRANS_TYPE_0 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_0
+#ifndef CONF_DMAC_TRIGSRC_0
+#define CONF_DMAC_TRIGSRC_0 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_0 == 0
+#define CONF_DMAC_TYPE_0 0
+#define CONF_DMAC_DSYNC_0 0
+#elif CONF_DMAC_TRANS_TYPE_0 == 1
+#define CONF_DMAC_TYPE_0 1
+#define CONF_DMAC_DSYNC_0 0
+#elif CONF_DMAC_TRANS_TYPE_0 == 2
+#define CONF_DMAC_TYPE_0 1
+#define CONF_DMAC_DSYNC_0 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_0 == 0xFF
+#define CONF_DMAC_SWREQ_0 1
+#else
+#define CONF_DMAC_SWREQ_0 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_0_SETTINGS == 1 && CONF_DMAC_BEATSIZE_0 != 2 && ((!CONF_DMAC_SRCINC_0) || (!CONF_DMAC_DSTINC_0)))
+#if (!CONF_DMAC_SRCINC_0)
+#define CONF_DMAC_SRC_STRIDE_0 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_0)
+#define CONF_DMAC_DES_STRIDE_0 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_0
+#define CONF_DMAC_SRC_STRIDE_0 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_0
+#define CONF_DMAC_DES_STRIDE_0 0
+#endif
+
+// <e> Channel 1 settings
+// <id> dmac_channel_1_settings
+#ifndef CONF_DMAC_CHANNEL_1_SETTINGS
+#define CONF_DMAC_CHANNEL_1_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_1
+#ifndef CONF_DMAC_BURSTSIZE_1
+#define CONF_DMAC_BURSTSIZE_1 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_1
+#ifndef CONF_DMAC_CHUNKSIZE_1
+#define CONF_DMAC_CHUNKSIZE_1 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_1
+#ifndef CONF_DMAC_BEATSIZE_1
+#define CONF_DMAC_BEATSIZE_1 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_1
+#ifndef CONF_DMAC_SRC_INTERFACE_1
+#define CONF_DMAC_SRC_INTERFACE_1 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_1
+#ifndef CONF_DMAC_DES_INTERFACE_1
+#define CONF_DMAC_DES_INTERFACE_1 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_1
+#ifndef CONF_DMAC_SRCINC_1
+#define CONF_DMAC_SRCINC_1 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_1
+#ifndef CONF_DMAC_DSTINC_1
+#define CONF_DMAC_DSTINC_1 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_1
+#ifndef CONF_DMAC_TRANS_TYPE_1
+#define CONF_DMAC_TRANS_TYPE_1 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_1
+#ifndef CONF_DMAC_TRIGSRC_1
+#define CONF_DMAC_TRIGSRC_1 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_1 == 0
+#define CONF_DMAC_TYPE_1 0
+#define CONF_DMAC_DSYNC_1 0
+#elif CONF_DMAC_TRANS_TYPE_1 == 1
+#define CONF_DMAC_TYPE_1 1
+#define CONF_DMAC_DSYNC_1 0
+#elif CONF_DMAC_TRANS_TYPE_1 == 2
+#define CONF_DMAC_TYPE_1 1
+#define CONF_DMAC_DSYNC_1 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_1 == 0xFF
+#define CONF_DMAC_SWREQ_1 1
+#else
+#define CONF_DMAC_SWREQ_1 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_1_SETTINGS == 1 && CONF_DMAC_BEATSIZE_1 != 2 && ((!CONF_DMAC_SRCINC_1) || (!CONF_DMAC_DSTINC_1)))
+#if (!CONF_DMAC_SRCINC_1)
+#define CONF_DMAC_SRC_STRIDE_1 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_1)
+#define CONF_DMAC_DES_STRIDE_1 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_1
+#define CONF_DMAC_SRC_STRIDE_1 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_1
+#define CONF_DMAC_DES_STRIDE_1 0
+#endif
+
+// <e> Channel 2 settings
+// <id> dmac_channel_2_settings
+#ifndef CONF_DMAC_CHANNEL_2_SETTINGS
+#define CONF_DMAC_CHANNEL_2_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_2
+#ifndef CONF_DMAC_BURSTSIZE_2
+#define CONF_DMAC_BURSTSIZE_2 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_2
+#ifndef CONF_DMAC_CHUNKSIZE_2
+#define CONF_DMAC_CHUNKSIZE_2 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_2
+#ifndef CONF_DMAC_BEATSIZE_2
+#define CONF_DMAC_BEATSIZE_2 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_2
+#ifndef CONF_DMAC_SRC_INTERFACE_2
+#define CONF_DMAC_SRC_INTERFACE_2 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_2
+#ifndef CONF_DMAC_DES_INTERFACE_2
+#define CONF_DMAC_DES_INTERFACE_2 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_2
+#ifndef CONF_DMAC_SRCINC_2
+#define CONF_DMAC_SRCINC_2 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_2
+#ifndef CONF_DMAC_DSTINC_2
+#define CONF_DMAC_DSTINC_2 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_2
+#ifndef CONF_DMAC_TRANS_TYPE_2
+#define CONF_DMAC_TRANS_TYPE_2 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_2
+#ifndef CONF_DMAC_TRIGSRC_2
+#define CONF_DMAC_TRIGSRC_2 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_2 == 0
+#define CONF_DMAC_TYPE_2 0
+#define CONF_DMAC_DSYNC_2 0
+#elif CONF_DMAC_TRANS_TYPE_2 == 1
+#define CONF_DMAC_TYPE_2 1
+#define CONF_DMAC_DSYNC_2 0
+#elif CONF_DMAC_TRANS_TYPE_2 == 2
+#define CONF_DMAC_TYPE_2 1
+#define CONF_DMAC_DSYNC_2 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_2 == 0xFF
+#define CONF_DMAC_SWREQ_2 1
+#else
+#define CONF_DMAC_SWREQ_2 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_2_SETTINGS == 1 && CONF_DMAC_BEATSIZE_2 != 2 && ((!CONF_DMAC_SRCINC_2) || (!CONF_DMAC_DSTINC_2)))
+#if (!CONF_DMAC_SRCINC_2)
+#define CONF_DMAC_SRC_STRIDE_2 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_2)
+#define CONF_DMAC_DES_STRIDE_2 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_2
+#define CONF_DMAC_SRC_STRIDE_2 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_2
+#define CONF_DMAC_DES_STRIDE_2 0
+#endif
+
+// <e> Channel 3 settings
+// <id> dmac_channel_3_settings
+#ifndef CONF_DMAC_CHANNEL_3_SETTINGS
+#define CONF_DMAC_CHANNEL_3_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_3
+#ifndef CONF_DMAC_BURSTSIZE_3
+#define CONF_DMAC_BURSTSIZE_3 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_3
+#ifndef CONF_DMAC_CHUNKSIZE_3
+#define CONF_DMAC_CHUNKSIZE_3 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_3
+#ifndef CONF_DMAC_BEATSIZE_3
+#define CONF_DMAC_BEATSIZE_3 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_3
+#ifndef CONF_DMAC_SRC_INTERFACE_3
+#define CONF_DMAC_SRC_INTERFACE_3 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_3
+#ifndef CONF_DMAC_DES_INTERFACE_3
+#define CONF_DMAC_DES_INTERFACE_3 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_3
+#ifndef CONF_DMAC_SRCINC_3
+#define CONF_DMAC_SRCINC_3 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_3
+#ifndef CONF_DMAC_DSTINC_3
+#define CONF_DMAC_DSTINC_3 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_3
+#ifndef CONF_DMAC_TRANS_TYPE_3
+#define CONF_DMAC_TRANS_TYPE_3 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_3
+#ifndef CONF_DMAC_TRIGSRC_3
+#define CONF_DMAC_TRIGSRC_3 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_3 == 0
+#define CONF_DMAC_TYPE_3 0
+#define CONF_DMAC_DSYNC_3 0
+#elif CONF_DMAC_TRANS_TYPE_3 == 1
+#define CONF_DMAC_TYPE_3 1
+#define CONF_DMAC_DSYNC_3 0
+#elif CONF_DMAC_TRANS_TYPE_3 == 2
+#define CONF_DMAC_TYPE_3 1
+#define CONF_DMAC_DSYNC_3 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_3 == 0xFF
+#define CONF_DMAC_SWREQ_3 1
+#else
+#define CONF_DMAC_SWREQ_3 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_3_SETTINGS == 1 && CONF_DMAC_BEATSIZE_3 != 2 && ((!CONF_DMAC_SRCINC_3) || (!CONF_DMAC_DSTINC_3)))
+#if (!CONF_DMAC_SRCINC_3)
+#define CONF_DMAC_SRC_STRIDE_3 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_3)
+#define CONF_DMAC_DES_STRIDE_3 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_3
+#define CONF_DMAC_SRC_STRIDE_3 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_3
+#define CONF_DMAC_DES_STRIDE_3 0
+#endif
+
+// <e> Channel 4 settings
+// <id> dmac_channel_4_settings
+#ifndef CONF_DMAC_CHANNEL_4_SETTINGS
+#define CONF_DMAC_CHANNEL_4_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_4
+#ifndef CONF_DMAC_BURSTSIZE_4
+#define CONF_DMAC_BURSTSIZE_4 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_4
+#ifndef CONF_DMAC_CHUNKSIZE_4
+#define CONF_DMAC_CHUNKSIZE_4 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_4
+#ifndef CONF_DMAC_BEATSIZE_4
+#define CONF_DMAC_BEATSIZE_4 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_4
+#ifndef CONF_DMAC_SRC_INTERFACE_4
+#define CONF_DMAC_SRC_INTERFACE_4 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_4
+#ifndef CONF_DMAC_DES_INTERFACE_4
+#define CONF_DMAC_DES_INTERFACE_4 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_4
+#ifndef CONF_DMAC_SRCINC_4
+#define CONF_DMAC_SRCINC_4 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_4
+#ifndef CONF_DMAC_DSTINC_4
+#define CONF_DMAC_DSTINC_4 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_4
+#ifndef CONF_DMAC_TRANS_TYPE_4
+#define CONF_DMAC_TRANS_TYPE_4 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_4
+#ifndef CONF_DMAC_TRIGSRC_4
+#define CONF_DMAC_TRIGSRC_4 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_4 == 0
+#define CONF_DMAC_TYPE_4 0
+#define CONF_DMAC_DSYNC_4 0
+#elif CONF_DMAC_TRANS_TYPE_4 == 1
+#define CONF_DMAC_TYPE_4 1
+#define CONF_DMAC_DSYNC_4 0
+#elif CONF_DMAC_TRANS_TYPE_4 == 2
+#define CONF_DMAC_TYPE_4 1
+#define CONF_DMAC_DSYNC_4 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_4 == 0xFF
+#define CONF_DMAC_SWREQ_4 1
+#else
+#define CONF_DMAC_SWREQ_4 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_4_SETTINGS == 1 && CONF_DMAC_BEATSIZE_4 != 2 && ((!CONF_DMAC_SRCINC_4) || (!CONF_DMAC_DSTINC_4)))
+#if (!CONF_DMAC_SRCINC_4)
+#define CONF_DMAC_SRC_STRIDE_4 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_4)
+#define CONF_DMAC_DES_STRIDE_4 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_4
+#define CONF_DMAC_SRC_STRIDE_4 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_4
+#define CONF_DMAC_DES_STRIDE_4 0
+#endif
+
+// <e> Channel 5 settings
+// <id> dmac_channel_5_settings
+#ifndef CONF_DMAC_CHANNEL_5_SETTINGS
+#define CONF_DMAC_CHANNEL_5_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_5
+#ifndef CONF_DMAC_BURSTSIZE_5
+#define CONF_DMAC_BURSTSIZE_5 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_5
+#ifndef CONF_DMAC_CHUNKSIZE_5
+#define CONF_DMAC_CHUNKSIZE_5 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_5
+#ifndef CONF_DMAC_BEATSIZE_5
+#define CONF_DMAC_BEATSIZE_5 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_5
+#ifndef CONF_DMAC_SRC_INTERFACE_5
+#define CONF_DMAC_SRC_INTERFACE_5 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_5
+#ifndef CONF_DMAC_DES_INTERFACE_5
+#define CONF_DMAC_DES_INTERFACE_5 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_5
+#ifndef CONF_DMAC_SRCINC_5
+#define CONF_DMAC_SRCINC_5 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_5
+#ifndef CONF_DMAC_DSTINC_5
+#define CONF_DMAC_DSTINC_5 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_5
+#ifndef CONF_DMAC_TRANS_TYPE_5
+#define CONF_DMAC_TRANS_TYPE_5 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_5
+#ifndef CONF_DMAC_TRIGSRC_5
+#define CONF_DMAC_TRIGSRC_5 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_5 == 0
+#define CONF_DMAC_TYPE_5 0
+#define CONF_DMAC_DSYNC_5 0
+#elif CONF_DMAC_TRANS_TYPE_5 == 1
+#define CONF_DMAC_TYPE_5 1
+#define CONF_DMAC_DSYNC_5 0
+#elif CONF_DMAC_TRANS_TYPE_5 == 2
+#define CONF_DMAC_TYPE_5 1
+#define CONF_DMAC_DSYNC_5 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_5 == 0xFF
+#define CONF_DMAC_SWREQ_5 1
+#else
+#define CONF_DMAC_SWREQ_5 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_5_SETTINGS == 1 && CONF_DMAC_BEATSIZE_5 != 2 && ((!CONF_DMAC_SRCINC_5) || (!CONF_DMAC_DSTINC_5)))
+#if (!CONF_DMAC_SRCINC_5)
+#define CONF_DMAC_SRC_STRIDE_5 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_5)
+#define CONF_DMAC_DES_STRIDE_5 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_5
+#define CONF_DMAC_SRC_STRIDE_5 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_5
+#define CONF_DMAC_DES_STRIDE_5 0
+#endif
+
+// <e> Channel 6 settings
+// <id> dmac_channel_6_settings
+#ifndef CONF_DMAC_CHANNEL_6_SETTINGS
+#define CONF_DMAC_CHANNEL_6_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_6
+#ifndef CONF_DMAC_BURSTSIZE_6
+#define CONF_DMAC_BURSTSIZE_6 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_6
+#ifndef CONF_DMAC_CHUNKSIZE_6
+#define CONF_DMAC_CHUNKSIZE_6 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_6
+#ifndef CONF_DMAC_BEATSIZE_6
+#define CONF_DMAC_BEATSIZE_6 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_6
+#ifndef CONF_DMAC_SRC_INTERFACE_6
+#define CONF_DMAC_SRC_INTERFACE_6 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_6
+#ifndef CONF_DMAC_DES_INTERFACE_6
+#define CONF_DMAC_DES_INTERFACE_6 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_6
+#ifndef CONF_DMAC_SRCINC_6
+#define CONF_DMAC_SRCINC_6 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_6
+#ifndef CONF_DMAC_DSTINC_6
+#define CONF_DMAC_DSTINC_6 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_6
+#ifndef CONF_DMAC_TRANS_TYPE_6
+#define CONF_DMAC_TRANS_TYPE_6 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_6
+#ifndef CONF_DMAC_TRIGSRC_6
+#define CONF_DMAC_TRIGSRC_6 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_6 == 0
+#define CONF_DMAC_TYPE_6 0
+#define CONF_DMAC_DSYNC_6 0
+#elif CONF_DMAC_TRANS_TYPE_6 == 1
+#define CONF_DMAC_TYPE_6 1
+#define CONF_DMAC_DSYNC_6 0
+#elif CONF_DMAC_TRANS_TYPE_6 == 2
+#define CONF_DMAC_TYPE_6 1
+#define CONF_DMAC_DSYNC_6 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_6 == 0xFF
+#define CONF_DMAC_SWREQ_6 1
+#else
+#define CONF_DMAC_SWREQ_6 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_6_SETTINGS == 1 && CONF_DMAC_BEATSIZE_6 != 2 && ((!CONF_DMAC_SRCINC_6) || (!CONF_DMAC_DSTINC_6)))
+#if (!CONF_DMAC_SRCINC_6)
+#define CONF_DMAC_SRC_STRIDE_6 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_6)
+#define CONF_DMAC_DES_STRIDE_6 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_6
+#define CONF_DMAC_SRC_STRIDE_6 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_6
+#define CONF_DMAC_DES_STRIDE_6 0
+#endif
+
+// <e> Channel 7 settings
+// <id> dmac_channel_7_settings
+#ifndef CONF_DMAC_CHANNEL_7_SETTINGS
+#define CONF_DMAC_CHANNEL_7_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_7
+#ifndef CONF_DMAC_BURSTSIZE_7
+#define CONF_DMAC_BURSTSIZE_7 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_7
+#ifndef CONF_DMAC_CHUNKSIZE_7
+#define CONF_DMAC_CHUNKSIZE_7 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_7
+#ifndef CONF_DMAC_BEATSIZE_7
+#define CONF_DMAC_BEATSIZE_7 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_7
+#ifndef CONF_DMAC_SRC_INTERFACE_7
+#define CONF_DMAC_SRC_INTERFACE_7 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_7
+#ifndef CONF_DMAC_DES_INTERFACE_7
+#define CONF_DMAC_DES_INTERFACE_7 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_7
+#ifndef CONF_DMAC_SRCINC_7
+#define CONF_DMAC_SRCINC_7 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_7
+#ifndef CONF_DMAC_DSTINC_7
+#define CONF_DMAC_DSTINC_7 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_7
+#ifndef CONF_DMAC_TRANS_TYPE_7
+#define CONF_DMAC_TRANS_TYPE_7 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_7
+#ifndef CONF_DMAC_TRIGSRC_7
+#define CONF_DMAC_TRIGSRC_7 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_7 == 0
+#define CONF_DMAC_TYPE_7 0
+#define CONF_DMAC_DSYNC_7 0
+#elif CONF_DMAC_TRANS_TYPE_7 == 1
+#define CONF_DMAC_TYPE_7 1
+#define CONF_DMAC_DSYNC_7 0
+#elif CONF_DMAC_TRANS_TYPE_7 == 2
+#define CONF_DMAC_TYPE_7 1
+#define CONF_DMAC_DSYNC_7 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_7 == 0xFF
+#define CONF_DMAC_SWREQ_7 1
+#else
+#define CONF_DMAC_SWREQ_7 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_7_SETTINGS == 1 && CONF_DMAC_BEATSIZE_7 != 2 && ((!CONF_DMAC_SRCINC_7) || (!CONF_DMAC_DSTINC_7)))
+#if (!CONF_DMAC_SRCINC_7)
+#define CONF_DMAC_SRC_STRIDE_7 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_7)
+#define CONF_DMAC_DES_STRIDE_7 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_7
+#define CONF_DMAC_SRC_STRIDE_7 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_7
+#define CONF_DMAC_DES_STRIDE_7 0
+#endif
+
+// <e> Channel 8 settings
+// <id> dmac_channel_8_settings
+#ifndef CONF_DMAC_CHANNEL_8_SETTINGS
+#define CONF_DMAC_CHANNEL_8_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_8
+#ifndef CONF_DMAC_BURSTSIZE_8
+#define CONF_DMAC_BURSTSIZE_8 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_8
+#ifndef CONF_DMAC_CHUNKSIZE_8
+#define CONF_DMAC_CHUNKSIZE_8 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_8
+#ifndef CONF_DMAC_BEATSIZE_8
+#define CONF_DMAC_BEATSIZE_8 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_8
+#ifndef CONF_DMAC_SRC_INTERFACE_8
+#define CONF_DMAC_SRC_INTERFACE_8 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_8
+#ifndef CONF_DMAC_DES_INTERFACE_8
+#define CONF_DMAC_DES_INTERFACE_8 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_8
+#ifndef CONF_DMAC_SRCINC_8
+#define CONF_DMAC_SRCINC_8 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_8
+#ifndef CONF_DMAC_DSTINC_8
+#define CONF_DMAC_DSTINC_8 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_8
+#ifndef CONF_DMAC_TRANS_TYPE_8
+#define CONF_DMAC_TRANS_TYPE_8 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_8
+#ifndef CONF_DMAC_TRIGSRC_8
+#define CONF_DMAC_TRIGSRC_8 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_8 == 0
+#define CONF_DMAC_TYPE_8 0
+#define CONF_DMAC_DSYNC_8 0
+#elif CONF_DMAC_TRANS_TYPE_8 == 1
+#define CONF_DMAC_TYPE_8 1
+#define CONF_DMAC_DSYNC_8 0
+#elif CONF_DMAC_TRANS_TYPE_8 == 2
+#define CONF_DMAC_TYPE_8 1
+#define CONF_DMAC_DSYNC_8 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_8 == 0xFF
+#define CONF_DMAC_SWREQ_8 1
+#else
+#define CONF_DMAC_SWREQ_8 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_8_SETTINGS == 1 && CONF_DMAC_BEATSIZE_8 != 2 && ((!CONF_DMAC_SRCINC_8) || (!CONF_DMAC_DSTINC_8)))
+#if (!CONF_DMAC_SRCINC_8)
+#define CONF_DMAC_SRC_STRIDE_8 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_8)
+#define CONF_DMAC_DES_STRIDE_8 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_8
+#define CONF_DMAC_SRC_STRIDE_8 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_8
+#define CONF_DMAC_DES_STRIDE_8 0
+#endif
+
+// <e> Channel 9 settings
+// <id> dmac_channel_9_settings
+#ifndef CONF_DMAC_CHANNEL_9_SETTINGS
+#define CONF_DMAC_CHANNEL_9_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_9
+#ifndef CONF_DMAC_BURSTSIZE_9
+#define CONF_DMAC_BURSTSIZE_9 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_9
+#ifndef CONF_DMAC_CHUNKSIZE_9
+#define CONF_DMAC_CHUNKSIZE_9 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_9
+#ifndef CONF_DMAC_BEATSIZE_9
+#define CONF_DMAC_BEATSIZE_9 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_9
+#ifndef CONF_DMAC_SRC_INTERFACE_9
+#define CONF_DMAC_SRC_INTERFACE_9 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_9
+#ifndef CONF_DMAC_DES_INTERFACE_9
+#define CONF_DMAC_DES_INTERFACE_9 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_9
+#ifndef CONF_DMAC_SRCINC_9
+#define CONF_DMAC_SRCINC_9 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_9
+#ifndef CONF_DMAC_DSTINC_9
+#define CONF_DMAC_DSTINC_9 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_9
+#ifndef CONF_DMAC_TRANS_TYPE_9
+#define CONF_DMAC_TRANS_TYPE_9 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_9
+#ifndef CONF_DMAC_TRIGSRC_9
+#define CONF_DMAC_TRIGSRC_9 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_9 == 0
+#define CONF_DMAC_TYPE_9 0
+#define CONF_DMAC_DSYNC_9 0
+#elif CONF_DMAC_TRANS_TYPE_9 == 1
+#define CONF_DMAC_TYPE_9 1
+#define CONF_DMAC_DSYNC_9 0
+#elif CONF_DMAC_TRANS_TYPE_9 == 2
+#define CONF_DMAC_TYPE_9 1
+#define CONF_DMAC_DSYNC_9 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_9 == 0xFF
+#define CONF_DMAC_SWREQ_9 1
+#else
+#define CONF_DMAC_SWREQ_9 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_9_SETTINGS == 1 && CONF_DMAC_BEATSIZE_9 != 2 && ((!CONF_DMAC_SRCINC_9) || (!CONF_DMAC_DSTINC_9)))
+#if (!CONF_DMAC_SRCINC_9)
+#define CONF_DMAC_SRC_STRIDE_9 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_9)
+#define CONF_DMAC_DES_STRIDE_9 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_9
+#define CONF_DMAC_SRC_STRIDE_9 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_9
+#define CONF_DMAC_DES_STRIDE_9 0
+#endif
+
+// <e> Channel 10 settings
+// <id> dmac_channel_10_settings
+#ifndef CONF_DMAC_CHANNEL_10_SETTINGS
+#define CONF_DMAC_CHANNEL_10_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_10
+#ifndef CONF_DMAC_BURSTSIZE_10
+#define CONF_DMAC_BURSTSIZE_10 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_10
+#ifndef CONF_DMAC_CHUNKSIZE_10
+#define CONF_DMAC_CHUNKSIZE_10 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_10
+#ifndef CONF_DMAC_BEATSIZE_10
+#define CONF_DMAC_BEATSIZE_10 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_10
+#ifndef CONF_DMAC_SRC_INTERFACE_10
+#define CONF_DMAC_SRC_INTERFACE_10 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_10
+#ifndef CONF_DMAC_DES_INTERFACE_10
+#define CONF_DMAC_DES_INTERFACE_10 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_10
+#ifndef CONF_DMAC_SRCINC_10
+#define CONF_DMAC_SRCINC_10 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_10
+#ifndef CONF_DMAC_DSTINC_10
+#define CONF_DMAC_DSTINC_10 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_10
+#ifndef CONF_DMAC_TRANS_TYPE_10
+#define CONF_DMAC_TRANS_TYPE_10 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_10
+#ifndef CONF_DMAC_TRIGSRC_10
+#define CONF_DMAC_TRIGSRC_10 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_10 == 0
+#define CONF_DMAC_TYPE_10 0
+#define CONF_DMAC_DSYNC_10 0
+#elif CONF_DMAC_TRANS_TYPE_10 == 1
+#define CONF_DMAC_TYPE_10 1
+#define CONF_DMAC_DSYNC_10 0
+#elif CONF_DMAC_TRANS_TYPE_10 == 2
+#define CONF_DMAC_TYPE_10 1
+#define CONF_DMAC_DSYNC_10 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_10 == 0xFF
+#define CONF_DMAC_SWREQ_10 1
+#else
+#define CONF_DMAC_SWREQ_10 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_10_SETTINGS == 1 && CONF_DMAC_BEATSIZE_10 != 2 \
+ && ((!CONF_DMAC_SRCINC_10) || (!CONF_DMAC_DSTINC_10)))
+#if (!CONF_DMAC_SRCINC_10)
+#define CONF_DMAC_SRC_STRIDE_10 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_10)
+#define CONF_DMAC_DES_STRIDE_10 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_10
+#define CONF_DMAC_SRC_STRIDE_10 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_10
+#define CONF_DMAC_DES_STRIDE_10 0
+#endif
+
+// <e> Channel 11 settings
+// <id> dmac_channel_11_settings
+#ifndef CONF_DMAC_CHANNEL_11_SETTINGS
+#define CONF_DMAC_CHANNEL_11_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_11
+#ifndef CONF_DMAC_BURSTSIZE_11
+#define CONF_DMAC_BURSTSIZE_11 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_11
+#ifndef CONF_DMAC_CHUNKSIZE_11
+#define CONF_DMAC_CHUNKSIZE_11 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_11
+#ifndef CONF_DMAC_BEATSIZE_11
+#define CONF_DMAC_BEATSIZE_11 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_11
+#ifndef CONF_DMAC_SRC_INTERFACE_11
+#define CONF_DMAC_SRC_INTERFACE_11 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_11
+#ifndef CONF_DMAC_DES_INTERFACE_11
+#define CONF_DMAC_DES_INTERFACE_11 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_11
+#ifndef CONF_DMAC_SRCINC_11
+#define CONF_DMAC_SRCINC_11 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_11
+#ifndef CONF_DMAC_DSTINC_11
+#define CONF_DMAC_DSTINC_11 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_11
+#ifndef CONF_DMAC_TRANS_TYPE_11
+#define CONF_DMAC_TRANS_TYPE_11 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_11
+#ifndef CONF_DMAC_TRIGSRC_11
+#define CONF_DMAC_TRIGSRC_11 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_11 == 0
+#define CONF_DMAC_TYPE_11 0
+#define CONF_DMAC_DSYNC_11 0
+#elif CONF_DMAC_TRANS_TYPE_11 == 1
+#define CONF_DMAC_TYPE_11 1
+#define CONF_DMAC_DSYNC_11 0
+#elif CONF_DMAC_TRANS_TYPE_11 == 2
+#define CONF_DMAC_TYPE_11 1
+#define CONF_DMAC_DSYNC_11 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_11 == 0xFF
+#define CONF_DMAC_SWREQ_11 1
+#else
+#define CONF_DMAC_SWREQ_11 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_11_SETTINGS == 1 && CONF_DMAC_BEATSIZE_11 != 2 \
+ && ((!CONF_DMAC_SRCINC_11) || (!CONF_DMAC_DSTINC_11)))
+#if (!CONF_DMAC_SRCINC_11)
+#define CONF_DMAC_SRC_STRIDE_11 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_11)
+#define CONF_DMAC_DES_STRIDE_11 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_11
+#define CONF_DMAC_SRC_STRIDE_11 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_11
+#define CONF_DMAC_DES_STRIDE_11 0
+#endif
+
+// <e> Channel 12 settings
+// <id> dmac_channel_12_settings
+#ifndef CONF_DMAC_CHANNEL_12_SETTINGS
+#define CONF_DMAC_CHANNEL_12_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_12
+#ifndef CONF_DMAC_BURSTSIZE_12
+#define CONF_DMAC_BURSTSIZE_12 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_12
+#ifndef CONF_DMAC_CHUNKSIZE_12
+#define CONF_DMAC_CHUNKSIZE_12 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_12
+#ifndef CONF_DMAC_BEATSIZE_12
+#define CONF_DMAC_BEATSIZE_12 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_12
+#ifndef CONF_DMAC_SRC_INTERFACE_12
+#define CONF_DMAC_SRC_INTERFACE_12 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_12
+#ifndef CONF_DMAC_DES_INTERFACE_12
+#define CONF_DMAC_DES_INTERFACE_12 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_12
+#ifndef CONF_DMAC_SRCINC_12
+#define CONF_DMAC_SRCINC_12 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_12
+#ifndef CONF_DMAC_DSTINC_12
+#define CONF_DMAC_DSTINC_12 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_12
+#ifndef CONF_DMAC_TRANS_TYPE_12
+#define CONF_DMAC_TRANS_TYPE_12 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_12
+#ifndef CONF_DMAC_TRIGSRC_12
+#define CONF_DMAC_TRIGSRC_12 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_12 == 0
+#define CONF_DMAC_TYPE_12 0
+#define CONF_DMAC_DSYNC_12 0
+#elif CONF_DMAC_TRANS_TYPE_12 == 1
+#define CONF_DMAC_TYPE_12 1
+#define CONF_DMAC_DSYNC_12 0
+#elif CONF_DMAC_TRANS_TYPE_12 == 2
+#define CONF_DMAC_TYPE_12 1
+#define CONF_DMAC_DSYNC_12 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_12 == 0xFF
+#define CONF_DMAC_SWREQ_12 1
+#else
+#define CONF_DMAC_SWREQ_12 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_12_SETTINGS == 1 && CONF_DMAC_BEATSIZE_12 != 2 \
+ && ((!CONF_DMAC_SRCINC_12) || (!CONF_DMAC_DSTINC_12)))
+#if (!CONF_DMAC_SRCINC_12)
+#define CONF_DMAC_SRC_STRIDE_12 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_12)
+#define CONF_DMAC_DES_STRIDE_12 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_12
+#define CONF_DMAC_SRC_STRIDE_12 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_12
+#define CONF_DMAC_DES_STRIDE_12 0
+#endif
+
+// <e> Channel 13 settings
+// <id> dmac_channel_13_settings
+#ifndef CONF_DMAC_CHANNEL_13_SETTINGS
+#define CONF_DMAC_CHANNEL_13_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_13
+#ifndef CONF_DMAC_BURSTSIZE_13
+#define CONF_DMAC_BURSTSIZE_13 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_13
+#ifndef CONF_DMAC_CHUNKSIZE_13
+#define CONF_DMAC_CHUNKSIZE_13 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_13
+#ifndef CONF_DMAC_BEATSIZE_13
+#define CONF_DMAC_BEATSIZE_13 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_13
+#ifndef CONF_DMAC_SRC_INTERFACE_13
+#define CONF_DMAC_SRC_INTERFACE_13 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_13
+#ifndef CONF_DMAC_DES_INTERFACE_13
+#define CONF_DMAC_DES_INTERFACE_13 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_13
+#ifndef CONF_DMAC_SRCINC_13
+#define CONF_DMAC_SRCINC_13 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_13
+#ifndef CONF_DMAC_DSTINC_13
+#define CONF_DMAC_DSTINC_13 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_13
+#ifndef CONF_DMAC_TRANS_TYPE_13
+#define CONF_DMAC_TRANS_TYPE_13 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_13
+#ifndef CONF_DMAC_TRIGSRC_13
+#define CONF_DMAC_TRIGSRC_13 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_13 == 0
+#define CONF_DMAC_TYPE_13 0
+#define CONF_DMAC_DSYNC_13 0
+#elif CONF_DMAC_TRANS_TYPE_13 == 1
+#define CONF_DMAC_TYPE_13 1
+#define CONF_DMAC_DSYNC_13 0
+#elif CONF_DMAC_TRANS_TYPE_13 == 2
+#define CONF_DMAC_TYPE_13 1
+#define CONF_DMAC_DSYNC_13 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_13 == 0xFF
+#define CONF_DMAC_SWREQ_13 1
+#else
+#define CONF_DMAC_SWREQ_13 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_13_SETTINGS == 1 && CONF_DMAC_BEATSIZE_13 != 2 \
+ && ((!CONF_DMAC_SRCINC_13) || (!CONF_DMAC_DSTINC_13)))
+#if (!CONF_DMAC_SRCINC_13)
+#define CONF_DMAC_SRC_STRIDE_13 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_13)
+#define CONF_DMAC_DES_STRIDE_13 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_13
+#define CONF_DMAC_SRC_STRIDE_13 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_13
+#define CONF_DMAC_DES_STRIDE_13 0
+#endif
+
+// <e> Channel 14 settings
+// <id> dmac_channel_14_settings
+#ifndef CONF_DMAC_CHANNEL_14_SETTINGS
+#define CONF_DMAC_CHANNEL_14_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_14
+#ifndef CONF_DMAC_BURSTSIZE_14
+#define CONF_DMAC_BURSTSIZE_14 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_14
+#ifndef CONF_DMAC_CHUNKSIZE_14
+#define CONF_DMAC_CHUNKSIZE_14 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_14
+#ifndef CONF_DMAC_BEATSIZE_14
+#define CONF_DMAC_BEATSIZE_14 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_14
+#ifndef CONF_DMAC_SRC_INTERFACE_14
+#define CONF_DMAC_SRC_INTERFACE_14 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_14
+#ifndef CONF_DMAC_DES_INTERFACE_14
+#define CONF_DMAC_DES_INTERFACE_14 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_14
+#ifndef CONF_DMAC_SRCINC_14
+#define CONF_DMAC_SRCINC_14 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_14
+#ifndef CONF_DMAC_DSTINC_14
+#define CONF_DMAC_DSTINC_14 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_14
+#ifndef CONF_DMAC_TRANS_TYPE_14
+#define CONF_DMAC_TRANS_TYPE_14 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_14
+#ifndef CONF_DMAC_TRIGSRC_14
+#define CONF_DMAC_TRIGSRC_14 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_14 == 0
+#define CONF_DMAC_TYPE_14 0
+#define CONF_DMAC_DSYNC_14 0
+#elif CONF_DMAC_TRANS_TYPE_14 == 1
+#define CONF_DMAC_TYPE_14 1
+#define CONF_DMAC_DSYNC_14 0
+#elif CONF_DMAC_TRANS_TYPE_14 == 2
+#define CONF_DMAC_TYPE_14 1
+#define CONF_DMAC_DSYNC_14 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_14 == 0xFF
+#define CONF_DMAC_SWREQ_14 1
+#else
+#define CONF_DMAC_SWREQ_14 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_14_SETTINGS == 1 && CONF_DMAC_BEATSIZE_14 != 2 \
+ && ((!CONF_DMAC_SRCINC_14) || (!CONF_DMAC_DSTINC_14)))
+#if (!CONF_DMAC_SRCINC_14)
+#define CONF_DMAC_SRC_STRIDE_14 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_14)
+#define CONF_DMAC_DES_STRIDE_14 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_14
+#define CONF_DMAC_SRC_STRIDE_14 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_14
+#define CONF_DMAC_DES_STRIDE_14 0
+#endif
+
+// <e> Channel 15 settings
+// <id> dmac_channel_15_settings
+#ifndef CONF_DMAC_CHANNEL_15_SETTINGS
+#define CONF_DMAC_CHANNEL_15_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_15
+#ifndef CONF_DMAC_BURSTSIZE_15
+#define CONF_DMAC_BURSTSIZE_15 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_15
+#ifndef CONF_DMAC_CHUNKSIZE_15
+#define CONF_DMAC_CHUNKSIZE_15 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_15
+#ifndef CONF_DMAC_BEATSIZE_15
+#define CONF_DMAC_BEATSIZE_15 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_15
+#ifndef CONF_DMAC_SRC_INTERFACE_15
+#define CONF_DMAC_SRC_INTERFACE_15 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_15
+#ifndef CONF_DMAC_DES_INTERFACE_15
+#define CONF_DMAC_DES_INTERFACE_15 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_15
+#ifndef CONF_DMAC_SRCINC_15
+#define CONF_DMAC_SRCINC_15 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_15
+#ifndef CONF_DMAC_DSTINC_15
+#define CONF_DMAC_DSTINC_15 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_15
+#ifndef CONF_DMAC_TRANS_TYPE_15
+#define CONF_DMAC_TRANS_TYPE_15 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_15
+#ifndef CONF_DMAC_TRIGSRC_15
+#define CONF_DMAC_TRIGSRC_15 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_15 == 0
+#define CONF_DMAC_TYPE_15 0
+#define CONF_DMAC_DSYNC_15 0
+#elif CONF_DMAC_TRANS_TYPE_15 == 1
+#define CONF_DMAC_TYPE_15 1
+#define CONF_DMAC_DSYNC_15 0
+#elif CONF_DMAC_TRANS_TYPE_15 == 2
+#define CONF_DMAC_TYPE_15 1
+#define CONF_DMAC_DSYNC_15 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_15 == 0xFF
+#define CONF_DMAC_SWREQ_15 1
+#else
+#define CONF_DMAC_SWREQ_15 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_15_SETTINGS == 1 && CONF_DMAC_BEATSIZE_15 != 2 \
+ && ((!CONF_DMAC_SRCINC_15) || (!CONF_DMAC_DSTINC_15)))
+#if (!CONF_DMAC_SRCINC_15)
+#define CONF_DMAC_SRC_STRIDE_15 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_15)
+#define CONF_DMAC_DES_STRIDE_15 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_15
+#define CONF_DMAC_SRC_STRIDE_15 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_15
+#define CONF_DMAC_DES_STRIDE_15 0
+#endif
+
+// <e> Channel 16 settings
+// <id> dmac_channel_16_settings
+#ifndef CONF_DMAC_CHANNEL_16_SETTINGS
+#define CONF_DMAC_CHANNEL_16_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_16
+#ifndef CONF_DMAC_BURSTSIZE_16
+#define CONF_DMAC_BURSTSIZE_16 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_16
+#ifndef CONF_DMAC_CHUNKSIZE_16
+#define CONF_DMAC_CHUNKSIZE_16 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_16
+#ifndef CONF_DMAC_BEATSIZE_16
+#define CONF_DMAC_BEATSIZE_16 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_16
+#ifndef CONF_DMAC_SRC_INTERFACE_16
+#define CONF_DMAC_SRC_INTERFACE_16 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_16
+#ifndef CONF_DMAC_DES_INTERFACE_16
+#define CONF_DMAC_DES_INTERFACE_16 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_16
+#ifndef CONF_DMAC_SRCINC_16
+#define CONF_DMAC_SRCINC_16 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_16
+#ifndef CONF_DMAC_DSTINC_16
+#define CONF_DMAC_DSTINC_16 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_16
+#ifndef CONF_DMAC_TRANS_TYPE_16
+#define CONF_DMAC_TRANS_TYPE_16 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_16
+#ifndef CONF_DMAC_TRIGSRC_16
+#define CONF_DMAC_TRIGSRC_16 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_16 == 0
+#define CONF_DMAC_TYPE_16 0
+#define CONF_DMAC_DSYNC_16 0
+#elif CONF_DMAC_TRANS_TYPE_16 == 1
+#define CONF_DMAC_TYPE_16 1
+#define CONF_DMAC_DSYNC_16 0
+#elif CONF_DMAC_TRANS_TYPE_16 == 2
+#define CONF_DMAC_TYPE_16 1
+#define CONF_DMAC_DSYNC_16 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_16 == 0xFF
+#define CONF_DMAC_SWREQ_16 1
+#else
+#define CONF_DMAC_SWREQ_16 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_16_SETTINGS == 1 && CONF_DMAC_BEATSIZE_16 != 2 \
+ && ((!CONF_DMAC_SRCINC_16) || (!CONF_DMAC_DSTINC_16)))
+#if (!CONF_DMAC_SRCINC_16)
+#define CONF_DMAC_SRC_STRIDE_16 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_16)
+#define CONF_DMAC_DES_STRIDE_16 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_16
+#define CONF_DMAC_SRC_STRIDE_16 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_16
+#define CONF_DMAC_DES_STRIDE_16 0
+#endif
+
+// <e> Channel 17 settings
+// <id> dmac_channel_17_settings
+#ifndef CONF_DMAC_CHANNEL_17_SETTINGS
+#define CONF_DMAC_CHANNEL_17_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_17
+#ifndef CONF_DMAC_BURSTSIZE_17
+#define CONF_DMAC_BURSTSIZE_17 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_17
+#ifndef CONF_DMAC_CHUNKSIZE_17
+#define CONF_DMAC_CHUNKSIZE_17 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_17
+#ifndef CONF_DMAC_BEATSIZE_17
+#define CONF_DMAC_BEATSIZE_17 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_17
+#ifndef CONF_DMAC_SRC_INTERFACE_17
+#define CONF_DMAC_SRC_INTERFACE_17 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_17
+#ifndef CONF_DMAC_DES_INTERFACE_17
+#define CONF_DMAC_DES_INTERFACE_17 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_17
+#ifndef CONF_DMAC_SRCINC_17
+#define CONF_DMAC_SRCINC_17 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_17
+#ifndef CONF_DMAC_DSTINC_17
+#define CONF_DMAC_DSTINC_17 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_17
+#ifndef CONF_DMAC_TRANS_TYPE_17
+#define CONF_DMAC_TRANS_TYPE_17 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_17
+#ifndef CONF_DMAC_TRIGSRC_17
+#define CONF_DMAC_TRIGSRC_17 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_17 == 0
+#define CONF_DMAC_TYPE_17 0
+#define CONF_DMAC_DSYNC_17 0
+#elif CONF_DMAC_TRANS_TYPE_17 == 1
+#define CONF_DMAC_TYPE_17 1
+#define CONF_DMAC_DSYNC_17 0
+#elif CONF_DMAC_TRANS_TYPE_17 == 2
+#define CONF_DMAC_TYPE_17 1
+#define CONF_DMAC_DSYNC_17 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_17 == 0xFF
+#define CONF_DMAC_SWREQ_17 1
+#else
+#define CONF_DMAC_SWREQ_17 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_17_SETTINGS == 1 && CONF_DMAC_BEATSIZE_17 != 2 \
+ && ((!CONF_DMAC_SRCINC_17) || (!CONF_DMAC_DSTINC_17)))
+#if (!CONF_DMAC_SRCINC_17)
+#define CONF_DMAC_SRC_STRIDE_17 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_17)
+#define CONF_DMAC_DES_STRIDE_17 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_17
+#define CONF_DMAC_SRC_STRIDE_17 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_17
+#define CONF_DMAC_DES_STRIDE_17 0
+#endif
+
+// <e> Channel 18 settings
+// <id> dmac_channel_18_settings
+#ifndef CONF_DMAC_CHANNEL_18_SETTINGS
+#define CONF_DMAC_CHANNEL_18_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_18
+#ifndef CONF_DMAC_BURSTSIZE_18
+#define CONF_DMAC_BURSTSIZE_18 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_18
+#ifndef CONF_DMAC_CHUNKSIZE_18
+#define CONF_DMAC_CHUNKSIZE_18 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_18
+#ifndef CONF_DMAC_BEATSIZE_18
+#define CONF_DMAC_BEATSIZE_18 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_18
+#ifndef CONF_DMAC_SRC_INTERFACE_18
+#define CONF_DMAC_SRC_INTERFACE_18 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_18
+#ifndef CONF_DMAC_DES_INTERFACE_18
+#define CONF_DMAC_DES_INTERFACE_18 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_18
+#ifndef CONF_DMAC_SRCINC_18
+#define CONF_DMAC_SRCINC_18 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_18
+#ifndef CONF_DMAC_DSTINC_18
+#define CONF_DMAC_DSTINC_18 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_18
+#ifndef CONF_DMAC_TRANS_TYPE_18
+#define CONF_DMAC_TRANS_TYPE_18 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_18
+#ifndef CONF_DMAC_TRIGSRC_18
+#define CONF_DMAC_TRIGSRC_18 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_18 == 0
+#define CONF_DMAC_TYPE_18 0
+#define CONF_DMAC_DSYNC_18 0
+#elif CONF_DMAC_TRANS_TYPE_18 == 1
+#define CONF_DMAC_TYPE_18 1
+#define CONF_DMAC_DSYNC_18 0
+#elif CONF_DMAC_TRANS_TYPE_18 == 2
+#define CONF_DMAC_TYPE_18 1
+#define CONF_DMAC_DSYNC_18 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_18 == 0xFF
+#define CONF_DMAC_SWREQ_18 1
+#else
+#define CONF_DMAC_SWREQ_18 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_18_SETTINGS == 1 && CONF_DMAC_BEATSIZE_18 != 2 \
+ && ((!CONF_DMAC_SRCINC_18) || (!CONF_DMAC_DSTINC_18)))
+#if (!CONF_DMAC_SRCINC_18)
+#define CONF_DMAC_SRC_STRIDE_18 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_18)
+#define CONF_DMAC_DES_STRIDE_18 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_18
+#define CONF_DMAC_SRC_STRIDE_18 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_18
+#define CONF_DMAC_DES_STRIDE_18 0
+#endif
+
+// <e> Channel 19 settings
+// <id> dmac_channel_19_settings
+#ifndef CONF_DMAC_CHANNEL_19_SETTINGS
+#define CONF_DMAC_CHANNEL_19_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_19
+#ifndef CONF_DMAC_BURSTSIZE_19
+#define CONF_DMAC_BURSTSIZE_19 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_19
+#ifndef CONF_DMAC_CHUNKSIZE_19
+#define CONF_DMAC_CHUNKSIZE_19 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_19
+#ifndef CONF_DMAC_BEATSIZE_19
+#define CONF_DMAC_BEATSIZE_19 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_19
+#ifndef CONF_DMAC_SRC_INTERFACE_19
+#define CONF_DMAC_SRC_INTERFACE_19 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_19
+#ifndef CONF_DMAC_DES_INTERFACE_19
+#define CONF_DMAC_DES_INTERFACE_19 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_19
+#ifndef CONF_DMAC_SRCINC_19
+#define CONF_DMAC_SRCINC_19 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_19
+#ifndef CONF_DMAC_DSTINC_19
+#define CONF_DMAC_DSTINC_19 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_19
+#ifndef CONF_DMAC_TRANS_TYPE_19
+#define CONF_DMAC_TRANS_TYPE_19 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_19
+#ifndef CONF_DMAC_TRIGSRC_19
+#define CONF_DMAC_TRIGSRC_19 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_19 == 0
+#define CONF_DMAC_TYPE_19 0
+#define CONF_DMAC_DSYNC_19 0
+#elif CONF_DMAC_TRANS_TYPE_19 == 1
+#define CONF_DMAC_TYPE_19 1
+#define CONF_DMAC_DSYNC_19 0
+#elif CONF_DMAC_TRANS_TYPE_19 == 2
+#define CONF_DMAC_TYPE_19 1
+#define CONF_DMAC_DSYNC_19 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_19 == 0xFF
+#define CONF_DMAC_SWREQ_19 1
+#else
+#define CONF_DMAC_SWREQ_19 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_19_SETTINGS == 1 && CONF_DMAC_BEATSIZE_19 != 2 \
+ && ((!CONF_DMAC_SRCINC_19) || (!CONF_DMAC_DSTINC_19)))
+#if (!CONF_DMAC_SRCINC_19)
+#define CONF_DMAC_SRC_STRIDE_19 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_19)
+#define CONF_DMAC_DES_STRIDE_19 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_19
+#define CONF_DMAC_SRC_STRIDE_19 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_19
+#define CONF_DMAC_DES_STRIDE_19 0
+#endif
+
+// <e> Channel 20 settings
+// <id> dmac_channel_20_settings
+#ifndef CONF_DMAC_CHANNEL_20_SETTINGS
+#define CONF_DMAC_CHANNEL_20_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_20
+#ifndef CONF_DMAC_BURSTSIZE_20
+#define CONF_DMAC_BURSTSIZE_20 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_20
+#ifndef CONF_DMAC_CHUNKSIZE_20
+#define CONF_DMAC_CHUNKSIZE_20 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_20
+#ifndef CONF_DMAC_BEATSIZE_20
+#define CONF_DMAC_BEATSIZE_20 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_20
+#ifndef CONF_DMAC_SRC_INTERFACE_20
+#define CONF_DMAC_SRC_INTERFACE_20 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_20
+#ifndef CONF_DMAC_DES_INTERFACE_20
+#define CONF_DMAC_DES_INTERFACE_20 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_20
+#ifndef CONF_DMAC_SRCINC_20
+#define CONF_DMAC_SRCINC_20 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_20
+#ifndef CONF_DMAC_DSTINC_20
+#define CONF_DMAC_DSTINC_20 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_20
+#ifndef CONF_DMAC_TRANS_TYPE_20
+#define CONF_DMAC_TRANS_TYPE_20 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_20
+#ifndef CONF_DMAC_TRIGSRC_20
+#define CONF_DMAC_TRIGSRC_20 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_20 == 0
+#define CONF_DMAC_TYPE_20 0
+#define CONF_DMAC_DSYNC_20 0
+#elif CONF_DMAC_TRANS_TYPE_20 == 1
+#define CONF_DMAC_TYPE_20 1
+#define CONF_DMAC_DSYNC_20 0
+#elif CONF_DMAC_TRANS_TYPE_20 == 2
+#define CONF_DMAC_TYPE_20 1
+#define CONF_DMAC_DSYNC_20 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_20 == 0xFF
+#define CONF_DMAC_SWREQ_20 1
+#else
+#define CONF_DMAC_SWREQ_20 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_20_SETTINGS == 1 && CONF_DMAC_BEATSIZE_20 != 2 \
+ && ((!CONF_DMAC_SRCINC_20) || (!CONF_DMAC_DSTINC_20)))
+#if (!CONF_DMAC_SRCINC_20)
+#define CONF_DMAC_SRC_STRIDE_20 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_20)
+#define CONF_DMAC_DES_STRIDE_20 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_20
+#define CONF_DMAC_SRC_STRIDE_20 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_20
+#define CONF_DMAC_DES_STRIDE_20 0
+#endif
+
+// <e> Channel 21 settings
+// <id> dmac_channel_21_settings
+#ifndef CONF_DMAC_CHANNEL_21_SETTINGS
+#define CONF_DMAC_CHANNEL_21_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_21
+#ifndef CONF_DMAC_BURSTSIZE_21
+#define CONF_DMAC_BURSTSIZE_21 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_21
+#ifndef CONF_DMAC_CHUNKSIZE_21
+#define CONF_DMAC_CHUNKSIZE_21 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_21
+#ifndef CONF_DMAC_BEATSIZE_21
+#define CONF_DMAC_BEATSIZE_21 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_21
+#ifndef CONF_DMAC_SRC_INTERFACE_21
+#define CONF_DMAC_SRC_INTERFACE_21 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_21
+#ifndef CONF_DMAC_DES_INTERFACE_21
+#define CONF_DMAC_DES_INTERFACE_21 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_21
+#ifndef CONF_DMAC_SRCINC_21
+#define CONF_DMAC_SRCINC_21 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_21
+#ifndef CONF_DMAC_DSTINC_21
+#define CONF_DMAC_DSTINC_21 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_21
+#ifndef CONF_DMAC_TRANS_TYPE_21
+#define CONF_DMAC_TRANS_TYPE_21 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_21
+#ifndef CONF_DMAC_TRIGSRC_21
+#define CONF_DMAC_TRIGSRC_21 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_21 == 0
+#define CONF_DMAC_TYPE_21 0
+#define CONF_DMAC_DSYNC_21 0
+#elif CONF_DMAC_TRANS_TYPE_21 == 1
+#define CONF_DMAC_TYPE_21 1
+#define CONF_DMAC_DSYNC_21 0
+#elif CONF_DMAC_TRANS_TYPE_21 == 2
+#define CONF_DMAC_TYPE_21 1
+#define CONF_DMAC_DSYNC_21 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_21 == 0xFF
+#define CONF_DMAC_SWREQ_21 1
+#else
+#define CONF_DMAC_SWREQ_21 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_21_SETTINGS == 1 && CONF_DMAC_BEATSIZE_21 != 2 \
+ && ((!CONF_DMAC_SRCINC_21) || (!CONF_DMAC_DSTINC_21)))
+#if (!CONF_DMAC_SRCINC_21)
+#define CONF_DMAC_SRC_STRIDE_21 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_21)
+#define CONF_DMAC_DES_STRIDE_21 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_21
+#define CONF_DMAC_SRC_STRIDE_21 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_21
+#define CONF_DMAC_DES_STRIDE_21 0
+#endif
+
+// <e> Channel 22 settings
+// <id> dmac_channel_22_settings
+#ifndef CONF_DMAC_CHANNEL_22_SETTINGS
+#define CONF_DMAC_CHANNEL_22_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_22
+#ifndef CONF_DMAC_BURSTSIZE_22
+#define CONF_DMAC_BURSTSIZE_22 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_22
+#ifndef CONF_DMAC_CHUNKSIZE_22
+#define CONF_DMAC_CHUNKSIZE_22 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_22
+#ifndef CONF_DMAC_BEATSIZE_22
+#define CONF_DMAC_BEATSIZE_22 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_22
+#ifndef CONF_DMAC_SRC_INTERFACE_22
+#define CONF_DMAC_SRC_INTERFACE_22 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_22
+#ifndef CONF_DMAC_DES_INTERFACE_22
+#define CONF_DMAC_DES_INTERFACE_22 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_22
+#ifndef CONF_DMAC_SRCINC_22
+#define CONF_DMAC_SRCINC_22 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_22
+#ifndef CONF_DMAC_DSTINC_22
+#define CONF_DMAC_DSTINC_22 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_22
+#ifndef CONF_DMAC_TRANS_TYPE_22
+#define CONF_DMAC_TRANS_TYPE_22 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_22
+#ifndef CONF_DMAC_TRIGSRC_22
+#define CONF_DMAC_TRIGSRC_22 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_22 == 0
+#define CONF_DMAC_TYPE_22 0
+#define CONF_DMAC_DSYNC_22 0
+#elif CONF_DMAC_TRANS_TYPE_22 == 1
+#define CONF_DMAC_TYPE_22 1
+#define CONF_DMAC_DSYNC_22 0
+#elif CONF_DMAC_TRANS_TYPE_22 == 2
+#define CONF_DMAC_TYPE_22 1
+#define CONF_DMAC_DSYNC_22 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_22 == 0xFF
+#define CONF_DMAC_SWREQ_22 1
+#else
+#define CONF_DMAC_SWREQ_22 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_22_SETTINGS == 1 && CONF_DMAC_BEATSIZE_22 != 2 \
+ && ((!CONF_DMAC_SRCINC_22) || (!CONF_DMAC_DSTINC_22)))
+#if (!CONF_DMAC_SRCINC_22)
+#define CONF_DMAC_SRC_STRIDE_22 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_22)
+#define CONF_DMAC_DES_STRIDE_22 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_22
+#define CONF_DMAC_SRC_STRIDE_22 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_22
+#define CONF_DMAC_DES_STRIDE_22 0
+#endif
+
+// <e> Channel 23 settings
+// <id> dmac_channel_23_settings
+#ifndef CONF_DMAC_CHANNEL_23_SETTINGS
+#define CONF_DMAC_CHANNEL_23_SETTINGS 0
+#endif
+
+// <o> Burst Size
+// <0x0=> 1 burst size
+// <0x1=> 4 burst size
+// <0x2=> 8 burst size
+// <0x3=> 16 burst size
+// <i> Define the memory burst size
+// <id> dmac_burstsize_23
+#ifndef CONF_DMAC_BURSTSIZE_23
+#define CONF_DMAC_BURSTSIZE_23 0x0
+#endif
+
+// <o> Chunk Size
+// <0x0=> 1 data transferred
+// <0x1=> 2 data transferred
+// <0x2=> 4 data transferred
+// <0x3=> 8 data transferred
+// <0x4=> 16 data transferred
+// <i> Define the peripheral chunk size
+// <id> dmac_chunksize_23
+#ifndef CONF_DMAC_CHUNKSIZE_23
+#define CONF_DMAC_CHUNKSIZE_23 0x0
+#endif
+
+// <o> Beat Size
+// <0=> 8-bit bus transfer
+// <1=> 16-bit bus transfer
+// <2=> 32-bit bus transfer
+// <i> Defines the size of one beat
+// <id> dmac_beatsize_23
+#ifndef CONF_DMAC_BEATSIZE_23
+#define CONF_DMAC_BEATSIZE_23 0x0
+#endif
+
+// <o> Source Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is read through the system bus interface 0 or 1
+// <id> dma_src_interface_23
+#ifndef CONF_DMAC_SRC_INTERFACE_23
+#define CONF_DMAC_SRC_INTERFACE_23 0x0
+#endif
+
+// <o> Destination Interface Identifier
+// <0x0=> AHB_IF0
+// <0x1=> AHB_IF1
+// <i> Define the data is written through the system bus interface 0 or 1
+// <id> dma_des_interface_23
+#ifndef CONF_DMAC_DES_INTERFACE_23
+#define CONF_DMAC_DES_INTERFACE_23 0x0
+#endif
+
+// <q> Source Address Increment
+// <i> Indicates whether the source address incremented as beat size or not
+// <id> dmac_srcinc_23
+#ifndef CONF_DMAC_SRCINC_23
+#define CONF_DMAC_SRCINC_23 0
+#endif
+
+// <q> Destination Address Increment
+// <i> Indicates whether the destination address incremented as beat size or not
+// <id> dmac_dstinc_23
+#ifndef CONF_DMAC_DSTINC_23
+#define CONF_DMAC_DSTINC_23 0
+#endif
+
+// <o> Transfer Type
+// <0x0=> Memory to Memory Transfer
+// <0x1=> Peripheral to Memory Transfer
+// <0x2=> Memory to Peripheral Transfer
+// <i> Define the data transfer type
+// <id> dma_trans_type_23
+#ifndef CONF_DMAC_TRANS_TYPE_23
+#define CONF_DMAC_TRANS_TYPE_23 0x0
+#endif
+
+// <o> Trigger source
+// <0xFF=> Software Trigger
+// <0x00=> HSMCI TX/RX Trigger
+// <0x01=> SPI0 TX Trigger
+// <0x02=> SPI0 RX Trigger
+// <0x03=> SPI1 TX Trigger
+// <0x04=> SPI1 RX Trigger
+// <0x05=> QSPI TX Trigger
+// <0x06=> QSPI RX Trigger
+// <0x07=> USART0 TX Trigger
+// <0x08=> USART0 RX Trigger
+// <0x09=> USART1 TX Trigger
+// <0x0A=> USART1 RX Trigger
+// <0x0B=> USART2 TX Trigger
+// <0x0C=> USART2 RX Trigger
+// <0x0D=> PWM0 TX Trigger
+// <0x0E=> TWIHS0 TX Trigger
+// <0x0F=> TWIHS0 RX Trigger
+// <0x10=> TWIHS1 TX Trigger
+// <0x11=> TWIHS1 RX Trigger
+// <0x12=> TWIHS2 TX Trigger
+// <0x13=> TWIHS2 RX Trigger
+// <0x14=> UART0 TX Trigger
+// <0x15=> UART0 RX Trigger
+// <0x16=> UART1 TX Trigger
+// <0x17=> UART1 RX Trigger
+// <0x18=> UART2 TX Trigger
+// <0x19=> UART2 RX Trigger
+// <0x1A=> UART3 TX Trigger
+// <0x1B=> UART3 RX Trigger
+// <0x1C=> UART4 TX Trigger
+// <0x1D=> UART4 RX Trigger
+// <0x1E=> DACC TX Trigger
+// <0x20=> SSC TX Trigger
+// <0x21=> SSC RX Trigger
+// <0x22=> PIOA RX Trigger
+// <0x23=> AFEC0 RX Trigger
+// <0x24=> AFEC1 RX Trigger
+// <0x25=> AES TX Trigger
+// <0x26=> AES RX Trigger
+// <0x27=> PWM1 TX Trigger
+// <0x28=> TC0 RX Trigger
+// <0x29=> TC3 RX Trigger
+// <0x2A=> TC6 RX Trigger
+// <0x2B=> TC9 RX Trigger
+// <0x2C=> I2SC0 TX Left Trigger
+// <0x2D=> I2SC0 RX Left Trigger
+// <0x2E=> I2SC1 TX Left Trigger
+// <0x2F=> I2SC1 RX Left Trigger
+// <0x30=> I2SC0 TX Right Trigger
+// <0x31=> I2SC0 RX Right Trigger
+// <0x32=> I2SC1 TX Right Trigger
+// <0x33=> I2SC1 RX Right Trigger
+// <i> Define the DMA trigger source
+// <id> dmac_trifsrc_23
+#ifndef CONF_DMAC_TRIGSRC_23
+#define CONF_DMAC_TRIGSRC_23 0xff
+#endif
+
+// </e>
+
+#if CONF_DMAC_TRANS_TYPE_23 == 0
+#define CONF_DMAC_TYPE_23 0
+#define CONF_DMAC_DSYNC_23 0
+#elif CONF_DMAC_TRANS_TYPE_23 == 1
+#define CONF_DMAC_TYPE_23 1
+#define CONF_DMAC_DSYNC_23 0
+#elif CONF_DMAC_TRANS_TYPE_23 == 2
+#define CONF_DMAC_TYPE_23 1
+#define CONF_DMAC_DSYNC_23 1
+#endif
+
+#if CONF_DMAC_TRIGSRC_23 == 0xFF
+#define CONF_DMAC_SWREQ_23 1
+#else
+#define CONF_DMAC_SWREQ_23 0
+#endif
+
+/* Errata: If XDMA is used to transfer 8-bit or 16-bit data in fixed source address
+ * or fixed destination address mode, source and destination addresses are incremented
+ * by 8-bit or 16-bit.
+ * Workaround: The user can fix the problem by setting the source addressing mode to
+ * use microblock and data striding with microblock stride set to 0 and data stride set to -1.
+ */
+#if (CONF_DMAC_CHANNEL_23_SETTINGS == 1 && CONF_DMAC_BEATSIZE_23 != 2 \
+ && ((!CONF_DMAC_SRCINC_23) || (!CONF_DMAC_DSTINC_23)))
+#if (!CONF_DMAC_SRCINC_23)
+#define CONF_DMAC_SRC_STRIDE_23 ((int16_t)(-1))
+#endif
+#if (!CONF_DMAC_DSTINC_23)
+#define CONF_DMAC_DES_STRIDE_23 ((int16_t)(-1))
+#endif
+#endif
+
+#ifndef CONF_DMAC_SRC_STRIDE_23
+#define CONF_DMAC_SRC_STRIDE_23 0
+#endif
+
+#ifndef CONF_DMAC_DES_STRIDE_23
+#define CONF_DMAC_DES_STRIDE_23 0
+#endif
+
+// </e>
+
+// <<< end of configuration section >>>
+
+#endif // HPL_XDMAC_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/peripheral_clk_config.h b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/peripheral_clk_config.h
new file mode 100644
index 0000000..84756f5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/peripheral_clk_config.h
@@ -0,0 +1,126 @@
+/* Auto-generated config file peripheral_clk_config.h */
+#ifndef PERIPHERAL_CLK_CONFIG_H
+#define PERIPHERAL_CLK_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+/**
+ * \def CONF_HCLK_FREQUENCY
+ * \brief HCLK's Clock frequency
+ */
+#ifndef CONF_HCLK_FREQUENCY
+#define CONF_HCLK_FREQUENCY 300000000
+#endif
+
+/**
+ * \def CONF_FCLK_FREQUENCY
+ * \brief FCLK's Clock frequency
+ */
+#ifndef CONF_FCLK_FREQUENCY
+#define CONF_FCLK_FREQUENCY 300000000
+#endif
+
+/**
+ * \def CONF_CPU_FREQUENCY
+ * \brief CPU's Clock frequency
+ */
+#ifndef CONF_CPU_FREQUENCY
+#define CONF_CPU_FREQUENCY 300000000
+#endif
+
+/**
+ * \def CONF_SLCK_FREQUENCY
+ * \brief Slow Clock frequency
+ */
+#define CONF_SLCK_FREQUENCY 0
+
+/**
+ * \def CONF_MCK_FREQUENCY
+ * \brief Master Clock frequency
+ */
+#define CONF_MCK_FREQUENCY 150000000
+
+/**
+ * \def CONF_PCK6_FREQUENCY
+ * \brief Programmable Clock Controller 6 frequency
+ */
+#define CONF_PCK6_FREQUENCY 1714285
+
+// <h> USART Clock Settings
+// <o> USART Clock source
+
+// <0=> Master Clock (MCK)
+// <1=> MCK / 8 for USART
+// <2=> Programmable Clock Controller 4 (PMC_PCK4)
+// <3=> External Clock
+// <i> This defines the clock source for the USART
+// <id> usart_clock_source
+#ifndef CONF_USART1_CK_SRC
+#define CONF_USART1_CK_SRC 0
+#endif
+
+// <o> USART External Clock Input on SCK <1-4294967295>
+// <i> Inputs the external clock frequency on SCK
+// <id> usart_clock_freq
+#ifndef CONF_USART1_SCK_FREQ
+#define CONF_USART1_SCK_FREQ 10000000
+#endif
+
+// </h>
+
+/**
+ * \def USART FREQUENCY
+ * \brief USART's Clock frequency
+ */
+#ifndef CONF_USART1_FREQUENCY
+#define CONF_USART1_FREQUENCY 150000000
+#endif
+
+#ifndef CONF_SRC_USB_480M
+#define CONF_SRC_USB_480M 0
+#endif
+
+#ifndef CONF_SRC_USB_48M
+#define CONF_SRC_USB_48M 1
+#endif
+
+// <y> USB Full/Low Speed Clock
+// <CONF_SRC_USB_48M"> USB Clock Controller (USB_48M)
+// <id> usb_fsls_clock_source
+// <i> 48MHz clock source for low speed and full speed.
+// <i> It must be available when low speed is supported by host driver.
+// <i> It must be available when low power mode is selected.
+#ifndef CONF_USBHS_FSLS_SRC
+#define CONF_USBHS_FSLS_SRC CONF_SRC_USB_48M
+#endif
+
+// <y> USB Clock Source(Normal/Low-power Mode Selection)
+// <CONF_SRC_USB_480M"> USB High Speed Clock (USB_480M)
+// <CONF_SRC_USB_48M"> USB Clock Controller (USB_48M)
+// <id> usb_clock_source
+// <i> Select the clock source for USB.
+// <i> In normal mode, use "USB High Speed Clock (USB_480M)".
+// <i> In low-power mode, use "USB Clock Controller (USB_48M)".
+#ifndef CONF_USBHS_SRC
+#define CONF_USBHS_SRC CONF_SRC_USB_480M
+#endif
+
+/**
+ * \def CONF_USBHS_FSLS_FREQUENCY
+ * \brief USBHS's Full/Low Speed Clock Source frequency
+ */
+#ifndef CONF_USBHS_FSLS_FREQUENCY
+#define CONF_USBHS_FSLS_FREQUENCY 48000000
+#endif
+
+/**
+ * \def CONF_USBHS_FREQUENCY
+ * \brief USBHS's Selected Clock Source frequency
+ */
+#ifndef CONF_USBHS_FREQUENCY
+#define CONF_USBHS_FREQUENCY 480000000
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // PERIPHERAL_CLK_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/same70_xplained.c b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/same70_xplained.c
new file mode 100644
index 0000000..e6e7db0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/same70_xplained/same70_xplained.c
@@ -0,0 +1,156 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+
+#include "peripheral_clk_config.h"
+#include "hpl/usart/hpl_usart_base.h"
+#include "hpl/pmc/hpl_pmc.h"
+#include "hal/include/hal_init.h"
+#include "hal/include/hal_usart_async.h"
+#include "hal/include/hal_gpio.h"
+
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+#define LED_PIN GPIO(GPIO_PORTC, 8)
+
+#define BUTTON_PIN GPIO(GPIO_PORTA, 11)
+#define BUTTON_STATE_ACTIVE 0
+
+#define UART_TX_PIN GPIO(GPIO_PORTB, 4)
+#define UART_RX_PIN GPIO(GPIO_PORTA, 21)
+
+static struct usart_async_descriptor edbg_com;
+static uint8_t edbg_com_buffer[64];
+static volatile bool uart_busy = false;
+
+static void tx_cb_EDBG_COM(const struct usart_async_descriptor *const io_descr)
+{
+ (void) io_descr;
+ uart_busy = false;
+}
+
+//------------- IMPLEMENTATION -------------//
+void board_init(void)
+{
+ init_mcu();
+
+ /* Disable Watchdog */
+ hri_wdt_set_MR_WDDIS_bit(WDT);
+
+ // LED
+ _pmc_enable_periph_clock(ID_PIOC);
+ gpio_set_pin_level(LED_PIN, false);
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
+
+ // Button
+ _pmc_enable_periph_clock(ID_PIOA);
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+ gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
+
+ // Uart via EDBG Com
+ _pmc_enable_periph_clock(ID_USART1);
+ gpio_set_pin_function(UART_RX_PIN, MUX_PA21A_USART1_RXD1);
+ gpio_set_pin_function(UART_TX_PIN, MUX_PB4D_USART1_TXD1);
+
+ usart_async_init(&edbg_com, USART1, edbg_com_buffer, sizeof(edbg_com_buffer), _usart_get_usart_async());
+ usart_async_set_baud_rate(&edbg_com, CFG_BOARD_UART_BAUDRATE);
+ usart_async_register_callback(&edbg_com, USART_ASYNC_TXC_CB, tx_cb_EDBG_COM);
+ usart_async_enable(&edbg_com);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer (samd SystemCoreClock may not correct)
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ // Enable USB clock
+ _pmc_enable_periph_clock(ID_USBHS);
+
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USBHS_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ // while until previous transfer is complete
+ while(uart_busy) {}
+ uart_busy = true;
+
+ io_write(&edbg_com.io, buf, len);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/board.mk b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/board.mk
new file mode 100644
index 0000000..deff694
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/board.mk
@@ -0,0 +1,52 @@
+DEPS_SUBMODULES += hw/mcu/microchip
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -D__SAMG55J19__ \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMG
+
+# suppress following warnings from mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=cast-qual -Wno-error=null-dereference
+
+ASF_DIR = hw/mcu/microchip/samg55
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/samg55j19_flash.ld
+
+SRC_C += \
+ src/portable/microchip/samg/dcd_samg.c \
+ $(ASF_DIR)/samg55/gcc/gcc/startup_samg55.c \
+ $(ASF_DIR)/samg55/gcc/system_samg55.c \
+ $(ASF_DIR)/hpl/core/hpl_init.c \
+ $(ASF_DIR)/hpl/usart/hpl_usart.c \
+ $(ASF_DIR)/hpl/pmc/hpl_pmc.c \
+ $(ASF_DIR)/hal/src/hal_atomic.c
+
+INC += \
+ $(TOP)/hw/bsp/$(BOARD) \
+ $(TOP)/$(ASF_DIR) \
+ $(TOP)/$(ASF_DIR)/config \
+ $(TOP)/$(ASF_DIR)/samg55/include \
+ $(TOP)/$(ASF_DIR)/hal/include \
+ $(TOP)/$(ASF_DIR)/hal/utils/include \
+ $(TOP)/$(ASF_DIR)/hpl/core \
+ $(TOP)/$(ASF_DIR)/hpl/pio \
+ $(TOP)/$(ASF_DIR)/hpl/pmc \
+ $(TOP)/$(ASF_DIR)/hri \
+ $(TOP)/$(ASF_DIR)/CMSIS/Core/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMG55J19
+
+# flash using edbg from https://github.com/ataradov/edbg
+flash: $(BUILD)/$(PROJECT).bin
+ edbg --verbose -t samg55 -pv -f $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/hpl_usart_config.h b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/hpl_usart_config.h
new file mode 100644
index 0000000..4f2837d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/hpl_usart_config.h
@@ -0,0 +1,215 @@
+/* Auto-generated config file hpl_usart_config.h */
+#ifndef HPL_USART_CONFIG_H
+#define HPL_USART_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include <peripheral_clk_config.h>
+
+#ifndef CONF_USART_7_ENABLE
+#define CONF_USART_7_ENABLE 1
+#endif
+
+// <h> Basic Configuration
+
+// <o> Frame parity
+// <0x0=>Even parity
+// <0x1=>Odd parity
+// <0x2=>Parity forced to 0
+// <0x3=>Parity forced to 1
+// <0x4=>No parity
+// <i> Parity bit mode for USART frame
+// <id> usart_parity
+#ifndef CONF_USART_7_PARITY
+#define CONF_USART_7_PARITY 0x4
+#endif
+
+// <o> Character Size
+// <0x0=>5 bits
+// <0x1=>6 bits
+// <0x2=>7 bits
+// <0x3=>8 bits
+// <i> Data character size in USART frame
+// <id> usart_character_size
+#ifndef CONF_USART_7_CHSIZE
+#define CONF_USART_7_CHSIZE 0x3
+#endif
+
+// <o> Stop Bit
+// <0=>1 stop bit
+// <1=>1.5 stop bits
+// <2=>2 stop bits
+// <i> Number of stop bits in USART frame
+// <id> usart_stop_bit
+#ifndef CONF_USART_7_SBMODE
+#define CONF_USART_7_SBMODE 0
+#endif
+
+// <o> Clock Output Select
+// <0=>The USART does not drive the SCK pin
+// <1=>The USART drives the SCK pin if USCLKS does not select the external clock SCK
+// <i> Clock Output Select in USART sck, if in usrt master mode, please drive SCK.
+// <id> usart_clock_output_select
+#ifndef CONF_USART_7_CLKO
+#define CONF_USART_7_CLKO 0
+#endif
+
+// <o> Baud rate <1-3000000>
+// <i> USART baud rate setting
+// <id> usart_baud_rate
+#ifndef CONF_USART_7_BAUD
+#define CONF_USART_7_BAUD 9600
+#endif
+
+// </h>
+
+// <e> Advanced configuration
+// <id> usart_advanced
+#ifndef CONF_USART_7_ADVANCED_CONFIG
+#define CONF_USART_7_ADVANCED_CONFIG 0
+#endif
+
+// <o> Channel Mode
+// <0=>Normal Mode
+// <1=>Automatic Echo
+// <2=>Local Loopback
+// <3=>Remote Loopback
+// <i> Channel mode in USART frame
+// <id> usart_channel_mode
+#ifndef CONF_USART_7_CHMODE
+#define CONF_USART_7_CHMODE 0
+#endif
+
+// <q> 9 bits character enable
+// <i> Enable 9 bits character, this has high priority than 5/6/7/8 bits.
+// <id> usart_9bits_enable
+#ifndef CONF_USART_7_MODE9
+#define CONF_USART_7_MODE9 0
+#endif
+
+// <o> Variable Sync
+// <0=>User defined configuration
+// <1=>sync field is updated when a character is written into US_THR
+// <i> Variable Synchronization of Command/Data Sync Start Frarm Delimiter
+// <id> variable_sync
+#ifndef CONF_USART_7_VAR_SYNC
+#define CONF_USART_7_VAR_SYNC 0
+#endif
+
+// <o> Oversampling Mode
+// <0=>16 Oversampling
+// <1=>8 Oversampling
+// <i> Oversampling Mode in UART mode
+// <id> usart__oversampling_mode
+#ifndef CONF_USART_7_OVER
+#define CONF_USART_7_OVER 0
+#endif
+
+// <o> Inhibit Non Ack
+// <0=>The NACK is generated
+// <1=>The NACK is not generated
+// <i> Inhibit Non Acknowledge
+// <id> usart__inack
+#ifndef CONF_USART_7_INACK
+#define CONF_USART_7_INACK 1
+#endif
+
+// <o> Disable Successive NACK
+// <0=>NACK is sent on the ISO line as soon as a parity error occurs
+// <1=>Many parity errors generate a NACK on the ISO line
+// <i> Disable Successive NACK
+// <id> usart_dsnack
+#ifndef CONF_USART_7_DSNACK
+#define CONF_USART_7_DSNACK 0
+#endif
+
+// <o> Inverted Data
+// <0=>Data isn't inverted, nomal mode
+// <1=>Data is inverted
+// <i> Inverted Data
+// <id> usart_invdata
+#ifndef CONF_USART_7_INVDATA
+#define CONF_USART_7_INVDATA 0
+#endif
+
+// <o> Maximum Number of Automatic Iteration <0-7>
+// <i> Defines the maximum number of iterations in mode ISO7816, protocol T = 0.
+// <id> usart_max_iteration
+#ifndef CONF_USART_7_MAX_ITERATION
+#define CONF_USART_7_MAX_ITERATION 0
+#endif
+
+// <q> Receive Line Filter enable
+// <i> whether the USART filters the receive line using a three-sample filter
+// <id> usart_receive_filter_enable
+#ifndef CONF_USART_7_FILTER
+#define CONF_USART_7_FILTER 0
+#endif
+
+// <q> Manchester Encoder/Decoder Enable
+// <i> whether the USART Manchester Encoder/Decoder
+// <id> usart_manchester_filter_enable
+#ifndef CONF_USART_7_MAN
+#define CONF_USART_7_MAN 0
+#endif
+
+// <o> Manchester Synchronization Mode
+// <0=>The Manchester start bit is a 0 to 1 transition
+// <1=>The Manchester start bit is a 1 to 0 transition
+// <i> Manchester Synchronization Mode
+// <id> usart_manchester_synchronization_mode
+#ifndef CONF_USART_7_MODSYNC
+#define CONF_USART_7_MODSYNC 0
+#endif
+
+// <o> Start Frame Delimiter Selector
+// <0=>Start frame delimiter is COMMAND or DATA SYNC
+// <1=>Start frame delimiter is one bit
+// <i> Start Frame Delimiter Selector
+// <id> usart_start_frame_delimiter
+#ifndef CONF_USART_7_ONEBIT
+#define CONF_USART_7_ONEBIT 0
+#endif
+
+// <o> Fractional Part <0-7>
+// <i> Fractional part of the baud rate if baud rate generator is in fractional mode
+// <id> usart_arch_fractional
+#ifndef CONF_USART_7_FRACTIONAL
+#define CONF_USART_7_FRACTIONAL 0x0
+#endif
+
+// <o> Data Order
+// <0=>LSB is transmitted first
+// <1=>MSB is transmitted first
+// <i> Data order of the data bits in the frame
+// <id> usart_arch_msbf
+#ifndef CONF_USART_7_MSBF
+#define CONF_USART_7_MSBF 0
+#endif
+
+// </e>
+
+#define CONF_USART_7_MODE 0x0
+
+// Calculate BAUD register value in UART mode
+#if CONF_FLEXCOM7_CK_SRC < 3
+#ifndef CONF_USART_7_BAUD_CD
+#define CONF_USART_7_BAUD_CD ((CONF_FLEXCOM7_FREQUENCY) / CONF_USART_7_BAUD / 8 / (2 - CONF_USART_7_OVER))
+#endif
+#ifndef CONF_USART_7_BAUD_FP
+#define CONF_USART_7_BAUD_FP \
+ ((CONF_FLEXCOM7_FREQUENCY) / CONF_USART_7_BAUD / (2 - CONF_USART_7_OVER) - 8 * CONF_USART_7_BAUD_CD)
+#endif
+#elif CONF_FLEXCOM7_CK_SRC == 3
+// No division is active. The value written in US_BRGR has no effect.
+#ifndef CONF_USART_7_BAUD_CD
+#define CONF_USART_7_BAUD_CD 1
+#endif
+#ifndef CONF_USART_7_BAUD_FP
+#define CONF_USART_7_BAUD_FP 1
+#endif
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // HPL_USART_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/peripheral_clk_config.h b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/peripheral_clk_config.h
new file mode 100644
index 0000000..6d390f3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/peripheral_clk_config.h
@@ -0,0 +1,85 @@
+/* Auto-generated config file peripheral_clk_config.h */
+#ifndef PERIPHERAL_CLK_CONFIG_H
+#define PERIPHERAL_CLK_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+/**
+ * \def CONF_HCLK_FREQUENCY
+ * \brief HCLK's Clock frequency
+ */
+#ifndef CONF_HCLK_FREQUENCY
+#define CONF_HCLK_FREQUENCY 8000000
+#endif
+
+/**
+ * \def CONF_FCLK_FREQUENCY
+ * \brief FCLK's Clock frequency
+ */
+#ifndef CONF_FCLK_FREQUENCY
+#define CONF_FCLK_FREQUENCY 8000000
+#endif
+
+/**
+ * \def CONF_CPU_FREQUENCY
+ * \brief CPU's Clock frequency
+ */
+#ifndef CONF_CPU_FREQUENCY
+#define CONF_CPU_FREQUENCY 8000000
+#endif
+
+/**
+ * \def CONF_SLCK_FREQUENCY
+ * \brief Slow Clock frequency
+ */
+#define CONF_SLCK_FREQUENCY 32768
+
+/**
+ * \def CONF_MCK_FREQUENCY
+ * \brief Master Clock frequency
+ */
+#define CONF_MCK_FREQUENCY 8000000
+
+// <o> USB Clock Source
+// <0=> USB Clock Controller (USB_48M)
+// <id> usb_clock_source
+// <i> Select the clock source for USB.
+#ifndef CONF_UDP_SRC
+#define CONF_UDP_SRC 0
+#endif
+
+/**
+ * \def CONF_UDP_FREQUENCY
+ * \brief UDP's Clock frequency
+ */
+#ifndef CONF_UDP_FREQUENCY
+#define CONF_UDP_FREQUENCY 48005120
+#endif
+
+// <h> FLEXCOM Clock Settings
+// <o> FLEXCOM Clock source
+// <0=> Master Clock (MCK)
+// <1=> MCK / 8
+// <2=> Programmable Clock Controller 6 (PMC_PCK6)
+// <2=> Programmable Clock Controller 7 (PMC_PCK7)
+// <3=> External Clock
+// <i> This defines the clock source for the FLEXCOM, PCK6 is used for FLEXCOM0/1/2/3 and PCK7 is used for FLEXCOM4/5/6/7
+// <id> flexcom_clock_source
+#ifndef CONF_FLEXCOM7_CK_SRC
+#define CONF_FLEXCOM7_CK_SRC 0
+#endif
+
+// <o> FLEXCOM External Clock Input on SCK <1-4294967295>
+// <i> Inputs the external clock frequency on SCK
+// <id> flexcom_clock_freq
+#ifndef CONF_FLEXCOM7_SCK_FREQ
+#define CONF_FLEXCOM7_SCK_FREQ 10000000
+#endif
+
+#ifndef CONF_FLEXCOM7_FREQUENCY
+#define CONF_FLEXCOM7_FREQUENCY 8000000
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // PERIPHERAL_CLK_CONFIG_H
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55j19_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55j19_flash.ld
new file mode 100644
index 0000000..21c0b5b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55j19_flash.ld
@@ -0,0 +1,158 @@
+/**
+ * \file
+ *
+ * \brief GCC linker script (flash) for ATSAMG55J19
+ *
+ * Copyright (c) 2017 Atmel Corporation, a wholly owned subsidiary of Microchip Technology Inc.
+ *
+ * \license_start
+ *
+ * \page License
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \license_stop
+ *
+ */
+
+/*------------------------------------------------------------------------------
+ * Linker script for running in internal FLASH on the ATSAMG55J19
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00400000, LENGTH = 0x00080000 /* rom, 524288K */
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000 /* ram, 163840K */
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
+
+/* The heapsize used by the application. NOTE: you need to adjust according to your application. */
+HEAP_SIZE = DEFINED(HEAP_SIZE) ? HEAP_SIZE : DEFINED(__heap_size__) ? __heap_size__ : 0x0200;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* heap section */
+ .heap (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sheap = .;
+ . = . + HEAP_SIZE;
+ . = ALIGN(8);
+ _eheap = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+ _ram_end_ = ORIGIN(ram) + LENGTH(ram) - 1 ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55xplained.c b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55xplained.c
new file mode 100644
index 0000000..ed106b0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/samg55xplained/samg55xplained.c
@@ -0,0 +1,157 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, hathach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+
+#include "peripheral_clk_config.h"
+#include "hal/include/hal_init.h"
+#include "hal/include/hpl_usart_sync.h"
+#include "hpl/pmc/hpl_pmc.h"
+#include "hal/include/hal_gpio.h"
+
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+#define LED_PIN GPIO(GPIO_PORTA, 6)
+
+#define BUTTON_PIN GPIO(GPIO_PORTA, 2)
+#define BUTTON_STATE_ACTIVE 0
+
+#define UART_TX_PIN GPIO(GPIO_PORTA, 28)
+#define UART_RX_PIN GPIO(GPIO_PORTA, 27)
+
+struct _usart_sync_device edbg_com;
+
+//------------- IMPLEMENTATION -------------//
+void board_init(void)
+{
+ init_mcu();
+
+ _pmc_enable_periph_clock(ID_PIOA);
+
+ /* Disable Watchdog */
+ hri_wdt_set_MR_WDDIS_bit(WDT);
+
+ // LED
+ gpio_set_pin_level(LED_PIN, false);
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
+
+ // Button
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+ gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
+
+ // Uart via EDBG Com
+ _pmc_enable_periph_clock(ID_FLEXCOM7);
+ gpio_set_pin_function(UART_RX_PIN, MUX_PA27B_FLEXCOM7_RXD);
+ gpio_set_pin_function(UART_TX_PIN, MUX_PA28B_FLEXCOM7_TXD);
+
+ _usart_sync_init(&edbg_com, FLEXCOM7);
+ _usart_sync_set_baud_rate(&edbg_com, CFG_BOARD_UART_BAUDRATE);
+ _usart_sync_set_mode(&edbg_com, USART_MODE_ASYNCHRONOUS);
+ _usart_sync_enable(&edbg_com);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer (samd SystemCoreClock may not correct)
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ // USB Pin, Clock init
+
+ /* Clear SYSIO 10 & 11 for USB DM & DP */
+ hri_matrix_clear_CCFG_SYSIO_reg(MATRIX, CCFG_SYSIO_SYSIO10 | CCFG_SYSIO_SYSIO11);
+
+ // Enable clock
+ _pmc_enable_periph_clock(ID_UDP);
+
+ /* USB Device mode & Transceiver active */
+ hri_matrix_write_CCFG_USBMR_reg(MATRIX, CCFG_USBMR_USBMODE);
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void UDP_Handler(void)
+{
+ #if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
+ tud_int_handler(0);
+ #endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ uint8_t const * buf8 = (uint8_t const *) buf;
+ for(int i=0; i<len; i++)
+ {
+ while ( !_usart_sync_is_ready_to_send(&edbg_com) ) {}
+ _usart_sync_write_byte(&edbg_com, buf8[i]);
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.h b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.h
new file mode 100644
index 0000000..a3e0399
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN (32 + 30) // PB30
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN (0 + 15) // PA15
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.mk b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.mk
new file mode 100644
index 0000000..5b9acb9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/board.mk
@@ -0,0 +1,12 @@
+CFLAGS += -D__SAML21J18B__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+SAML_VARIANT = saml21
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/saml21j18b_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAML21J18
+
+# flash using jlink
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld
new file mode 100644
index 0000000..7f6b7fa
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld
@@ -0,0 +1,153 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAML21J18B
+ *
+ * Copyright (c) 2016 Atmel Corporation,
+ * a wholly owned subsidiary of Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+ lpram (rwx) : ORIGIN = 0x30000000, LENGTH = 0x00002000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ .lpram (NOLOAD):
+ {
+ . = ALIGN(8);
+ _slpram = .;
+ *(.lpram .lpram.*);
+ . = ALIGN(8);
+ _elpram = .;
+ } > lpram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.h b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.h
new file mode 100644
index 0000000..13a3260
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.h
@@ -0,0 +1,47 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN PIN_PA08
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN PIN_PA06
+#define BUTTON_STATE_ACTIVE 0
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.mk b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.mk
new file mode 100644
index 0000000..0adfdd6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -D__SAML22J18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+SAML_VARIANT = saml22
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAML22J18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld
new file mode 100644
index 0000000..d1aaa44
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAML22J18A
+ *
+ * Copyright (c) 2018 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.h b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.h
new file mode 100644
index 0000000..7fc690a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.h
@@ -0,0 +1,47 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN PIN_PA21
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN PIN_PA22
+#define BUTTON_STATE_ACTIVE 1
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.mk b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.mk
new file mode 100644
index 0000000..0adfdd6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -D__SAML22J18A__ -DCFG_EXAMPLE_VIDEO_READONLY
+
+SAML_VARIANT = saml22
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/$(BOARD).ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAML22J18
+
+flash: flash-bossac
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld
new file mode 100644
index 0000000..d1aaa44
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld
@@ -0,0 +1,146 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAML22J18A
+ *
+ * Copyright (c) 2018 Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+ENTRY(Reset_Handler)
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ end = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/family.c b/circuitpython/lib/tinyusb/hw/bsp/saml2x/family.c
new file mode 100644
index 0000000..470fde7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/family.c
@@ -0,0 +1,163 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "sam.h"
+#include "bsp/board.h"
+#include "board.h"
+
+#include "hal/include/hal_gpio.h"
+#include "hal/include/hal_init.h"
+#include "hpl/gclk/hpl_gclk_base.h"
+#include "hpl_mclk_config.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_Handler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+/* Referenced GCLKs (out of 0~4), should be initialized firstly */
+#define _GCLK_INIT_1ST 0x00000000
+/* Not referenced GCLKs, initialized last */
+#define _GCLK_INIT_LAST 0x0000001F
+
+void board_init(void)
+{
+ // Clock init ( follow hpl_init.c )
+ hri_nvmctrl_set_CTRLB_RWS_bf(NVMCTRL, CONF_NVM_WAIT_STATE);
+
+ _set_performance_level(2);
+
+ _osc32kctrl_init_sources();
+ _oscctrl_init_sources();
+ _mclk_init();
+#if _GCLK_INIT_1ST
+ _gclk_init_generators_by_fref(_GCLK_INIT_1ST);
+#endif
+ _oscctrl_init_referenced_generators();
+ _gclk_init_generators_by_fref(_GCLK_INIT_LAST);
+
+#if (CONF_PORT_EVCTRL_PORT_0 | CONF_PORT_EVCTRL_PORT_1 | CONF_PORT_EVCTRL_PORT_2 | CONF_PORT_EVCTRL_PORT_3)
+ hri_port_set_EVCTRL_reg(PORT, 0, CONF_PORTA_EVCTRL);
+ hri_port_set_EVCTRL_reg(PORT, 1, CONF_PORTB_EVCTRL);
+#endif
+
+ // Update SystemCoreClock since it is hard coded with asf4 and not correct
+ // Init 1ms tick timer (samd SystemCoreClock may not correct)
+ SystemCoreClock = CONF_CPU_FREQUENCY;
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+
+ // Led init
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(LED_PIN, !LED_STATE_ON);
+
+ // Button init
+ gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+ gpio_set_pin_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULL_DOWN : GPIO_PULL_UP);
+
+#if CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+ /* USB Clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation. */
+ hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+ hri_mclk_set_AHBMASK_USB_bit(MCLK);
+ hri_mclk_set_APBBMASK_USB_bit(MCLK);
+
+ // USB Pin Init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24G_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25G_USB_DP);
+
+ // Output 500hz PWM on PB23 (TCC0 WO[3]) so we can validate the GCLK1 clock speed
+// hri_mclk_set_APBCMASK_TCC0_bit(MCLK);
+// TCC0->PER.bit.PER = 48000000 / 1000;
+// TCC0->CC[3].bit.CC = 48000000 / 2000;
+// TCC0->CTRLA.bit.ENABLE = true;
+//
+// gpio_set_pin_function(PIN_PB23, PINMUX_PB23F_TCC0_WO3);
+// hri_gclk_write_PCHCTRL_reg(GCLK, TCC0_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+ // button is active low
+ return gpio_get_pin_level(BUTTON_PIN) ? 0 : 1;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/saml2x/family.mk b/circuitpython/lib/tinyusb/hw/bsp/saml2x/family.mk
new file mode 100644
index 0000000..bb1faeb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/saml2x/family.mk
@@ -0,0 +1,51 @@
+UF2_FAMILY_ID = 0x68ed2b88
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/microchip
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+MCU_DIR = hw/mcu/microchip/$(SAML_VARIANT)
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -nostdlib -nostartfiles \
+ -DCONF_OSC32K_CALIB_ENABLE=0 \
+ -DCFG_TUSB_MCU=OPT_MCU_SAML22
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/microchip/samd/dcd_samd.c \
+ $(MCU_DIR)/gcc/gcc/startup_$(SAML_VARIANT).c \
+ $(MCU_DIR)/gcc/system_$(SAML_VARIANT).c \
+ $(MCU_DIR)/hpl/gclk/hpl_gclk.c \
+ $(MCU_DIR)/hpl/mclk/hpl_mclk.c \
+ $(MCU_DIR)/hpl/pm/hpl_pm.c \
+ $(MCU_DIR)/hpl/osc32kctrl/hpl_osc32kctrl.c \
+ $(MCU_DIR)/hpl/oscctrl/hpl_oscctrl.c \
+ $(MCU_DIR)/hal/src/hal_atomic.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)/ \
+ $(TOP)/$(MCU_DIR)/config \
+ $(TOP)/$(MCU_DIR)/include \
+ $(TOP)/$(MCU_DIR)/hal/include \
+ $(TOP)/$(MCU_DIR)/hal/utils/include \
+ $(TOP)/$(MCU_DIR)/hpl/port \
+ $(TOP)/$(MCU_DIR)/hri \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash-bossac: $(BUILD)/$(PROJECT).bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R
diff --git a/circuitpython/lib/tinyusb/hw/bsp/sltb009a/board.mk b/circuitpython/lib/tinyusb/hw/bsp/sltb009a/board.mk
new file mode 100644
index 0000000..f5c240c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/sltb009a/board.mk
@@ -0,0 +1,43 @@
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -D__STARTUP_CLEAR_BSS \
+ -D__START=main \
+ -DEFM32GG12B810F1024GM64 \
+ -DCFG_TUSB_MCU=OPT_MCU_EFM32GG
+
+# mcu driver cause following warnings
+#CFLAGS += -Wno-error=unused-parameter
+
+SILABS_FAMILY = efm32gg12b
+SILABS_CMSIS = hw/mcu/silabs/cmsis-dfp-$(SILABS_FAMILY)/Device/SiliconLabs/$(shell echo $(SILABS_FAMILY) | tr a-z A-Z)
+
+DEPS_SUBMODULES += hw/mcu/silabs/cmsis-dfp-$(SILABS_FAMILY)
+DEPS_SUBMODULES += lib/CMSIS_5
+
+# All source paths should be relative to the top level.
+LD_FILE = $(SILABS_CMSIS)/Source/GCC/$(SILABS_FAMILY).ld
+
+SRC_C += \
+ $(SILABS_CMSIS)/Source/system_$(SILABS_FAMILY).c \
+ src/portable/synopsys/dwc2/dcd_dwc2.c
+
+SRC_S += \
+ $(SILABS_CMSIS)/Source/GCC/startup_$(SILABS_FAMILY).S
+
+INC += \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(SILABS_CMSIS)/Include \
+ $(TOP)/hw/bsp/$(BOARD)
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# For flash-jlink target
+JLINK_DEVICE = EFM32GG12B810F1024
+
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/sltb009a/sltb009a.c b/circuitpython/lib/tinyusb/hw/bsp/sltb009a/sltb009a.c
new file mode 100644
index 0000000..b929adb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/sltb009a/sltb009a.c
@@ -0,0 +1,721 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021 Rafael Silva (@perigoso)
+ * Copyright (c) 2021 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+
+#include "em_device.h"
+
+/*--------------------------------------------------------------------*/
+/* MACRO TYPEDEF CONSTANT ENUM */
+/*--------------------------------------------------------------------*/
+
+#define LED_PORT 0 // A
+#define LED_PIN_R 12 // 12
+#define LED_PIN_B 13 // 13
+#define LED_PIN_G 14 // 14
+#define LED_STATE_ON 0 // active-low
+
+#define BUTTON_PORT 3 // D
+#define BUTTON_PIN 5 // 5
+#define BUTTON_STATE_ACTIVE 0 // active-low
+
+/*--------------------------------------------------------------------*/
+/* Forward USB interrupt events to TinyUSB IRQ Handler */
+/*--------------------------------------------------------------------*/
+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+/*--------------------------------------------------------------------*/
+/* Fault Handlers */
+/*--------------------------------------------------------------------*/
+
+void HardFault_Handler(void)
+{
+ asm("bkpt");
+}
+
+void MemManage_Handler(void)
+{
+ asm("bkpt");
+}
+
+void BusFault_Handler(void)
+{
+ asm("bkpt");
+}
+
+void UsageFault_Handler(void)
+{
+ asm("bkpt");
+}
+
+/*--------------------------------------------------------------------*/
+/* Startup */
+/*--------------------------------------------------------------------*/
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
+
+/*--------------------------------------------------------------------*/
+/* Initing Funcs */
+/*--------------------------------------------------------------------*/
+
+void emu_init(uint8_t immediate_switch)
+{
+ EMU->PWRCTRL = (immediate_switch ? EMU_PWRCTRL_IMMEDIATEPWRSWITCH : 0) | EMU_PWRCTRL_REGPWRSEL_DVDD | EMU_PWRCTRL_ANASW_AVDD;
+}
+
+void emu_reg_init(float target_voltage)
+{
+ if(target_voltage < 2300.f || target_voltage >= 3800.f)
+ return;
+
+ uint8_t level = ((target_voltage - 2300.f) / 100.f);
+
+ EMU->R5VCTRL = EMU_R5VCTRL_INPUTMODE_AUTO;
+
+ EMU->R5VOUTLEVEL = level; /* Reg output to 3.3V*/
+}
+
+void emu_dcdc_init(float target_voltage, float max_ln_current, float max_lp_current, float max_reverse_current)
+{
+ if(target_voltage < 1800.f || target_voltage >= 3000.f)
+ return;
+
+ if(max_ln_current <= 0.f || max_ln_current > 200.f)
+ return;
+
+ if(max_lp_current <= 0.f || max_lp_current > 10000.f)
+ return;
+
+ if(max_reverse_current < 0.f || max_reverse_current > 160.f)
+ return;
+
+ // Low Power & Low Noise current limit
+ uint8_t lp_bias = 0;
+
+ if(max_lp_current < 75.f)
+ lp_bias = 0;
+ else if(max_lp_current < 500.f)
+ lp_bias = 1;
+ else if(max_lp_current < 2500.f)
+ lp_bias = 2;
+ else
+ lp_bias = 3;
+
+ EMU->DCDCMISCCTRL = (EMU->DCDCMISCCTRL & ~_EMU_DCDCMISCCTRL_LPCMPBIASEM234H_MASK) | ((uint32_t)lp_bias << _EMU_DCDCMISCCTRL_LPCMPBIASEM234H_SHIFT);
+ EMU->DCDCMISCCTRL |= EMU_DCDCMISCCTRL_LNFORCECCM; // Force CCM to prevent reverse current
+ EMU->DCDCLPCTRL |= EMU_DCDCLPCTRL_LPVREFDUTYEN; // Enable duty cycling of the bias for LP mode
+ EMU->DCDCLNFREQCTRL = (EMU->DCDCLNFREQCTRL & ~_EMU_DCDCLNFREQCTRL_RCOBAND_MASK) | 4; // Set RCO Band to 7MHz
+
+ uint8_t fet_count = 0;
+
+ if(max_ln_current < 20.f)
+ fet_count = 4;
+ else if(max_ln_current >= 20.f && max_ln_current < 40.f)
+ fet_count = 8;
+ else
+ fet_count = 16;
+
+ EMU->DCDCMISCCTRL = (EMU->DCDCMISCCTRL & ~_EMU_DCDCMISCCTRL_NFETCNT_MASK) | ((uint32_t)(fet_count - 1) << _EMU_DCDCMISCCTRL_NFETCNT_SHIFT);
+ EMU->DCDCMISCCTRL = (EMU->DCDCMISCCTRL & ~_EMU_DCDCMISCCTRL_PFETCNT_MASK) | ((uint32_t)(fet_count - 1) << _EMU_DCDCMISCCTRL_PFETCNT_SHIFT);
+
+ uint8_t ln_current_limit = (((max_ln_current + 40.f) * 1.5f) / (5.f * fet_count)) - 1;
+ uint8_t lp_current_limit = 1; // Recommended value
+
+ EMU->DCDCMISCCTRL = (EMU->DCDCMISCCTRL & ~(_EMU_DCDCMISCCTRL_LNCLIMILIMSEL_MASK | _EMU_DCDCMISCCTRL_LPCLIMILIMSEL_MASK)) | ((uint32_t)ln_current_limit << _EMU_DCDCMISCCTRL_LNCLIMILIMSEL_SHIFT) | ((uint32_t)lp_current_limit << _EMU_DCDCMISCCTRL_LPCLIMILIMSEL_SHIFT);
+
+ uint8_t z_det_limit = ((max_reverse_current + 40.f) * 1.5f) / (2.5f * fet_count);
+
+ EMU->DCDCZDETCTRL = (EMU->DCDCZDETCTRL & ~_EMU_DCDCZDETCTRL_ZDETILIMSEL_MASK) | ((uint32_t)z_det_limit << _EMU_DCDCZDETCTRL_ZDETILIMSEL_SHIFT);
+
+ EMU->DCDCCLIMCTRL |= EMU_DCDCCLIMCTRL_BYPLIMEN; // Enable bypass current limiter to prevent overcurrent when switching modes
+
+ // Output Voltage
+ if(target_voltage > 1800.f)
+ {
+ float max_vout = 3000.f;
+ float min_vout = 1800.f;
+ float diff_vout = max_vout - min_vout;
+
+ uint8_t ln_vref_high = (DEVINFO->DCDCLNVCTRL0 & _DEVINFO_DCDCLNVCTRL0_3V0LNATT1_MASK) >> _DEVINFO_DCDCLNVCTRL0_3V0LNATT1_SHIFT;
+ uint8_t ln_vref_low = (DEVINFO->DCDCLNVCTRL0 & _DEVINFO_DCDCLNVCTRL0_1V8LNATT1_MASK) >> _DEVINFO_DCDCLNVCTRL0_1V8LNATT1_SHIFT;
+
+ uint8_t ln_vref = ((target_voltage - min_vout) * (float)(ln_vref_high - ln_vref_low)) / diff_vout;
+ ln_vref += ln_vref_low;
+
+ EMU->DCDCLNVCTRL = (ln_vref << _EMU_DCDCLNVCTRL_LNVREF_SHIFT) | EMU_DCDCLNVCTRL_LNATT;
+
+ uint8_t lp_vref_low = 0;
+ uint8_t lp_vref_high = 0;
+
+ switch(lp_bias)
+ {
+ case 0:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL2 & _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS0_MASK) >> _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS0_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL2 & _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS0_MASK) >> _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS0_SHIFT;
+ }
+ break;
+ case 1:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL2 & _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS1_MASK) >> _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS1_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL2 & _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS1_MASK) >> _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS1_SHIFT;
+ }
+ break;
+ case 2:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL3 & _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS2_MASK) >> _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS2_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL3 & _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS2_MASK) >> _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS2_SHIFT;
+ }
+ break;
+ case 3:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL3 & _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS3_MASK) >> _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS3_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL3 & _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS3_MASK) >> _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS3_SHIFT;
+ }
+ break;
+ }
+
+ uint8_t lp_vref = ((target_voltage - min_vout) * (float)(lp_vref_high - lp_vref_low)) / diff_vout;
+ lp_vref += lp_vref_low;
+
+ EMU->DCDCLPVCTRL = (lp_vref << _EMU_DCDCLPVCTRL_LPVREF_SHIFT) | EMU_DCDCLPVCTRL_LPATT;
+ }
+ else
+ {
+ float max_vout = 1800.f;
+ float min_vout = 1200.f;
+ float diff_vout = max_vout - min_vout;
+
+ uint8_t ln_vref_high = (DEVINFO->DCDCLNVCTRL0 & _DEVINFO_DCDCLNVCTRL0_1V8LNATT0_MASK) >> _DEVINFO_DCDCLNVCTRL0_1V8LNATT0_SHIFT;
+ uint8_t ln_vref_low = (DEVINFO->DCDCLNVCTRL0 & _DEVINFO_DCDCLNVCTRL0_1V2LNATT0_MASK) >> _DEVINFO_DCDCLNVCTRL0_1V2LNATT0_SHIFT;
+
+ uint8_t ln_vref = ((target_voltage - min_vout) * (float)(ln_vref_high - ln_vref_low)) / diff_vout;
+ ln_vref += ln_vref_low;
+
+ EMU->DCDCLNVCTRL = ln_vref << _EMU_DCDCLNVCTRL_LNVREF_SHIFT;
+
+ uint8_t lp_vref_low = 0;
+ uint8_t lp_vref_high = 0;
+
+ switch(lp_bias)
+ {
+ case 0:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL0 & _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS0_MASK) >> _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS0_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL0 & _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS0_MASK) >> _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS0_SHIFT;
+ }
+ break;
+ case 1:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL0 & _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS1_MASK) >> _DEVINFO_DCDCLPVCTRL2_3V0LPATT1LPCMPBIAS1_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL0 & _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS1_MASK) >> _DEVINFO_DCDCLPVCTRL2_1V8LPATT1LPCMPBIAS1_SHIFT;
+ }
+ break;
+ case 2:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL1 & _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS2_MASK) >> _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS2_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL1 & _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS2_MASK) >> _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS2_SHIFT;
+ }
+ break;
+ case 3:
+ {
+ lp_vref_high = (DEVINFO->DCDCLPVCTRL1 & _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS3_MASK) >> _DEVINFO_DCDCLPVCTRL3_3V0LPATT1LPCMPBIAS3_SHIFT;
+ lp_vref_low = (DEVINFO->DCDCLPVCTRL1 & _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS3_MASK) >> _DEVINFO_DCDCLPVCTRL3_1V8LPATT1LPCMPBIAS3_SHIFT;
+ }
+ break;
+ }
+
+ uint8_t lp_vref = ((target_voltage - min_vout) * (float)(lp_vref_high - lp_vref_low)) / diff_vout;
+ lp_vref += lp_vref_low;
+
+ EMU->DCDCLPVCTRL = lp_vref << _EMU_DCDCLPVCTRL_LPVREF_SHIFT;
+ }
+
+ EMU->DCDCLPCTRL = (EMU->DCDCLPCTRL & ~_EMU_DCDCLPCTRL_LPCMPHYSSELEM234H_MASK) | (((DEVINFO->DCDCLPCMPHYSSEL1 & (((uint32_t)0xFF) << (lp_bias * 8))) >> (lp_bias * 8)) << _EMU_DCDCLPCTRL_LPCMPHYSSELEM234H_SHIFT);
+
+ while(EMU->DCDCSYNC & EMU_DCDCSYNC_DCDCCTRLBUSY); // Wait for configuration to write
+
+ // Calibration
+ //EMU->DCDCLNCOMPCTRL = 0x57204077; // Compensation for 1uF DCDC capacitor
+ EMU->DCDCLNCOMPCTRL = 0xB7102137; // Compensation for 4.7uF DCDC capacitor
+
+ // Enable DCDC converter
+ EMU->DCDCCTRL = EMU_DCDCCTRL_DCDCMODEEM4_EM4LOWPOWER | EMU_DCDCCTRL_DCDCMODEEM23_EM23LOWPOWER | EMU_DCDCCTRL_DCDCMODE_LOWNOISE;
+
+ // Switch digital domain to DVDD
+ EMU->PWRCTRL = EMU_PWRCTRL_REGPWRSEL_DVDD | EMU_PWRCTRL_ANASW_AVDD;
+}
+
+void cmu_hfxo_startup_calib(uint16_t ib_trim, uint16_t c_tune)
+{
+ if(CMU->STATUS & CMU_STATUS_HFXOENS)
+ return;
+
+ CMU->HFXOSTARTUPCTRL = (CMU->HFXOSTARTUPCTRL & ~(_CMU_HFXOSTARTUPCTRL_CTUNE_MASK | _CMU_HFXOSTARTUPCTRL_IBTRIMXOCORE_MASK)) | (((uint32_t)c_tune << _CMU_HFXOSTARTUPCTRL_CTUNE_SHIFT) & _CMU_HFXOSTARTUPCTRL_CTUNE_MASK) | (((uint32_t)ib_trim << _CMU_HFXOSTARTUPCTRL_IBTRIMXOCORE_SHIFT) & _CMU_HFXOSTARTUPCTRL_IBTRIMXOCORE_MASK);
+}
+
+void cmu_hfxo_steady_calib(uint16_t ib_trim, uint16_t c_tune)
+{
+ if(CMU->STATUS & CMU_STATUS_HFXOENS)
+ return;
+
+ CMU->HFXOSTEADYSTATECTRL = (CMU->HFXOSTEADYSTATECTRL & ~(_CMU_HFXOSTEADYSTATECTRL_CTUNE_MASK | _CMU_HFXOSTEADYSTATECTRL_IBTRIMXOCORE_MASK)) | (((uint32_t)c_tune << _CMU_HFXOSTEADYSTATECTRL_CTUNE_SHIFT) & _CMU_HFXOSTEADYSTATECTRL_CTUNE_MASK) | (((uint32_t)ib_trim << _CMU_HFXOSTEADYSTATECTRL_IBTRIMXOCORE_SHIFT) & _CMU_HFXOSTEADYSTATECTRL_IBTRIMXOCORE_MASK);
+}
+
+void cmu_hfrco_calib(uint32_t calibration)
+{
+ if(CMU->STATUS & CMU_STATUS_DPLLENS)
+ return;
+
+ while(CMU->SYNCBUSY & CMU_SYNCBUSY_HFRCOBSY);
+
+ CMU->HFRCOCTRL = calibration;
+
+ while(CMU->SYNCBUSY & CMU_SYNCBUSY_HFRCOBSY);
+}
+
+void cmu_ushfrco_calib(uint8_t enable, uint32_t calibration)
+{
+ if(CMU->USBCRCTRL & CMU_USBCRCTRL_USBCREN)
+ return;
+
+ if(!enable)
+ {
+ CMU->OSCENCMD = CMU_OSCENCMD_USHFRCODIS;
+ while(CMU->STATUS & CMU_STATUS_USHFRCOENS);
+
+ return;
+ }
+
+ while(CMU->SYNCBUSY & CMU_SYNCBUSY_USHFRCOBSY);
+
+ CMU->USHFRCOCTRL = calibration | CMU_USHFRCOCTRL_FINETUNINGEN;
+
+ while(CMU->SYNCBUSY & CMU_SYNCBUSY_USHFRCOBSY);
+
+ if(enable && !(CMU->STATUS & CMU_STATUS_USHFRCOENS))
+ {
+ CMU->OSCENCMD = CMU_OSCENCMD_USHFRCOEN;
+
+ while(!(CMU->STATUS & CMU_STATUS_USHFRCORDY));
+ }
+}
+
+void cmu_auxhfrco_calib(uint8_t enable, uint32_t calibration)
+{
+ if(!enable)
+ {
+ CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCODIS;
+ while(CMU->STATUS & CMU_STATUS_AUXHFRCOENS);
+
+ return;
+ }
+
+ while(CMU->SYNCBUSY & CMU_SYNCBUSY_AUXHFRCOBSY);
+
+ CMU->AUXHFRCOCTRL = calibration;
+
+ while(CMU->SYNCBUSY & CMU_SYNCBUSY_AUXHFRCOBSY);
+
+ if(enable && !(CMU->STATUS & CMU_STATUS_AUXHFRCOENS))
+ {
+ CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
+
+ while(!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY));
+ }
+}
+
+
+void cmu_init(void)
+{
+ // Change SDIO clock to HFXO if HFRCO selected and disable it
+ CMU->SDIOCTRL = CMU_SDIOCTRL_SDIOCLKDIS | CMU_SDIOCTRL_SDIOCLKSEL_HFXO;
+ while(CMU->STATUS & CMU_STATUS_SDIOCLKENS);
+
+ // Change QSPI clock to HFXO if HFRCO selected and disable it
+ CMU->QSPICTRL = CMU_QSPICTRL_QSPI0CLKDIS | CMU_QSPICTRL_QSPI0CLKSEL_HFXO;
+ while(CMU->STATUS & CMU_STATUS_QSPI0CLKENS);
+
+ // Disable DPLL if enabled
+ if(CMU->STATUS & CMU_STATUS_DPLLENS)
+ {
+ CMU->OSCENCMD = CMU_OSCENCMD_DPLLDIS;
+ while(CMU->STATUS & CMU_STATUS_DPLLENS);
+ }
+
+ // Disable HFXO if enabled
+ if(CMU->STATUS & CMU_STATUS_HFXOENS)
+ {
+ CMU->OSCENCMD = CMU_OSCENCMD_HFXODIS;
+ while(CMU->STATUS & CMU_STATUS_HFXOENS);
+ }
+
+ // Setup HFXO
+ CMU->HFXOCTRL = CMU_HFXOCTRL_PEAKDETMODE_AUTOCMD | CMU_HFXOCTRL_MODE_XTAL;
+ CMU->HFXOCTRL1 = CMU_HFXOCTRL1_PEAKDETTHR_DEFAULT;
+ CMU->HFXOSTEADYSTATECTRL |= CMU_HFXOSTEADYSTATECTRL_PEAKMONEN;
+ CMU->HFXOTIMEOUTCTRL = (7 << _CMU_HFXOTIMEOUTCTRL_PEAKDETTIMEOUT_SHIFT) | (8 << _CMU_HFXOTIMEOUTCTRL_STEADYTIMEOUT_SHIFT) | (12 << _CMU_HFXOTIMEOUTCTRL_STARTUPTIMEOUT_SHIFT);
+
+ // Enable HFXO and wait for it to be ready
+ CMU->OSCENCMD = CMU_OSCENCMD_HFXOEN;
+ while(!(CMU->STATUS & CMU_STATUS_HFXORDY));
+
+ // Switch main clock to HFXO and wait for it to be selected
+ CMU->HFCLKSEL = CMU_HFCLKSEL_HF_HFXO;
+ while((CMU->HFCLKSTATUS & _CMU_HFCLKSTATUS_SELECTED_MASK) != CMU_HFCLKSTATUS_SELECTED_HFXO);
+
+ // Calibrate HFRCO for 72MHz and enable tunning by PLL
+ cmu_hfrco_calib((DEVINFO->HFRCOCAL16) | CMU_HFRCOCTRL_FINETUNINGEN);
+
+ // Setup the PLL
+ CMU->DPLLCTRL = CMU_DPLLCTRL_REFSEL_HFXO | CMU_DPLLCTRL_AUTORECOVER | CMU_DPLLCTRL_EDGESEL_RISE | CMU_DPLLCTRL_MODE_FREQLL;
+ // 72MHz = 50MHz (HFXO) * 1.44 (144/100)
+ CMU->DPLLCTRL1 = (143 << _CMU_DPLLCTRL1_N_SHIFT) | (99 << _CMU_DPLLCTRL1_M_SHIFT); // fHFRCO = fHFXO * (N + 1) / (M + 1)
+
+ // Enable the DPLL and wait for it to be ready
+ CMU->OSCENCMD = CMU_OSCENCMD_DPLLEN;
+ while(!(CMU->STATUS & CMU_STATUS_DPLLRDY));
+
+ // Config peripherals for the new frequency (freq > 32MHz)
+ CMU->CTRL |= CMU_CTRL_WSHFLE;
+
+ // Set prescalers
+ CMU->HFPRESC = CMU_HFPRESC_HFCLKLEPRESC_DIV2 | CMU_HFPRESC_PRESC_NODIVISION;
+ CMU->HFBUSPRESC = 1 << _CMU_HFBUSPRESC_PRESC_SHIFT;
+ CMU->HFCOREPRESC = 0 << _CMU_HFCOREPRESC_PRESC_SHIFT;
+ CMU->HFPERPRESC = 1 << _CMU_HFPERPRESC_PRESC_SHIFT;
+ CMU->HFEXPPRESC = 0 << _CMU_HFEXPPRESC_PRESC_SHIFT;
+ CMU->HFPERPRESCB = 0 << _CMU_HFPERPRESCB_PRESC_SHIFT;
+ CMU->HFPERPRESCC = 1 << _CMU_HFPERPRESCC_PRESC_SHIFT;
+
+ // Enable clock to peripherals
+ CMU->CTRL |= CMU_CTRL_HFPERCLKEN;
+
+ // Switch main clock to HFRCO and wait for it to be selected
+ CMU->HFCLKSEL = CMU_HFCLKSEL_HF_HFRCO;
+ while((CMU->HFCLKSTATUS & _CMU_HFCLKSTATUS_SELECTED_MASK) != CMU_HFCLKSTATUS_SELECTED_HFRCO);
+
+ // LFA Clock
+ CMU->LFACLKSEL = CMU_LFACLKSEL_LFA_LFRCO;
+
+ // LFB Clock
+ CMU->LFBCLKSEL = CMU_LFBCLKSEL_LFB_LFRCO;
+
+ // LFC Clock
+ CMU->LFCCLKSEL = CMU_LFCCLKSEL_LFC_LFRCO;
+
+ // LFE Clock
+ CMU->LFECLKSEL = CMU_LFECLKSEL_LFE_ULFRCO;
+}
+
+void systick_init(void)
+{
+ SysTick->LOAD = (72000000 / 1000) - 1;
+ SysTick->VAL = 0;
+ SysTick->CTRL = SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk;
+
+ SCB->SHP[11] = 7 << (8 - __NVIC_PRIO_BITS); // Set priority 3,1 (min)
+}
+
+void gpio_init(void)
+{
+ CMU->HFBUSCLKEN0 |= CMU_HFBUSCLKEN0_GPIO;
+
+ // NC - Not Connected (not available in mcu package)
+ // NR - Not routed (no routing to pin on pcb, floating)
+ // NU - Not used (not currently in use)
+
+ // Port A
+ GPIO->P[0].CTRL = GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG | (6 << _GPIO_P_CTRL_SLEWRATEALT_SHIFT)
+ | GPIO_P_CTRL_DRIVESTRENGTH_STRONG | (6 << _GPIO_P_CTRL_SLEWRATE_SHIFT);
+ GPIO->P[0].MODEL = GPIO_P_MODEL_MODE0_DISABLED // NU
+ | GPIO_P_MODEL_MODE1_DISABLED // NU
+ | GPIO_P_MODEL_MODE2_DISABLED // NU
+ | GPIO_P_MODEL_MODE3_DISABLED // NU
+ | GPIO_P_MODEL_MODE4_DISABLED // NU
+ | GPIO_P_MODEL_MODE5_DISABLED // NU
+ | GPIO_P_MODEL_MODE6_DISABLED // NU
+ | GPIO_P_MODEL_MODE7_DISABLED; // NC
+ GPIO->P[0].MODEH = GPIO_P_MODEH_MODE8_DISABLED // GPIO - MIC_ENABLE
+ | GPIO_P_MODEH_MODE9_DISABLED // NC
+ | GPIO_P_MODEH_MODE10_DISABLED // NC
+ | GPIO_P_MODEH_MODE11_DISABLED // NC
+ | GPIO_P_MODEH_MODE12_WIREDAND // LED0R
+ | GPIO_P_MODEH_MODE13_WIREDAND // LED0B
+ | GPIO_P_MODEH_MODE14_WIREDAND // LED0G
+ | GPIO_P_MODEH_MODE15_DISABLED; // NU
+ GPIO->P[0].DOUT = 0x7000; // Leds off By default
+ GPIO->P[0].OVTDIS = 0;
+
+ // Port B
+ GPIO->P[1].CTRL = GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG | (6 << _GPIO_P_CTRL_SLEWRATEALT_SHIFT)
+ | GPIO_P_CTRL_DRIVESTRENGTH_STRONG | (6 << _GPIO_P_CTRL_SLEWRATE_SHIFT);
+ GPIO->P[1].MODEL = GPIO_P_MODEL_MODE0_DISABLED // NC
+ | GPIO_P_MODEL_MODE1_DISABLED // NC
+ | GPIO_P_MODEL_MODE2_DISABLED // NC
+ | GPIO_P_MODEL_MODE3_DISABLED // NU
+ | GPIO_P_MODEL_MODE4_DISABLED // NU
+ | GPIO_P_MODEL_MODE5_DISABLED // NU
+ | GPIO_P_MODEL_MODE6_DISABLED // NU
+ | GPIO_P_MODEL_MODE7_DISABLED; // MAIN_LFXTAL_P
+ GPIO->P[1].MODEH = GPIO_P_MODEH_MODE8_DISABLED // MAIN_LFXTAL_N
+ | GPIO_P_MODEH_MODE9_DISABLED // NC
+ | GPIO_P_MODEH_MODE10_DISABLED // NC
+ | GPIO_P_MODEH_MODE11_DISABLED // PDM_DAT0 - MIC_DATA
+ | GPIO_P_MODEH_MODE12_DISABLED // PDM_CLK - MIC_CLOCK
+ | GPIO_P_MODEH_MODE13_DISABLED // MAIN_HFXTAL_P
+ | GPIO_P_MODEH_MODE14_DISABLED // MAIN_HFXTAL_N
+ | GPIO_P_MODEH_MODE15_DISABLED; // NC
+ GPIO->P[1].DOUT = 0;
+ GPIO->P[1].OVTDIS = 0;
+
+ // Port C
+ GPIO->P[2].CTRL = GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG | (6 << _GPIO_P_CTRL_SLEWRATEALT_SHIFT)
+ | GPIO_P_CTRL_DRIVESTRENGTH_STRONG | (7 << _GPIO_P_CTRL_SLEWRATE_SHIFT);
+ GPIO->P[2].MODEL = GPIO_P_MODEL_MODE0_DISABLED // NC
+ | GPIO_P_MODEL_MODE1_DISABLED // NC
+ | GPIO_P_MODEL_MODE2_DISABLED // NC
+ | GPIO_P_MODEL_MODE3_DISABLED // NC
+ | GPIO_P_MODEL_MODE4_DISABLED // NU
+ | GPIO_P_MODEL_MODE5_DISABLED // NU
+ | GPIO_P_MODEL_MODE6_DISABLED // NC
+ | GPIO_P_MODEL_MODE7_DISABLED; // NC
+ GPIO->P[2].MODEH = GPIO_P_MODEH_MODE8_DISABLED // NC
+ | GPIO_P_MODEH_MODE9_DISABLED // NC
+ | GPIO_P_MODEH_MODE10_DISABLED // NC
+ | GPIO_P_MODEH_MODE11_DISABLED // NC
+ | GPIO_P_MODEH_MODE12_DISABLED // NC
+ | GPIO_P_MODEH_MODE13_DISABLED // NC
+ | GPIO_P_MODEH_MODE14_DISABLED // NC
+ | GPIO_P_MODEH_MODE15_DISABLED; // NC
+ GPIO->P[2].DOUT = 0;
+ GPIO->P[2].OVTDIS = 0;
+
+ // Port D
+ GPIO->P[3].CTRL = GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG | (6 << _GPIO_P_CTRL_SLEWRATEALT_SHIFT)
+ | GPIO_P_CTRL_DRIVESTRENGTH_STRONG | (6 << _GPIO_P_CTRL_SLEWRATE_SHIFT);
+ GPIO->P[3].MODEL = GPIO_P_MODEL_MODE0_DISABLED // NU
+ | GPIO_P_MODEL_MODE1_DISABLED // NU
+ | GPIO_P_MODEL_MODE2_DISABLED // NU
+ | GPIO_P_MODEL_MODE3_DISABLED // NU
+ | GPIO_P_MODEL_MODE4_DISABLED // NU
+ | GPIO_P_MODEL_MODE5_INPUT // GPIO - BTN0
+ | GPIO_P_MODEL_MODE6_WIREDAND // LED1R
+ | GPIO_P_MODEL_MODE7_DISABLED; // NU
+ GPIO->P[3].MODEH = GPIO_P_MODEH_MODE8_INPUT // GPIO - BTN1
+ | GPIO_P_MODEH_MODE9_DISABLED // NC
+ | GPIO_P_MODEH_MODE10_DISABLED // NC
+ | GPIO_P_MODEH_MODE11_DISABLED // NC
+ | GPIO_P_MODEH_MODE12_DISABLED // NC
+ | GPIO_P_MODEH_MODE13_DISABLED // NC
+ | GPIO_P_MODEH_MODE14_DISABLED // NC
+ | GPIO_P_MODEH_MODE15_DISABLED; // NC
+ GPIO->P[3].DOUT = 0;
+ GPIO->P[3].OVTDIS = 0;
+
+ // Port E
+ GPIO->P[4].CTRL = GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG | (6 << _GPIO_P_CTRL_SLEWRATEALT_SHIFT)
+ | GPIO_P_CTRL_DRIVESTRENGTH_STRONG | (6 << _GPIO_P_CTRL_SLEWRATE_SHIFT);
+ GPIO->P[4].MODEL = GPIO_P_MODEL_MODE0_DISABLED // NC
+ | GPIO_P_MODEL_MODE1_DISABLED // NC
+ | GPIO_P_MODEL_MODE2_DISABLED // NC
+ | GPIO_P_MODEL_MODE3_DISABLED // NC
+ | GPIO_P_MODEL_MODE4_DISABLED // NU
+ | GPIO_P_MODEL_MODE5_DISABLED // NU
+ | GPIO_P_MODEL_MODE6_DISABLED // NU
+ | GPIO_P_MODEL_MODE7_DISABLED; // NU
+ GPIO->P[4].MODEH = GPIO_P_MODEH_MODE8_DISABLED // NU
+ | GPIO_P_MODEH_MODE9_DISABLED // NU
+ | GPIO_P_MODEH_MODE10_DISABLED // NU
+ | GPIO_P_MODEH_MODE11_DISABLED // NU
+ | GPIO_P_MODEH_MODE12_WIREDAND // LED1B
+ | GPIO_P_MODEH_MODE13_DISABLED // NU
+ | GPIO_P_MODEH_MODE14_DISABLED // NU
+ | GPIO_P_MODEH_MODE15_DISABLED; // NU
+ GPIO->P[4].DOUT = 0;
+ GPIO->P[4].OVTDIS = 0;
+
+ // Port F
+ GPIO->P[5].CTRL = GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG | (6 << _GPIO_P_CTRL_SLEWRATEALT_SHIFT)
+ | GPIO_P_CTRL_DRIVESTRENGTH_STRONG | (6 << _GPIO_P_CTRL_SLEWRATE_SHIFT);
+ GPIO->P[5].MODEL = GPIO_P_MODEL_MODE0_PUSHPULL // SWCLK
+ | GPIO_P_MODEL_MODE1_PUSHPULL // SWDIO
+ | GPIO_P_MODEL_MODE2_PUSHPULL // SWO
+ | GPIO_P_MODEL_MODE3_DISABLED // NC
+ | GPIO_P_MODEL_MODE4_DISABLED // NC
+ | GPIO_P_MODEL_MODE5_DISABLED // NU
+ | GPIO_P_MODEL_MODE6_DISABLED // NC
+ | GPIO_P_MODEL_MODE7_DISABLED; // NC
+ GPIO->P[5].MODEH = GPIO_P_MODEH_MODE8_DISABLED // NC
+ | GPIO_P_MODEH_MODE9_DISABLED // NC
+ | GPIO_P_MODEH_MODE10_DISABLED // USB N
+ | GPIO_P_MODEH_MODE11_DISABLED // USB P
+ | GPIO_P_MODEH_MODE12_WIREDAND // LED1G
+ | GPIO_P_MODEH_MODE13_DISABLED // NC
+ | GPIO_P_MODEH_MODE14_DISABLED // NC
+ | GPIO_P_MODEH_MODE15_DISABLED; // NC
+ GPIO->P[5].DOUT = 0;
+
+ GPIO->P[5].OVTDIS = 0;
+
+ // Debugger Route
+ GPIO->ROUTEPEN &= ~(GPIO_ROUTEPEN_TDIPEN | GPIO_ROUTEPEN_TDOPEN); // Disable JTAG
+ GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN; // Enable SWO
+ GPIO->ROUTELOC0 = GPIO_ROUTELOC0_SWVLOC_LOC0; // SWO on PF2
+
+ // External interrupts
+ GPIO->EXTIPSELL = GPIO_EXTIPSELL_EXTIPSEL0_PORTE // NU
+ | GPIO_EXTIPSELL_EXTIPSEL1_PORTB // NU
+ | GPIO_EXTIPSELL_EXTIPSEL2_PORTB // NU
+ | GPIO_EXTIPSELL_EXTIPSEL3_PORTB // NU
+ | GPIO_EXTIPSELL_EXTIPSEL4_PORTA // NU
+ | GPIO_EXTIPSELL_EXTIPSEL5_PORTA // NU
+ | GPIO_EXTIPSELL_EXTIPSEL6_PORTC // NU
+ | GPIO_EXTIPSELL_EXTIPSEL7_PORTC; // NU
+ GPIO->EXTIPSELH = GPIO_EXTIPSELH_EXTIPSEL8_PORTA // NU
+ | GPIO_EXTIPSELH_EXTIPSEL9_PORTE // NU
+ | GPIO_EXTIPSELH_EXTIPSEL10_PORTF // NU
+ | GPIO_EXTIPSELH_EXTIPSEL11_PORTA // NU
+ | GPIO_EXTIPSELH_EXTIPSEL12_PORTA // NU
+ | GPIO_EXTIPSELH_EXTIPSEL13_PORTE // NU
+ | GPIO_EXTIPSELH_EXTIPSEL14_PORTF // NU
+ | GPIO_EXTIPSELH_EXTIPSEL15_PORTA; // NU
+
+ GPIO->EXTIPINSELL = GPIO_EXTIPINSELL_EXTIPINSEL0_PIN3 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL1_PIN1 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL2_PIN2 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL3_PIN3 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL4_PIN6 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL5_PIN7 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL6_PIN4 // NU
+ | GPIO_EXTIPINSELL_EXTIPINSEL7_PIN7; // NU
+ GPIO->EXTIPINSELH = GPIO_EXTIPINSELH_EXTIPINSEL8_PIN8 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL9_PIN9 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL10_PIN11 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL11_PIN8 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL12_PIN13 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL13_PIN15 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL14_PIN12 // NU
+ | GPIO_EXTIPINSELH_EXTIPINSEL15_PIN12; // NU
+
+}
+
+/*--------------------------------------------------------------------*/
+/* Board Init */
+/*--------------------------------------------------------------------*/
+
+void board_init(void)
+{
+
+ emu_dcdc_init(1800.f, 50.f, 100.f, 0.f); // Init DC-DC converter (1.8 V, 50 mA active, 100 uA sleep, 0 mA reverse limit)
+ emu_init(0);
+ emu_reg_init(3300.f); // set output regulator to 3.3V
+
+ cmu_hfxo_startup_calib(0x200, 0x145); // Config HFXO Startup for 1280 uA, 36 pF (18 pF + 2 pF CLOAD)
+ cmu_hfxo_steady_calib(0x009, 0x145); // Config HFXO Steady for 12 uA, 36 pF (18 pF + 2 pF CLOAD)
+
+ cmu_init(); // Init Clock Management Unit
+
+ cmu_ushfrco_calib(1, DEVINFO->USHFRCOCAL13); // Enable and calibrate USHFRCO for 48 MHz
+ cmu_auxhfrco_calib(1, DEVINFO->AUXHFRCOCAL11); // Enable and calibrate AUXHFRCO for 32 MHz
+
+ CMU->USBCRCTRL = CMU_USBCRCTRL_USBCREN; // enable USB clock recovery
+ CMU->USBCTRL = CMU_USBCTRL_USBCLKSEL_USHFRCO | CMU_USBCTRL_USBCLKEN; // select USHFRCO as USB Phy clock source and enable it
+
+ CMU->HFBUSCLKEN0 |= CMU_HFBUSCLKEN0_USB; // enable USB peripheral clock
+
+ systick_init(); // Init system tick
+
+ gpio_init(); // Init IOs
+
+}
+
+/*--------------------------------------------------------------------*/
+/* Board porting API */
+/*--------------------------------------------------------------------*/
+
+void board_led_write(bool state)
+{
+ // Combine red and blue for pink Because it looks good :)
+ GPIO->P[LED_PORT].DOUT = (GPIO->P[LED_PORT].DOUT & ~((1 << LED_PIN_R) | (1 << LED_PIN_B))) | (state << LED_PIN_R) | (state << LED_PIN_B);
+}
+
+uint32_t board_button_read(void)
+{
+ return !!(GPIO->P[BUTTON_PORT].DIN & (1 << BUTTON_PIN));
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
+void assert_failed(char *file, uint32_t line)
+{
+ /* USER CODE BEGIN 6 */
+ /* User can add his own implementation to report the file name and line number,
+ tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+ /* USER CODE END 6 */
+}
+#endif /* USE_FULL_ASSERT */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/spresense/board.mk b/circuitpython/lib/tinyusb/hw/bsp/spresense/board.mk
new file mode 100644
index 0000000..ba291e8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/spresense/board.mk
@@ -0,0 +1,74 @@
+DEPS_SUBMODULES += hw/mcu/sony/cxd56/spresense-exported-sdk
+
+# Platforms are: Linux, Darwin, MSYS, CYGWIN
+PLATFORM := $(firstword $(subst _, ,$(shell uname -s 2>/dev/null)))
+
+ifeq ($(PLATFORM),Darwin)
+ # macOS
+ MKSPK = $(TOP)/hw/mcu/sony/cxd56/mkspk/mkspk
+else ifeq ($(PLATFORM),Linux)
+ # Linux
+ MKSPK = $(TOP)/hw/mcu/sony/cxd56/mkspk/mkspk
+else
+ # Cygwin/MSYS2
+ MKSPK = $(TOP)/hw/mcu/sony/cxd56/mkspk/mkspk.exe
+endif
+
+SERIAL ?= /dev/ttyUSB0
+
+CFLAGS += \
+ -DCONFIG_HAVE_DOUBLE \
+ -Dmain=spresense_main \
+ -pipe \
+ -std=gnu11 \
+ -mcpu=cortex-m4 \
+ -mthumb \
+ -mfpu=fpv4-sp-d16 \
+ -mfloat-abi=hard \
+ -mabi=aapcs \
+ -fno-builtin \
+ -fno-strength-reduce \
+ -fomit-frame-pointer \
+ -Wno-error=undef \
+ -Wno-error=cast-align \
+ -Wno-error=unused-parameter \
+ -DCFG_TUSB_MCU=OPT_MCU_CXD56 \
+
+# lwip/src/core/raw.c:334:43: error: declaration of 'recv' shadows a global declaration
+CFLAGS += -Wno-error=shadow
+
+SPRESENSE_SDK = $(TOP)/hw/mcu/sony/cxd56/spresense-exported-sdk
+
+SRC_C += src/portable/sony/cxd56/dcd_cxd56.c
+
+INC += \
+ $(SPRESENSE_SDK)/nuttx/include \
+ $(SPRESENSE_SDK)/nuttx/arch \
+ $(SPRESENSE_SDK)/nuttx/arch/chip \
+ $(SPRESENSE_SDK)/nuttx/arch/os \
+ $(SPRESENSE_SDK)/sdk/include \
+
+LIBS += \
+ $(SPRESENSE_SDK)/nuttx/libs/libapps.a \
+ $(SPRESENSE_SDK)/nuttx/libs/libnuttx.a \
+
+LD_FILE = hw/mcu/sony/cxd56/spresense-exported-sdk/nuttx/scripts/ramconfig.ld
+
+LDFLAGS += \
+ -Xlinker --entry=__start \
+ -nostartfiles \
+ -nodefaultlibs \
+ -Wl,--gc-sections \
+ -u spresense_main
+
+$(MKSPK): $(BUILD)/$(PROJECT).elf
+ $(MAKE) -C $(TOP)/hw/mcu/sony/cxd56/mkspk
+
+$(BUILD)/$(PROJECT).spk: $(MKSPK)
+ @echo CREATE $@
+ @$(MKSPK) -c 2 $(BUILD)/$(PROJECT).elf nuttx $@
+
+# flash
+flash: $(BUILD)/$(PROJECT).spk
+ @echo FLASH $<
+ @$(PYTHON) $(TOP)/hw/mcu/sony/cxd56/tools/flash_writer.py -s -c $(SERIAL) -d -b 115200 -n $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/spresense/board_spresense.c b/circuitpython/lib/tinyusb/hw/bsp/spresense/board_spresense.c
new file mode 100644
index 0000000..256bccd
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/spresense/board_spresense.c
@@ -0,0 +1,105 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright 2019 Sony Semiconductor Solutions Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include <sys/boardctl.h>
+#include <nuttx/arch.h>
+#include <arch/board/board.h>
+#include <arch/chip/pin.h>
+
+#include "bsp/board.h"
+
+/*------------------------------------------------------------------*/
+/* MACRO TYPEDEF CONSTANT ENUM
+ *------------------------------------------------------------------*/
+#define LED_PIN PIN_I2S1_BCK
+
+#define BUTTON_PIN PIN_HIF_IRQ_OUT
+
+// Initialize on-board peripherals : led, button, uart and USB
+void board_init(void)
+{
+ boardctl(BOARDIOC_INIT, 0);
+
+ board_gpio_write(PIN_I2S1_BCK, -1);
+ board_gpio_config(PIN_I2S1_BCK, 0, false, true, PIN_FLOAT);
+
+ board_gpio_write(PIN_HIF_IRQ_OUT, -1);
+ board_gpio_config(PIN_HIF_IRQ_OUT, 0, true, true, PIN_FLOAT);
+};
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+// Turn LED on or off
+void board_led_write(bool state)
+{
+ board_gpio_write(LED_PIN, state);
+}
+
+// Get the current state of button
+// a '1' means active (pressed), a '0' means inactive.
+uint32_t board_button_read(void)
+{
+ if (board_gpio_read(BUTTON_PIN))
+ {
+ return 0;
+ }
+
+ return 1;
+}
+
+// Get characters from UART
+int board_uart_read(uint8_t *buf, int len)
+{
+ int r = read(0, buf, len);
+
+ return r;
+}
+
+// Send characters to UART
+int board_uart_write(void const *buf, int len)
+{
+ int r = write(1, buf, len);
+
+ return r;
+}
+
+// Get current milliseconds
+uint32_t board_millis(void)
+{
+ struct timespec tp;
+
+ /* Wait until RTC is available */
+ while (g_rtc_enabled == false);
+
+ if (clock_gettime(CLOCK_MONOTONIC, &tp))
+ {
+ return 0;
+ }
+
+ return (((uint64_t)tp.tv_sec) * 1000 + tp.tv_nsec / 1000000);
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.h
new file mode 100644
index 0000000..7c527e2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.h
@@ -0,0 +1,93 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_5
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART2
+#define UART_CLK_EN __HAL_RCC_USART2_CLK_ENABLE
+#define UART_GPIO_PORT GPIOA
+#define UART_GPIO_AF GPIO_AF1_USART2
+#define UART_TX_PIN GPIO_PIN_2
+#define UART_RX_PIN GPIO_PIN_3
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32f0_clock_init(void)
+{
+ /* Configure the system clock to 48 MHz */
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
+
+ /* Enable HSE Oscillator and activate PLL with 8 MHz HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
+ RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
+
+
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) ;
+}
+
+static inline void board_vbus_sense_init(void)
+{
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk
new file mode 100644
index 0000000..7c0ee40
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F070xB -DCFG_EXAMPLE_VIDEO_READONLY
+
+LD_FILE = $(BOARD_PATH)/stm32F070rbtx_flash.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f070xb.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f070rb
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/stm32F070rbtx_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/stm32F070rbtx_flash.ld
new file mode 100644
index 0000000..59e18f3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f070rbnucleo/stm32F070rbtx_flash.ld
@@ -0,0 +1,200 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by STM32CubeIDE
+**
+** Abstract : Linker script for STM32F070RBTx Device from STM32F0 series
+** 128Kbytes FLASH
+** 16Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+**
+** Redistribution and use in source and binary forms, with or without modification,
+** are permitted provided that the following conditions are met:
+** 1. Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+** 3. Neither the name of STMicroelectronics nor the names of its contributors
+** may be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20004000; /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/STM32F072RBTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/STM32F072RBTx_FLASH.ld
new file mode 100644
index 0000000..8d31f6a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/STM32F072RBTx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F072RBTx Device with
+** 128KByte FLASH, 16KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20004000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.h
new file mode 100644
index 0000000..0b1824b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.h
@@ -0,0 +1,85 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOC
+#define LED_PIN GPIO_PIN_6
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+#define UART_DEV USART1
+#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOA
+#define UART_GPIO_AF GPIO_AF1_USART1
+#define UART_TX_PIN GPIO_PIN_9
+#define UART_RX_PIN GPIO_PIN_10
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32f0_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Select HSI48 Oscillator as PLL source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI48;
+ RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV2;
+ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK and PCLK1 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.mk
new file mode 100644
index 0000000..7c72d8f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072disco/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F072xB -DCFG_EXAMPLE_VIDEO_READONLY
+
+LD_FILE = $(BOARD_PATH)/STM32F072RBTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f072xb.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f072rb
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld
new file mode 100644
index 0000000..581613a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld
@@ -0,0 +1,177 @@
+/**
+ ******************************************************************************
+ * @file LinkerScript.ld
+ * @author Auto-generated by STM32CubeIDE
+ * Abstract : Linker script for STM32072B-EVAL Board embedding STM32F072VBTx Device from stm32f0 series
+ * 128Kbytes FLASH
+ * 16Kbytes RAM
+ *
+ * Set heap size, stack size and stack location according
+ * to application requirements.
+ *
+ * Set memory bank area and size if external memory is used
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.h
new file mode 100644
index 0000000..8869d5d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.h
@@ -0,0 +1,102 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOD
+#define LED_PIN GPIO_PIN_8 // LED1, GREEN
+// #define LED_PIN GPIO_PIN_9 // LED2, ORANGE
+// #define LED_PIN GPIO_PIN_10 // LED3, RED
+// #define LED_PIN GPIO_PIN_11 // LED4, BLUE
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0 // JOY_SEL
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+#define UART_DEV USART2
+#define UART_CLK_EN __HAL_RCC_USART2_CLK_ENABLE
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF0_USART2
+#define UART_TX_PIN GPIO_PIN_5
+#define UART_RX_PIN GPIO_PIN_6
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32f0_clock_init(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
+
+ /** Initializes the RCC Oscillators according to the specified parameters
+ * in the RCC_OscInitTypeDef structure.
+ */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
+ RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
+ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
+ RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
+
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /** Initializes the CPU, AHB and APB buses clocks
+ */
+ RCC_ClkInitStruct.ClockType =
+ RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
+
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART2;
+ PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.mk
new file mode 100644
index 0000000..b625c3e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/boards/stm32f072eval/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F072xB -DLSI_VALUE=40000 -DCFG_EXAMPLE_VIDEO_READONLY
+
+LD_FILE = $(BOARD_PATH)/STM32F072VBTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f072xb.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f072vb
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.c
new file mode 100644
index 0000000..8de3147
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.c
@@ -0,0 +1,182 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32f0xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_stm32f0_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOF_CLK_ENABLE();
+
+ // Enable UART Clock
+ UART_CLK_EN();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+ // LED
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // Uart
+ GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+
+ UartHandle.Instance = UART_DEV;
+ UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
+ UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
+ UartHandle.Init.StopBits = UART_STOPBITS_1;
+ UartHandle.Init.Parity = UART_PARITY_NONE;
+ UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ UartHandle.Init.Mode = UART_MODE_TX_RX;
+ UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
+ HAL_UART_Init(&UartHandle);
+
+ // USB Pins
+ // Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // USB Clock enable
+ __HAL_RCC_USB_CLK_ENABLE();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
+void assert_failed(uint8_t* file, uint32_t line)
+{
+ (void) file; (void) line;
+ /* USER CODE BEGIN 6 */
+ /* User can add his own implementation to report the file name and line number,
+ tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+ /* USER CODE END 6 */
+}
+#endif /* USE_FULL_ASSERT */
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.mk
new file mode 100644
index 0000000..39831e1
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/family.mk
@@ -0,0 +1,40 @@
+UF2_FAMILY_ID = 0x647824b6
+ST_FAMILY = f0
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0 \
+ -mfloat-abi=soft \
+ -nostdlib -nostartfiles \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32F0
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual
+
+SRC_C += \
+ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f0/stm32f0xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/stm32f0xx_hal_conf.h
new file mode 100644
index 0000000..cfa66b3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f0/stm32f0xx_hal_conf.h
@@ -0,0 +1,321 @@
+/**
+ ******************************************************************************
+ * @file stm32f0xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F0xx_HAL_CONF_H
+#define __STM32F0xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/*#define HAL_ADC_MODULE_ENABLED */
+/*#define HAL_CAN_MODULE_ENABLED */
+/*#define HAL_CEC_MODULE_ENABLED */
+/*#define HAL_COMP_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/*#define HAL_CRC_MODULE_ENABLED */
+/*#define HAL_DAC_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+/*#define HAL_EXTI_MODULE_ENABLED */
+/*#define HAL_I2C_MODULE_ENABLED */
+/*#define HAL_I2S_MODULE_ENABLED */
+/*#define HAL_IRDA_MODULE_ENABLED */
+/*#define HAL_IWDG_MODULE_ENABLED */
+#define HAL_PCD_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+/*#define HAL_RTC_MODULE_ENABLED */
+/*#define HAL_SMARTCARD_MODULE_ENABLED */
+/*#define HAL_SMBUS_MODULE_ENABLED */
+/*#define HAL_SPI_MODULE_ENABLED */
+/*#define HAL_TIM_MODULE_ENABLED */
+/*#define HAL_TSC_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/*#define HAL_USART_MODULE_ENABLED */
+/*#define HAL_WWDG_MODULE_ENABLED */
+
+/* ######################### Oscillator Values adaptation ################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+/**
+ * @brief In the following line adjust the External High Speed oscillator (HSE) Startup
+ * Timeout value
+ */
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup
+ * Timeout value
+ */
+#if !defined (HSI_STARTUP_TIMEOUT)
+ #define HSI_STARTUP_TIMEOUT 5000U /*!< Time out for HSI start up */
+#endif /* HSI_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator for ADC (HSI14) value.
+ */
+#if !defined (HSI14_VALUE)
+ #define HSI14_VALUE 14000000U /*!< Value of the Internal High Speed oscillator for ADC in Hz.
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+#endif /* HSI14_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator for USB (HSI48) value.
+ */
+#if !defined (HSI48_VALUE)
+ #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB in Hz.
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+#endif /* HSI48_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE 32000U
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+/**
+ * @brief Time out for LSE start up value in ms.
+ */
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE 3300U /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)(1U<<__NVIC_PRIO_BITS) - 1U) /*!< tick interrupt priority (lowest by default) */
+ /* Warning: Must be set to higher priority for HAL_Delay() */
+ /* and HAL_GetTick() usage under interrupt context */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 0U
+#define DATA_CACHE_ENABLE 0U
+#define USE_SPI_CRC 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_TSC_REGISTER_CALLBACKS 0U /* TSC register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+ #define USE_FULL_ASSERT 1
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f0xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f0xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f0xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f0xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f0xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f0xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f0xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f0xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+ #include "stm32f0xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f0xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f0xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f0xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f0xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f0xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f0xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f0xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f0xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f0xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f0xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f0xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f0xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f0xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f0xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_TSC_MODULE_ENABLED
+ #include "stm32f0xx_hal_tsc.h"
+#endif /* HAL_TSC_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f0xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f0xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f0xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F0xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/STM32F103X8_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/STM32F103X8_FLASH.ld
new file mode 100644
index 0000000..ca18049
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/STM32F103X8_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+** File : STM32F103XB_FLASH.ld
+**
+** Abstract : Linker script for STM32F103xB Device with
+** 128KByte FLASH, 20KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20004FFF; /* end of RAM */
+
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.h
new file mode 100644
index 0000000..57a607e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.h
@@ -0,0 +1,92 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOC
+#define LED_PIN GPIO_PIN_13
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+//#define UART_DEV USART1
+//#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+//#define UART_GPIO_PORT GPIOA
+//#define UART_GPIO_AF GPIO_AF1_USART1
+//#define UART_TX_PIN GPIO_PIN_9
+//#define UART_RX_PIN GPIO_PIN_10
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32f1_clock_init(void)
+{
+ RCC_ClkInitTypeDef clkinitstruct = {0};
+ RCC_OscInitTypeDef oscinitstruct = {0};
+ RCC_PeriphCLKInitTypeDef rccperiphclkinit = {0};
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ oscinitstruct.HSEState = RCC_HSE_ON;
+ oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
+ oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9;
+ oscinitstruct.PLL.PLLState = RCC_PLL_ON;
+ oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ HAL_RCC_OscConfig(&oscinitstruct);
+
+ /* USB clock selection */
+ rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ rccperiphclkinit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
+ HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.mk
new file mode 100644
index 0000000..db64b3a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_bluepill/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F103xB -DHSE_VALUE=8000000U -DCFG_EXAMPLE_VIDEO_READONLY
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32F103X8_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f103xb.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f103c8
+
+# flash target ROM bootloader
+flash: flash-dfu-util
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/STM32F103XC_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/STM32F103XC_FLASH.ld
new file mode 100644
index 0000000..da40d1e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/STM32F103XC_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+** File : STM32F103XB_FLASH.ld
+**
+** Abstract : Linker script for STM32F103xB Device with
+** 128KByte FLASH, 20KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20004FFF; /* end of RAM */
+
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.h
new file mode 100644
index 0000000..bedce7f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.h
@@ -0,0 +1,92 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_8
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+//#define UART_DEV USART1
+//#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+//#define UART_GPIO_PORT GPIOA
+//#define UART_GPIO_AF GPIO_AF1_USART1
+//#define UART_TX_PIN GPIO_PIN_9
+//#define UART_RX_PIN GPIO_PIN_10
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32f1_clock_init(void)
+{
+ RCC_ClkInitTypeDef clkinitstruct = {0};
+ RCC_OscInitTypeDef oscinitstruct = {0};
+ RCC_PeriphCLKInitTypeDef rccperiphclkinit = {0};
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ oscinitstruct.HSEState = RCC_HSE_ON;
+ oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
+ oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9;
+ oscinitstruct.PLL.PLLState = RCC_PLL_ON;
+ oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ HAL_RCC_OscConfig(&oscinitstruct);
+
+ /* USB clock selection */
+ rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ rccperiphclkinit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
+ HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.mk
new file mode 100644
index 0000000..eeda870
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/boards/stm32f103_mini_2/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F103xB -DHSE_VALUE=8000000U
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32F103XC_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f103xb.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f103rc
+
+# flash target ROM bootloader
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.c
new file mode 100644
index 0000000..8fcf9eb
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.c
@@ -0,0 +1,167 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32f1xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_HP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB_LP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USBWakeUp_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+void board_init(void)
+{
+ board_stm32f1_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_HP_CAN1_TX_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+ NVIC_SetPriority(USBWakeUp_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+
+ // LED
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = LED_STATE_ON ? GPIO_PULLDOWN : GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // USB Pins
+ // Configure USB DM and DP pins.
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // USB Clock enable
+ __HAL_RCC_USB_CLK_ENABLE();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
+void assert_failed(char *file, uint32_t line)
+{
+ /* USER CODE BEGIN 6 */
+ /* User can add his own implementation to report the file name and line number,
+ tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+ /* USER CODE END 6 */
+}
+#endif /* USE_FULL_ASSERT */
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.mk
new file mode 100644
index 0000000..3fb2e6e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/family.mk
@@ -0,0 +1,45 @@
+ST_FAMILY = f1
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -mfloat-abi=soft \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32F1
+
+# mcu driver cause following warnings
+#CFLAGS += -Wno-error=unused-parameter
+
+# All source paths should be relative to the top level.
+SRC_C += \
+ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f103c8
+
+# flash target ROM bootloader
+flash-dfu-util: $(BUILD)/$(PROJECT).bin
+ dfu-util -R -a 0 --dfuse-address 0x08000000 -D $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f1/stm32f1xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/stm32f1xx_hal_conf.h
new file mode 100644
index 0000000..a4a3f30
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f1/stm32f1xx_hal_conf.h
@@ -0,0 +1,379 @@
+/**
+ ******************************************************************************
+ * @file USB_Device/HID_Standalone/Inc/stm32f1xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration template file.
+ * This file should be copied to the application folder and renamed
+ * to stm32f1xx_hal_conf.h.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F1xx_HAL_CONF_H
+#define __STM32F1xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+#define HAL_PCD_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+
+/* ########################## Oscillator Values adaptation ####################*/
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+#if defined(USE_STM3210C_EVAL)
+ #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
+#else
+ #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
+#endif
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ * This value is used by the UART, RTC HAL module to compute the system frequency
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE 3300U /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f1xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f1xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f1xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f1xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f1xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "Legacy/stm32f1xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f1xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f1xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f1xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f1xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f1xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f1xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f1xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f1xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f1xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f1xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f1xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f1xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f1xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f1xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f1xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f1xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f1xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f1xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f1xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f1xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f1xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f1xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f1xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F1xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/STM32F207ZGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/STM32F207ZGTx_FLASH.ld
new file mode 100644
index 0000000..29e387f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/STM32F207ZGTx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F207IGHx Device with
+** 1024KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/board.mk
new file mode 100644
index 0000000..fa7d283
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/board.mk
@@ -0,0 +1,48 @@
+ST_FAMILY = f2
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m3 \
+ -mfloat-abi=soft \
+ -nostdlib -nostartfiles \
+ -DSTM32F207xx \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32F2
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=sign-compare
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/STM32F207ZGTx_FLASH.ld
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+SRC_S += \
+ $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f207xx.s
+
+INC += \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc \
+ $(TOP)/hw/bsp/$(BOARD)
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM3
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f207zg
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f207nucleo.c b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f207nucleo.c
new file mode 100644
index 0000000..619c90d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f207nucleo.c
@@ -0,0 +1,213 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+
+#include "stm32f2xx_hal.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void OTG_FS_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+
+// enable all LED, Button, Uart, USB clock
+static void all_rcc_clk_enable(void)
+{
+ __HAL_RCC_GPIOA_CLK_ENABLE(); // USB D+, D-
+ __HAL_RCC_GPIOB_CLK_ENABLE(); // LED
+ __HAL_RCC_GPIOC_CLK_ENABLE(); // Button
+}
+
+/**
+ * @brief System Clock Configuration
+ * The system Clock is configured as follow :
+ * System Clock source = PLL (HSE)
+ * SYSCLK(Hz) = 120000000
+ * HCLK(Hz) = 120000000
+ * AHB Prescaler = 1
+ * APB1 Prescaler = 4
+ * APB2 Prescaler = 2
+ * HSE Frequency(Hz) = 8000000
+ * PLL_M = HSE_VALUE/1000000
+ * PLL_N = 240
+ * PLL_P = 2
+ * PLL_Q = 5
+ * VDD(V) = 3.3
+ * Flash Latency(WS) = 3
+ * @param None
+ * @retval None
+ */
+void SystemClock_Config(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 240;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 5;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+}
+
+void board_init(void)
+{
+ SystemClock_Config();
+
+ #if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+ #endif
+
+
+ all_rcc_clk_enable();
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ board_led_write(false);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ /* Configure DM DP Pins */
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Configure VBUS Pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Configure ID pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Enable USB FS Clocks */
+ __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f2xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f2xx_hal_conf.h
new file mode 100644
index 0000000..2ab46b2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f207nucleo/stm32f2xx_hal_conf.h
@@ -0,0 +1,407 @@
+/**
+ ******************************************************************************
+ * @file stm32f2xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F2xx_HAL_CONF_H
+#define __STM32F2xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+/* #define HAL_DMA_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+/* #define HAL_UART_MODULE_ENABLED */
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE 3300U /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 5U /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 5U /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f2xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f2xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f2xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f2xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f2xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f2xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f2xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f2xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f2xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f2xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f2xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f2xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f2xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f2xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f2xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f2xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f2xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f2xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f2xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f2xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f2xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f2xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f2xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f2xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f2xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f2xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f2xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f2xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f2xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f2xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f2xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f2xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f2xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f2xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F2xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/STM32F303VCTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/STM32F303VCTx_FLASH.ld
new file mode 100644
index 0000000..ca9046d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/STM32F303VCTx_FLASH.ld
@@ -0,0 +1,189 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F303VCTx Device with
+** 256KByte FLASH, 40KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x2000a000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x800;; /* required amount of heap */
+_Min_Stack_Size = 0x800;; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
+CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 8K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ _siccmram = LOADADDR(.ccmram);
+
+ /* CCM-RAM section
+ *
+ * IMPORTANT NOTE!
+ * If initialized variables will be placed in this section,
+ * the startup code needs to be modified to copy the init-values.
+ */
+ .ccmram :
+ {
+ . = ALIGN(4);
+ _sccmram = .; /* create a global symbol at ccmram start */
+ *(.ccmram)
+ *(.ccmram*)
+
+ . = ALIGN(4);
+ _eccmram = .; /* create a global symbol at ccmram end */
+ } >CCMRAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/board.mk
new file mode 100644
index 0000000..9dd27a8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/board.mk
@@ -0,0 +1,49 @@
+ST_FAMILY = f3
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DSTM32F303xC \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32F3
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/STM32F303VCTx_FLASH.ld
+
+SRC_C += \
+ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+SRC_S += \
+ $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f303xc.s
+
+INC += \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc \
+ $(TOP)/hw/bsp/$(BOARD)
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f303vc
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f303disco.c b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f303disco.c
new file mode 100644
index 0000000..33552bc
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f303disco.c
@@ -0,0 +1,215 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+#include "stm32f3xx_hal.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+
+// USB defaults to using interrupts 19, 20 and 42, however, this BSP sets the
+// SYSCFG_CFGR1.USB_IT_RMP bit remapping interrupts to 74, 75 and 76.
+
+// FIXME: Do all three need to be handled, or just the LP one?
+// USB high-priority interrupt (Channel 74): Triggered only by a correct
+// transfer event for isochronous and double-buffer bulk transfer to reach
+// the highest possible transfer rate.
+void USB_HP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+// USB low-priority interrupt (Channel 75): Triggered by all USB events
+// (Correct transfer, USB reset, etc.). The firmware has to check the
+// interrupt source before serving the interrupt.
+void USB_LP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+// USB wakeup interrupt (Channel 76): Triggered by the wakeup event from the USB
+// Suspend mode.
+void USBWakeUp_RMP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+#define LED_PORT GPIOE
+#define LED_PIN GPIO_PIN_9
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+
+/**
+ * @brief System Clock Configuration
+ * The system Clock is configured as follow :
+ * System Clock source = PLL (HSE)
+ * SYSCLK(Hz) = 72000000
+ * HCLK(Hz) = 72000000
+ * AHB Prescaler = 1
+ * APB1 Prescaler = 2
+ * APB2 Prescaler = 1
+ * HSE Frequency(Hz) = 8000000
+ * HSE PREDIV = 1
+ * PLLMUL = RCC_PLL_MUL9 (9)
+ * Flash Latency(WS) = 2
+ * @param None
+ * @retval None
+ */
+static void SystemClock_Config(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Configures the USB clock */
+ HAL_RCCEx_GetPeriphCLKConfig(&RCC_PeriphClkInit);
+ RCC_PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
+ HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+
+ /* Enable Power Clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+}
+
+void board_init(void)
+{
+ SystemClock_Config();
+
+ #if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+ #endif
+
+ // Remap the USB interrupts
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+ __HAL_REMAPINTERRUPT_USB_ENABLE();
+
+ // LED
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ // Button
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ /* Configure USB DM and DP pins */
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF14_USB;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // Enable USB clock
+ __HAL_RCC_USB_CLK_ENABLE();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f3xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f3xx_hal_conf.h
new file mode 100644
index 0000000..0abcbb0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f303disco/stm32f3xx_hal_conf.h
@@ -0,0 +1,357 @@
+/**
+ ******************************************************************************
+ * @file stm32f3xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F3xx_HAL_CONF_H
+#define __STM32F3xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_COMP_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_HRTIM_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_OPAMP_MODULE_ENABLED */
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_PWR_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SDADC_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+/* #define HAL_TSC_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+/**
+ * @brief In the following line adjust the External High Speed oscillator (HSE) Startup
+ * Timeout value
+ */
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (8000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup
+ * Timeout value
+ */
+#if !defined (HSI_STARTUP_TIMEOUT)
+ #define HSI_STARTUP_TIMEOUT (5000U) /*!< Time out for HSI start up */
+#endif /* HSI_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (40000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+/**
+ * @brief Time out for LSE start up value in ms.
+ */
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ * - External clock generated through external PLL component on EVAL 303 (based on MCO or crystal)
+ * - External clock not generated on EVAL 373
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (8000000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)(1U<<__NVIC_PRIO_BITS) - 1U) /*!< tick interrupt priority (lowest by default) */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 0U
+#define DATA_CACHE_ENABLE 0U
+#define USE_SPI_CRC 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SDADC_REGISTER_CALLBACKS 0U /* SDADC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* OPAMP register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_TSC_REGISTER_CALLBACKS 0U /* TSC register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/*#define USE_FULL_ASSERT 1U*/
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f3xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f3xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f3xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f3xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f3xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f3xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f3xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f3xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f3xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+ #include "stm32f3xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f3xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f3xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f3xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f3xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f3xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f3xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f3xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_HRTIM_MODULE_ENABLED
+ #include "stm32f3xx_hal_hrtim.h"
+#endif /* HAL_HRTIM_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f3xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f3xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f3xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f3xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_OPAMP_MODULE_ENABLED
+ #include "stm32f3xx_hal_opamp.h"
+#endif /* HAL_OPAMP_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f3xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f3xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f3xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SDADC_MODULE_ENABLED
+ #include "stm32f3xx_hal_sdadc.h"
+#endif /* HAL_SDADC_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f3xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f3xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f3xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f3xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_TSC_MODULE_ENABLED
+ #include "stm32f3xx_hal_tsc.h"
+#endif /* HAL_TSC_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f3xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f3xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f3xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F3xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/STM32F405RGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/STM32F405RGTx_FLASH.ld
new file mode 100644
index 0000000..57ef61e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/STM32F405RGTx_FLASH.ld
@@ -0,0 +1,189 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F405RGTx Device with
+** 1024KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ _siccmram = LOADADDR(.ccmram);
+
+ /* CCM-RAM section
+ *
+ * IMPORTANT NOTE!
+ * If initialized variables will be placed in this section,
+ * the startup code needs to be modified to copy the init-values.
+ */
+ .ccmram :
+ {
+ . = ALIGN(4);
+ _sccmram = .; /* create a global symbol at ccmram start */
+ *(.ccmram)
+ *(.ccmram*)
+
+ . = ALIGN(4);
+ _eccmram = .; /* create a global symbol at ccmram end */
+ } >CCMRAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.h
new file mode 100644
index 0000000..19d0a1e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.h
@@ -0,0 +1,104 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOC
+#define LED_PIN GPIO_PIN_1
+#define LED_STATE_ON 1
+
+// Button: Pin D5
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_7
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_DEV USART3
+#define UART_GPIO_PORT GPIOB
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_10
+#define UART_RX_PIN GPIO_PIN_11
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_USART3_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk
new file mode 100644
index 0000000..1de56fe
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk
@@ -0,0 +1,12 @@
+CFLAGS += -DSTM32F405xx
+
+LD_FILE = $(BOARD_PATH)/STM32F405RGTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f405rg
+
+# flash target ROM bootloader
+flash: $(BUILD)/$(PROJECT).bin
+ dfu-util -R -a 0 --dfuse-address 0x08000000 -D $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..b892df3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/feather_stm32f405/stm32f4xx_hal_conf.h
@@ -0,0 +1,491 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf.h
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_EXTI_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)12000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+/* Copied over manually- STM32Cube didn't generate these for some reason. */
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848_PHY_ADDRESS Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFFU)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/STM32F405RGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/STM32F405RGTx_FLASH.ld
new file mode 100644
index 0000000..57ef61e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/STM32F405RGTx_FLASH.ld
@@ -0,0 +1,189 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F405RGTx Device with
+** 1024KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ _siccmram = LOADADDR(.ccmram);
+
+ /* CCM-RAM section
+ *
+ * IMPORTANT NOTE!
+ * If initialized variables will be placed in this section,
+ * the startup code needs to be modified to copy the init-values.
+ */
+ .ccmram :
+ {
+ . = ALIGN(4);
+ _sccmram = .; /* create a global symbol at ccmram start */
+ *(.ccmram)
+ *(.ccmram*)
+
+ . = ALIGN(4);
+ _eccmram = .; /* create a global symbol at ccmram end */
+ } >CCMRAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.h
new file mode 100644
index 0000000..685919c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.h
@@ -0,0 +1,102 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Blue LED is chosen because the other LEDs are connected to ST-LINK lines.
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_4
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOB
+#define BUTTON_PIN GPIO_PIN_3
+#define BUTTON_STATE_ACTIVE 1
+
+// Enable PA2 as the debug log UART
+// It is not routed to the ST/Link on the Discovery board.
+//#define UART_DEV USART2
+//#define UART_GPIO_PORT GPIOA
+//#define UART_GPIO_AF GPIO_AF7_USART2
+//#define UART_TX_PIN GPIO_PIN_2
+//#define UART_RX_PIN GPIO_PIN_3
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.mk
new file mode 100644
index 0000000..02dcd12
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F405xx
+
+LD_FILE = $(BOARD_PATH)/STM32F405RGTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f405rg
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..b892df3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/pyboardv11/stm32f4xx_hal_conf.h
@@ -0,0 +1,491 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf.h
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_EXTI_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)12000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+/* Copied over manually- STM32Cube didn't generate these for some reason. */
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848_PHY_ADDRESS Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFFU)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/STM32F401VCTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/STM32F401VCTx_FLASH.ld
new file mode 100644
index 0000000..f51f1ab
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/STM32F401VCTx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F401VCTx Device with
+** 256KByte FLASH, 64KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20010000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200;; /* required amount of heap */
+_Min_Stack_Size = 0x400;; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.h
new file mode 100644
index 0000000..0f82051
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.h
@@ -0,0 +1,106 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOC
+#define LED_PIN GPIO_PIN_13
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 0
+
+// Enable PA2 as the debug log UART
+//#define UART_DEV USART2
+//#define UART_GPIO_PORT GPIOA
+//#define UART_GPIO_AF GPIO_AF7_USART2
+//#define UART_TX_PIN GPIO_PIN_2
+//#define UART_RX_PIN GPIO_PIN_3
+
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ //__HAL_RCC_USART2_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Blackpill doens't use VBUS sense (B device) explicitly disable it
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk
new file mode 100644
index 0000000..de0f3d4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk
@@ -0,0 +1,12 @@
+CFLAGS += -DSTM32F401xC
+
+LD_FILE = $(BOARD_PATH)/STM32F401VCTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f401xc.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f401cc
+
+# flash target ROM bootloader
+flash: $(BUILD)/$(PROJECT).bin
+ dfu-util -R -a 0 --dfuse-address 0x08000000 -D $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..2ab9a1d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f401blackpill/stm32f4xx_hal_conf.h
@@ -0,0 +1,493 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (25000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/STM32F407VGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/STM32F407VGTx_FLASH.ld
new file mode 100644
index 0000000..c416027
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/STM32F407VGTx_FLASH.ld
@@ -0,0 +1,189 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F407VGTx Device with
+** 1024KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x1000; /* required amount of heap */
+_Min_Stack_Size = 0x4000; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+ CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ _siccmram = LOADADDR(.ccmram);
+
+ /* CCM-RAM section
+ *
+ * IMPORTANT NOTE!
+ * If initialized variables will be placed in this section,
+ * the startup code needs to be modified to copy the init-values.
+ */
+ .ccmram :
+ {
+ . = ALIGN(4);
+ _sccmram = .; /* create a global symbol at ccmram start */
+ *(.ccmram)
+ *(.ccmram*)
+
+ . = ALIGN(4);
+ _eccmram = .; /* create a global symbol at ccmram end */
+ } >CCMRAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.h
new file mode 100644
index 0000000..693e039
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.h
@@ -0,0 +1,105 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOD
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// Enable PA2 as the debug log UART
+// It is not routed to the ST/Link on the Discovery board.
+#define UART_DEV USART2
+#define UART_GPIO_PORT GPIOA
+#define UART_GPIO_AF GPIO_AF7_USART2
+#define UART_TX_PIN GPIO_PIN_2
+#define UART_RX_PIN GPIO_PIN_3
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_USART2_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.mk
new file mode 100644
index 0000000..212b924
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F407xx
+
+LD_FILE = $(BOARD_PATH)/STM32F407VGTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f407xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f407vg
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..7864f8d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f407disco/stm32f4xx_hal_conf.h
@@ -0,0 +1,493 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/STM32F411CEUx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/STM32F411CEUx_FLASH.ld
new file mode 100644
index 0000000..efea1e0
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/STM32F411CEUx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F411CEUx Device with
+** 512KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200;; /* required amount of heap */
+_Min_Stack_Size = 0x400;; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(4);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(4);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.h
new file mode 100644
index 0000000..0f82051
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.h
@@ -0,0 +1,106 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOC
+#define LED_PIN GPIO_PIN_13
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 0
+
+// Enable PA2 as the debug log UART
+//#define UART_DEV USART2
+//#define UART_GPIO_PORT GPIOA
+//#define UART_GPIO_AF GPIO_AF7_USART2
+//#define UART_TX_PIN GPIO_PIN_2
+//#define UART_RX_PIN GPIO_PIN_3
+
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ //__HAL_RCC_USART2_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Blackpill doens't use VBUS sense (B device) explicitly disable it
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk
new file mode 100644
index 0000000..78be434
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk
@@ -0,0 +1,12 @@
+CFLAGS += -DSTM32F411xE
+
+LD_FILE = $(BOARD_PATH)/STM32F411CEUx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f411ce
+
+# flash target ROM bootloader
+flash: $(BUILD)/$(PROJECT).bin
+ dfu-util -R -a 0 --dfuse-address 0x08000000 -D $<
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..2ab9a1d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411blackpill/stm32f4xx_hal_conf.h
@@ -0,0 +1,493 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (25000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/STM32F411VETx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/STM32F411VETx_FLASH.ld
new file mode 100644
index 0000000..3a0ce52
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/STM32F411VETx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F411VETx Device with
+** 512KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200;; /* required amount of heap */
+_Min_Stack_Size = 0x400;; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.h
new file mode 100644
index 0000000..008a94a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.h
@@ -0,0 +1,104 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// Orange LED
+#define LED_PORT GPIOD
+#define LED_PIN GPIO_PIN_13
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// Enable PA2 as the debug log UART
+#define UART_DEV USART2
+#define UART_GPIO_PORT GPIOA
+#define UART_GPIO_AF GPIO_AF7_USART2
+#define UART_TX_PIN GPIO_PIN_2
+#define UART_RX_PIN GPIO_PIN_3
+
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_USART2_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.mk
new file mode 100644
index 0000000..48272ac
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F411xE
+
+LD_FILE = $(BOARD_PATH)/STM32F411VETx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f411ve
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..7864f8d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f411disco/stm32f4xx_hal_conf.h
@@ -0,0 +1,493 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/STM32F412ZGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/STM32F412ZGTx_FLASH.ld
new file mode 100644
index 0000000..b00b5db
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/STM32F412ZGTx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F412ZGTx Device with
+** 1024KByte FLASH, 256KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20040000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.h
new file mode 100644
index 0000000..7f4a4fa
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.h
@@ -0,0 +1,118 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOE
+#define LED_PIN GPIO_PIN_2
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// UART Enable PA2 as the debug log UART
+#define UART_DEV USART2
+#define UART_GPIO_PORT GPIOA
+#define UART_GPIO_AF GPIO_AF7_USART2
+#define UART_TX_PIN GPIO_PIN_2
+#define UART_RX_PIN GPIO_PIN_3
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the
+ * device is clocked below the maximum system frequency, to update the
+ * voltage scaling value regarding system frequency refer to product
+ * datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 200;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLLSAI output as USB clock source */
+ PeriphClkInitStruct.PLLI2S.PLLI2SM = 8;
+ PeriphClkInitStruct.PLLI2S.PLLI2SQ = 4;
+ PeriphClkInitStruct.PLLI2S.PLLI2SN = 192;
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CK48;
+ PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLI2SQ;
+ PeriphClkInitStruct.PLLI2SSelection = RCC_PLLI2SCLKSOURCE_PLLSRC;
+ PeriphClkInitStruct.PLLI2S.PLLI2SR = 7;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ * clocks dividers */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
+ RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_USART2_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.mk
new file mode 100644
index 0000000..50973f7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F412Zx
+
+LD_FILE = $(BOARD_PATH)/STM32F412ZGTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f412zx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f412zg
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..7864f8d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412disco/stm32f4xx_hal_conf.h
@@ -0,0 +1,493 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/STM32F412ZGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/STM32F412ZGTx_FLASH.ld
new file mode 100644
index 0000000..b00b5db
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/STM32F412ZGTx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F412ZGTx Device with
+** 1024KByte FLASH, 256KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20040000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.h
new file mode 100644
index 0000000..73c5f83
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.h
@@ -0,0 +1,119 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+// UART Enable for STLink VCOM
+#define UART_DEV USART3
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_8
+#define UART_RX_PIN GPIO_PIN_9
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the
+ * device is clocked below the maximum system frequency, to update the
+ * voltage scaling value regarding system frequency refer to product
+ * datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 200;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLLSAI output as USB clock source */
+ PeriphClkInitStruct.PLLI2S.PLLI2SM = 8;
+ PeriphClkInitStruct.PLLI2S.PLLI2SQ = 4;
+ PeriphClkInitStruct.PLLI2S.PLLI2SN = 192;
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CK48;
+ PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLI2SQ;
+ PeriphClkInitStruct.PLLI2SSelection = RCC_PLLI2SCLKSOURCE_PLLSRC;
+ PeriphClkInitStruct.PLLI2S.PLLI2SR = 7;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ * clocks dividers */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
+ RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_USART3_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk
new file mode 100644
index 0000000..50973f7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F412Zx
+
+LD_FILE = $(BOARD_PATH)/STM32F412ZGTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f412zx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f412zg
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..7864f8d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f412nucleo/stm32f4xx_hal_conf.h
@@ -0,0 +1,493 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/STM32F439ZITX_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/STM32F439ZITX_FLASH.ld
new file mode 100644
index 0000000..2dc277c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/STM32F439ZITX_FLASH.ld
@@ -0,0 +1,206 @@
+/*
+******************************************************************************
+**
+** @file : LinkerScript.ld
+**
+** @author : Auto-generated by STM32CubeIDE
+**
+** Abstract : Linker script for NUCLEO-F439ZI Board embedding STM32F439ZITx Device from stm32f4 series
+** 2048Kbytes FLASH
+** 64Kbytes CCMRAM
+** 192Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+******************************************************************************
+** @attention
+**
+** Copyright (c) 2021 STMicroelectronics.
+** All rights reserved.
+**
+** This software is licensed under terms that can be found in the LICENSE file
+** in the root directory of this software component.
+** If no LICENSE file comes with this software, it is provided AS-IS.
+**
+******************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ _siccmram = LOADADDR(.ccmram);
+
+ /* CCM-RAM section
+ *
+ * IMPORTANT NOTE!
+ * If initialized variables will be placed in this section,
+ * the startup code needs to be modified to copy the init-values.
+ */
+ .ccmram :
+ {
+ . = ALIGN(4);
+ _sccmram = .; /* create a global symbol at ccmram start */
+ *(.ccmram)
+ *(.ccmram*)
+
+ . = ALIGN(4);
+ _eccmram = .; /* create a global symbol at ccmram end */
+ } >CCMRAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.h
new file mode 100644
index 0000000..e5a8224
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.h
@@ -0,0 +1,108 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+// UART Enable for STLink VCOM
+#define UART_DEV USART3
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_8
+#define UART_RX_PIN GPIO_PIN_9
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the
+ * device is clocked below the maximum system frequency, to update the
+ * voltage scaling value regarding system frequency refer to product
+ * datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ * clocks dividers */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
+ RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+
+ // Enable clocks for LED, Button, Uart
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_USART3_CLK_ENABLE();
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk
new file mode 100644
index 0000000..b7b36a8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DSTM32F439xx
+
+LD_FILE = $(BOARD_PATH)/STM32F439ZITX_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f439xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f439zi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/stm32f4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000..a2c11d7
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/boards/stm32f439nucleo/stm32f4xx_hal_conf.h
@@ -0,0 +1,486 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+// #define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE (32000U)
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE (3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* LAN8742A_PHY_ADDRESS Address*/
+#define LAN8742A_PHY_ADDRESS 0U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY 0x000000FFU
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY 0x00000FFFU
+
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00U) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01U) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
+
+#define PHY_ISFR ((uint16_t)0x001DU) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x000BU) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32f4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.c
new file mode 100644
index 0000000..82d4957
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.c
@@ -0,0 +1,201 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32f4xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void OTG_FS_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void OTG_HS_IRQHandler(void)
+{
+ tud_int_handler(1);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_clock_init();
+ //SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ board_led_write(false);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+#ifdef UART_DEV
+ // UART
+ GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+
+ UartHandle = (UART_HandleTypeDef){
+ .Instance = UART_DEV,
+ .Init.BaudRate = CFG_BOARD_UART_BAUDRATE,
+ .Init.WordLength = UART_WORDLENGTH_8B,
+ .Init.StopBits = UART_STOPBITS_1,
+ .Init.Parity = UART_PARITY_NONE,
+ .Init.HwFlowCtl = UART_HWCONTROL_NONE,
+ .Init.Mode = UART_MODE_TX_RX,
+ .Init.OverSampling = UART_OVERSAMPLING_16
+ };
+ HAL_UART_Init(&UartHandle);
+#endif
+
+ /* Configure USB FS GPIOs */
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+
+ /* Configure USB D+ D- Pins */
+ GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
+ GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Configure VBUS Pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* ID Pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+#ifdef STM32F412Zx
+ /* Configure POWER_SWITCH IO pin */
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ GPIO_InitStruct.Pin = GPIO_PIN_8;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
+#endif
+
+ // Enable USB OTG clock
+ __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+// __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
+
+ board_vbus_sense_init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+#ifdef UART_DEV
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+#else
+ (void) buf; (void) len; (void) UartHandle;
+ return 0;
+#endif
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.mk
new file mode 100644
index 0000000..9811d33
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f4/family.mk
@@ -0,0 +1,43 @@
+UF2_FAMILY_ID = 0x57755a57
+ST_FAMILY = f4
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32F4
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/STM32F723xE_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/STM32F723xE_FLASH.ld
new file mode 100644
index 0000000..8645ce5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/STM32F723xE_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F723xE Device with
+** 512KByte FLASH, 256KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20040000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x460; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.h
new file mode 100644
index 0000000..d0ef662
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.h
@@ -0,0 +1,101 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_10
+#define LED_STATE_ON 1
+
+// No physical button is populated
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART6
+#define UART_CLK_EN __HAL_RCC_USART6_CLK_ENABLE
+#define UART_GPIO_AF GPIO_AF8_USART6
+
+#define UART_TX_PORT GPIOG
+#define UART_TX_PIN GPIO_PIN_9
+
+#define UART_RX_PORT GPIOG
+#define UART_RX_PIN GPIO_PIN_14
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 432;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 9;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Activate the OverDrive to reach the 216 MHz Frequency */
+ HAL_PWREx_EnableOverDrive();
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk
new file mode 100644
index 0000000..a18b323
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk
@@ -0,0 +1,14 @@
+# Only OTG-HS has a connector on this board
+PORT ?= 1
+SPEED ?= high
+
+CFLAGS += \
+ -DSTM32F723xx \
+ -DHSE_VALUE=25000000 \
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32F723xE_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f723xx.s
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/stm32f7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/stm32f7xx_hal_conf.h
new file mode 100644
index 0000000..581f0e4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stlinkv3mini/stm32f7xx_hal_conf.h
@@ -0,0 +1,472 @@
+/**
+ ******************************************************************************
+ * @file stm32f7xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F7xx_HAL_CONF_H
+#define __STM32F7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x00000FFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f7xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f7xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32f7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32f7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/STM32F723xE_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/STM32F723xE_FLASH.ld
new file mode 100644
index 0000000..8645ce5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/STM32F723xE_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F723xE Device with
+** 512KByte FLASH, 256KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20040000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x460; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.h
new file mode 100644
index 0000000..93d83ef
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.h
@@ -0,0 +1,105 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_1
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART6
+#define UART_CLK_EN __HAL_RCC_USART6_CLK_ENABLE
+#define UART_GPIO_AF GPIO_AF8_USART6
+
+#define UART_TX_PORT GPIOC
+#define UART_TX_PIN GPIO_PIN_6
+
+#define UART_RX_PORT GPIOC
+#define UART_RX_PIN GPIO_PIN_7
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 432;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 9;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Activate the OverDrive to reach the 216 MHz Frequency */
+ HAL_PWREx_EnableOverDrive();
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
+}
+
+//static inline void board_vbus_sense_init(void)
+//{
+//
+//}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.mk
new file mode 100644
index 0000000..66d9ff8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/board.mk
@@ -0,0 +1,15 @@
+PORT ?= 1
+SPEED ?= high
+
+CFLAGS += \
+ -DSTM32F723xx \
+ -DHSE_VALUE=25000000 \
+
+LD_FILE = $(BOARD_PATH)/STM32F723xE_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f723xx.s
+
+# flash target using on-board stlink
+flash: flash-stlink
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f723ie
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/stm32f7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/stm32f7xx_hal_conf.h
new file mode 100644
index 0000000..581f0e4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f723disco/stm32f7xx_hal_conf.h
@@ -0,0 +1,472 @@
+/**
+ ******************************************************************************
+ * @file stm32f7xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F7xx_HAL_CONF_H
+#define __STM32F7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x00000FFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f7xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f7xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32f7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32f7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/STM32F746ZGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/STM32F746ZGTx_FLASH.ld
new file mode 100644
index 0000000..045ec76
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/STM32F746ZGTx_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F746ZGTx Device with
+** 1024KByte FLASH, 320KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20050000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x460; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.h
new file mode 100644
index 0000000..ee342b9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.h
@@ -0,0 +1,100 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOI
+#define LED_PIN GPIO_PIN_1
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOI
+#define BUTTON_PIN GPIO_PIN_11
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART1
+#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+#define UART_GPIO_AF GPIO_AF7_USART1
+
+#define UART_TX_PORT GPIOA
+#define UART_TX_PIN GPIO_PIN_9
+
+#define UART_RX_PORT GPIOB
+#define UART_RX_PIN GPIO_PIN_7
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 0
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 432;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 9;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Activate the OverDrive to reach the 216 MHz Frequency */
+ HAL_PWREx_EnableOverDrive();
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.mk
new file mode 100644
index 0000000..2ba59f6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/board.mk
@@ -0,0 +1,12 @@
+PORT ?= 1
+SPEED ?= high
+
+CFLAGS += \
+ -DSTM32F746xx \
+ -DHSE_VALUE=25000000
+
+LD_FILE = $(BOARD_PATH)/STM32F746ZGTx_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f746xx.s
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/stm32f7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/stm32f7xx_hal_conf.h
new file mode 100644
index 0000000..03dec8f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746disco/stm32f7xx_hal_conf.h
@@ -0,0 +1,472 @@
+/**
+ ******************************************************************************
+ * @file stm32f7xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F7xx_HAL_CONF_H
+#define __STM32F7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x00000FFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f7xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f7xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32f7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32f7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/STM32F746ZGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/STM32F746ZGTx_FLASH.ld
new file mode 100644
index 0000000..b434a01
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/STM32F746ZGTx_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F746ZGTx Device with
+** 1024KByte FLASH, 320KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20050000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x460; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.h
new file mode 100644
index 0000000..92c109a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.h
@@ -0,0 +1,98 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_AF GPIO_AF7_USART3
+
+#define UART_TX_PORT GPIOD
+#define UART_TX_PIN GPIO_PIN_8
+#define UART_RX_PORT GPIOD
+#define UART_RX_PIN GPIO_PIN_9
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 432;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 9;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ // TODO need to enable usb clock source
+
+ /* Activate the OverDrive to reach the 216 MHz Frequency */
+ HAL_PWREx_EnableOverDrive();
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk
new file mode 100644
index 0000000..3dcf481
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk
@@ -0,0 +1,12 @@
+PORT ?= 0
+SPEED ?= full
+
+CFLAGS += \
+ -DSTM32F746xx \
+ -DHSE_VALUE=8000000
+
+LD_FILE = $(BOARD_PATH)/STM32F746ZGTx_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f746xx.s
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/stm32f7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/stm32f7xx_hal_conf.h
new file mode 100644
index 0000000..234191b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f746nucleo/stm32f7xx_hal_conf.h
@@ -0,0 +1,472 @@
+/**
+ ******************************************************************************
+ * @file stm32f7xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F7xx_HAL_CONF_H
+#define __STM32F7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x00000FFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f7xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f7xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32f7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32f7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/STM32F767ZITx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/STM32F767ZITx_FLASH.ld
new file mode 100644
index 0000000..0b6d5a4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/STM32F767ZITx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F767ZITx Device with
+** 2048KByte FLASH, 512KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20080000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.h
new file mode 100644
index 0000000..1283f23
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.h
@@ -0,0 +1,102 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_AF GPIO_AF7_USART3
+
+#define UART_TX_PORT GPIOD
+#define UART_TX_PIN GPIO_PIN_8
+
+#define UART_RX_PORT GPIOD
+#define UART_RX_PIN GPIO_PIN_9
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 432;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 9;
+ RCC_OscInitStruct.PLL.PLLR = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Activate the OverDrive to reach the 216 MHz Frequency */
+ HAL_PWREx_EnableOverDrive();
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
+}
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk
new file mode 100644
index 0000000..7710619
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk
@@ -0,0 +1,15 @@
+PORT ?= 0
+SPEED ?= full
+
+CFLAGS += \
+ -DSTM32F767xx \
+ -DHSE_VALUE=8000000 \
+
+LD_FILE = $(BOARD_PATH)/STM32F767ZITx_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f767xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32f767zi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/stm32f7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/stm32f7xx_hal_conf.h
new file mode 100644
index 0000000..234191b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f767nucleo/stm32f7xx_hal_conf.h
@@ -0,0 +1,472 @@
+/**
+ ******************************************************************************
+ * @file stm32f7xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F7xx_HAL_CONF_H
+#define __STM32F7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x00000FFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f7xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f7xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32f7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32f7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/STM32F769ZITx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/STM32F769ZITx_FLASH.ld
new file mode 100644
index 0000000..378ed80
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/STM32F769ZITx_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32F767ZITx Device with
+** 2048KByte FLASH, 512KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20080000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.h
new file mode 100644
index 0000000..5ec217f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.h
@@ -0,0 +1,101 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOJ
+#define LED_PIN GPIO_PIN_12
+#define LED_STATE_ON 5
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART1
+#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+#define UART_GPIO_AF GPIO_AF7_USART1
+
+#define UART_TX_PORT GPIOA
+#define UART_TX_PIN GPIO_PIN_9
+
+#define UART_RX_PORT GPIOA
+#define UART_RX_PIN GPIO_PIN_10
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* Enable Power Control clock */
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 432;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 9;
+ RCC_OscInitStruct.PLL.PLLR = 7;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Activate the OverDrive to reach the 216 MHz Frequency */
+ HAL_PWREx_EnableOverDrive();
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.mk
new file mode 100644
index 0000000..45b4a78
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/board.mk
@@ -0,0 +1,13 @@
+# Only OTG-HS has a connector on this board
+PORT ?= 1
+SPEED ?= high
+
+CFLAGS += \
+ -DSTM32F769xx \
+ -DHSE_VALUE=25000000 \
+
+LD_FILE = $(BOARD_PATH)/STM32F769ZITx_FLASH.ld
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f769xx.s
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/stm32f7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/stm32f7xx_hal_conf.h
new file mode 100644
index 0000000..581f0e4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/boards/stm32f769disco/stm32f7xx_hal_conf.h
@@ -0,0 +1,472 @@
+/**
+ ******************************************************************************
+ * @file stm32f7xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F7xx_HAL_CONF_H
+#define __STM32F7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0FU) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define ART_ACCLERATOR_ENABLE 1U /* To enable instruction cache and prefetch */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIOS register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration for NUCLEO 144 board ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+/* LAN8742A PHY Address*/
+#define LAN8742A_PHY_ADDRESS 0x00
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x00000FFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x1F) /*!< PHY special control/ status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0004) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0010) /*!< PHY Duplex mask */
+
+
+#define PHY_ISFR ((uint16_t)0x1D) /*!< PHY Interrupt Source Flag register Offset */
+#define PHY_ISFR_INT4 ((uint16_t)0x0010) /*!< PHY Link down inturrupt */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f7xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "stm32f7xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32f7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32f7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.c
new file mode 100644
index 0000000..14e3b2f
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.c
@@ -0,0 +1,314 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 William D. Jones (thor0505@comcast.net),
+ * Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de),
+ * Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32f7xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void OTG_FS_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+// Despite being call USB2_OTG
+// OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port
+void OTG_HS_IRQHandler(void)
+{
+ tud_int_handler(1);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE(); // ULPI NXT
+ __HAL_RCC_GPIOI_CLK_ENABLE(); // ULPI NXT
+
+#ifdef __HAL_RCC_GPIOJ_CLK_ENABLE
+ __HAL_RCC_GPIOJ_CLK_ENABLE();
+#endif
+
+ UART_CLK_EN();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+ NVIC_SetPriority(OTG_HS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // Uart TX
+ GPIO_InitStruct.Pin = UART_TX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_TX_PORT, &GPIO_InitStruct);
+
+ // Uart RX
+ GPIO_InitStruct.Pin = UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_RX_PORT, &GPIO_InitStruct);
+
+ UartHandle.Instance = UART_DEV;
+ UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
+ UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
+ UartHandle.Init.StopBits = UART_STOPBITS_1;
+ UartHandle.Init.Parity = UART_PARITY_NONE;
+ UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ UartHandle.Init.Mode = UART_MODE_TX_RX;
+ UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
+ HAL_UART_Init(&UartHandle);
+
+#if BOARD_DEVICE_RHPORT_NUM == 0
+ // OTG_FS
+
+ /* Configure DM DP Pins */
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Configure OTG-FS ID pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Enable USB FS Clocks */
+ __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+#if OTG_FS_VBUS_SENSE
+ /* Configure VBUS Pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+#else
+ // Disable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+
+ // B-peripheral session valid override enable
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif // vbus sense
+
+#else
+ // OTG_HS
+
+ #ifdef USB_HS_PHYC
+ // MCU with built-in HS PHY such as F723, F733, F730
+
+ /* Configure DM DP Pins */
+ GPIO_InitStruct.Pin = (GPIO_PIN_14 | GPIO_PIN_15);
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ // Enable HS VBUS sense (B device) via pin PB13
+ USB_OTG_HS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+
+ /* Configure OTG-HS ID pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_13;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+
+ /* Enable PHYC Clocks */
+ __HAL_RCC_OTGPHYC_CLK_ENABLE();
+
+ #else
+ // MUC with external ULPI PHY
+
+ /* ULPI CLK */
+ GPIO_InitStruct.Pin = GPIO_PIN_5;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* ULPI D0 */
+ GPIO_InitStruct.Pin = GPIO_PIN_3;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* ULPI D1 D2 D3 D4 D5 D6 D7 */
+ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_5;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* ULPI STP */
+ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_2;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+ /* NXT */
+ GPIO_InitStruct.Pin = GPIO_PIN_4;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
+
+ /* ULPI DIR */
+ GPIO_InitStruct.Pin = GPIO_PIN_11;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
+ HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
+ #endif // USB_HS_PHYC
+
+ // Enable USB HS & ULPI Clocks
+ __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();
+ __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
+
+#if OTG_HS_VBUS_SENSE
+ #error OTG HS VBUS Sense enabled is not implemented
+#else
+ // No VBUS sense
+ USB_OTG_HS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+
+ // B-peripheral session valid override enable
+ USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
+ USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif
+
+ // Force device mode
+ USB_OTG_HS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD;
+ USB_OTG_HS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
+
+#endif // BOARD_DEVICE_RHPORT_NUM
+
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.mk
new file mode 100644
index 0000000..8482e6d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32f7/family.mk
@@ -0,0 +1,54 @@
+UF2_FAMILY_ID = 0x53b80f00
+ST_FAMILY = f7
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32F7 \
+ -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
+
+ifeq ($(PORT), 1)
+ ifeq ($(SPEED), high)
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+ $(info "Using OTG_HS in HighSpeed mode")
+ else
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
+ $(info "Using OTG_HS in FullSpeed mode")
+ endif
+else
+ $(info "Using OTG_FS")
+endif
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=shadow -Wno-error=cast-align
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM7/r0p1
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/STM32G474RETx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/STM32G474RETx_FLASH.ld
new file mode 100644
index 0000000..935d97c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/STM32G474RETx_FLASH.ld
@@ -0,0 +1,190 @@
+/*
+******************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by Ac6 System Workbench
+**
+** Abstract : Linker script for STM32G474RETx series
+** 512Kbytes FLASH and 160Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed “as is,” without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
+**
+** Redistribution and use in source and binary forms, with or without modification,
+** are permitted provided that the following conditions are met:
+** 1. Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+** 3. Neither the name of Ac6 nor the names of its contributors
+** may be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+CCMSRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 32K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.h
new file mode 100644
index 0000000..eab0bd5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.h
@@ -0,0 +1,134 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// G474RE Nucleo does not has usb connection. We need to manually connect
+// - PA12 for D+, CN10.12
+// - PA11 for D-, CN10.14
+
+// LED
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_5
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+// UART Enable for STLink VCOM
+#define UART_DEV LPUART1
+#define UART_CLK_EN __HAL_RCC_LPUART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOA
+#define UART_GPIO_AF GPIO_AF12_LPUART1
+#define UART_TX_PIN GPIO_PIN_2
+#define UART_RX_PIN GPIO_PIN_3
+
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
+
+ // Configure the main internal regulator output voltage
+ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
+
+ // Initializes the CPU, AHB and APB busses clocks
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
+ RCC_OscInitStruct.PLL.PLLN = 50;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
+ RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ // Initializes the CPU, AHB and APB busses clocks
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8);
+
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) ;
+
+#if 0 // TODO need to check if USB clock is enabled
+ /* Enable HSI48 */
+ memset(&RCC_OscInitStruct, 0, sizeof(RCC_OscInitStruct));
+
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /*Enable CRS Clock*/
+ RCC_CRSInitTypeDef RCC_CRSInitStruct= {0};
+ __HAL_RCC_CRS_CLK_ENABLE();
+
+ /* Default Synchro Signal division factor (not divided) */
+ RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
+
+ /* Set the SYNCSRC[1:0] bits according to CRS_Source value */
+ RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
+
+ /* HSI48 is synchronized with USB SOF at 1KHz rate */
+ RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
+ RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT;
+
+ /* Set the TRIM[5:0] to the default value */
+ RCC_CRSInitStruct.HSI48CalibrationValue = RCC_CRS_HSI48CALIBRATION_DEFAULT;
+
+ /* Start automatic synchronization */
+ HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
+#endif
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk
new file mode 100644
index 0000000..e41edd3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk
@@ -0,0 +1,10 @@
+CFLAGS += \
+ -DSTM32G474xx \
+ -DHSE_VALUE=24000000
+
+LD_FILE = $(BOARD_PATH)/STM32G474RETx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32g474xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32g474re
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.c
new file mode 100644
index 0000000..461dc61
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.c
@@ -0,0 +1,186 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32g4xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_HP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB_LP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USBWakeUp_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+
+ UART_CLK_EN();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ board_led_write(false);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+#ifdef UART_DEV
+ // UART
+ GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+
+ UartHandle = (UART_HandleTypeDef){
+ .Instance = UART_DEV,
+ .Init.BaudRate = CFG_BOARD_UART_BAUDRATE,
+ .Init.WordLength = UART_WORDLENGTH_8B,
+ .Init.StopBits = UART_STOPBITS_1,
+ .Init.Parity = UART_PARITY_NONE,
+ .Init.HwFlowCtl = UART_HWCONTROL_NONE,
+ .Init.Mode = UART_MODE_TX_RX,
+ .Init.OverSampling = UART_OVERSAMPLING_16
+ };
+ HAL_UART_Init(&UartHandle);
+#endif
+
+ // USB Pins TODO double check USB clock and pin setup
+ // Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ __HAL_RCC_USB_CLK_ENABLE();
+
+ board_vbus_sense_init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+#ifdef UART_DEV
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+#else
+ (void) buf; (void) len; (void) UartHandle;
+ return 0;
+#endif
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.mk
new file mode 100644
index 0000000..04222f3
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/family.mk
@@ -0,0 +1,44 @@
+UF2_FAMILY_ID = 0x4c71240a
+ST_FAMILY = g4
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32G4
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align
+
+SRC_C += \
+ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32g4/stm32g4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/stm32g4xx_hal_conf.h
new file mode 100644
index 0000000..ad5f7db
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32g4/stm32g4xx_hal_conf.h
@@ -0,0 +1,381 @@
+/**
+ ******************************************************************************
+ * @file stm32g4xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef STM32G4xx_HAL_CONF_H
+#define STM32G4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+
+#define HAL_MODULE_ENABLED
+
+ /*#define HAL_ADC_MODULE_ENABLED */
+/*#define HAL_COMP_MODULE_ENABLED */
+/*#define HAL_CORDIC_MODULE_ENABLED */
+/*#define HAL_CRC_MODULE_ENABLED */
+/*#define HAL_CRYP_MODULE_ENABLED */
+/*#define HAL_DAC_MODULE_ENABLED */
+/*#define HAL_FDCAN_MODULE_ENABLED */
+/*#define HAL_FMAC_MODULE_ENABLED */
+/*#define HAL_HRTIM_MODULE_ENABLED */
+/*#define HAL_IRDA_MODULE_ENABLED */
+/*#define HAL_IWDG_MODULE_ENABLED */
+/*#define HAL_I2C_MODULE_ENABLED */
+/*#define HAL_I2S_MODULE_ENABLED */
+/*#define HAL_LPTIM_MODULE_ENABLED */
+/*#define HAL_NAND_MODULE_ENABLED */
+/*#define HAL_NOR_MODULE_ENABLED */
+/*#define HAL_OPAMP_MODULE_ENABLED */
+/*#define HAL_PCD_MODULE_ENABLED */
+/*#define HAL_QSPI_MODULE_ENABLED */
+/*#define HAL_RNG_MODULE_ENABLED */
+/*#define HAL_RTC_MODULE_ENABLED */
+/*#define HAL_SAI_MODULE_ENABLED */
+/*#define HAL_SMARTCARD_MODULE_ENABLED */
+/*#define HAL_SMBUS_MODULE_ENABLED */
+/*#define HAL_SPI_MODULE_ENABLED */
+/*#define HAL_SRAM_MODULE_ENABLED */
+/*#define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/*#define HAL_USART_MODULE_ENABLED */
+/*#define HAL_WWDG_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+
+/* ########################## Register Callbacks selection ############################## */
+/**
+ * @brief This is the list of modules where register callback can be used
+ */
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U
+#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U
+#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U
+#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U
+#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U
+#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U
+#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U
+
+/* ########################## Oscillator Values adaptation ####################*/
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE (24000000UL) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG.
+ * This internal oscillator is mainly dedicated to provide a high precision clock to
+ * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry.
+ * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency
+ * which is subject to manufacturing process variations.
+ */
+#if !defined (HSI48_VALUE)
+ #define HSI48_VALUE (48000000UL) /*!< Value of the Internal High Speed oscillator for USB FS/RNG in Hz.
+ The real value my vary depending on manufacturing process variations.*/
+#endif /* HSI48_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+/*!< Value of the Internal Low Speed oscillator in Hz
+The real value may vary depending on the variations in voltage and temperature.*/
+#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ * This value is used by the UART, RTC HAL module to compute the system frequency
+ */
+#if !defined (LSE_VALUE)
+#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S and SAI peripherals
+ * This value is used by the I2S and SAI HAL modules to compute the I2S and SAI clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+
+#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY (0UL) /*!< tick interrupt priority (lowest by default) */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 0U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+ * Activated: CRC code is present inside driver
+ * Deactivated: CRC code cleaned from driver
+ */
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+#include "stm32g4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+#include "stm32g4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+#include "stm32g4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+#include "stm32g4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+#include "stm32g4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+#include "stm32g4xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CORDIC_MODULE_ENABLED
+#include "stm32g4xx_hal_cordic.h"
+#endif /* HAL_CORDIC_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+#include "stm32g4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+#include "stm32g4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+#include "stm32g4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+#include "stm32g4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_FDCAN_MODULE_ENABLED
+#include "stm32g4xx_hal_fdcan.h"
+#endif /* HAL_FDCAN_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+#include "stm32g4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_FMAC_MODULE_ENABLED
+#include "stm32g4xx_hal_fmac.h"
+#endif /* HAL_FMAC_MODULE_ENABLED */
+
+#ifdef HAL_HRTIM_MODULE_ENABLED
+#include "stm32g4xx_hal_hrtim.h"
+#endif /* HAL_HRTIM_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+#include "stm32g4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+#include "stm32g4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+#include "stm32g4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+#include "stm32g4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+#include "stm32g4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+#include "stm32g4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+#include "stm32g4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_OPAMP_MODULE_ENABLED
+#include "stm32g4xx_hal_opamp.h"
+#endif /* HAL_OPAMP_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+#include "stm32g4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+#include "stm32g4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+#include "stm32g4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+#include "stm32g4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+#include "stm32g4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+#include "stm32g4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+#include "stm32g4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+#include "stm32g4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+#include "stm32g4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+#include "stm32g4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+#include "stm32g4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+#include "stm32g4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+#include "stm32g4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+#include "stm32g4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+void assert_failed(uint8_t *file, uint32_t line);
+#else
+#define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* STM32G4xx_HAL_CONF_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.h
new file mode 100644
index 0000000..af2063c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.h
@@ -0,0 +1,143 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_4
+#define LED_STATE_ON 1
+
+// Tamper push-button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 0
+
+// Need to change jumper setting J7 and J8 from RS-232 to STLink
+#define UART_DEV USART1
+#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOB
+#define UART_GPIO_AF GPIO_AF4_USART1
+#define UART_TX_PIN GPIO_PIN_14
+#define UART_RX_PIN GPIO_PIN_15
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+// USB HS External PHY Pin: CLK, STP, DIR, NXT, D0-D7
+#define ULPI_PINS \
+ {GPIOA, GPIO_PIN_3 }, {GPIOA, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_0 }, {GPIOB, GPIO_PIN_1 }, \
+ {GPIOB, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_10}, {GPIOB, GPIO_PIN_11}, {GPIOB, GPIO_PIN_12}, \
+ {GPIOB, GPIO_PIN_13}, {GPIOC, GPIO_PIN_0 }, {GPIOH, GPIO_PIN_4 }, {GPIOI, GPIO_PIN_11}
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /*!< Supply configuration update enable */
+ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
+
+ /* The voltage scaling allows optimizing the power consumption when the device is
+ clocked below the maximum system frequency, to update the voltage scaling value
+ regarding system frequency refer to product datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
+ RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+
+ /* PLL1 for System Clock */
+ RCC_OscInitStruct.PLL.PLLM = 5;
+ RCC_OscInitStruct.PLL.PLLN = 160;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 4;
+
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* PLL3 for USB Clock */
+ PeriphClkInitStruct.PLL3.PLL3M = 25;
+ PeriphClkInitStruct.PLL3.PLL3N = 336;
+ PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
+ PeriphClkInitStruct.PLL3.PLL3P = 2;
+ PeriphClkInitStruct.PLL3.PLL3R = 2;
+ PeriphClkInitStruct.PLL3.PLL3Q = 7;
+
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure bus clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
+ RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+
+ /*activate CSI clock mondatory for I/O Compensation Cell*/
+ __HAL_RCC_CSI_ENABLE() ;
+
+ /* Enable SYSCFG clock mondatory for I/O Compensation Cell */
+ __HAL_RCC_SYSCFG_CLK_ENABLE() ;
+
+ /* Enables the I/O Compensation Cell */
+ HAL_EnableCompensationCell();
+}
+
+static inline void board_stm32h7_post_init(void)
+{
+ // For this board does nothing
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.mk
new file mode 100644
index 0000000..b768a0e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/board.mk
@@ -0,0 +1,14 @@
+CFLAGS += -DSTM32H743xx -DHSE_VALUE=25000000
+
+# Default is Highspeed port
+PORT ?= 1
+SPEED ?= high
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
+LD_FILE = $(BOARD_PATH)/stm32h743xx_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h743xi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/stm32h743xx_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/stm32h743xx_flash.ld
new file mode 100644
index 0000000..59b9ff4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743eval/stm32h743xx_flash.ld
@@ -0,0 +1,173 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32H743XIHx Device with
+** 2048KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
+RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
+RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
+ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >DTCMRAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >DTCMRAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >DTCMRAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h
new file mode 100644
index 0000000..06148c8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.h
@@ -0,0 +1,122 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_0
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_8
+#define UART_RX_PIN GPIO_PIN_9
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+
+ /* The PWR block is always enabled on the H7 series- there is no clock
+ enable. For now, use the default VOS3 scale mode (lowest) and limit clock
+ frequencies to avoid potential current draw problems from bus
+ power when using the max clock speeds throughout the chip. */
+
+ /* Enable HSE Oscillator and activate PLL1 with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
+ RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000;
+ RCC_OscInitStruct.PLL.PLLN = 336;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 7;
+ RCC_OscInitStruct.PLL.PLLR = 2; /* Unused */
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_0;
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | \
+ RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | \
+ RCC_CLOCKTYPE_D3PCLK1);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
+
+ /* Unlike on the STM32F4 family, it appears the maximum APB frequencies are
+ device-dependent- 120 MHz for this board according to Figure 2 of
+ the datasheet. Dividing by half will be safe for now. */
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
+
+ /* 4 wait states required for 168MHz and VOS3. */
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+
+ /* Like on F4, on H7, USB's actual peripheral clock and bus clock are
+ separate. However, the main system PLL (PLL1) doesn't have a direct
+ connection to the USB peripheral clock to generate 48 MHz, so we do this
+ dance. This will connect PLL1's Q output to the USB peripheral clock. */
+ RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;
+
+ RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ RCC_PeriphCLKInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
+ HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
+}
+
+static inline void board_stm32h7_post_init(void)
+{
+ // For this board does nothing
+}
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk
new file mode 100644
index 0000000..fc670fe
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/board.mk
@@ -0,0 +1,13 @@
+CFLAGS += -DSTM32H743xx -DHSE_VALUE=8000000
+
+# Default is FulSpeed port
+PORT ?= 0
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
+LD_FILE = $(BOARD_PATH)/stm32h743xx_flash.ld
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h743zi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/stm32h743xx_flash.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/stm32h743xx_flash.ld
new file mode 100644
index 0000000..59b9ff4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h743nucleo/stm32h743xx_flash.ld
@@ -0,0 +1,173 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32H743XIHx Device with
+** 2048KByte FLASH, 128KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
+RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
+RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
+ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >DTCMRAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >DTCMRAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >DTCMRAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.h
new file mode 100644
index 0000000..d33e0c8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.h
@@ -0,0 +1,139 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOJ
+#define LED_PIN GPIO_PIN_2
+#define LED_STATE_ON 1
+
+// Blue push-button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+// UART
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_PORT GPIOB
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_10
+#define UART_RX_PIN GPIO_PIN_11
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /*!< Supply configuration update enable */
+ /* For STM32H750XB, use "HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);" */
+ HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY);
+
+ /* The voltage scaling allows optimizing the power consumption when the
+ device is clocked below the maximum system frequency, to update the
+ voltage scaling value regarding system frequency refer to product
+ datasheet. */
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}
+
+ /* Enable HSE Oscillator and activate PLL with HSE as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
+ RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
+ RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+
+ /* PLL1 for System Clock */
+ RCC_OscInitStruct.PLL.PLLM = 5;
+ RCC_OscInitStruct.PLL.PLLN = 160;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 4;
+
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM;
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* PLL3 for USB Clock */
+ PeriphClkInitStruct.PLL3.PLL3M = 25;
+ PeriphClkInitStruct.PLL3.PLL3N = 336;
+ PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
+ PeriphClkInitStruct.PLL3.PLL3P = 2;
+ PeriphClkInitStruct.PLL3.PLL3R = 2;
+ PeriphClkInitStruct.PLL3.PLL3Q = 7;
+
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure bus clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
+ RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
+
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+
+ /*activate CSI clock mondatory for I/O Compensation Cell*/
+ __HAL_RCC_CSI_ENABLE() ;
+
+ /* Enable SYSCFG clock mondatory for I/O Compensation Cell */
+ __HAL_RCC_SYSCFG_CLK_ENABLE() ;
+
+ /* Enables the I/O Compensation Cell */
+ HAL_EnableCompensationCell();
+}
+
+static inline void board_stm32h7_post_init(void)
+{
+ // For this board does nothing
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.mk
new file mode 100644
index 0000000..384065b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/stm32h745disco/board.mk
@@ -0,0 +1,17 @@
+# STM32H745I-DISCO uses OTG_FS
+# FIXME: Reset enumerates, un/replug USB plug does not enumerate
+
+CFLAGS += -DSTM32H745xx -DCORE_CM7 -DHSE_VALUE=25000000
+
+# Default is FulSpeed port
+PORT ?= 0
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h745xx.s
+LD_FILE = $(ST_CMSIS)/Source/Templates/gcc/linker/stm32h745xx_flash_CM7.ld
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h745xi_m7
+
+# flash target using on-board stlink
+flash: flash-stlink
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/STM32H743IITX_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/STM32H743IITX_FLASH.ld
new file mode 100644
index 0000000..73d2ded
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/STM32H743IITX_FLASH.ld
@@ -0,0 +1,175 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32H7 series
+** 2048Kbytes FLASH and 192Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** Copyright (c) 2019 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x2000 ; /* required amount of heap */
+_Min_Stack_Size = 0x2000 ; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+ RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
+ RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
+ RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
+ ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.h
new file mode 100644
index 0000000..09442c2
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.h
@@ -0,0 +1,229 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021
+ * Ha Thach (tinyusb.org)
+ * Benjamin Evans
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+/* ** BOARD SETUP **
+ *
+ * NOTE: This board has bad signal integrity so you may experience some problems.
+ * This setup assumes you have an openh743i-c Core and breakout board. For the HS
+ * examples it also assumes you have a waveshare USB3300 breakout board plugged
+ * into the ULPI PMOD header on the openh743i-c.
+ *
+ * UART Debugging:
+ * Due to pin conflicts in the HS configuration, this BSP uses USART3 (PD8, PD9).
+ * As such, you won't be able to use the UART to USB converter on board and will
+ * require an external UART to USB converter. You could use the waveshare FT232
+ * USB UART Board (micro) but any 3.3V UART to USB converter will be fine.
+ *
+ * Fullspeed:
+ * If VBUS sense is enabled, ensure the PA9-VBUS jumper is connected on the core
+ * board. Connect the PB6 jumper for the LED and the Wakeup - PA0 jumper for the
+ * button. Connect the USB cable to the USB connector on the core board.
+ *
+ * High Speed:
+ * Remove all jumpers from the openh743i-c (especially the USART1 jumpers as the
+ * pins conflict). Connect the PB6 jumper for the LED and the Wakeup - PA0
+ * jumper for the button.
+ *
+ * The reset pin on the ULPI PMOD port is not connected to the MCU. You'll need
+ * to solder a wire from the RST pin on the USB3300 to a pin of your choosing on
+ * the openh743i-c board (this example assumes you've used PD14 as specified with
+ * the ULPI_RST_PORT and ULPI_RST_PIN defines below).
+ *
+ * Preferably power the board using the external 5VDC jack. Connect the USB cable
+ * to the USB connector on the ULPI board. Adjust delays in this file as required.
+ *
+ * If you're having trouble, ask a question on the tinyUSB Github Discussion boards.
+ *
+ * Have fun!
+ *
+*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_6
+#define LED_STATE_ON 1
+
+// Tamper push-button
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+// Need to change jumper setting J7 and J8 from RS-232 to STLink
+#define UART_DEV USART3
+#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF7_USART3
+#define UART_TX_PIN GPIO_PIN_8
+#define UART_RX_PIN GPIO_PIN_9
+
+// VBUS Sense detection
+#define OTG_FS_VBUS_SENSE 1
+#define OTG_HS_VBUS_SENSE 0
+
+ // USB HS External PHY Pin: CLK, STP, DIR, NXT, D0-D7
+#define ULPI_PINS \
+ {GPIOA, GPIO_PIN_3 }, {GPIOA, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_0 }, {GPIOB, GPIO_PIN_1 }, \
+ {GPIOB, GPIO_PIN_5 }, {GPIOB, GPIO_PIN_10}, {GPIOB, GPIO_PIN_11}, {GPIOB, GPIO_PIN_12}, \
+ {GPIOB, GPIO_PIN_13}, {GPIOC, GPIO_PIN_0 }, {GPIOC, GPIO_PIN_2 }, {GPIOC, GPIO_PIN_3 }
+
+// ULPI PHY reset pin used by walkaround
+#define ULPI_RST_PORT GPIOD
+#define ULPI_RST_PIN GPIO_PIN_14
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_stm32h7_clock_init(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+
+ // Supply configuration update enable
+ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
+
+ // Configure the main internal regulator output voltage
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
+
+ while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY))
+ {
+ }
+ // Macro to configure the PLL clock source
+ __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE);
+
+ // Initializes the RCC Oscillators according to the specified parameters in the RCC_OscInitTypeDef structure.
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = 2;
+ RCC_OscInitStruct.PLL.PLLN = 240;
+ RCC_OscInitStruct.PLL.PLLP = 2;
+ RCC_OscInitStruct.PLL.PLLQ = 2;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
+ RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
+ RCC_OscInitStruct.PLL.PLLFRACN = 0;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_USART3;
+ PeriphClkInitStruct.PLL3.PLL3M = 8;
+ PeriphClkInitStruct.PLL3.PLL3N = 336;
+ PeriphClkInitStruct.PLL3.PLL3P = 2;
+ PeriphClkInitStruct.PLL3.PLL3Q = 7;
+ PeriphClkInitStruct.PLL3.PLL3R = 2;
+ PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0;
+ PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE;
+ PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
+ PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_PLL3;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ // Initializes the CPU, AHB and APB buses clocks
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
+ RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+
+ __HAL_RCC_CSI_ENABLE();
+
+ // Enable SYSCFG clock mondatory for I/O Compensation Cell
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+
+ // Enables the I/O Compensation Cell
+ HAL_EnableCompensationCell();
+
+ // Enable voltage detector
+ HAL_PWREx_EnableUSBVoltageDetector();
+}
+
+static inline void timer_board_delay(TIM_HandleTypeDef* tim_hdl, uint32_t ms)
+{
+ uint32_t startMs = __HAL_TIM_GET_COUNTER(tim_hdl);
+ while ((__HAL_TIM_GET_COUNTER(tim_hdl) - startMs) < ms)
+ {
+ asm("nop"); //do nothing
+ }
+}
+
+static inline void board_stm32h7_post_init(void)
+{
+ // walkaround for reseting the ULPI PHY using Timer since systick is not
+ // available when RTOS is used.
+
+ // Init timer
+ TIM_HandleTypeDef tim2Handle;
+ TIM_ClockConfigTypeDef sClockSourceConfig = {0};
+
+ __HAL_RCC_TIM2_CLK_ENABLE();
+
+ //Assuming timer clock is running at 260Mhz this should configure the timer counter to 1000Hz
+ tim2Handle.Instance = TIM2;
+ tim2Handle.Init.Prescaler = 60000U - 1U;
+ tim2Handle.Init.CounterMode = TIM_COUNTERMODE_UP;
+ tim2Handle.Init.Period = 0xFFFFFFFFU;
+ tim2Handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4;
+ tim2Handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ HAL_TIM_Base_Init(&tim2Handle);
+
+ sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
+ HAL_TIM_ConfigClockSource(&tim2Handle, &sClockSourceConfig);
+
+ //Start the timer
+ HAL_TIM_Base_Start(&tim2Handle);
+
+ // Reset PHY, change the delays as you see fit
+ timer_board_delay(&tim2Handle, 5U);
+ HAL_GPIO_WritePin(ULPI_RST_PORT, ULPI_RST_PIN, 1U);
+ timer_board_delay(&tim2Handle, 20U);
+ HAL_GPIO_WritePin(ULPI_RST_PORT, ULPI_RST_PIN, 0U);
+ timer_board_delay(&tim2Handle, 20U);
+
+ //Disable the timer used for delays
+ HAL_TIM_Base_Stop(&tim2Handle);
+ __HAL_RCC_TIM2_CLK_DISABLE();
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.mk
new file mode 100644
index 0000000..4dfcc1c
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/boards/waveshare_openh743i/board.mk
@@ -0,0 +1,19 @@
+CFLAGS += -DSTM32H743xx -DHSE_VALUE=8000000
+
+# Default is HS port
+PORT ?= 1
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h743xx.s
+LD_FILE = $(BOARD_PATH)/STM32H743IITX_FLASH.ld
+
+# Use Timer module for ULPI PHY reset
+CFLAGS += -DHAL_TIM_MODULE_ENABLED
+SRC_C += \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_tim.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_tim_ex.c
+
+# For flash-jlink target
+JLINK_DEVICE = stm32h743ii
+
+# flash target using jlink
+flash: flash-jlink \ No newline at end of file
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.c
new file mode 100644
index 0000000..84976b4
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.c
@@ -0,0 +1,268 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019
+ * William D. Jones (thor0505@comcast.net),
+ * Ha Thach (tinyusb.org)
+ * Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32h7xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+
+// Despite being call USB2_OTG
+// OTG_FS is marked as RHPort0 by TinyUSB to be consistent across stm32 port
+void OTG_FS_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+// Despite being call USB2_OTG
+// OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port
+void OTG_HS_IRQHandler(void)
+{
+ tud_int_handler(1);
+}
+
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_stm32h7_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOC_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOI_CLK_ENABLE(); // USB ULPI NXT
+ __HAL_RCC_GPIOJ_CLK_ENABLE();
+
+ // Enable UART Clock
+ UART_CLK_EN();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+ NVIC_SetPriority(OTG_HS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // Uart
+ GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+
+ UartHandle.Instance = UART_DEV;
+ UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
+ UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
+ UartHandle.Init.StopBits = UART_STOPBITS_1;
+ UartHandle.Init.Parity = UART_PARITY_NONE;
+ UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ UartHandle.Init.Mode = UART_MODE_TX_RX;
+ UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
+ HAL_UART_Init(&UartHandle);
+
+#if BOARD_DEVICE_RHPORT_NUM == 0
+ // Despite being call USB2_OTG
+ // OTG_FS is marked as RHPort0 by TinyUSB to be consistent across stm32 port
+ // PA9 VUSB, PA10 ID, PA11 DM, PA12 DP
+
+ // Configure DM DP Pins
+ GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // This for ID line debug
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // https://community.st.com/s/question/0D50X00009XkYZLSA3/stm32h7-nucleo-usb-fs-cdc
+ // TODO: Board init actually works fine without this line.
+ HAL_PWREx_EnableUSBVoltageDetector();
+ __HAL_RCC_USB2_OTG_FS_CLK_ENABLE();
+
+#if OTG_FS_VBUS_SENSE
+ // Configure VBUS Pin
+ GPIO_InitStruct.Pin = GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+#else
+ // Disable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+
+ // B-peripheral session valid override enable
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif // vbus sense
+
+#elif BOARD_DEVICE_RHPORT_NUM == 1
+ // Despite being call USB2_OTG
+ // OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port
+
+ struct {
+ GPIO_TypeDef* port;
+ uint32_t pin;
+ } const ulpi_pins[] =
+ {
+ ULPI_PINS
+ };
+
+ for (uint8_t i=0; i < sizeof(ulpi_pins)/sizeof(ulpi_pins[0]); i++)
+ {
+ GPIO_InitStruct.Pin = ulpi_pins[i].pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
+ HAL_GPIO_Init(ulpi_pins[i].port, &GPIO_InitStruct);
+ }
+
+ // Enable USB HS & ULPI Clocks
+ __HAL_RCC_USB1_OTG_HS_ULPI_CLK_ENABLE();
+ __HAL_RCC_USB1_OTG_HS_CLK_ENABLE();
+
+#if OTG_HS_VBUS_SENSE
+ #error OTG HS VBUS Sense enabled is not implemented
+#else
+ // No VBUS sense
+ USB_OTG_HS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+
+ // B-peripheral session valid override enable
+ USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN;
+ USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL;
+#endif
+
+ // Force device mode
+ USB_OTG_HS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD;
+ USB_OTG_HS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
+
+ HAL_PWREx_EnableUSBVoltageDetector();
+
+ // For waveshare openh743 ULPI PHY reset walkaround
+ board_stm32h7_post_init();
+#endif // rhport = 1
+
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return (BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) ? 1 : 0;
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+}
+
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler(void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.mk
new file mode 100644
index 0000000..096d04d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/family.mk
@@ -0,0 +1,57 @@
+UF2_FAMILY_ID = 0x6db66082
+ST_FAMILY = h7
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32H7 \
+ -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
+
+ifeq ($(PORT), 1)
+ ifeq ($(SPEED), high)
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+ $(info "Using OTG_HS in HighSpeed mode")
+ else
+ CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
+ $(info "Using OTG_HS in FullSpeed mode")
+ endif
+else
+ $(info "Using OTG_FS")
+endif
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
+
+# All source paths should be relative to the top level.
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM7/r0p1
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32h7/stm32h7xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/stm32h7xx_hal_conf.h
new file mode 100644
index 0000000..a7cc6d8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32h7/stm32h7xx_hal_conf.h
@@ -0,0 +1,483 @@
+/**
+ ******************************************************************************
+ * @file stm32h7xx_hal_conf_template.h
+ * @brief HAL configuration template file.
+ * This file should be copied to the application folder and renamed
+ * to stm32h7xx_hal_conf.h.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32H7xx_HAL_CONF_H
+#define __STM32H7xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+#define HAL_ADC_MODULE_ENABLED
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_COMP_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+/* #define HAL_EXTI_MODULE_ENABLED */
+/* #define HAL_FDCAN_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_HASH_MODULE_ENABLED */
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_HRTIM_MODULE_ENABLED */
+/* #define HAL_HSEM_MODULE_ENABLED */
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_JPEG_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_MDIOS_MODULE_ENABLED */
+/* #define HAL_MDMA_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_OPAMP_MODULE_ENABLED */
+/* #define HAL_PCD_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_RAMECC_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+#define HAL_SPI_MODULE_ENABLED
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SWPMI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+
+/* ########################## Oscillator Values adaptation ####################*/
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+//#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+#error HSE_VALUE is not defined
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal oscillator (CSI) default value.
+ * This value is the default CSI value after Reset.
+ */
+#if !defined (CSI_VALUE)
+ #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* CSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ * This value is used by the UART, RTC HAL module to compute the system frequency
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
+#endif /* LSE_VALUE */
+
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0x0F) /*!< tick interrupt priority */
+#define USE_RTOS 0
+#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */
+#define USE_SPI_CRC 1U /*!< use CRC in SPI */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################### Ethernet Configuration ######################### */
+#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
+#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */
+
+#define ETH_MAC_ADDR0 ((uint8_t)0x02)
+#define ETH_MAC_ADDR1 ((uint8_t)0x00)
+#define ETH_MAC_ADDR2 ((uint8_t)0x00)
+#define ETH_MAC_ADDR3 ((uint8_t)0x00)
+#define ETH_MAC_ADDR4 ((uint8_t)0x00)
+#define ETH_MAC_ADDR5 ((uint8_t)0x00)
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32h7xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32h7xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32h7xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_MDMA_MODULE_ENABLED
+ #include "stm32h7xx_hal_mdma.h"
+#endif /* HAL_MDMA_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32h7xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32h7xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32h7xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32h7xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32h7xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32h7xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32h7xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32h7xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32h7xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_FDCAN_MODULE_ENABLED
+ #include "stm32h7xx_hal_fdcan.h"
+#endif /* HAL_FDCAN_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32h7xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+ #include "stm32h7xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32h7xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32h7xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32h7xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32h7xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_HRTIM_MODULE_ENABLED
+ #include "stm32h7xx_hal_hrtim.h"
+#endif /* HAL_HRTIM_MODULE_ENABLED */
+
+#ifdef HAL_HSEM_MODULE_ENABLED
+ #include "stm32h7xx_hal_hsem.h"
+#endif /* HAL_HSEM_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32h7xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32h7xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32h7xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32h7xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32h7xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32h7xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_JPEG_MODULE_ENABLED
+ #include "stm32h7xx_hal_jpeg.h"
+#endif /* HAL_JPEG_MODULE_ENABLED */
+
+#ifdef HAL_MDIOS_MODULE_ENABLED
+ #include "stm32h7xx_hal_mdios.h"
+#endif /* HAL_MDIOS_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32h7xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+#include "stm32h7xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+#include "stm32h7xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_OPAMP_MODULE_ENABLED
+#include "stm32h7xx_hal_opamp.h"
+#endif /* HAL_OPAMP_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32h7xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32h7xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RAMECC_MODULE_ENABLED
+ #include "stm32h7xx_hal_ramecc.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32h7xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32h7xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32h7xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32h7xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32h7xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32h7xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32h7xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_SWPMI_MODULE_ENABLED
+ #include "stm32h7xx_hal_swpmi.h"
+#endif /* HAL_SWPMI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32h7xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32h7xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32h7xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32h7xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32h7xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32h7xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32h7xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32h7xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32h7xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t *file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32H7xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/STM32L053C8Tx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/STM32L053C8Tx_FLASH.ld
new file mode 100644
index 0000000..787418e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/STM32L053C8Tx_FLASH.ld
@@ -0,0 +1,169 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32L053C8Tx Device with
+** 64KByte FLASH, 8KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20002000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x200; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/board.mk
new file mode 100644
index 0000000..e19101d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/board.mk
@@ -0,0 +1,54 @@
+ST_FAMILY = l0
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m0plus \
+ -mfloat-abi=soft \
+ -nostdlib -nostartfiles \
+ -DSTM32L053xx \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32L0
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter -Wno-error=maybe-uninitialized
+
+# All source paths should be relative to the top level.
+LD_FILE = hw/bsp/$(BOARD)/STM32L053C8Tx_FLASH.ld
+
+SRC_C += \
+ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+SRC_S += \
+ $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l053xx.s
+
+INC += \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc \
+ $(TOP)/hw/bsp/$(BOARD)
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM0
+
+# For flash-jlink target
+JLINK_DEVICE = STM32L053R8
+
+# Path to STM32 Cube Programmer CLI, should be added into system path
+STM32Prog = STM32_Programmer_CLI
+
+# flash target using on-board stlink
+flash: $(BUILD)/$(PROJECT).elf
+ $(STM32Prog) --connect port=swd --write $< --go
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0538disco.c b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0538disco.c
new file mode 100644
index 0000000..f0f1d02
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0538disco.c
@@ -0,0 +1,205 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "../board.h"
+#include "stm32l0xx_hal.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_5
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+/**
+ * @brief System Clock Configuration
+ * The system Clock is configured as follow:
+ * HSI48 used as USB clock source
+ * - System Clock source = HSI
+ * - HSI Frequency(Hz) = 16000000
+ * - SYSCLK(Hz) = 16000000
+ * - HCLK(Hz) = 16000000
+ * - AHB Prescaler = 1
+ * - APB1 Prescaler = 1
+ * - APB2 Prescaler = 1
+ * - Flash Latency(WS) = 0
+ * - Main regulator output voltage = Scale1 mode
+ * @param None
+ * @retval None
+ */
+static void SystemClock_Config(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+ static RCC_CRSInitTypeDef RCC_CRSInitStruct;
+
+ /* Enable HSI Oscillator to be used as System clock source
+ Enable HSI48 Oscillator to be used as USB clock source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
+ RCC_OscInitStruct.HSIState = RCC_HSI_ON;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Select HSI48 as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select HSI as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clock dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
+
+ /*Configure the clock recovery system (CRS)**********************************/
+
+ /*Enable CRS Clock*/
+ __HAL_RCC_CRS_CLK_ENABLE();
+
+ /* Default Synchro Signal division factor (not divided) */
+ RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
+ /* Set the SYNCSRC[1:0] bits according to CRS_Source value */
+ RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
+ /* HSI48 is synchronized with USB SOF at 1KHz rate */
+ RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
+ RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT;
+ /* Set the TRIM[5:0] to the default value*/
+ RCC_CRSInitStruct.HSI48CalibrationValue = 0x20;
+ /* Start automatic synchronization */
+ HAL_RCCEx_CRSConfig (&RCC_CRSInitStruct);
+}
+
+void board_init(void)
+{
+ SystemClock_Config();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ //NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ board_led_write(false);
+
+ // Button
+ //__HAL_RCC_GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // USB
+ /* Configure DM DP Pins */
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Enable USB FS Clock */
+ __HAL_RCC_USB_CLK_ENABLE();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0xx_hal_conf.h
new file mode 100644
index 0000000..773b74e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l0538disco/stm32l0xx_hal_conf.h
@@ -0,0 +1,331 @@
+/**
+ ******************************************************************************
+ * @file stm32l0xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ *
+ * Copyright (c) 2016 STMicroelectronics International N.V. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions are met:
+ *
+ * 1. Redistribution of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of other
+ * contributors to this software may be used to endorse or promote products
+ * derived from this software without specific written permission.
+ * 4. This software, including modifications and/or derivative works of this
+ * software, must execute solely and exclusively on microcontroller or
+ * microprocessor devices manufactured by or for STMicroelectronics.
+ * 5. Redistribution and use of this software other than as permitted under
+ * this license is void and will automatically terminate your rights under
+ * this license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
+ * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
+ * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32L0xx_HAL_CONF_H
+#define __STM32L0xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+// #define HAL_ADC_MODULE_ENABLED
+/* #define HAL_COMP_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_FIREWALL_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+/* #define HAL_I2C_MODULE_ENABLED */
+/* #define HAL_I2S_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LCD_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+//#define HAL_RNG_MODULE_ENABLED
+/* #define HAL_RTC_MODULE_ENABLED */
+//#define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+/* #define HAL_TSC_MODULE_ENABLED */
+/* #define HAL_UART_MODULE_ENABLED */
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+//#define HAL_PCD_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
+
+
+/* ########################## Oscillator Values adaptation ####################*/
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal Multiple Speed oscillator (MSI) default value.
+ * This value is the default MSI range value after Reset.
+ */
+#if !defined (MSI_VALUE)
+ #define MSI_VALUE ((uint32_t)2097152U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* MSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator for USB (HSI48) value.
+ */
+#if !defined (HSI48_VALUE)
+#define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB in Hz.
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+#endif /* HSI48_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)37000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ * This value is used by the UART, RTC HAL module to compute the system frequency
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/
+#endif /* LSE_VALUE */
+
+/**
+ * @brief Time out for LSE start up value in ms.
+ */
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define PREREAD_ENABLE 1U
+#define BUFFER_CACHE_DISABLE 0U
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+ * Activated: CRC code is present inside driver
+ * Deactivated: CRC code cleaned from driver
+ */
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32l0xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32l0xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32l0xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32l0xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32l0xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+ #include "stm32l0xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32l0xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32l0xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32l0xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_FIREWALL_MODULE_ENABLED
+ #include "stm32l0xx_hal_firewall.h"
+#endif /* HAL_FIREWALL_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32l0xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32l0xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32l0xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32l0xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LCD_MODULE_ENABLED
+ #include "stm32l0xx_hal_lcd.h"
+#endif /* HAL_LCD_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+#include "stm32l0xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32l0xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32l0xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32l0xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32l0xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32l0xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_TSC_MODULE_ENABLED
+ #include "stm32l0xx_hal_tsc.h"
+#endif /* HAL_TSC_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32l0xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32l0xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32l0xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32l0xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32l0xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32l0xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32l0xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t *file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32L0xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/STM32L476VGTx_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/STM32L476VGTx_FLASH.ld
new file mode 100644
index 0000000..98f468a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/STM32L476VGTx_FLASH.ld
@@ -0,0 +1,183 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32L476VGTx Device with
+** 1024KByte FLASH, 96KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20018000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x500; /* required amount of heap */
+_Min_Stack_Size = 0x1000; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(8);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(8);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(8);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(8);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(8);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(8);
+ } >FLASH
+
+ .ARM.extab :
+ {
+ . = ALIGN(8);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(8);
+ } >FLASH
+ .ARM : {
+ . = ALIGN(8);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(8);
+ } >FLASH
+
+ .preinit_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(8);
+ } >FLASH
+
+ .init_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(8);
+ } >FLASH
+ .fini_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(8);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(8);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(8);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.h
new file mode 100644
index 0000000..42c657d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.h
@@ -0,0 +1,139 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_2
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOA
+#define BUTTON_PIN GPIO_PIN_0
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV USART2
+#define UART_CLK_EN __HAL_RCC_USART2_CLK_ENABLE
+#define UART_GPIO_PORT GPIOD
+#define UART_GPIO_AF GPIO_AF7_USART2
+#define UART_TX_PIN GPIO_PIN_5
+#define UART_RX_PIN GPIO_PIN_6
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+
+/**
+ * @brief System Clock Configuration
+ * The system Clock is configured as follow :
+ *
+ * If define USB_USE_LSE_MSI_CLOCK enabled:
+ * System Clock source = PLL (MSI)
+ * SYSCLK(Hz) = 80000000
+ * HCLK(Hz) = 80000000
+ * AHB Prescaler = 1
+ * APB1 Prescaler = 1
+ * APB2 Prescaler = 2
+ * MSI Frequency(Hz) = 4800000
+ * LSE Frequency(Hz) = 32768
+ * PLL_M = 6
+ * PLL_N = 40
+ * PLL_P = 7
+ * PLL_Q = 4
+ * PLL_R = 4
+ * Flash Latency(WS) = 4
+ * @param None
+ * @retval None
+ */
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
+
+ /* Enable the LSE Oscillator */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
+ RCC_OscInitStruct.LSEState = RCC_LSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Enable the CSS interrupt in case LSE signal is corrupted or not present */
+ HAL_RCCEx_DisableLSECSS();
+
+ /* Set tick interrupt priority, default HAL value is intentionally invalid
+ and that prevents PLL initialization in HAL_RCC_OscConfig() */
+ HAL_InitTick((1UL << __NVIC_PRIO_BITS) - 1UL);
+
+ /* Enable MSI Oscillator and activate PLL with MSI as source */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
+ RCC_OscInitStruct.MSIState = RCC_MSI_ON;
+ RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
+ RCC_OscInitStruct.PLL.PLLM = 6;
+ RCC_OscInitStruct.PLL.PLLN = 40;
+ RCC_OscInitStruct.PLL.PLLP = 7;
+ RCC_OscInitStruct.PLL.PLLQ = 4;
+ RCC_OscInitStruct.PLL.PLLR = 4;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Enable MSI Auto-calibration through LSE */
+ HAL_RCCEx_EnableMSIPLLMode();
+
+ /* Select MSI output as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // L476Disco use general GPIO PC11 for VBUS sensing instead of dedicated PA9 as others
+ // Disable VBUS Sense and force device mode
+ USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN;
+
+ USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN | USB_OTG_GOTGCTL_BVALOVAL;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.mk
new file mode 100644
index 0000000..e7b8557
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l476disco/board.mk
@@ -0,0 +1,10 @@
+CFLAGS += \
+ -DSTM32L476xx \
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32L476VGTx_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l476xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32l476vg
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/STM32L4P5ZGTX_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/STM32L4P5ZGTX_FLASH.ld
new file mode 100644
index 0000000..c1a490a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/STM32L4P5ZGTX_FLASH.ld
@@ -0,0 +1,200 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by STM32CubeIDE
+**
+** Abstract : Linker script for STM32L4P5ZGTx Device from STM32L4PLUS series
+** 1024Kbytes ROM
+** 320Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
+**
+** Redistribution and use in source and binary forms, with or without modification,
+** are permitted provided that the following conditions are met:
+** 1. Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+** 2. Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+** 3. Neither the name of STMicroelectronics nor the names of its contributors
+** may be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + 0x0001FFFF; /* end of "SRAM1" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
+ ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "ROM" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >ROM
+
+ /* The program code and other data into "ROM" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >ROM
+
+ /* Constant data into "ROM" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >ROM
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >ROM
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >ROM
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >ROM
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >ROM
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >ROM
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> ROM
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.h
new file mode 100644
index 0000000..1df389a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.h
@@ -0,0 +1,137 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV LPUART1
+#define UART_CLK_EN __HAL_RCC_LPUART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOG
+#define UART_GPIO_AF GPIO_AF8_LPUART1
+#define UART_TX_PIN GPIO_PIN_7
+#define UART_RX_PIN GPIO_PIN_8
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+
+/**
+ * @brief System Clock Configuration
+ * The system Clock is configured as follow :
+ * System Clock source = PLL (MSI)
+ * SYSCLK(Hz) = 120000000
+ * HCLK(Hz) = 120000000
+ * AHB Prescaler = 1
+ * APB1 Prescaler = 1
+ * APB2 Prescaler = 1
+ * MSI Frequency(Hz) = 48000000
+ * PLL_M = 12
+ * PLL_N = 60
+ * PLL_P = 2
+ * PLL_Q = 2
+ * VDD(V) = 3.3
+ * Main regulator output voltage = Scale1 mode
+ * Flash Latency(WS) = 5
+ * The USB clock configuration from PLLSAI:
+ * PLLSAIP = 8 FIXME
+ * PLLSAIN = 384 FIXME
+ * PLLSAIQ = 7 FIXME
+ * @param None
+ * @retval None
+ */
+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+
+ /* Activate PLL with MSI , stabilizied via PLL by LSE */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
+ RCC_OscInitStruct.MSIState = RCC_MSI_ON;
+ RCC_OscInitStruct.LSEState = RCC_LSE_ON;
+ RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11;
+ RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
+ RCC_OscInitStruct.PLL.PLLM = 12;
+ RCC_OscInitStruct.PLL.PLLN = 60;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Enable MSI Auto-calibration through LSE */
+ HAL_RCCEx_EnableMSIPLLMode();
+
+ /* Select MSI output as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select MSI output as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
+ PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ // Avoid overshoot and start with HCLK 60 MHz
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+
+ /* AHB prescaler divider at 1 as second step */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk
new file mode 100644
index 0000000..8252dd8
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk
@@ -0,0 +1,10 @@
+CFLAGS += \
+ -DSTM32L4P5xx \
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32L4P5ZGTX_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l4p5xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32l4p5zg
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/STM32L4RXxI_FLASH.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/STM32L4RXxI_FLASH.ld
new file mode 100644
index 0000000..f93a160
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/STM32L4RXxI_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+*****************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Abstract : Linker script for STM32L4RxI Device with
+** 2048KByte FLASH, 640KByte RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+** (c)Copyright Ac6.
+** You may use this file as-is or modify it according to the needs of your
+** project. Distribution of this file (unmodified or modified) is not
+** permitted. Ac6 permit registered System Workbench for MCU users the
+** rights to distribute the assembled, compiled & linked contents of this
+** file as part of an application binary file, provided that it is built
+** using the System Workbench for MCU toolchain.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x200a0000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x460; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.h
new file mode 100644
index 0000000..1df389a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.h
@@ -0,0 +1,137 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_14
+#define LED_STATE_ON 1
+
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_13
+#define BUTTON_STATE_ACTIVE 1
+
+#define UART_DEV LPUART1
+#define UART_CLK_EN __HAL_RCC_LPUART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOG
+#define UART_GPIO_AF GPIO_AF8_LPUART1
+#define UART_TX_PIN GPIO_PIN_7
+#define UART_RX_PIN GPIO_PIN_8
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+
+/**
+ * @brief System Clock Configuration
+ * The system Clock is configured as follow :
+ * System Clock source = PLL (MSI)
+ * SYSCLK(Hz) = 120000000
+ * HCLK(Hz) = 120000000
+ * AHB Prescaler = 1
+ * APB1 Prescaler = 1
+ * APB2 Prescaler = 1
+ * MSI Frequency(Hz) = 48000000
+ * PLL_M = 12
+ * PLL_N = 60
+ * PLL_P = 2
+ * PLL_Q = 2
+ * VDD(V) = 3.3
+ * Main regulator output voltage = Scale1 mode
+ * Flash Latency(WS) = 5
+ * The USB clock configuration from PLLSAI:
+ * PLLSAIP = 8 FIXME
+ * PLLSAIN = 384 FIXME
+ * PLLSAIQ = 7 FIXME
+ * @param None
+ * @retval None
+ */
+
+static inline void board_clock_init(void)
+{
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+
+ /* Activate PLL with MSI , stabilizied via PLL by LSE */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
+ RCC_OscInitStruct.MSIState = RCC_MSI_ON;
+ RCC_OscInitStruct.LSEState = RCC_LSE_ON;
+ RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11;
+ RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
+ RCC_OscInitStruct.PLL.PLLM = 12;
+ RCC_OscInitStruct.PLL.PLLN = 60;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /* Enable MSI Auto-calibration through LSE */
+ HAL_RCCEx_EnableMSIPLLMode();
+
+ /* Select MSI output as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select MSI output as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
+ PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
+ clocks dividers */
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ // Avoid overshoot and start with HCLK 60 MHz
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+
+ /* AHB prescaler divider at 1 as second step */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // Enable VBUS sense (B device) via pin PA9
+ USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBDEN;
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk
new file mode 100644
index 0000000..3d7fa22
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk
@@ -0,0 +1,14 @@
+CFLAGS += \
+ -DHSE_VALUE=8000000 \
+ -DSTM32L4R5xx \
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32L4RXxI_FLASH.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l4r5xx.s
+
+# For flash-jlink target
+JLINK_DEVICE = stm32l4r5zi
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.c
new file mode 100644
index 0000000..c15be98
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.c
@@ -0,0 +1,198 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 William D. Jones (thor0505@comcast.net),
+ * Ha Thach (tinyusb.org)
+ * Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32l4xx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void OTG_FS_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOF_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+ UART_CLK_EN();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ //NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ /* Enable USB power on Pwrctrl CR2 register */
+ /* Enable Power Clock*/
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+#if defined(PWR_CR5_R1MODE)
+ /* Enable voltage range 1 boost mode for frequency above 80 Mhz */
+ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
+#endif
+
+ /* Enable USB power on Pwrctrl CR2 register */
+ HAL_PWREx_EnableVddUSB();
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+ // IOSV bit MUST be set to access GPIO port G[2:15] */
+ __HAL_RCC_PWR_CLK_ENABLE();
+ HAL_PWREx_EnableVddIO2();
+
+ // Uart
+ GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+
+ UartHandle.Instance = UART_DEV;
+ UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
+ UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
+ UartHandle.Init.StopBits = UART_STOPBITS_1;
+ UartHandle.Init.Parity = UART_PARITY_NONE;
+ UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ UartHandle.Init.Mode = UART_MODE_TX_RX;
+ UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
+ UartHandle.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
+ //UartHandle.Init.ClockPrescaler = UART_PRESCALER_DIV1;
+ UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
+
+ HAL_UART_Init(&UartHandle);
+
+ /* Configure USB FS GPIOs */
+ /* Configure DM DP Pins */
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Configure VBUS Pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Configure ID pin */
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Enable USB FS Clocks */
+ __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+ board_vbus_sense_init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.mk
new file mode 100644
index 0000000..d6f55e5
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/family.mk
@@ -0,0 +1,45 @@
+ST_FAMILY = l4
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32L4
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align
+
+#src/portable/st/synopsys/dcd_synopsys.c
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c
+
+INC += \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc \
+ $(TOP)/$(BOARD_PATH)
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32l4/stm32l4xx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/stm32l4xx_hal_conf.h
new file mode 100644
index 0000000..312f86d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32l4/stm32l4xx_hal_conf.h
@@ -0,0 +1,420 @@
+/**
+ ******************************************************************************
+ * @file stm32l4xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration template file.
+ * This file should be copied to the application folder and renamed
+ * to stm32l4xx_hal_conf.h.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32L4xx_HAL_CONF_H
+#define __STM32L4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
+/* #define HAL_COMP_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_FIREWALL_MODULE_ENABLED */
+#define HAL_FLASH_MODULE_ENABLED
+/* #define HAL_NAND_MODULE_ENABLED */
+// #define HAL_NOR_MODULE_ENABLED
+// #define HAL_SRAM_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+//#define HAL_I2C_MODULE_ENABLED
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_IWDG_MODULE_ENABLED */
+//#define HAL_LCD_MODULE_ENABLED
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_OPAMP_MODULE_ENABLED */
+//#define HAL_PCD_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RCC_MODULE_ENABLED
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+//#define HAL_SAI_MODULE_ENABLED
+//#define HAL_SD_MODULE_ENABLED
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_SMBUS_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_SWPMI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+/* #define HAL_TSC_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+
+
+/* ########################## Oscillator Values adaptation ####################*/
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal Multiple Speed oscillator (MSI) default value.
+ * This value is the default MSI range value after Reset.
+ */
+#if !defined (MSI_VALUE)
+ #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* MSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG.
+ * This internal oscillator is mainly dedicated to provide a high precision clock to
+ * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry.
+ * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency
+ * which is subject to manufacturing process variations.
+ */
+#if !defined (HSI48_VALUE)
+ #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz.
+ The real value my vary depending on manufacturing process variations.*/
+#endif /* HSI48_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ * This value is used by the UART, RTC HAL module to compute the system frequency
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for SAI1 peripheral
+ * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
+ * frequency.
+ */
+#if !defined (EXTERNAL_SAI1_CLOCK_VALUE)
+ #define EXTERNAL_SAI1_CLOCK_VALUE 48000U /*!< Value of the SAI1 External clock source in Hz*/
+#endif /* EXTERNAL_SAI1_CLOCK_VALUE */
+
+/**
+ * @brief External clock source for SAI2 peripheral
+ * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
+ * frequency.
+ */
+#if !defined (EXTERNAL_SAI2_CLOCK_VALUE)
+ #define EXTERNAL_SAI2_CLOCK_VALUE 48000U /*!< Value of the SAI2 External clock source in Hz*/
+#endif /* EXTERNAL_SAI2_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE 3300U /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 0U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
+#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
+#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
+#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
+#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
+#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
+#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+ * Activated: CRC code is present inside driver
+ * Deactivated: CRC code cleaned from driver
+ */
+
+#define USE_SPI_CRC 1U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32l4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32l4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32l4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32l4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32l4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32l4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32l4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "Legacy/stm32l4xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+ #include "stm32l4xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32l4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32l4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32l4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_FIREWALL_MODULE_ENABLED
+ #include "stm32l4xx_hal_firewall.h"
+#endif /* HAL_FIREWALL_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32l4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32l4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32l4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32l4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32l4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32l4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LCD_MODULE_ENABLED
+ #include "stm32l4xx_hal_lcd.h"
+#endif /* HAL_LCD_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+#include "stm32l4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_OPAMP_MODULE_ENABLED
+#include "stm32l4xx_hal_opamp.h"
+#endif /* HAL_OPAMP_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32l4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32l4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32l4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32l4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32l4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32l4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32l4xx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32l4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_SWPMI_MODULE_ENABLED
+ #include "stm32l4xx_hal_swpmi.h"
+#endif /* HAL_SWPMI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32l4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_TSC_MODULE_ENABLED
+ #include "stm32l4xx_hal_tsc.h"
+#endif /* HAL_TSC_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32l4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32l4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32l4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32l4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32l4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32l4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32l4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t *file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32L4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.h b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.h
new file mode 100644
index 0000000..f42c7d6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.h
@@ -0,0 +1,122 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2022, Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_5
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_4
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for STLink VCOM
+#define UART_DEV USART1
+#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
+#define UART_GPIO_PORT GPIOB
+#define UART_GPIO_AF GPIO_AF7_USART1
+#define UART_TX_PIN GPIO_PIN_6
+#define UART_RX_PIN GPIO_PIN_7
+
+
+//--------------------------------------------------------------------+
+// RCC Clock
+//--------------------------------------------------------------------+
+static inline void board_clock_init(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
+
+ // Initializes the CPU, AHB and APB busses clocks
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
+ RCC_OscInitStruct.PLL.PLLN = 24;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
+ RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4;
+ RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV3;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ // Initializes the CPU, AHB and APB busses clocks
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) ;
+
+#if 0 // TODO need to check if USB clock is enabled
+ /* Enable HSI48 */
+ memset(&RCC_OscInitStruct, 0, sizeof(RCC_OscInitStruct));
+
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+
+ /*Enable CRS Clock*/
+ RCC_CRSInitTypeDef RCC_CRSInitStruct= {0};
+ __HAL_RCC_CRS_CLK_ENABLE();
+
+ /* Default Synchro Signal division factor (not divided) */
+ RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
+
+ /* Set the SYNCSRC[1:0] bits according to CRS_Source value */
+ RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
+
+ /* HSI48 is synchronized with USB SOF at 1KHz rate */
+ RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
+ RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT;
+
+ /* Set the TRIM[5:0] to the default value */
+ RCC_CRSInitStruct.HSI48CalibrationValue = RCC_CRS_HSI48CALIBRATION_DEFAULT;
+
+ /* Start automatic synchronization */
+ HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
+#endif
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.mk
new file mode 100644
index 0000000..d6adc6b
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += \
+ -DSTM32WB55xx
+
+LD_FILE = $(BOARD_PATH)/stm32wb55xx_flash_cm4.ld
+
+SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32wb55xx_cm4.s
+
+# For flash-jlink target
+JLINK_DEVICE = STM32WB55RG
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/stm32wb55xx_flash_cm4.ld b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/stm32wb55xx_flash_cm4.ld
new file mode 100644
index 0000000..660f301
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/boards/stm32wb55nucleo/stm32wb55xx_flash_cm4.ld
@@ -0,0 +1,171 @@
+/**
+*****************************************************************************
+**
+** File : stm32wb55xx_flash_cm4.ld
+**
+** Abstract : System Workbench Minimal System calls file
+**
+** For more information about which c-functions
+** need which of these lowlevel functions
+** please consult the Newlib libc-manual
+**
+** Environment : System Workbench for MCU
+**
+** Distribution: The file is distributed “as is,†without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** Copyright (c) 2019 STMicroelectronics.
+** All rights reserved.
+**
+** This software is licensed under terms that can be found in the LICENSE file
+** in the root directory of this software component.
+** If no LICENSE file comes with this software, it is provided AS-IS.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20030000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x400; /* required amount of heap */
+_Min_Stack_Size = 0x1000; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+RAM1 (xrw) : ORIGIN = 0x20000008, LENGTH = 0x2FFF8
+RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM1 AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM1
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM1
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+ MAPPING_TABLE (NOLOAD) : { *(MAPPING_TABLE) } >RAM_SHARED
+ MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED
+ MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED
+}
+
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.c b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.c
new file mode 100644
index 0000000..1ed3830
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.c
@@ -0,0 +1,190 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2022 Jerzy Kasenberg
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "stm32wbxx_hal.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_HP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void USB_LP_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+UART_HandleTypeDef UartHandle;
+
+void board_init(void)
+{
+ board_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+
+ UART_CLK_EN();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ GPIO_InitTypeDef GPIO_InitStruct;
+
+ // LED
+ GPIO_InitStruct.Pin = LED_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+
+#if 0
+ // MCO configuration for System clock value verification PA8 will have SYSCLK / 2
+ GPIO_InitStruct.Pin = 8;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+ HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_2);
+#endif
+
+ board_led_write(false);
+
+ // Button
+ GPIO_InitStruct.Pin = BUTTON_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+
+#ifdef UART_DEV
+ // UART
+ GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+
+ UartHandle = (UART_HandleTypeDef){
+ .Instance = UART_DEV,
+ .Init.BaudRate = CFG_BOARD_UART_BAUDRATE,
+ .Init.WordLength = UART_WORDLENGTH_8B,
+ .Init.StopBits = UART_STOPBITS_1,
+ .Init.Parity = UART_PARITY_NONE,
+ .Init.HwFlowCtl = UART_HWCONTROL_NONE,
+ .Init.Mode = UART_MODE_TX_RX,
+ .Init.OverSampling = UART_OVERSAMPLING_16
+ };
+ HAL_UART_Init(&UartHandle);
+#endif
+
+ // USB Pins TODO double check USB clock and pin setup
+ // Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
+ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ HAL_PWREx_EnableVddUSB();
+ __HAL_RCC_USB_CLK_ENABLE();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+ (void) buf; (void) len;
+ return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+#ifdef UART_DEV
+ HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
+ return len;
+#else
+ (void) buf; (void) len; (void) UartHandle;
+ return 0;
+#endif
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler (void)
+{
+ asm("bkpt");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.mk b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.mk
new file mode 100644
index 0000000..f85c5ba
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/family.mk
@@ -0,0 +1,44 @@
+UF2_FAMILY_ID = 0x70d16653
+ST_FAMILY = wb
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
+ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32WB
+
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align -Wno-unused-parameter
+
+SRC_C += \
+ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
+ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \
+ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/$(ST_CMSIS)/Include \
+ $(TOP)/$(ST_HAL_DRIVER)/Inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/stm32wb/stm32wbxx_hal_conf.h b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/stm32wbxx_hal_conf.h
new file mode 100644
index 0000000..754c94e
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/stm32wb/stm32wbxx_hal_conf.h
@@ -0,0 +1,349 @@
+/**
+ ******************************************************************************
+ * @file stm32wbxx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32WBxx_HAL_CONF_H
+#define __STM32WBxx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+/*#define HAL_ADC_MODULE_ENABLED */
+/*#define HAL_COMP_MODULE_ENABLED */
+/*#define HAL_CRC_MODULE_ENABLED */
+/*#define HAL_HSEM_MODULE_ENABLED */
+/*#define HAL_IPCC_MODULE_ENABLED */
+/*#define HAL_IRDA_MODULE_ENABLED */
+/*#define HAL_LCD_MODULE_ENABLED */
+/*#define HAL_LPTIM_MODULE_ENABLED */
+/*#define HAL_PCD_MODULE_ENABLED */
+/*#define HAL_PKA_MODULE_ENABLED */
+/*#define HAL_QSPI_MODULE_ENABLED */
+#define HAL_RTC_MODULE_ENABLED
+/*#define HAL_SAI_MODULE_ENABLED */
+/*#define HAL_SMBUS_MODULE_ENABLED */
+/*#define HAL_SMARTCARD_MODULE_ENABLED */
+/*#define HAL_TSC_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/*#define HAL_USART_MODULE_ENABLED */
+/*#define HAL_WWDG_MODULE_ENABLED */
+#define HAL_CORTEX_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_IWDG_MODULE_ENABLED
+#define HAL_TIM_MODULE_ENABLED
+#define HAL_SPI_MODULE_ENABLED
+#define HAL_I2C_MODULE_ENABLED
+#define HAL_RNG_MODULE_ENABLED
+/*#define HAL_CRYP_MODULE_ENABLED */
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0u
+#define USE_HAL_COMP_REGISTER_CALLBACKS 0u
+#define USE_HAL_CRYP_REGISTER_CALLBACKS 0u
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0u
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0u
+#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0u
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0u
+#define USE_HAL_PKA_REGISTER_CALLBACKS 0u
+#define USE_HAL_QSPI_REGISTER_CALLBACKS 0u
+#define USE_HAL_RNG_REGISTER_CALLBACKS 0u
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0u
+#define USE_HAL_SAI_REGISTER_CALLBACKS 0u
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0u
+#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0u
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0u
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0u
+#define USE_HAL_TSC_REGISTER_CALLBACKS 0u
+#define USE_HAL_UART_REGISTER_CALLBACKS 0u
+#define USE_HAL_USART_REGISTER_CALLBACKS 0u
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0u
+
+/* ########################## Oscillator Values adaptation ####################*/
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+#define HSE_VALUE 32000000U /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal Multiple Speed oscillator (MSI) default value.
+ * This value is the default MSI range value after Reset.
+ */
+#if !defined (MSI_VALUE)
+ #define MSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* MSI_VALUE */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI1) value.
+ */
+#if !defined (LSI1_VALUE)
+ #define LSI1_VALUE ((uint32_t)32000) /*!< LSI1 Typical Value in Hz*/
+#endif /* LSI1_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief Internal Low Speed oscillator (LSI2) value.
+ */
+#if !defined (LSI2_VALUE)
+ #define LSI2_VALUE ((uint32_t)32000) /*!< LSI2 Typical Value in Hz*/
+#endif /* LSI2_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ * This value is used by the UART, RTC HAL module to compute the system frequency
+ */
+#if !defined (LSE_VALUE)
+#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
+#endif /* LSE_VALUE */
+
+/**
+ * @brief Internal Multiple Speed oscillator (HSI48) default value.
+ * This value is the default HSI48 range value after Reset.
+ */
+#if !defined (HSI48_VALUE)
+ #define HSI48_VALUE ((uint32_t)48000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI48_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for SAI1 peripheral
+ * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
+ * frequency.
+ */
+#if !defined (EXTERNAL_SAI1_CLOCK_VALUE)
+ #define EXTERNAL_SAI1_CLOCK_VALUE ((uint32_t)2097000) /*!< Value of the SAI1 External clock source in Hz*/
+#endif /* EXTERNAL_SAI1_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+
+#define VDD_VALUE 3300U /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1
+#define INSTRUCTION_CACHE_ENABLE 1
+#define DATA_CACHE_ENABLE 1
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+ * Activated: CRC code is present inside driver
+ * Deactivated: CRC code cleaned from driver
+ */
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32wbxx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32wbxx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+ #include "stm32wbxx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32wbxx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32wbxx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32wbxx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32wbxx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32wbxx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_HSEM_MODULE_ENABLED
+ #include "stm32wbxx_hal_hsem.h"
+#endif /* HAL_HSEM_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32wbxx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_IPCC_MODULE_ENABLED
+ #include "stm32wbxx_hal_ipcc.h"
+#endif /* HAL_IPCC_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32wbxx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32wbxx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LCD_MODULE_ENABLED
+ #include "stm32wbxx_hal_lcd.h"
+#endif /* HAL_LCD_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32wbxx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32wbxx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_PKA_MODULE_ENABLED
+ #include "stm32wbxx_hal_pka.h"
+#endif /* HAL_PKA_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32wbxx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #define USE_HAL_QSPI_REGISTER_CALLBACKS 0U
+ #include "stm32wbxx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32wbxx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32wbxx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32wbxx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32wbxx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32wbxx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_SMBUS_MODULE_ENABLED
+ #include "stm32wbxx_hal_smbus.h"
+#endif /* HAL_SMBUS_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32wbxx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32wbxx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_TSC_MODULE_ENABLED
+ #include "stm32wbxx_hal_tsc.h"
+#endif /* HAL_TSC_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32wbxx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32wbxx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32wbxx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32WBxx_HAL_CONF_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h
new file mode 100644
index 0000000..5732056
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define BOARD_UART UART0
+#define BOARD_UART_PORT GPIOA
+
+#define BOARD_BTN_PORT GPIOF
+#define BOARD_BTN 4
+#define BOARD_BTN_Msk (1u<<4)
+#define BUTTON_STATE_ACTIVE 0
+
+#define LED_PORT GPIOF
+#define LED_PIN_RED 1
+#define LED_PIN_BLUE 2
+#define LED_PIN_GREEN 3
+#define LED_STATE_ON 1
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk
new file mode 100644
index 0000000..d60365d
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk
@@ -0,0 +1,11 @@
+CFLAGS += -DTM4C123GH6PM
+
+LD_FILE = $(BOARD_PATH)/tm4c123.ld
+
+# For flash-jlink target
+JLINK_DEVICE = TM4C123GH6PM
+
+# flash using openocd
+OPENOCD_OPTION = -f board/ti_ek-tm4c123gxl.cfg
+
+flash: flash-openocd
diff --git a/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld
new file mode 100644
index 0000000..e2720a9
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld
@@ -0,0 +1,65 @@
+ENTRY(Reset_Handler)
+
+_estack = 0x20008000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0; /* required amount of heap */
+_Min_Stack_Size = 0x1000; /* required amount of stack */
+
+
+MEMORY
+{
+ FLASH(rx) : ORIGIN = 0x00000000, LENGTH = 256K
+ SRAM(rwx) : ORIGIN = 0x20000000, LENGTH = 32K
+}
+
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4) ;
+ *(.vectors)
+ *(.text)
+ *(.text.*)
+ *(.init)
+ *(.fini)
+ *(.rodata)
+ *(.rodata.*)
+ . = ALIGN(4) ;
+ __end_text = . ;
+ } >FLASH
+
+ .data : AT(ADDR(.text) + SIZEOF(.text))
+ {
+ . = ALIGN(4);
+ __start_data = . ;
+ __la_data = LOADADDR(.data);
+ *(.data)
+ *(.data.*)
+ . = ALIGN(4);
+ __end_data = . ;
+
+ } >SRAM
+
+ .bss :
+ {
+ . = ALIGN(4) ;
+ __start_bss = . ;
+ __bss_start__ = __start_bss;
+ *(.bss)
+ *(.bss.*)
+ *(.COMMON)
+ __end_bss = . ;
+ . = ALIGN(4);
+ }>SRAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >SRAM
+}
diff --git a/circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.c b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.c
new file mode 100644
index 0000000..b0947d6
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.c
@@ -0,0 +1,178 @@
+#include "TM4C123.h"
+#include "bsp/board.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_Handler(void)
+{
+#if CFG_TUH_ENABLED
+ tuh_int_handler(0);
+#endif
+
+#if CFG_TUD_ENABLED
+ tud_int_handler(0);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+
+static void board_uart_init (void)
+{
+ SYSCTL->RCGCUART |= (1 << 0); // Enable the clock to UART0
+ SYSCTL->RCGCGPIO |= (1 << 0); // Enable the clock to GPIOA
+
+ GPIOA->AFSEL |= (1 << 1) | (1 << 0); // Enable the alternate function on pin PA0 & PA1
+ GPIOA->PCTL |= (1 << 0) | (1 << 4); // Configure the GPIOPCTL register to select UART0 in PA0 and PA1
+ GPIOA->DEN |= (1 << 0) | (1 << 1); // Enable the digital functionality in PA0 and PA1
+
+ // BAUDRATE = 115200, with SystemCoreClock = 50 Mhz refer manual for calculation
+ // - BRDI = SystemCoreClock / (16* baud)
+ // - BRDF = int(fraction*64 + 0.5)
+ UART0->CTL &= ~(1 << 0); // Disable UART0 by clearing UARTEN bit in the UARTCTL register
+ UART0->IBRD = 27; // Write the integer portion of the BRD to the UARTIRD register
+ UART0->FBRD = 8; // Write the fractional portion of the BRD to the UARTFBRD registerer
+
+ UART0->LCRH = (0x3 << 5); // 8-bit, no parity, 1 stop bit
+ UART0->CC = 0x0; // Configure the UART clock source as system clock
+
+ UART0->CTL = (1 << 0) | (1 << 8) | (1 << 9); // UART0 Enable, Transmit Enable, Recieve Enable
+}
+
+static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirmsk)
+{
+ /* Enable PortF Clock */
+ SYSCTL->RCGCGPIO |= (1 << 5);
+
+ /* Let the clock stabilize */
+ while ( !((SYSCTL->PRGPIO) & (1 << 5)) ) {}
+
+ /* Port Digital Enable */
+ port->DEN |= PinMsk;
+
+ /* Set direction */
+ port->DIR = dirmsk;
+}
+
+static void board_switch_init (void)
+{
+ GPIOF->DIR &= ~(1 << BOARD_BTN);
+ GPIOF->PUR |= (1 << BOARD_BTN);
+ GPIOF->DEN |= (1 << BOARD_BTN);
+}
+
+static void WriteGPIOPin (GPIOA_Type *port, uint8_t PinMsk, bool state)
+{
+ if ( state )
+ {
+ port->DATA |= PinMsk;
+ }
+ else
+ {
+ port->DATA &= ~(PinMsk);
+ }
+}
+
+static uint32_t ReadGPIOPin (GPIOA_Type *port, uint8_t pinMsk)
+{
+ return (port->DATA & pinMsk);
+}
+
+void board_init (void)
+{
+ SystemCoreClockUpdate();
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ /* Reset USB */
+ SYSCTL->SRCR2 |= (1u << 16);
+
+ for ( volatile uint8_t i = 0; i < 20; i++ ) {}
+
+ SYSCTL->SRCR2 &= ~(1u << 16);
+
+ /* Open the USB clock gate */
+ SYSCTL->RCGCUSB |= (1 << 0);
+
+ /* Power-up USB PLL */
+ SYSCTL->RCC2 &= ~(1u << 14);
+
+ /* USB IO Initialization */
+ SYSCTL->RCGCGPIO |= (1u << 3);
+
+ /* Let the clock stabilize */
+ while ( !(SYSCTL->PRGPIO & (1u << 3)) ) {}
+
+ /* USB IOs to Analog Mode */
+ GPIOD->AFSEL &= ~((1u << 4) | (1u << 5));
+ GPIOD->DEN &= ~((1u << 4) | (1u << 5));
+ GPIOD->AMSEL |= ((1u << 4) | (1u << 5));
+
+ uint8_t leds = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN);
+ uint8_t dirmsk = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN);
+
+ /* Configure GPIO for board LED */
+ initialize_board_led(LED_PORT, leds, dirmsk);
+
+ /* Configure GPIO for board switch */
+ board_switch_init();
+
+ /* Initialize board UART */
+ board_uart_init();
+
+ TU_LOG1_INT(SystemCoreClock);
+}
+
+void board_led_write (bool state)
+{
+ WriteGPIOPin(LED_PORT, (1 << LED_PIN_BLUE), state);
+}
+
+uint32_t board_button_read (void)
+{
+ uint32_t gpio_value = ReadGPIOPin(BOARD_BTN_PORT, BOARD_BTN_Msk);
+ return BUTTON_STATE_ACTIVE ? gpio_value : !gpio_value;
+}
+
+int board_uart_write (void const *buf, int len)
+{
+ uint8_t const * data = buf;
+
+ for ( int i = 0; i < len; i++ )
+ {
+ while ( (UART0->FR & (1 << 5)) != 0 ) {} // Poll until previous data was shofted out
+ UART0->DR = data[i]; // Write UART0 DATA REGISTER
+ }
+
+ return len;
+}
+
+int board_uart_read (uint8_t *buf, int len)
+{
+ (void) buf;
+ (void) len;
+ return 0;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis (void)
+{
+ return system_ticks;
+}
+#endif
+
diff --git a/circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.mk b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.mk
new file mode 100644
index 0000000..7510761
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/tm4c123/family.mk
@@ -0,0 +1,36 @@
+DEPS_SUBMODULES += hw/mcu/ti
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -DCFG_TUSB_MCU=OPT_MCU_TM4C123 \
+ -uvectors \
+ -DTM4C123GH6PM
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes -Wno-error=cast-qual
+
+MCU_DIR=hw/mcu/ti/tm4c123xx/
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/tm4c123.ld
+
+INC += \
+ $(TOP)/$(MCU_DIR)/CMSIS/5.7.0/CMSIS/Include \
+ $(TOP)/$(MCU_DIR)/Include/TM4C123 \
+ $(TOP)/$(BOARD_PATH)
+
+SRC_C += \
+ src/portable/mentor/musb/dcd_musb.c \
+ src/portable/mentor/musb/hcd_musb.c \
+ $(MCU_DIR)/Source/system_TM4C123.c \
+ $(MCU_DIR)/Source/GCC/tm4c123_startup.c
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
diff --git a/circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.h b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.h
new file mode 100644
index 0000000..3e2cb95
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.h
@@ -0,0 +1,88 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PIN P1_1
+#define LED_STATE_ON 1
+
+#define BUTTON_PIN P1_14
+#define BUTTON_STATE_ACTIVE 0
+
+//#define UART_DEV USART6
+//#define UART_CLK_EN __HAL_RCC_USART6_CLK_ENABLE
+//#define UART_GPIO_AF GPIO_AF8_USART6
+//
+//#define UART_TX_PORT GPIOC
+//#define UART_TX_PIN GPIO_PIN_6
+//
+//#define UART_RX_PORT GPIOC
+//#define UART_RX_PIN GPIO_PIN_7
+
+static inline void board_clock_init(void)
+{
+ /* Clock configuration */
+ /* fPLL = 120MHz */
+ /* fSYS = 120MHz */
+ /* fUSBPLL = 192MHz */
+ /* fUSB = 48MHz */
+ const XMC_SCU_CLOCK_CONFIG_t clock_config =
+ {
+ .syspll_config.p_div = 2,
+ .syspll_config.n_div = 80,
+ .syspll_config.k_div = 4,
+ .syspll_config.mode = XMC_SCU_CLOCK_SYSPLL_MODE_NORMAL,
+ .syspll_config.clksrc = XMC_SCU_CLOCK_SYSPLLCLKSRC_OSCHP,
+ .enable_oschp = true,
+ .calibration_mode = XMC_SCU_CLOCK_FOFI_CALIBRATION_MODE_FACTORY,
+ .fsys_clksrc = XMC_SCU_CLOCK_SYSCLKSRC_PLL,
+ .fsys_clkdiv = 1,
+ .fcpu_clkdiv = 1,
+ .fccu_clkdiv = 1,
+ .fperipheral_clkdiv = 1
+ };
+
+ /* Setup settings for USB clock */
+ XMC_SCU_CLOCK_Init(&clock_config);
+
+ XMC_SCU_CLOCK_EnableUsbPll();
+ XMC_SCU_CLOCK_StartUsbPll(2, 64);
+ XMC_SCU_CLOCK_SetUsbClockDivider(4);
+ XMC_SCU_CLOCK_SetUsbClockSource(XMC_SCU_CLOCK_USBCLKSRC_USBPLL);
+ XMC_SCU_CLOCK_EnableClock(XMC_SCU_CLOCK_USB);
+}
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.mk b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.mk
new file mode 100644
index 0000000..a2c2c5a
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/boards/xmc4500_relax/board.mk
@@ -0,0 +1,9 @@
+MCU_VARIANT = XMC4500
+CFLAGS += \
+ -DXMC4500_F100x1024 \
+
+LD_FILE = $(MCU_DIR)/CMSIS/Infineon/COMPONENT_$(MCU_VARIANT)/Source/TOOLCHAIN_GCC_ARM/XMC4500x1024.ld
+
+JLINK_DEVICE = XMC4500-1024
+
+flash: flash-jlink
diff --git a/circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.c b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.c
new file mode 100644
index 0000000..bf66847
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.c
@@ -0,0 +1,130 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#include "xmc_gpio.h"
+#include "xmc_scu.h"
+
+#include "bsp/board.h"
+#include "board.h"
+
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB0_0_IRQHandler(void)
+{
+ tud_int_handler(0);
+}
+
+void board_init(void)
+{
+ board_clock_init();
+ SystemCoreClockUpdate();
+
+ // LED
+ XMC_GPIO_CONFIG_t led_cfg;
+ led_cfg.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
+ led_cfg.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH;
+ led_cfg.output_strength = XMC_GPIO_OUTPUT_STRENGTH_MEDIUM;
+ XMC_GPIO_Init(LED_PIN, &led_cfg);
+
+ // Button
+ XMC_GPIO_CONFIG_t button_cfg;
+ button_cfg.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
+ XMC_GPIO_Init(BUTTON_PIN, &button_cfg);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+#endif
+
+ // USB Power Enable
+ XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_USB0);
+ XMC_SCU_POWER_EnableUsb();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+ uint32_t is_high = state ? LED_STATE_ON : (1-LED_STATE_ON);
+
+ XMC_GPIO_SetOutputLevel(LED_PIN, is_high ? XMC_GPIO_OUTPUT_LEVEL_HIGH : XMC_GPIO_OUTPUT_LEVEL_LOW);
+}
+
+uint32_t board_button_read(void)
+{
+ return BUTTON_STATE_ACTIVE == XMC_GPIO_GetInput(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+#ifdef UART_DEV
+ for(int i=0;i<len;i++) {
+ buf[i] = uart_getc(uart_inst);
+ }
+ return len;
+#else
+ (void) buf; (void) len;
+ return 0;
+#endif
+}
+
+int board_uart_write(void const * buf, int len)
+{
+#ifdef UART_DEV
+ char const* bufch = (char const*) buf;
+ for(int i=0;i<len;i++) {
+ uart_putc(uart_inst, bufch[i]);
+ }
+ return len;
+#else
+ (void) buf; (void) len;
+ return 0;
+#endif
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+void SysTick_Handler(void)
+{
+ system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+ return system_ticks;
+}
+#endif
diff --git a/circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.mk b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.mk
new file mode 100644
index 0000000..0b32bde
--- /dev/null
+++ b/circuitpython/lib/tinyusb/hw/bsp/xmc4000/family.mk
@@ -0,0 +1,40 @@
+UF2_FAMILY_ID = 0x00
+MCU_DIR = hw/mcu/infineon/mtb-xmclib-cat3
+
+DEPS_SUBMODULES += $(MCU_DIR)
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m4 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_XMC4000
+
+# mcu driver cause following warnings
+#CFLAGS += -Wno-error=shadow -Wno-error=cast-align
+
+SKIP_NANOLIB = 1
+
+SRC_C += \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ $(MCU_DIR)/Newlib/syscalls.c \
+ $(MCU_DIR)/CMSIS/Infineon/COMPONENT_$(MCU_VARIANT)/Source/system_$(MCU_VARIANT).c \
+ $(MCU_DIR)/XMCLib/src/xmc4_gpio.c \
+ $(MCU_DIR)/XMCLib/src/xmc4_scu.c
+
+
+SRC_S += $(MCU_DIR)/CMSIS/Infineon/COMPONENT_$(MCU_VARIANT)/Source/TOOLCHAIN_GCC_ARM/startup_$(MCU_VARIANT).S
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MCU_DIR)/CMSIS/Core/Include \
+ $(TOP)/$(MCU_DIR)/CMSIS/Infineon/COMPONENT_$(MCU_VARIANT)/Include \
+ $(TOP)/$(MCU_DIR)/XMCLib/inc
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F