summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorZixun LI <[email protected]>2025-11-25 10:59:43 +0100
committerZixun LI <[email protected]>2025-11-25 10:59:43 +0100
commitdc083e4d9c87658498a3bd0b527d25bc88dd1ed6 (patch)
tree0523e934e5a1b1fe8331b28990ddf2e2f4478077 /hw
parente59b2c40fc9e655918629d73cc8c54b86b4a70c1 (diff)
parentfee2d2a034d65aa625bc1a8b32c3b7a51292a39f (diff)
Merge remote-tracking branch 'tinyusb/master' into n6_build
Signed-off-by: Zixun LI <[email protected]>
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/BoardPresets.json922
-rw-r--r--hw/bsp/ansi_escape.h6
-rw-r--r--hw/bsp/at32f402_405/at32f402_405_int.h6
-rw-r--r--hw/bsp/at32f402_405/family.c14
-rw-r--r--hw/bsp/at32f402_405/family.cmake87
-rw-r--r--hw/bsp/at32f403a_407/at32f403a_407_int.h6
-rw-r--r--hw/bsp/at32f403a_407/family.c2
-rw-r--r--hw/bsp/at32f403a_407/family.cmake82
-rw-r--r--hw/bsp/at32f413/at32f413_int.h6
-rw-r--r--hw/bsp/at32f413/family.c2
-rw-r--r--hw/bsp/at32f413/family.cmake83
-rw-r--r--hw/bsp/at32f415/at32f415_int.h3
-rw-r--r--hw/bsp/at32f415/family.c2
-rw-r--r--hw/bsp/at32f415/family.cmake87
-rw-r--r--hw/bsp/at32f423/at32f423_int.h5
-rw-r--r--hw/bsp/at32f423/family.c2
-rw-r--r--hw/bsp/at32f423/family.cmake87
-rw-r--r--hw/bsp/at32f425/at32f425_int.h3
-rw-r--r--hw/bsp/at32f425/family.c2
-rw-r--r--hw/bsp/at32f425/family.cmake87
-rw-r--r--hw/bsp/at32f435_437/at32f435_437_int.h5
-rw-r--r--hw/bsp/at32f435_437/family.c2
-rw-r--r--hw/bsp/at32f435_437/family.cmake87
-rw-r--r--hw/bsp/board.c27
-rw-r--r--hw/bsp/board_api.h9
-rw-r--r--hw/bsp/broadcom_32bit/family.cmake90
-rw-r--r--hw/bsp/broadcom_64bit/family.cmake92
-rw-r--r--hw/bsp/ch32f20x/ch32f20x_it.h12
-rw-r--r--hw/bsp/ch32f20x/family.c1
-rw-r--r--hw/bsp/ch32v10x/ch32v10x_it.h14
-rw-r--r--hw/bsp/ch32v10x/family.c3
-rw-r--r--hw/bsp/ch32v10x/family.cmake92
-rw-r--r--hw/bsp/ch32v20x/ch32v20x_it.h17
-rw-r--r--hw/bsp/ch32v20x/family.c3
-rw-r--r--hw/bsp/ch32v20x/family.cmake92
-rw-r--r--hw/bsp/ch32v30x/ch32v30x_it.h14
-rw-r--r--hw/bsp/ch32v30x/debug_uart.c3
-rw-r--r--hw/bsp/ch32v30x/family.c3
-rw-r--r--hw/bsp/ch32v30x/family.cmake81
-rw-r--r--hw/bsp/cxd56/FreeRTOSConfig/FreeRTOSConfig.h150
-rw-r--r--hw/bsp/cxd56/boards/spresense/board.cmake6
-rw-r--r--hw/bsp/cxd56/boards/spresense/board.h43
-rw-r--r--hw/bsp/cxd56/boards/spresense/board.mk7
-rw-r--r--hw/bsp/cxd56/family.c (renamed from hw/bsp/spresense/board_spresense.c)23
-rw-r--r--hw/bsp/cxd56/family.cmake126
-rw-r--r--hw/bsp/cxd56/family.mk (renamed from hw/bsp/spresense/board.mk)19
-rw-r--r--hw/bsp/da1469x/family.cmake86
-rw-r--r--hw/bsp/efm32/FreeRTOSConfig/FreeRTOSConfig.h150
-rw-r--r--hw/bsp/efm32/boards/sltb009a/board.cmake8
-rw-r--r--hw/bsp/efm32/boards/sltb009a/board.h49
-rw-r--r--hw/bsp/efm32/boards/sltb009a/board.mk9
-rw-r--r--hw/bsp/efm32/family.c (renamed from hw/bsp/sltb009a/sltb009a.c)36
-rw-r--r--hw/bsp/efm32/family.cmake91
-rw-r--r--hw/bsp/efm32/family.mk (renamed from hw/bsp/sltb009a/board.mk)23
-rw-r--r--hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt38
-rw-r--r--hw/bsp/f1c100s/family.cmake102
-rw-r--r--hw/bsp/family_rules.mk177
-rw-r--r--hw/bsp/family_support.cmake250
-rw-r--r--hw/bsp/family_support.mk173
-rw-r--r--hw/bsp/fomu/family.c1
-rw-r--r--hw/bsp/fomu/family.cmake86
-rw-r--r--hw/bsp/fomu/family.mk2
-rw-r--r--hw/bsp/gd32vf103/family.cmake95
-rw-r--r--hw/bsp/imxrt/family.c1
-rw-r--r--hw/bsp/imxrt/family.cmake102
-rw-r--r--hw/bsp/kinetis_k/family.c1
-rw-r--r--hw/bsp/kinetis_k/family.cmake82
-rw-r--r--hw/bsp/kinetis_k32l2/family.c1
-rw-r--r--hw/bsp/kinetis_k32l2/family.cmake82
-rw-r--r--hw/bsp/kinetis_kl/family.c1
-rw-r--r--hw/bsp/kinetis_kl/family.cmake75
-rw-r--r--hw/bsp/lpc11/boards/lpcxpresso11u68/board.cmake2
-rw-r--r--hw/bsp/lpc11/family.cmake57
-rw-r--r--hw/bsp/lpc13/family.cmake28
-rw-r--r--hw/bsp/lpc15/family.cmake28
-rw-r--r--hw/bsp/lpc17/family.c6
-rw-r--r--hw/bsp/lpc17/family.cmake31
-rw-r--r--hw/bsp/lpc17/family.mk1
-rw-r--r--hw/bsp/lpc18/family.cmake27
-rw-r--r--hw/bsp/lpc40/family.cmake31
-rw-r--r--hw/bsp/lpc40/family.mk1
-rw-r--r--hw/bsp/lpc43/family.cmake81
-rw-r--r--hw/bsp/lpc51/family.c1
-rw-r--r--hw/bsp/lpc51/family.cmake86
-rw-r--r--hw/bsp/lpc54/family.c1
-rw-r--r--hw/bsp/lpc54/family.cmake92
-rw-r--r--hw/bsp/lpc55/boards/double_m33_express/board.cmake5
-rw-r--r--hw/bsp/lpc55/boards/lpcxpresso55s28/board.cmake5
-rw-r--r--hw/bsp/lpc55/boards/lpcxpresso55s69/board.cmake5
-rw-r--r--hw/bsp/lpc55/family.c71
-rw-r--r--hw/bsp/lpc55/family.cmake137
-rw-r--r--hw/bsp/maxim/family.c2
-rw-r--r--hw/bsp/maxim/family.cmake83
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/board.cmake9
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/board.mk8
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.c (renamed from hw/bsp/mcx/boards/frdm_mcxa153/clock_config.c)129
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.h385
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.c492
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.h211
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/clock_config.h170
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/frdm_mcxa153.mex573
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.c130
-rw-r--r--hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.h51
-rw-r--r--hw/bsp/mcx/family.c7
-rw-r--r--hw/bsp/mcx/family.cmake108
-rw-r--r--hw/bsp/mcx/family.mk13
-rw-r--r--hw/bsp/mm32/family.cmake80
-rw-r--r--hw/bsp/msp430/family.c9
-rw-r--r--hw/bsp/msp430/family.cmake40
-rw-r--r--hw/bsp/msp432e4/family.cmake87
-rw-r--r--hw/bsp/nrf/boards/adafruit_clue/board.mk2
-rw-r--r--hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk2
-rw-r--r--hw/bsp/nrf/boards/feather_nrf52840_express/board.mk2
-rw-r--r--hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk2
-rw-r--r--hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk2
-rw-r--r--hw/bsp/nrf/boards/nrf52833dk/board.cmake (renamed from hw/bsp/nrf/boards/pca10100/board.cmake)0
-rw-r--r--hw/bsp/nrf/boards/nrf52833dk/board.h (renamed from hw/bsp/nrf/boards/pca10100/board.h)0
-rw-r--r--hw/bsp/nrf/boards/nrf52833dk/board.mk (renamed from hw/bsp/nrf/boards/pca10100/board.mk)2
-rw-r--r--hw/bsp/nrf/boards/nrf52840dk/board.cmake (renamed from hw/bsp/nrf/boards/pca10056/board.cmake)0
-rw-r--r--hw/bsp/nrf/boards/nrf52840dk/board.h (renamed from hw/bsp/nrf/boards/pca10056/board.h)0
-rw-r--r--hw/bsp/nrf/boards/nrf52840dk/board.mk (renamed from hw/bsp/nrf/boards/pca10056/board.mk)2
-rw-r--r--hw/bsp/nrf/boards/nrf52840dk/ozone/nrf52840.jdebug (renamed from hw/bsp/nrf/boards/pca10056/ozone/nrf52840.jdebug)0
-rw-r--r--hw/bsp/nrf/boards/nrf52840dongle/board.cmake (renamed from hw/bsp/nrf/boards/pca10059/board.cmake)2
-rw-r--r--hw/bsp/nrf/boards/nrf52840dongle/board.h (renamed from hw/bsp/nrf/boards/pca10059/board.h)0
-rw-r--r--hw/bsp/nrf/boards/nrf52840dongle/board.mk (renamed from hw/bsp/nrf/boards/pca10059/board.mk)0
-rw-r--r--hw/bsp/nrf/boards/nrf52840dongle/nrf52840dongle.ld (renamed from hw/bsp/nrf/boards/pca10059/pca10059.ld)6
-rw-r--r--hw/bsp/nrf/boards/nrf5340dk/board.cmake4
-rw-r--r--hw/bsp/nrf/boards/nrf5340dk/board.h (renamed from hw/bsp/nrf/boards/pca10095/board.h)0
-rw-r--r--hw/bsp/nrf/boards/nrf5340dk/board.mk (renamed from hw/bsp/nrf/boards/pca10095/board.mk)7
-rw-r--r--hw/bsp/nrf/boards/nrf5340dk/ozone/nrf5340.jdebug (renamed from hw/bsp/nrf/boards/pca10095/ozone/nrf5340.jdebug)0
-rw-r--r--hw/bsp/nrf/boards/nrf54h20dk/board.cmake11
-rw-r--r--hw/bsp/nrf/boards/nrf54h20dk/board.h65
-rw-r--r--hw/bsp/nrf/boards/nrf54h20dk/board.mk12
-rw-r--r--hw/bsp/nrf/boards/pca10095/board.cmake7
-rw-r--r--hw/bsp/nrf/family.c117
-rw-r--r--hw/bsp/nrf/family.cmake148
-rw-r--r--hw/bsp/nrf/family.mk45
-rw-r--r--hw/bsp/nrf/linker/nrf52833_xxaa.ld6
-rw-r--r--hw/bsp/nrf/linker/nrf52840_s140_v6.ld6
-rw-r--r--hw/bsp/nrf/linker/nrf52840_xxaa.ld6
-rw-r--r--hw/bsp/nrf/linker/nrf5340_xxaa_application.ld6
-rw-r--r--hw/bsp/nrf/linker/nrf54h20_xxaa_application.ld21
-rw-r--r--hw/bsp/nrf/nrfx_config/nrfx_config.h115
-rw-r--r--hw/bsp/nrf/nrfx_config/nrfx_config_common.h84
-rw-r--r--hw/bsp/nrf/nrfx_config/nrfx_config_ext.h39
-rw-r--r--hw/bsp/nuc100_120/FreeRTOSConfig/FreeRTOSConfig.h (renamed from hw/bsp/saml2x/FreeRTOSConfig/FreeRTOSConfig.h)11
-rw-r--r--hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.cmake5
-rw-r--r--hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.h43
-rw-r--r--hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.mk2
-rw-r--r--hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/nuc120_flash.ld (renamed from hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld)0
-rw-r--r--hw/bsp/nuc100_120/family.c (renamed from hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c)10
-rw-r--r--hw/bsp/nuc100_120/family.cmake89
-rw-r--r--hw/bsp/nuc100_120/family.mk (renamed from hw/bsp/nutiny_sdk_nuc120/board.mk)20
-rw-r--r--hw/bsp/nuc121_125/FreeRTOSConfig/FreeRTOSConfig.h150
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.cmake6
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.h43
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.mk3
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/nuc121_flash.ld (renamed from hw/bsp/nutiny_nuc121s/nuc121_flash.ld)0
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.cmake6
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.h43
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.mk3
-rw-r--r--hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/nuc125_flash.ld (renamed from hw/bsp/nutiny_nuc125s/nuc125_flash.ld)0
-rw-r--r--hw/bsp/nuc121_125/family.c (renamed from hw/bsp/nutiny_nuc121s/nutiny_nuc121.c)8
-rw-r--r--hw/bsp/nuc121_125/family.cmake94
-rw-r--r--hw/bsp/nuc121_125/family.mk (renamed from hw/bsp/nutiny_nuc121s/board.mk)29
-rw-r--r--hw/bsp/nuc126/FreeRTOSConfig/FreeRTOSConfig.h150
-rw-r--r--hw/bsp/nuc126/boards/nutiny_nuc126v/board.cmake5
-rw-r--r--hw/bsp/nuc126/boards/nutiny_nuc126v/board.h46
-rw-r--r--hw/bsp/nuc126/boards/nutiny_nuc126v/board.mk2
-rw-r--r--hw/bsp/nuc126/boards/nutiny_nuc126v/nuc126_flash.ld (renamed from hw/bsp/nutiny_nuc126v/nuc126_flash.ld)0
-rw-r--r--hw/bsp/nuc126/family.c (renamed from hw/bsp/nutiny_nuc126v/nutiny_nuc126.c)13
-rw-r--r--hw/bsp/nuc126/family.cmake97
-rw-r--r--hw/bsp/nuc126/family.mk (renamed from hw/bsp/nutiny_nuc126v/board.mk)18
-rw-r--r--hw/bsp/nuc505/FreeRTOSConfig/FreeRTOSConfig.h150
-rw-r--r--hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.cmake5
-rw-r--r--hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.h42
-rw-r--r--hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.mk2
-rw-r--r--hw/bsp/nuc505/boards/nutiny_sdk_nuc505/nuc505_flashtoram.ld (renamed from hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld)0
-rw-r--r--hw/bsp/nuc505/family.c (renamed from hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c)4
-rw-r--r--hw/bsp/nuc505/family.cmake93
-rw-r--r--hw/bsp/nuc505/family.mk (renamed from hw/bsp/nutiny_sdk_nuc505/board.mk)26
-rw-r--r--hw/bsp/nutiny_nuc125s/board.mk42
-rw-r--r--hw/bsp/nutiny_nuc125s/nutiny_nuc125.c121
-rw-r--r--hw/bsp/ra/family.cmake166
-rw-r--r--hw/bsp/rp2040/family.c6
-rw-r--r--hw/bsp/rp2040/family.cmake67
-rw-r--r--hw/bsp/samd11/family.c5
-rw-r--r--hw/bsp/samd11/family.cmake77
-rw-r--r--hw/bsp/samd11/family.mk1
-rw-r--r--hw/bsp/samd21/boards/seeeduino_xiao/board.cmake9
-rw-r--r--hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.cmake9
-rw-r--r--hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.mk9
-rw-r--r--hw/bsp/samd21/family.cmake110
-rw-r--r--hw/bsp/samd2x_l2x/FreeRTOSConfig/FreeRTOSConfig.h (renamed from hw/bsp/samd21/FreeRTOSConfig/FreeRTOSConfig.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.cmake (renamed from hw/bsp/samd21/boards/atsamd21_xpro/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.h (renamed from hw/bsp/samd21/boards/atsamd21_xpro/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.mk (renamed from hw/bsp/samd21/boards/atsamd21_xpro/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsamd21_xpro/samd21j18a_flash.ld (renamed from hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.cmake (renamed from hw/bsp/saml2x/boards/atsaml21_xpro/board.cmake)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.h (renamed from hw/bsp/saml2x/boards/atsaml21_xpro/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.mk (renamed from hw/bsp/saml2x/boards/atsaml21_xpro/board.mk)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/atsaml21_xpro/saml21j18b_flash.ld (renamed from hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.cmake (renamed from hw/bsp/samd21/boards/circuitplayground_express/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.h (renamed from hw/bsp/samd21/boards/circuitplayground_express/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.mk (renamed from hw/bsp/samd21/boards/feather_m0_express/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/circuitplayground_express/circuitplayground_express.ld (renamed from hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/curiosity_nano/board.cmake (renamed from hw/bsp/samd21/boards/curiosity_nano/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/curiosity_nano/board.h (renamed from hw/bsp/samd21/boards/curiosity_nano/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/curiosity_nano/board.mk (renamed from hw/bsp/samd21/boards/curiosity_nano/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/curiosity_nano/samd21g17a_flash.ld (renamed from hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/cynthion_d21/board.cmake (renamed from hw/bsp/samd21/boards/cynthion_d21/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/cynthion_d21/board.h (renamed from hw/bsp/samd21/boards/cynthion_d21/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/cynthion_d21/board.mk (renamed from hw/bsp/samd21/boards/cynthion_d21/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/cynthion_d21/samd21g18a_flash.ld (renamed from hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/feather_m0_express/board.cmake (renamed from hw/bsp/samd21/boards/itsybitsy_m0/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/feather_m0_express/board.h (renamed from hw/bsp/samd21/boards/feather_m0_express/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/feather_m0_express/board.mk (renamed from hw/bsp/samd21/boards/itsybitsy_m0/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/feather_m0_express/feather_m0_express.ld (renamed from hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.cmake (renamed from hw/bsp/samd21/boards/metro_m0_express/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.h (renamed from hw/bsp/samd21/boards/itsybitsy_m0/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.mk (renamed from hw/bsp/samd21/boards/metro_m0_express/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/itsybitsy_m0/itsybitsy_m0.ld (renamed from hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/metro_m0_express/board.cmake (renamed from hw/bsp/samd21/boards/feather_m0_express/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/metro_m0_express/board.h (renamed from hw/bsp/samd21/boards/metro_m0_express/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/metro_m0_express/board.mk (renamed from hw/bsp/samd21/boards/circuitplayground_express/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/metro_m0_express/metro_m0_express.ld (renamed from hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/qtpy/board.cmake (renamed from hw/bsp/samd21/boards/qtpy/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/qtpy/board.h (renamed from hw/bsp/samd21/boards/qtpy/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/qtpy/board.mk (renamed from hw/bsp/samd21/boards/qtpy/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/qtpy/qtpy.ld (renamed from hw/bsp/samd21/boards/qtpy/qtpy.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/saml22_feather/board.cmake (renamed from hw/bsp/saml2x/boards/saml22_feather/board.cmake)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/saml22_feather/board.h (renamed from hw/bsp/saml2x/boards/saml22_feather/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/saml22_feather/board.mk (renamed from hw/bsp/saml2x/boards/saml22_feather/board.mk)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/saml22_feather/saml22_feather.ld (renamed from hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.cmake10
-rw-r--r--hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.h (renamed from hw/bsp/samd21/boards/seeeduino_xiao/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.mk (renamed from hw/bsp/samd21/boards/seeeduino_xiao/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/seeeduino_xiao/seeeduino_xiao.ld (renamed from hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.cmake (renamed from hw/bsp/saml2x/boards/sensorwatch_m0/board.cmake)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.h (renamed from hw/bsp/saml2x/boards/sensorwatch_m0/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.mk (renamed from hw/bsp/saml2x/boards/sensorwatch_m0/board.mk)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/sensorwatch_m0/sensorwatch_m0.ld (renamed from hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.cmake10
-rw-r--r--hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.h (renamed from hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.mk11
-rw-r--r--hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld (renamed from hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/trinket_m0/board.cmake (renamed from hw/bsp/samd21/boards/trinket_m0/board.cmake)1
-rw-r--r--hw/bsp/samd2x_l2x/boards/trinket_m0/board.h (renamed from hw/bsp/samd21/boards/trinket_m0/board.h)0
-rw-r--r--hw/bsp/samd2x_l2x/boards/trinket_m0/board.mk (renamed from hw/bsp/samd21/boards/trinket_m0/board.mk)2
-rw-r--r--hw/bsp/samd2x_l2x/boards/trinket_m0/trinket_m0.ld (renamed from hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld)0
-rw-r--r--hw/bsp/samd2x_l2x/family.c (renamed from hw/bsp/samd21/family.c)117
-rw-r--r--hw/bsp/samd2x_l2x/family.cmake148
-rw-r--r--hw/bsp/samd2x_l2x/family.mk (renamed from hw/bsp/samd21/family.mk)55
-rw-r--r--hw/bsp/samd5x_e5x/family.c2
-rw-r--r--hw/bsp/samd5x_e5x/family.cmake76
-rw-r--r--hw/bsp/same70_qmtech/board.mk59
-rw-r--r--hw/bsp/same70_qmtech/same70_qmtech.c159
-rw-r--r--hw/bsp/same70_xplained/board.mk67
-rw-r--r--hw/bsp/same70_xplained/same70_xplained.c156
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/board.cmake8
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/board.h64
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/board.mk3
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/hpl_pmc_config.h (renamed from hw/bsp/same70_qmtech/hpl_pmc_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/hpl_usart_config.h (renamed from hw/bsp/same70_qmtech/hpl_usart_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/hpl_xdmac_config.h (renamed from hw/bsp/same70_qmtech/hpl_xdmac_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_qmtech/peripheral_clk_config.h (renamed from hw/bsp/same70_qmtech/peripheral_clk_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/board.cmake8
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/board.h64
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/board.mk3
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/hpl_pmc_config.h (renamed from hw/bsp/same70_xplained/hpl_pmc_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/hpl_usart_config.h (renamed from hw/bsp/same70_xplained/hpl_usart_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/hpl_xdmac_config.h (renamed from hw/bsp/same70_xplained/hpl_xdmac_config.h)0
-rw-r--r--hw/bsp/same7x/boards/same70_xplained/peripheral_clk_config.h (renamed from hw/bsp/same70_xplained/peripheral_clk_config.h)0
-rw-r--r--hw/bsp/same7x/family.c196
-rw-r--r--hw/bsp/same7x/family.cmake98
-rw-r--r--hw/bsp/same7x/family.mk56
-rw-r--r--hw/bsp/samg/family.c1
-rw-r--r--hw/bsp/samg/family.cmake77
-rw-r--r--hw/bsp/saml2x/family.c172
-rw-r--r--hw/bsp/saml2x/family.cmake115
-rw-r--r--hw/bsp/saml2x/family.mk53
-rw-r--r--hw/bsp/stm32c0/family.cmake81
-rw-r--r--hw/bsp/stm32f0/family.cmake79
-rw-r--r--hw/bsp/stm32f1/family.cmake85
-rw-r--r--hw/bsp/stm32f2/family.cmake89
-rw-r--r--hw/bsp/stm32f3/family.cmake79
-rw-r--r--hw/bsp/stm32f4/family.c2
-rw-r--r--hw/bsp/stm32f4/family.cmake83
-rw-r--r--hw/bsp/stm32f7/family.c2
-rw-r--r--hw/bsp/stm32f7/family.cmake83
-rw-r--r--hw/bsp/stm32g0/family.cmake83
-rw-r--r--hw/bsp/stm32g4/family.cmake81
-rw-r--r--hw/bsp/stm32h5/family.cmake85
-rw-r--r--hw/bsp/stm32h7/boards/stm32h743eval/board.cmake2
-rw-r--r--hw/bsp/stm32h7/boards/stm32h743eval/board.h8
-rw-r--r--hw/bsp/stm32h7/family.c6
-rw-r--r--hw/bsp/stm32h7/family.cmake79
-rw-r--r--hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.cmake2
-rw-r--r--hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.mk2
-rw-r--r--hw/bsp/stm32h7rs/family.c2
-rw-r--r--hw/bsp/stm32h7rs/family.cmake95
-rw-r--r--hw/bsp/stm32h7rs/family.mk2
-rw-r--r--hw/bsp/stm32l0/family.cmake79
-rw-r--r--hw/bsp/stm32l4/boards/stm32l496nucleo/STM32L496ZGTX_FLASH.ld208
-rw-r--r--hw/bsp/stm32l4/boards/stm32l496nucleo/board.cmake10
-rw-r--r--hw/bsp/stm32l4/boards/stm32l496nucleo/board.h158
-rw-r--r--hw/bsp/stm32l4/boards/stm32l496nucleo/board.mk13
-rw-r--r--hw/bsp/stm32l4/family.c2
-rw-r--r--hw/bsp/stm32l4/family.cmake87
-rw-r--r--hw/bsp/stm32n6/boards/stm32n6570dk/board.h10
-rw-r--r--hw/bsp/stm32n6/boards/stm32n657nucleo/board.h2
-rw-r--r--hw/bsp/stm32n6/family.c2
-rw-r--r--hw/bsp/stm32n6/family.cmake98
-rw-r--r--hw/bsp/stm32n6/family.mk2
-rw-r--r--hw/bsp/stm32u0/FreeRTOSConfig/FreeRTOSConfig.h149
-rw-r--r--hw/bsp/stm32u0/boards/stm32u083cdk/STM32U083MCTx_FLASH.ld176
-rw-r--r--hw/bsp/stm32u0/boards/stm32u083cdk/board.cmake12
-rw-r--r--hw/bsp/stm32u0/boards/stm32u083cdk/board.h129
-rw-r--r--hw/bsp/stm32u0/boards/stm32u083cdk/board.mk13
-rw-r--r--hw/bsp/stm32u0/boards/stm32u083cdk/stm32u083xx_flash.icf32
-rw-r--r--hw/bsp/stm32u0/family.c182
-rw-r--r--hw/bsp/stm32u0/family.cmake106
-rw-r--r--hw/bsp/stm32u0/family.mk50
-rw-r--r--hw/bsp/stm32u0/stm32u0xx_hal_conf.h337
-rw-r--r--hw/bsp/stm32u5/family.cmake94
-rw-r--r--hw/bsp/stm32wb/family.cmake87
-rw-r--r--hw/bsp/stm32wba/family.cmake97
-rw-r--r--hw/bsp/tm4c/family.cmake72
-rw-r--r--hw/bsp/xmc4000/family.cmake75
-rw-r--r--hw/bsp/zephyr_board_aliases.cmake2
330 files changed, 10223 insertions, 4988 deletions
diff --git a/hw/bsp/BoardPresets.json b/hw/bsp/BoardPresets.json
index 24da362da..5df924138 100644
--- a/hw/bsp/BoardPresets.json
+++ b/hw/bsp/BoardPresets.json
@@ -13,7 +13,7 @@
}
},
{
- "name": "default single",
+ "name": "default single config",
"hidden": true,
"description": "Configure preset for the ${presetName} board",
"generator": "Ninja",
@@ -27,31 +27,67 @@
"inherits": "default"
},
{
- "name": "adafruit_feather_esp32_v2",
- "inherits": "default single"
+ "name": "adafruit_feather_rp2040_usb_host",
+ "inherits": "default"
},
{
- "name": "adafruit_feather_esp32s2",
- "inherits": "default single"
+ "name": "adafruit_fruit_jam",
+ "inherits": "default"
},
{
- "name": "adafruit_feather_esp32s3",
- "inherits": "default single"
+ "name": "adafruit_metro_rp2350",
+ "inherits": "default"
},
{
- "name": "adafruit_magtag_29gray",
+ "name": "apard32690",
"inherits": "default"
},
{
- "name": "adafruit_metro_esp32s2",
- "inherits": "default single"
+ "name": "arduino_nano33_ble",
+ "inherits": "default"
},
{
- "name": "apard32690",
+ "name": "at32f403a_weact_blackpill",
"inherits": "default"
},
{
- "name": "arduino_nano33_ble",
+ "name": "at_start_f402",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f403a",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f405",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f407",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f413",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f415",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f423",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f425",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f435",
+ "inherits": "default"
+ },
+ {
+ "name": "at_start_f437",
"inherits": "default"
},
{
@@ -139,42 +175,6 @@
"inherits": "default"
},
{
- "name": "espressif_addax_1",
- "inherits": "default single"
- },
- {
- "name": "espressif_c3_devkitc",
- "inherits": "default single"
- },
- {
- "name": "espressif_c6_devkitc",
- "inherits": "default single"
- },
- {
- "name": "espressif_kaluga_1",
- "inherits": "default single"
- },
- {
- "name": "espressif_p4_function_ev",
- "inherits": "default single"
- },
- {
- "name": "espressif_s2_devkitc",
- "inherits": "default single"
- },
- {
- "name": "espressif_s3_devkitc",
- "inherits": "default single"
- },
- {
- "name": "espressif_s3_devkitm",
- "inherits": "default single"
- },
- {
- "name": "espressif_saola_1",
- "inherits": "default single"
- },
- {
"name": "f1c100s",
"inherits": "default"
},
@@ -227,6 +227,10 @@
"inherits": "default"
},
{
+ "name": "frdm_mcxa156",
+ "inherits": "default"
+ },
+ {
"name": "frdm_mcxn947",
"inherits": "default"
},
@@ -359,6 +363,10 @@
"inherits": "default"
},
{
+ "name": "metro_nrf52840",
+ "inherits": "default"
+ },
+ {
"name": "mimxrt1010_evk",
"inherits": "default"
},
@@ -411,19 +419,47 @@
"inherits": "default"
},
{
- "name": "pca10056",
+ "name": "nanoch32v305",
+ "inherits": "default"
+ },
+ {
+ "name": "nrf52833dk",
+ "inherits": "default"
+ },
+ {
+ "name": "nrf52840dk",
"inherits": "default"
},
{
- "name": "pca10059",
+ "name": "nrf52840dongle",
"inherits": "default"
},
{
- "name": "pca10095",
+ "name": "nrf5340dk",
"inherits": "default"
},
{
- "name": "pca10100",
+ "name": "nrf54h20dk",
+ "inherits": "default"
+ },
+ {
+ "name": "nutiny_nuc126v",
+ "inherits": "default"
+ },
+ {
+ "name": "nutiny_sdk_nuc120",
+ "inherits": "default"
+ },
+ {
+ "name": "nutiny_sdk_nuc121",
+ "inherits": "default"
+ },
+ {
+ "name": "nutiny_sdk_nuc125",
+ "inherits": "default"
+ },
+ {
+ "name": "nutiny_sdk_nuc505",
"inherits": "default"
},
{
@@ -483,6 +519,14 @@
"inherits": "default"
},
{
+ "name": "raspberry_pi_pico2_riscv",
+ "inherits": "default"
+ },
+ {
+ "name": "raspberry_pi_pico_w",
+ "inherits": "default"
+ },
+ {
"name": "raspberrypi_cm4",
"inherits": "default"
},
@@ -503,6 +547,14 @@
"inherits": "default"
},
{
+ "name": "same70_qmtech",
+ "inherits": "default"
+ },
+ {
+ "name": "same70_xplained",
+ "inherits": "default"
+ },
+ {
"name": "samg55_xplained",
"inherits": "default"
},
@@ -523,10 +575,18 @@
"inherits": "default"
},
{
+ "name": "sltb009a",
+ "inherits": "default"
+ },
+ {
"name": "sparkfun_samd21_mini_usb",
"inherits": "default"
},
{
+ "name": "spresense",
+ "inherits": "default"
+ },
+ {
"name": "stlinkv3mini",
"inherits": "default"
},
@@ -687,6 +747,10 @@
"inherits": "default"
},
{
+ "name": "stm32l496nucleo",
+ "inherits": "default"
+ },
+ {
"name": "stm32l4p5nucleo",
"inherits": "default"
},
@@ -695,6 +759,18 @@
"inherits": "default"
},
{
+ "name": "stm32n6570dk",
+ "inherits": "default"
+ },
+ {
+ "name": "stm32n657nucleo",
+ "inherits": "default"
+ },
+ {
+ "name": "stm32u083cdk",
+ "inherits": "default"
+ },
+ {
"name": "stm32u545nucleo",
"inherits": "default"
},
@@ -715,6 +791,10 @@
"inherits": "default"
},
{
+ "name": "stm32wba_nucleo",
+ "inherits": "default"
+ },
+ {
"name": "teensy_35",
"inherits": "default"
},
@@ -745,6 +825,66 @@
{
"name": "xmc4700_relax",
"inherits": "default"
+ },
+ {
+ "name": "adafruit_feather_esp32_v2",
+ "inherits": "default single config"
+ },
+ {
+ "name": "adafruit_feather_esp32c6",
+ "inherits": "default single config"
+ },
+ {
+ "name": "adafruit_feather_esp32s2",
+ "inherits": "default single config"
+ },
+ {
+ "name": "adafruit_feather_esp32s3",
+ "inherits": "default single config"
+ },
+ {
+ "name": "adafruit_magtag_29gray",
+ "inherits": "default single config"
+ },
+ {
+ "name": "adafruit_metro_esp32s2",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_addax_1",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_c3_devkitc",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_c6_devkitc",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_kaluga_1",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_p4_function_ev",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_s2_devkitc",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_s3_devkitc",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_s3_devkitm",
+ "inherits": "default single config"
+ },
+ {
+ "name": "espressif_saola_1",
+ "inherits": "default single config"
}
],
"buildPresets": [
@@ -759,6 +899,11 @@
"configurePreset": "adafruit_feather_esp32_v2"
},
{
+ "name": "adafruit_feather_esp32c6",
+ "description": "Build preset for the adafruit_feather_esp32c6 board",
+ "configurePreset": "adafruit_feather_esp32c6"
+ },
+ {
"name": "adafruit_feather_esp32s2",
"description": "Build preset for the adafruit_feather_esp32s2 board",
"configurePreset": "adafruit_feather_esp32s2"
@@ -769,6 +914,16 @@
"configurePreset": "adafruit_feather_esp32s3"
},
{
+ "name": "adafruit_feather_rp2040_usb_host",
+ "description": "Build preset for the adafruit_feather_rp2040_usb_host board",
+ "configurePreset": "adafruit_feather_rp2040_usb_host"
+ },
+ {
+ "name": "adafruit_fruit_jam",
+ "description": "Build preset for the adafruit_fruit_jam board",
+ "configurePreset": "adafruit_fruit_jam"
+ },
+ {
"name": "adafruit_magtag_29gray",
"description": "Build preset for the adafruit_magtag_29gray board",
"configurePreset": "adafruit_magtag_29gray"
@@ -779,6 +934,11 @@
"configurePreset": "adafruit_metro_esp32s2"
},
{
+ "name": "adafruit_metro_rp2350",
+ "description": "Build preset for the adafruit_metro_rp2350 board",
+ "configurePreset": "adafruit_metro_rp2350"
+ },
+ {
"name": "apard32690",
"description": "Build preset for the apard32690 board",
"configurePreset": "apard32690"
@@ -789,6 +949,61 @@
"configurePreset": "arduino_nano33_ble"
},
{
+ "name": "at32f403a_weact_blackpill",
+ "description": "Build preset for the at32f403a_weact_blackpill board",
+ "configurePreset": "at32f403a_weact_blackpill"
+ },
+ {
+ "name": "at_start_f402",
+ "description": "Build preset for the at_start_f402 board",
+ "configurePreset": "at_start_f402"
+ },
+ {
+ "name": "at_start_f403a",
+ "description": "Build preset for the at_start_f403a board",
+ "configurePreset": "at_start_f403a"
+ },
+ {
+ "name": "at_start_f405",
+ "description": "Build preset for the at_start_f405 board",
+ "configurePreset": "at_start_f405"
+ },
+ {
+ "name": "at_start_f407",
+ "description": "Build preset for the at_start_f407 board",
+ "configurePreset": "at_start_f407"
+ },
+ {
+ "name": "at_start_f413",
+ "description": "Build preset for the at_start_f413 board",
+ "configurePreset": "at_start_f413"
+ },
+ {
+ "name": "at_start_f415",
+ "description": "Build preset for the at_start_f415 board",
+ "configurePreset": "at_start_f415"
+ },
+ {
+ "name": "at_start_f423",
+ "description": "Build preset for the at_start_f423 board",
+ "configurePreset": "at_start_f423"
+ },
+ {
+ "name": "at_start_f425",
+ "description": "Build preset for the at_start_f425 board",
+ "configurePreset": "at_start_f425"
+ },
+ {
+ "name": "at_start_f435",
+ "description": "Build preset for the at_start_f435 board",
+ "configurePreset": "at_start_f435"
+ },
+ {
+ "name": "at_start_f437",
+ "description": "Build preset for the at_start_f437 board",
+ "configurePreset": "at_start_f437"
+ },
+ {
"name": "atsamd21_xpro",
"description": "Build preset for the atsamd21_xpro board",
"configurePreset": "atsamd21_xpro"
@@ -1004,6 +1219,11 @@
"configurePreset": "frdm_mcxa153"
},
{
+ "name": "frdm_mcxa156",
+ "description": "Build preset for the frdm_mcxa156 board",
+ "configurePreset": "frdm_mcxa156"
+ },
+ {
"name": "frdm_mcxn947",
"description": "Build preset for the frdm_mcxn947 board",
"configurePreset": "frdm_mcxn947"
@@ -1169,6 +1389,11 @@
"configurePreset": "metro_m7_1011_sd"
},
{
+ "name": "metro_nrf52840",
+ "description": "Build preset for the metro_nrf52840 board",
+ "configurePreset": "metro_nrf52840"
+ },
+ {
"name": "mimxrt1010_evk",
"description": "Build preset for the mimxrt1010_evk board",
"configurePreset": "mimxrt1010_evk"
@@ -1234,24 +1459,59 @@
"configurePreset": "nanoch32v203"
},
{
- "name": "pca10056",
- "description": "Build preset for the pca10056 board",
- "configurePreset": "pca10056"
+ "name": "nanoch32v305",
+ "description": "Build preset for the nanoch32v305 board",
+ "configurePreset": "nanoch32v305"
+ },
+ {
+ "name": "nrf52833dk",
+ "description": "Build preset for the nrf52833dk board",
+ "configurePreset": "nrf52833dk"
+ },
+ {
+ "name": "nrf52840dk",
+ "description": "Build preset for the nrf52840dk board",
+ "configurePreset": "nrf52840dk"
+ },
+ {
+ "name": "nrf52840dongle",
+ "description": "Build preset for the nrf52840dongle board",
+ "configurePreset": "nrf52840dongle"
+ },
+ {
+ "name": "nrf5340dk",
+ "description": "Build preset for the nrf5340dk board",
+ "configurePreset": "nrf5340dk"
},
{
- "name": "pca10059",
- "description": "Build preset for the pca10059 board",
- "configurePreset": "pca10059"
+ "name": "nrf54h20dk",
+ "description": "Build preset for the nrf54h20dk board",
+ "configurePreset": "nrf54h20dk"
},
{
- "name": "pca10095",
- "description": "Build preset for the pca10095 board",
- "configurePreset": "pca10095"
+ "name": "nutiny_nuc126v",
+ "description": "Build preset for the nutiny_nuc126v board",
+ "configurePreset": "nutiny_nuc126v"
},
{
- "name": "pca10100",
- "description": "Build preset for the pca10100 board",
- "configurePreset": "pca10100"
+ "name": "nutiny_sdk_nuc120",
+ "description": "Build preset for the nutiny_sdk_nuc120 board",
+ "configurePreset": "nutiny_sdk_nuc120"
+ },
+ {
+ "name": "nutiny_sdk_nuc121",
+ "description": "Build preset for the nutiny_sdk_nuc121 board",
+ "configurePreset": "nutiny_sdk_nuc121"
+ },
+ {
+ "name": "nutiny_sdk_nuc125",
+ "description": "Build preset for the nutiny_sdk_nuc125 board",
+ "configurePreset": "nutiny_sdk_nuc125"
+ },
+ {
+ "name": "nutiny_sdk_nuc505",
+ "description": "Build preset for the nutiny_sdk_nuc505 board",
+ "configurePreset": "nutiny_sdk_nuc505"
},
{
"name": "pico_sdk",
@@ -1324,6 +1584,16 @@
"configurePreset": "raspberry_pi_pico2"
},
{
+ "name": "raspberry_pi_pico2_riscv",
+ "description": "Build preset for the raspberry_pi_pico2_riscv board",
+ "configurePreset": "raspberry_pi_pico2_riscv"
+ },
+ {
+ "name": "raspberry_pi_pico_w",
+ "description": "Build preset for the raspberry_pi_pico_w board",
+ "configurePreset": "raspberry_pi_pico_w"
+ },
+ {
"name": "raspberrypi_cm4",
"description": "Build preset for the raspberrypi_cm4 board",
"configurePreset": "raspberrypi_cm4"
@@ -1349,6 +1619,16 @@
"configurePreset": "same54_xplained"
},
{
+ "name": "same70_qmtech",
+ "description": "Build preset for the same70_qmtech board",
+ "configurePreset": "same70_qmtech"
+ },
+ {
+ "name": "same70_xplained",
+ "description": "Build preset for the same70_xplained board",
+ "configurePreset": "same70_xplained"
+ },
+ {
"name": "samg55_xplained",
"description": "Build preset for the samg55_xplained board",
"configurePreset": "samg55_xplained"
@@ -1374,11 +1654,21 @@
"configurePreset": "sipeed_longan_nano"
},
{
+ "name": "sltb009a",
+ "description": "Build preset for the sltb009a board",
+ "configurePreset": "sltb009a"
+ },
+ {
"name": "sparkfun_samd21_mini_usb",
"description": "Build preset for the sparkfun_samd21_mini_usb board",
"configurePreset": "sparkfun_samd21_mini_usb"
},
{
+ "name": "spresense",
+ "description": "Build preset for the spresense board",
+ "configurePreset": "spresense"
+ },
+ {
"name": "stlinkv3mini",
"description": "Build preset for the stlinkv3mini board",
"configurePreset": "stlinkv3mini"
@@ -1579,6 +1869,11 @@
"configurePreset": "stm32l476disco"
},
{
+ "name": "stm32l496nucleo",
+ "description": "Build preset for the stm32l496nucleo board",
+ "configurePreset": "stm32l496nucleo"
+ },
+ {
"name": "stm32l4p5nucleo",
"description": "Build preset for the stm32l4p5nucleo board",
"configurePreset": "stm32l4p5nucleo"
@@ -1589,6 +1884,21 @@
"configurePreset": "stm32l4r5nucleo"
},
{
+ "name": "stm32n6570dk",
+ "description": "Build preset for the stm32n6570dk board",
+ "configurePreset": "stm32n6570dk"
+ },
+ {
+ "name": "stm32n657nucleo",
+ "description": "Build preset for the stm32n657nucleo board",
+ "configurePreset": "stm32n657nucleo"
+ },
+ {
+ "name": "stm32u083cdk",
+ "description": "Build preset for the stm32u083cdk board",
+ "configurePreset": "stm32u083cdk"
+ },
+ {
"name": "stm32u545nucleo",
"description": "Build preset for the stm32u545nucleo board",
"configurePreset": "stm32u545nucleo"
@@ -1614,6 +1924,11 @@
"configurePreset": "stm32wb55nucleo"
},
{
+ "name": "stm32wba_nucleo",
+ "description": "Build preset for the stm32wba_nucleo board",
+ "configurePreset": "stm32wba_nucleo"
+ },
+ {
"name": "teensy_35",
"description": "Build preset for the teensy_35 board",
"configurePreset": "teensy_35"
@@ -1682,6 +1997,19 @@
]
},
{
+ "name": "adafruit_feather_esp32c6",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "adafruit_feather_esp32c6"
+ },
+ {
+ "type": "build",
+ "name": "adafruit_feather_esp32c6"
+ }
+ ]
+ },
+ {
"name": "adafruit_feather_esp32s2",
"steps": [
{
@@ -1708,6 +2036,32 @@
]
},
{
+ "name": "adafruit_feather_rp2040_usb_host",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "adafruit_feather_rp2040_usb_host"
+ },
+ {
+ "type": "build",
+ "name": "adafruit_feather_rp2040_usb_host"
+ }
+ ]
+ },
+ {
+ "name": "adafruit_fruit_jam",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "adafruit_fruit_jam"
+ },
+ {
+ "type": "build",
+ "name": "adafruit_fruit_jam"
+ }
+ ]
+ },
+ {
"name": "adafruit_magtag_29gray",
"steps": [
{
@@ -1734,6 +2088,19 @@
]
},
{
+ "name": "adafruit_metro_rp2350",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "adafruit_metro_rp2350"
+ },
+ {
+ "type": "build",
+ "name": "adafruit_metro_rp2350"
+ }
+ ]
+ },
+ {
"name": "apard32690",
"steps": [
{
@@ -1760,6 +2127,149 @@
]
},
{
+ "name": "at32f403a_weact_blackpill",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at32f403a_weact_blackpill"
+ },
+ {
+ "type": "build",
+ "name": "at32f403a_weact_blackpill"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f402",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f402"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f402"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f403a",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f403a"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f403a"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f405",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f405"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f405"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f407",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f407"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f407"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f413",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f413"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f413"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f415",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f415"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f415"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f423",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f423"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f423"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f425",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f425"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f425"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f435",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f435"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f435"
+ }
+ ]
+ },
+ {
+ "name": "at_start_f437",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "at_start_f437"
+ },
+ {
+ "type": "build",
+ "name": "at_start_f437"
+ }
+ ]
+ },
+ {
"name": "atsamd21_xpro",
"steps": [
{
@@ -2319,6 +2829,19 @@
]
},
{
+ "name": "frdm_mcxa156",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "frdm_mcxa156"
+ },
+ {
+ "type": "build",
+ "name": "frdm_mcxa156"
+ }
+ ]
+ },
+ {
"name": "frdm_mcxn947",
"steps": [
{
@@ -2748,6 +3271,19 @@
]
},
{
+ "name": "metro_nrf52840",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "metro_nrf52840"
+ },
+ {
+ "type": "build",
+ "name": "metro_nrf52840"
+ }
+ ]
+ },
+ {
"name": "mimxrt1010_evk",
"steps": [
{
@@ -2917,54 +3453,145 @@
]
},
{
- "name": "pca10056",
+ "name": "nanoch32v305",
"steps": [
{
"type": "configure",
- "name": "pca10056"
+ "name": "nanoch32v305"
},
{
"type": "build",
- "name": "pca10056"
+ "name": "nanoch32v305"
}
]
},
{
- "name": "pca10059",
+ "name": "nrf52833dk",
"steps": [
{
"type": "configure",
- "name": "pca10059"
+ "name": "nrf52833dk"
},
{
"type": "build",
- "name": "pca10059"
+ "name": "nrf52833dk"
}
]
},
{
- "name": "pca10095",
+ "name": "nrf52840dk",
"steps": [
{
"type": "configure",
- "name": "pca10095"
+ "name": "nrf52840dk"
},
{
"type": "build",
- "name": "pca10095"
+ "name": "nrf52840dk"
}
]
},
{
- "name": "pca10100",
+ "name": "nrf52840dongle",
"steps": [
{
"type": "configure",
- "name": "pca10100"
+ "name": "nrf52840dongle"
},
{
"type": "build",
- "name": "pca10100"
+ "name": "nrf52840dongle"
+ }
+ ]
+ },
+ {
+ "name": "nrf5340dk",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nrf5340dk"
+ },
+ {
+ "type": "build",
+ "name": "nrf5340dk"
+ }
+ ]
+ },
+ {
+ "name": "nrf54h20dk",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nrf54h20dk"
+ },
+ {
+ "type": "build",
+ "name": "nrf54h20dk"
+ }
+ ]
+ },
+ {
+ "name": "nutiny_nuc126v",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nutiny_nuc126v"
+ },
+ {
+ "type": "build",
+ "name": "nutiny_nuc126v"
+ }
+ ]
+ },
+ {
+ "name": "nutiny_sdk_nuc120",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nutiny_sdk_nuc120"
+ },
+ {
+ "type": "build",
+ "name": "nutiny_sdk_nuc120"
+ }
+ ]
+ },
+ {
+ "name": "nutiny_sdk_nuc121",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nutiny_sdk_nuc121"
+ },
+ {
+ "type": "build",
+ "name": "nutiny_sdk_nuc121"
+ }
+ ]
+ },
+ {
+ "name": "nutiny_sdk_nuc125",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nutiny_sdk_nuc125"
+ },
+ {
+ "type": "build",
+ "name": "nutiny_sdk_nuc125"
+ }
+ ]
+ },
+ {
+ "name": "nutiny_sdk_nuc505",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "nutiny_sdk_nuc505"
+ },
+ {
+ "type": "build",
+ "name": "nutiny_sdk_nuc505"
}
]
},
@@ -3151,6 +3778,32 @@
]
},
{
+ "name": "raspberry_pi_pico2_riscv",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "raspberry_pi_pico2_riscv"
+ },
+ {
+ "type": "build",
+ "name": "raspberry_pi_pico2_riscv"
+ }
+ ]
+ },
+ {
+ "name": "raspberry_pi_pico_w",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "raspberry_pi_pico_w"
+ },
+ {
+ "type": "build",
+ "name": "raspberry_pi_pico_w"
+ }
+ ]
+ },
+ {
"name": "raspberrypi_cm4",
"steps": [
{
@@ -3216,6 +3869,32 @@
]
},
{
+ "name": "same70_qmtech",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "same70_qmtech"
+ },
+ {
+ "type": "build",
+ "name": "same70_qmtech"
+ }
+ ]
+ },
+ {
+ "name": "same70_xplained",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "same70_xplained"
+ },
+ {
+ "type": "build",
+ "name": "same70_xplained"
+ }
+ ]
+ },
+ {
"name": "samg55_xplained",
"steps": [
{
@@ -3281,6 +3960,19 @@
]
},
{
+ "name": "sltb009a",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "sltb009a"
+ },
+ {
+ "type": "build",
+ "name": "sltb009a"
+ }
+ ]
+ },
+ {
"name": "sparkfun_samd21_mini_usb",
"steps": [
{
@@ -3294,6 +3986,19 @@
]
},
{
+ "name": "spresense",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "spresense"
+ },
+ {
+ "type": "build",
+ "name": "spresense"
+ }
+ ]
+ },
+ {
"name": "stlinkv3mini",
"steps": [
{
@@ -3814,6 +4519,19 @@
]
},
{
+ "name": "stm32l496nucleo",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "stm32l496nucleo"
+ },
+ {
+ "type": "build",
+ "name": "stm32l496nucleo"
+ }
+ ]
+ },
+ {
"name": "stm32l4p5nucleo",
"steps": [
{
@@ -3840,6 +4558,45 @@
]
},
{
+ "name": "stm32n6570dk",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "stm32n6570dk"
+ },
+ {
+ "type": "build",
+ "name": "stm32n6570dk"
+ }
+ ]
+ },
+ {
+ "name": "stm32n657nucleo",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "stm32n657nucleo"
+ },
+ {
+ "type": "build",
+ "name": "stm32n657nucleo"
+ }
+ ]
+ },
+ {
+ "name": "stm32u083cdk",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "stm32u083cdk"
+ },
+ {
+ "type": "build",
+ "name": "stm32u083cdk"
+ }
+ ]
+ },
+ {
"name": "stm32u545nucleo",
"steps": [
{
@@ -3905,6 +4662,19 @@
]
},
{
+ "name": "stm32wba_nucleo",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "stm32wba_nucleo"
+ },
+ {
+ "type": "build",
+ "name": "stm32wba_nucleo"
+ }
+ ]
+ },
+ {
"name": "teensy_35",
"steps": [
{
diff --git a/hw/bsp/ansi_escape.h b/hw/bsp/ansi_escape.h
index 15af2f3ab..0b72bea17 100644
--- a/hw/bsp/ansi_escape.h
+++ b/hw/bsp/ansi_escape.h
@@ -28,8 +28,8 @@
* \defgroup group_ansi_esc ANSI Escape Code
* @{ */
-#ifndef _TUSB_ANSI_ESC_CODE_H_
-#define _TUSB_ANSI_ESC_CODE_H_
+#ifndef TUSB_ANSI_ESC_CODE_H_
+#define TUSB_ANSI_ESC_CODE_H_
#ifdef __cplusplus
@@ -92,6 +92,6 @@
}
#endif
-#endif /* _TUSB_ANSI_ESC_CODE_H_ */
+#endif /* TUSB_ANSI_ESC_CODE_H_ */
/** @} */
diff --git a/hw/bsp/at32f402_405/at32f402_405_int.h b/hw/bsp/at32f402_405/at32f402_405_int.h
index 207a7d6df..82f924b61 100644
--- a/hw/bsp/at32f402_405/at32f402_405_int.h
+++ b/hw/bsp/at32f402_405/at32f402_405_int.h
@@ -48,6 +48,12 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void OTGFS1_IRQHandler(void);
+void OTGHS_IRQHandler(void);
+void OTGFS1_WKUP_IRQHandler(void);
+void OTGHS_WKUP_IRQHandler(void);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f402_405/family.c b/hw/bsp/at32f402_405/family.c
index cb5987cd4..beac1a7f8 100644
--- a/hw/bsp/at32f402_405/family.c
+++ b/hw/bsp/at32f402_405/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f402_405_clock.h"
+#include "at32f402_405_int.h"
#include "bsp/board_api.h"
#include "board.h"
@@ -40,20 +41,16 @@ void usb_gpio_config(void);
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
-void OTGFS1_IRQHandler(void)
-{
+void OTGFS1_IRQHandler(void) {
tusb_int_handler(0, true);
}
-void OTGHS_IRQHandler(void)
-{
+void OTGHS_IRQHandler(void) {
tusb_int_handler(1, true);
}
-void OTGFS1_WKUP_IRQHandler(void)
-{
+void OTGFS1_WKUP_IRQHandler(void) {
tusb_int_handler(0, true);
}
-void OTGHS_WKUP_IRQHandler(void)
-{
+void OTGHS_WKUP_IRQHandler(void) {
tusb_int_handler(1, true);
}
@@ -278,6 +275,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f402_405/family.cmake b/hw/bsp/at32f402_405/family.cmake
index b10760cef..87869cfe9 100644
--- a/hw/bsp/at32f402_405/family.cmake
+++ b/hw/bsp/at32f402_405/family.cmake
@@ -32,25 +32,21 @@ if (NOT DEFINED RHPORT_HOST_SPEED)
endif ()
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
@@ -58,7 +54,6 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -74,58 +69,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/at32f403a_407/at32f403a_407_int.h b/hw/bsp/at32f403a_407/at32f403a_407_int.h
index 6d85c70ca..242a4abe1 100644
--- a/hw/bsp/at32f403a_407/at32f403a_407_int.h
+++ b/hw/bsp/at32f403a_407/at32f403a_407_int.h
@@ -48,6 +48,12 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void USBFS_H_CAN1_TX_IRQHandler(void);
+void USBFS_L_CAN1_RX0_IRQHandler(void);
+void USBFS_MAPH_IRQHandler(void);
+void USBFS_MAPL_IRQHandler(void);
+void USBFSWakeUp_IRQHandler(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f403a_407/family.c b/hw/bsp/at32f403a_407/family.c
index 8c8329323..dd9b85dc5 100644
--- a/hw/bsp/at32f403a_407/family.c
+++ b/hw/bsp/at32f403a_407/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f403a_407_clock.h"
+#include "at32f403a_407_int.h"
#include "bsp/board_api.h"
#include "board.h"
@@ -266,6 +267,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f403a_407/family.cmake b/hw/bsp/at32f403a_407/family.cmake
index ae4037088..498b89c1a 100644
--- a/hw/bsp/at32f403a_407/family.cmake
+++ b/hw/bsp/at32f403a_407/family.cmake
@@ -15,25 +15,21 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
@@ -41,7 +37,6 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -51,56 +46,47 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/at32f413/at32f413_int.h b/hw/bsp/at32f413/at32f413_int.h
index fbbf30dbc..46ce271e5 100644
--- a/hw/bsp/at32f413/at32f413_int.h
+++ b/hw/bsp/at32f413/at32f413_int.h
@@ -48,6 +48,12 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void USBFS_H_CAN1_TX_IRQHandler(void);
+void USBFS_L_CAN1_RX0_IRQHandler(void);
+void USBFS_MAPH_IRQHandler(void);
+void USBFS_MAPL_IRQHandler(void);
+void USBFSWakeUp_IRQHandler(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f413/family.c b/hw/bsp/at32f413/family.c
index bb16d4d5b..bdaed523c 100644
--- a/hw/bsp/at32f413/family.c
+++ b/hw/bsp/at32f413/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f413_clock.h"
+#include "at32f413_int.h"
#include "board.h"
#include "bsp/board_api.h"
@@ -266,6 +267,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f413/family.cmake b/hw/bsp/at32f413/family.cmake
index b534bcbbc..02692daf5 100644
--- a/hw/bsp/at32f413/family.cmake
+++ b/hw/bsp/at32f413/family.cmake
@@ -15,25 +15,21 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
@@ -41,7 +37,6 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -51,56 +46,48 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/at32f415/at32f415_int.h b/hw/bsp/at32f415/at32f415_int.h
index 2106538b6..c6df83835 100644
--- a/hw/bsp/at32f415/at32f415_int.h
+++ b/hw/bsp/at32f415/at32f415_int.h
@@ -48,6 +48,9 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void OTGFS1_IRQHandler(void);
+void OTGFS1_WKUP_IRQHandler(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f415/family.c b/hw/bsp/at32f415/family.c
index 381b79eeb..2fbd4c821 100644
--- a/hw/bsp/at32f415/family.c
+++ b/hw/bsp/at32f415/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f415_clock.h"
+#include "at32f415_int.h"
#include "board.h"
#include "bsp/board_api.h"
@@ -262,6 +263,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f415/family.cmake b/hw/bsp/at32f415/family.cmake
index 8ac946265..f28da6f47 100644
--- a/hw/bsp/at32f415/family.cmake
+++ b/hw/bsp/at32f415/family.cmake
@@ -15,32 +15,27 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_misc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -49,58 +44,50 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/inc
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/at32f423/at32f423_int.h b/hw/bsp/at32f423/at32f423_int.h
index 28550331e..aa707346d 100644
--- a/hw/bsp/at32f423/at32f423_int.h
+++ b/hw/bsp/at32f423/at32f423_int.h
@@ -39,7 +39,7 @@ extern "C" {
/* exported functions ------------------------------------------------------- */
void NMI_Handler(void);
-//void HardFault_Handler(void);
+void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
@@ -48,6 +48,9 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void OTGFS1_IRQHandler(void);
+void OTGFS1_WKUP_IRQHandler(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f423/family.c b/hw/bsp/at32f423/family.c
index 723a8a2c9..f30c6a83f 100644
--- a/hw/bsp/at32f423/family.c
+++ b/hw/bsp/at32f423/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f423_clock.h"
+#include "at32f423_int.h"
#include "board.h"
#include "bsp/board_api.h"
@@ -266,6 +267,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f423/family.cmake b/hw/bsp/at32f423/family.cmake
index 17c3f37a2..3c666b132 100644
--- a/hw/bsp/at32f423/family.cmake
+++ b/hw/bsp/at32f423/family.cmake
@@ -15,25 +15,21 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
@@ -41,7 +37,6 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -51,58 +46,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/at32f425/at32f425_int.h b/hw/bsp/at32f425/at32f425_int.h
index ad9dc308b..56bb52d87 100644
--- a/hw/bsp/at32f425/at32f425_int.h
+++ b/hw/bsp/at32f425/at32f425_int.h
@@ -48,6 +48,9 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void OTGFS1_IRQHandler(void);
+void OTGFS1_WKUP_IRQHandler(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f425/family.c b/hw/bsp/at32f425/family.c
index 963e1485f..4ff4c8d6a 100644
--- a/hw/bsp/at32f425/family.c
+++ b/hw/bsp/at32f425/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f425_clock.h"
+#include "at32f425_int.h"
#include "board.h"
#include "bsp/board_api.h"
@@ -270,6 +271,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f425/family.cmake b/hw/bsp/at32f425/family.cmake
index 3f6b36a6b..39d98a220 100644
--- a/hw/bsp/at32f425/family.cmake
+++ b/hw/bsp/at32f425/family.cmake
@@ -15,32 +15,27 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_misc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_usart.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -49,58 +44,50 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/inc
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/at32f435_437/at32f435_437_int.h b/hw/bsp/at32f435_437/at32f435_437_int.h
index 76bfaaae4..1fa34419f 100644
--- a/hw/bsp/at32f435_437/at32f435_437_int.h
+++ b/hw/bsp/at32f435_437/at32f435_437_int.h
@@ -48,6 +48,11 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void OTGFS1_IRQHandler(void);
+void OTGFS2_IRQHandler(void);
+void OTGFS1_WKUP_IRQHandler(void);
+void OTGFS2_WKUP_IRQHandler(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bsp/at32f435_437/family.c b/hw/bsp/at32f435_437/family.c
index a65116729..4bd6ee73c 100644
--- a/hw/bsp/at32f435_437/family.c
+++ b/hw/bsp/at32f435_437/family.c
@@ -29,6 +29,7 @@
*/
#include "at32f435_437_clock.h"
+#include "at32f435_437_int.h"
#include "board.h"
#include "bsp/board_api.h"
@@ -332,6 +333,7 @@ void HardFault_Handler(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/at32f435_437/family.cmake b/hw/bsp/at32f435_437/family.cmake
index 085e5462b..32a401bb6 100644
--- a/hw/bsp/at32f435_437/family.cmake
+++ b/hw/bsp/at32f435_437/family.cmake
@@ -15,25 +15,21 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS ${AT32_FAMILY_UPPER} CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+set(STARTUP_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/startup_${AT32_FAMILY}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/startup_${AT32_FAMILY}.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/gcc/linker/${MCU_LINKER_NAME}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${AT32_SDK_LIB}/cmsis/cm4/device_support/startup/iar/linker/${MCU_LINKER_NAME}.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${AT32_SDK_LIB}/cmsis/cm4/device_support/system_${AT32_FAMILY}.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_gpio.c
@@ -42,7 +38,6 @@ function(add_board_target BOARD_TARGET)
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_acc.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_crm.c
${AT32_SDK_LIB}/drivers/src/${AT32_FAMILY}_exint.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -58,58 +53,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_clock.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${AT32_FAMILY}_int.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${AT32_FAMILY_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index e141664da..483d9dc28 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -31,7 +31,7 @@
#ifdef __ICCARM__
#define sys_write __write
#define sys_read __read
-#elif defined(__MSP430__) || defined(__RX__)
+#elif defined(__MSP430__) || defined(__RX__) || TU_CHECK_MCU(OPT_MCU_NUC120, OPT_MCU_NUC121, OPT_MCU_NUC126, OPT_MCU_NUC505)
#define sys_write write
#define sys_read read
#else
@@ -51,8 +51,7 @@ int sys_read(int fhdl, char *buf, size_t count) TU_ATTR_USED;
int sys_write(int fhdl, const char *buf, size_t count) {
(void) fhdl;
- SEGGER_RTT_Write(0, (const char *) buf, (int) count);
- return (int) count;
+ return (int) SEGGER_RTT_Write(0, buf, (int) count);
}
int sys_read(int fhdl, char *buf, size_t count) {
@@ -111,16 +110,6 @@ int sys_read (int fhdl, char *buf, size_t count) {
#endif
-//int _close(int fhdl) {
-// (void) fhdl;
-// return 0;
-//}
-
-//int _fstat(int file, struct stat *st) {
-// memset(st, 0, sizeof(*st));
-// st->st_mode = S_IFCHR;
-//}
-
// Clang use picolibc
#if defined(__clang__)
static int cl_putc(char c, FILE *f) {
@@ -147,8 +136,8 @@ TU_ATTR_WEAK size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
// fixed serial string is 01234567889ABCDEF
uint32_t* uid32 = (uint32_t*) (uintptr_t)id;
- uid32[0] = 0x67452301;
- uid32[1] = 0xEFCDAB89;
+ uid32[0] = 0x67452301u;
+ uid32[1] = 0xEFCDAB89u;
return 8;
}
@@ -169,7 +158,7 @@ int board_getchar(void) {
}
void board_putchar(int c) {
- sys_write(0, (const char*)&c, 1);
+ (void) sys_write(0, (const char*)&c, 1);
}
uint32_t tusb_time_millis_api(void) {
@@ -180,9 +169,11 @@ uint32_t tusb_time_millis_api(void) {
// FreeRTOS hooks
//--------------------------------------------------------------------
#if CFG_TUSB_OS == OPT_OS_FREERTOS && !defined(ESP_PLATFORM)
+
#include "FreeRTOS.h"
#include "task.h"
+void vApplicationMallocFailedHook(void); // missing prototype
void vApplicationMallocFailedHook(void) {
taskDISABLE_INTERRUPTS();
TU_ASSERT(false, );
@@ -199,7 +190,7 @@ void vApplicationStackOverflowHook(xTaskHandle pxTask, char *pcTaskName) {
/* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
* used by the Idle task. */
-void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) {
+void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
/* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits. */
@@ -243,6 +234,8 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
}
#if CFG_TUSB_MCU == OPT_MCU_RX63X || CFG_TUSB_MCU == OPT_MCU_RX65X
+void vApplicationSetupTimerInterrupt(void);
+
#include "iodefine.h"
void vApplicationSetupTimerInterrupt(void) {
/* Enable CMT0 */
diff --git a/hw/bsp/board_api.h b/hw/bsp/board_api.h
index 5ecd7797a..606ac484f 100644
--- a/hw/bsp/board_api.h
+++ b/hw/bsp/board_api.h
@@ -35,6 +35,7 @@ extern "C" {
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
+#include <stdio.h>
#include "tusb.h"
@@ -154,15 +155,17 @@ static inline size_t board_usb_get_serial(uint16_t desc_str1[], size_t max_chars
// TODO work with make, but not working with esp32s3 cmake
uid_len = board_get_unique_id(uid, sizeof(uid));
- if ( uid_len > max_chars / 2 ) uid_len = max_chars / 2;
+ if ( uid_len > max_chars / 2u ) {
+ uid_len = max_chars / 2u;
+ }
for ( size_t i = 0; i < uid_len; i++ ) {
for ( size_t j = 0; j < 2; j++ ) {
- const char nibble_to_hex[16] = {
+ const unsigned char nibble_to_hex[16] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
- uint8_t const nibble = (uid[i] >> (j * 4)) & 0xf;
+ const uint8_t nibble = (uint8_t) ((uid[i] >> (j * 4u)) & 0xfu);
desc_str1[i * 2 + (1 - j)] = nibble_to_hex[nibble]; // UTF-16-LE
}
}
diff --git a/hw/bsp/broadcom_32bit/family.cmake b/hw/bsp/broadcom_32bit/family.cmake
index 5e57d8b1e..3f327861b 100644
--- a/hw/bsp/broadcom_32bit/family.cmake
+++ b/hw/bsp/broadcom_32bit/family.cmake
@@ -10,24 +10,20 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS BCM2835 CACHE INTERNAL "")
-
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/broadcom/link.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/broadcom/boot.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/broadcom/link.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/broadcom/boot.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/broadcom/gen/interrupt_handlers.c
${SDK_DIR}/broadcom/gpio.c
@@ -35,7 +31,6 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/broadcom/mmu.c
${SDK_DIR}/broadcom/caches.c
${SDK_DIR}/broadcom/vcmailbox.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_compile_options(${BOARD_TARGET} PUBLIC
-O0
@@ -49,60 +44,53 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- "LINKER:--entry=_start"
- --specs=nosys.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- "LINKER:--entry=_start"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_BCM2835)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_BCM2835)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ "LINKER:--entry=_start"
+ --specs=nosys.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ "LINKER:--entry=_start"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/broadcom_64bit/family.cmake b/hw/bsp/broadcom_64bit/family.cmake
index 1a088c2c0..6294ebafd 100644
--- a/hw/bsp/broadcom_64bit/family.cmake
+++ b/hw/bsp/broadcom_64bit/family.cmake
@@ -11,24 +11,20 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/aarch64_${
set(FAMILY_MCUS BCM2711 BCM2835 CACHE INTERNAL "")
-
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/broadcom/link8.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/broadcom/boot8.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/broadcom/link8.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/broadcom/boot8.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/broadcom/gen/interrupt_handlers.c
${SDK_DIR}/broadcom/gpio.c
@@ -36,7 +32,6 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/broadcom/mmu.c
${SDK_DIR}/broadcom/caches.c
${SDK_DIR}/broadcom/vcmailbox.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_compile_options(${BOARD_TARGET} PUBLIC
-O0
@@ -54,62 +49,53 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
-# target_compile_options(${BOARD_TARGET} PUBLIC
-# )
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- "LINKER:--entry=_start"
- --specs=nosys.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- "LINKER:--entry=_start"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_BCM${BCM_VERSION})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_BCM${BCM_VERSION})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ "LINKER:--entry=_start"
+ --specs=nosys.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ "LINKER:--entry=_start"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/ch32f20x/ch32f20x_it.h b/hw/bsp/ch32f20x/ch32f20x_it.h
index 34f3bbf96..7daf0d76e 100644
--- a/hw/bsp/ch32f20x/ch32f20x_it.h
+++ b/hw/bsp/ch32f20x/ch32f20x_it.h
@@ -1,9 +1,9 @@
/********************************** (C) COPYRIGHT *******************************
-* File Name : ch32f20x_it.h
-* Author : WCH
-* Version : V1.0.0
-* Date : 2021/08/08
-* Description : This file contains the headers of the interrupt handlers.
+ * File Name : ch32f20x_it.h
+ * Author : WCH
+ * Version : V1.0.0
+ * Date : 2021/08/08
+ * Description : This file contains the headers of the interrupt handlers.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -21,5 +21,7 @@ void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
+void USBHS_IRQHandler(void);
+void SysTick_Handler(void);
#endif /* __CH32F20xIT_H */
diff --git a/hw/bsp/ch32f20x/family.c b/hw/bsp/ch32f20x/family.c
index 7fef71d47..7eae62fa4 100644
--- a/hw/bsp/ch32f20x/family.c
+++ b/hw/bsp/ch32f20x/family.c
@@ -32,6 +32,7 @@
#include "debug_uart.h"
#include "ch32f20x.h"
+#include "ch32f20x_it.h"
#include "bsp/board_api.h"
#include "board.h"
diff --git a/hw/bsp/ch32v10x/ch32v10x_it.h b/hw/bsp/ch32v10x/ch32v10x_it.h
index 13afc2412..34615bb69 100644
--- a/hw/bsp/ch32v10x/ch32v10x_it.h
+++ b/hw/bsp/ch32v10x/ch32v10x_it.h
@@ -12,4 +12,18 @@
#ifndef __CH32V10x_IT_H
#define __CH32V10x_IT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ch32v10x.h"
+
+void USBHD_IRQHandler(void);
+void USBWakeUp_IRQHandler(void);
+void SysTick_Handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __CH32V10x_IT_H */
diff --git a/hw/bsp/ch32v10x/family.c b/hw/bsp/ch32v10x/family.c
index f25102494..dfc041462 100644
--- a/hw/bsp/ch32v10x/family.c
+++ b/hw/bsp/ch32v10x/family.c
@@ -12,6 +12,7 @@
#endif
#include "ch32v10x.h"
+#include "ch32v10x_it.h"
#ifdef __GNUC__
#pragma GCC diagnostic pop
@@ -44,7 +45,7 @@ void SysTick_Handler(void) {
system_ticks++;
}
-uint32_t SysTick_Config(uint32_t ticks) {
+static uint32_t SysTick_Config(uint32_t ticks) {
NVIC_EnableIRQ(SysTicK_IRQn);
SysTick->CTLR = 0;
SysTick->CNTL0 = SysTick->CNTL1 = SysTick->CNTL2 = SysTick->CNTL3 = 0;
diff --git a/hw/bsp/ch32v10x/family.cmake b/hw/bsp/ch32v10x/family.cmake
index a73898050..fb9ccb3a3 100644
--- a/hw/bsp/ch32v10x/family.cmake
+++ b/hw/bsp/ch32v10x/family.cmake
@@ -16,24 +16,21 @@ set(FAMILY_MCUS CH32V103 CACHE INTERNAL "")
set(OPENOCD_OPTION "-f ${CMAKE_CURRENT_LIST_DIR}/wch-riscv.cfg")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${CH32_FAMILY}.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_SRC_DIR}/Startup/startup_${CH32_FAMILY}.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${CH32_FAMILY}.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_SRC_DIR}/Startup/startup_${CH32_FAMILY}.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_SRC_DIR}/Core/core_riscv.c
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_gpio.c
@@ -41,76 +38,61 @@ function(add_board_target BOARD_TARGET)
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_rcc.c
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_usart.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/system_${CH32_FAMILY}.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_SRC_DIR}/Core
${SDK_SRC_DIR}/Peripheral/inc
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
)
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- )
update_board(${BOARD_TARGET})
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_compile_options(${BOARD_TARGET} PUBLIC
- -mcmodel=medany
- )
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -Wl,--defsym=__FLASH_SIZE=${LD_FLASH_SIZE}
- -Wl,--defsym=__RAM_SIZE=${LD_RAM_SIZE}
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for MSP432E4")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_compile_options(${BOARD_TARGET} PUBLIC -mcmodel=medany)
+ endif()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_CH32V103)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/wch/dcd_ch32_usbfs.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_CH32V103)
-
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/wch/dcd_ch32_usbfs.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -Wl,--defsym=__FLASH_SIZE=${LD_FLASH_SIZE}
+ -Wl,--defsym=__RAM_SIZE=${LD_RAM_SIZE}
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_openocd_wch(${TARGET})
-
- #family_add_uf2(${TARGET} ${UF2_FAMILY_ID})
#family_flash_uf2(${TARGET} ${UF2_FAMILY_ID})
endfunction()
diff --git a/hw/bsp/ch32v20x/ch32v20x_it.h b/hw/bsp/ch32v20x/ch32v20x_it.h
index e49c61ae2..d1e8db255 100644
--- a/hw/bsp/ch32v20x/ch32v20x_it.h
+++ b/hw/bsp/ch32v20x/ch32v20x_it.h
@@ -12,4 +12,21 @@
#ifndef __CH32V20x_IT_H
#define __CH32V20x_IT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ch32v20x.h"
+
+void USB_LP_CAN1_RX0_IRQHandler(void);
+void USB_HP_CAN1_TX_IRQHandler(void);
+void USBWakeUp_IRQHandler(void);
+void USBHD_IRQHandler(void);
+void USBHDWakeUp_IRQHandler(void);
+void SysTick_Handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __CH32V20x_IT_H */
diff --git a/hw/bsp/ch32v20x/family.c b/hw/bsp/ch32v20x/family.c
index 510f82981..690acee1e 100644
--- a/hw/bsp/ch32v20x/family.c
+++ b/hw/bsp/ch32v20x/family.c
@@ -12,6 +12,7 @@ manufacturer: WCH
#endif
#include "ch32v20x.h"
+#include "ch32v20x_it.h"
#ifdef __GNUC__
#pragma GCC diagnostic pop
@@ -74,7 +75,7 @@ __attribute__((interrupt)) void SysTick_Handler(void) {
system_ticks++;
}
-uint32_t SysTick_Config(uint32_t ticks) {
+static uint32_t SysTick_Config(uint32_t ticks) {
NVIC_EnableIRQ(SysTicK_IRQn);
SysTick->CTLR = 0;
SysTick->SR = 0;
diff --git a/hw/bsp/ch32v20x/family.cmake b/hw/bsp/ch32v20x/family.cmake
index 10044d5b3..d8c7c5327 100644
--- a/hw/bsp/ch32v20x/family.cmake
+++ b/hw/bsp/ch32v20x/family.cmake
@@ -24,24 +24,21 @@ endif ()
set(RHPORT_HOST 1)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${CH32_FAMILY}.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_SRC_DIR}/Startup/startup_${CH32_FAMILY}_${MCU_VARIANT}.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${CH32_FAMILY}.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_SRC_DIR}/Startup/startup_${CH32_FAMILY}_${MCU_VARIANT}.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_SRC_DIR}/Core/core_riscv.c
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_flash.c
@@ -50,7 +47,6 @@ function(add_board_target BOARD_TARGET)
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_rcc.c
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_usart.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/system_${CH32_FAMILY}.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_SRC_DIR}/Core
@@ -79,65 +75,55 @@ function(add_board_target BOARD_TARGET)
)
endif()
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_compile_options(${BOARD_TARGET} PUBLIC
- -mcmodel=medany
- )
- target_link_options(${BOARD_TARGET} PUBLIC
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- -Wl,--defsym=__FLASH_SIZE=${LD_FLASH_SIZE}
- -Wl,--defsym=__RAM_SIZE=${LD_RAM_SIZE}
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for CH32v")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_compile_options(${TARGET} PUBLIC -mcmodel=medany)
+ endif()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_CH32V20X)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/wch/dcd_ch32_usbfs.c
+ ${TOP}/src/portable/wch/hcd_ch32_usbfs.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_CH32V20X)
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ -Wl,--defsym=__FLASH_SIZE=${LD_FLASH_SIZE}
+ -Wl,--defsym=__RAM_SIZE=${LD_RAM_SIZE}
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/wch/dcd_ch32_usbfs.c
- ${TOP}/src/portable/wch/hcd_ch32_usbfs.c
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_openocd_wch(${TARGET})
family_flash_wlink_rs(${TARGET})
-
- #family_add_uf2(${TARGET} ${UF2_FAMILY_ID})
#family_flash_uf2(${TARGET} ${UF2_FAMILY_ID})
endfunction()
diff --git a/hw/bsp/ch32v30x/ch32v30x_it.h b/hw/bsp/ch32v30x/ch32v30x_it.h
index f3977a8be..b9bf0b82e 100644
--- a/hw/bsp/ch32v30x/ch32v30x_it.h
+++ b/hw/bsp/ch32v30x/ch32v30x_it.h
@@ -10,7 +10,19 @@
#ifndef __CH32V30x_IT_H
#define __CH32V30x_IT_H
-// #include "debug.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ch32v30x.h"
+
+void USBHS_IRQHandler(void);
+void OTG_FS_IRQHandler(void);
+void SysTick_Handler(void);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __CH32V30x_IT_H */
diff --git a/hw/bsp/ch32v30x/debug_uart.c b/hw/bsp/ch32v30x/debug_uart.c
index 2fd3a9d64..4d2992c58 100644
--- a/hw/bsp/ch32v30x/debug_uart.c
+++ b/hw/bsp/ch32v30x/debug_uart.c
@@ -49,7 +49,8 @@ void USART1_IRQHandler(void) {
__asm volatile ("call USART1_IRQHandler_impl; mret");
}
-__attribute__((used)) void USART1_IRQHandler_impl(void)
+void USART1_IRQHandler_impl(void) __attribute__((used)) ;
+void USART1_IRQHandler_impl(void)
{
if(USART_GetITStatus(USART1, USART_IT_TC) != RESET)
{
diff --git a/hw/bsp/ch32v30x/family.c b/hw/bsp/ch32v30x/family.c
index bd01f4f46..c694f1a08 100644
--- a/hw/bsp/ch32v30x/family.c
+++ b/hw/bsp/ch32v30x/family.c
@@ -40,6 +40,7 @@
#include "debug_uart.h"
#include "ch32v30x.h"
+#include "ch32v30x_it.h"
#ifdef __GNUC__
#pragma GCC diagnostic pop
@@ -70,7 +71,7 @@ __attribute__((interrupt)) void OTG_FS_IRQHandler(void) {
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
-uint32_t SysTick_Config(uint32_t ticks) {
+static uint32_t SysTick_Config(uint32_t ticks) {
NVIC_EnableIRQ(SysTicK_IRQn);
SysTick->CTLR = 0;
SysTick->SR = 0;
diff --git a/hw/bsp/ch32v30x/family.cmake b/hw/bsp/ch32v30x/family.cmake
index 0fd9b786a..b974bd5e7 100644
--- a/hw/bsp/ch32v30x/family.cmake
+++ b/hw/bsp/ch32v30x/family.cmake
@@ -20,24 +20,21 @@ if (NOT DEFINED SPEED)
endif()
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/ch32v30x.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_SRC_DIR}/Startup/startup_${CH32_FAMILY}_D8C.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/ch32v30x.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_SRC_DIR}/Startup/startup_${CH32_FAMILY}_D8C.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_SRC_DIR}/Core/core_riscv.c
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_gpio.c
@@ -46,7 +43,6 @@ function(add_board_target BOARD_TARGET)
${SDK_SRC_DIR}/Peripheral/src/${CH32_FAMILY}_usart.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${CH32_FAMILY}_it.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/system_${CH32_FAMILY}.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_SRC_DIR}/Core
@@ -73,54 +69,49 @@ function(add_board_target BOARD_TARGET)
-fmessage-length=0
-fsigned-char
)
- target_link_options(${BOARD_TARGET} PUBLIC
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- -Wl,--defsym=__FLASH_SIZE=${LD_FLASH_SIZE}
- -Wl,--defsym=__RAM_SIZE=${LD_RAM_SIZE}
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for CH32v")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_CH32V307)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/debug_uart.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/wch/dcd_ch32_usbhs.c
+ ${TOP}/src/portable/wch/dcd_ch32_usbfs.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_CH32V307)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/wch/dcd_ch32_usbhs.c
- ${TOP}/src/portable/wch/dcd_ch32_usbfs.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ -Wl,--defsym=__FLASH_SIZE=${LD_FLASH_SIZE}
+ -Wl,--defsym=__RAM_SIZE=${LD_RAM_SIZE}
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/cxd56/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/cxd56/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..57b9d7dba
--- /dev/null
+++ b/hw/bsp/cxd56/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,150 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "nuttx/config.h"
+#endif
+
+/* Cortex-M4F port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*8*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+// CXD56 (Cortex-M4F) has 3 priority bits
+#define configPRIO_BITS 3
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#endif
diff --git a/hw/bsp/cxd56/boards/spresense/board.cmake b/hw/bsp/cxd56/boards/spresense/board.cmake
new file mode 100644
index 000000000..5fe77bfaf
--- /dev/null
+++ b/hw/bsp/cxd56/boards/spresense/board.cmake
@@ -0,0 +1,6 @@
+set(SERIAL /dev/ttyUSB0 CACHE STRING "Serial port for flashing")
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ )
+endfunction()
diff --git a/hw/bsp/cxd56/boards/spresense/board.h b/hw/bsp/cxd56/boards/spresense/board.h
new file mode 100644
index 000000000..45b1bb3e3
--- /dev/null
+++ b/hw/bsp/cxd56/boards/spresense/board.h
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include <arch/chip/pin.h>
+
+#define LED_PIN PIN_I2S1_BCK
+#define BUTTON_PIN PIN_HIF_IRQ_OUT
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/cxd56/boards/spresense/board.mk b/hw/bsp/cxd56/boards/spresense/board.mk
new file mode 100644
index 000000000..6c31c9d9d
--- /dev/null
+++ b/hw/bsp/cxd56/boards/spresense/board.mk
@@ -0,0 +1,7 @@
+# Spresense board configuration
+SERIAL ?= /dev/ttyUSB0
+
+# 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/hw/bsp/spresense/board_spresense.c b/hw/bsp/cxd56/family.c
index 8cd04a49d..a8e2fd52b 100644
--- a/hw/bsp/spresense/board_spresense.c
+++ b/hw/bsp/cxd56/family.c
@@ -25,18 +25,21 @@
*/
#include <sys/boardctl.h>
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
#include <nuttx/arch.h>
#include <arch/board/board.h>
-#include <arch/chip/pin.h>
-
-#include "bsp/board_api.h"
-/*------------------------------------------------------------------*/
-/* MACRO TYPEDEF CONSTANT ENUM
- *------------------------------------------------------------------*/
-#define LED_PIN PIN_I2S1_BCK
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
-#define BUTTON_PIN PIN_HIF_IRQ_OUT
+#include "bsp/board_api.h"
+#include "board.h"
// Initialize on-board peripherals : led, button, uart and USB
void board_init(void)
@@ -50,6 +53,10 @@ void board_init(void)
board_gpio_config(PIN_HIF_IRQ_OUT, 0, true, true, PIN_FLOAT);
};
+void board_late_initialize(void) {
+
+}
+
//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+
diff --git a/hw/bsp/cxd56/family.cmake b/hw/bsp/cxd56/family.cmake
new file mode 100644
index 000000000..7cd2f51f8
--- /dev/null
+++ b/hw/bsp/cxd56/family.cmake
@@ -0,0 +1,126 @@
+include_guard()
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+set(SDK_DIR ${TOP}/hw/mcu/sony/cxd56/spresense-exported-sdk)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+
+set(FAMILY_MCUS CXD56 CACHE INTERNAL "")
+
+# Detect platform for mkspk tool
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ set(MKSPK ${TOP}/hw/mcu/sony/cxd56/mkspk/mkspk)
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ set(MKSPK ${TOP}/hw/mcu/sony/cxd56/mkspk/mkspk)
+else()
+ set(MKSPK ${TOP}/hw/mcu/sony/cxd56/mkspk/mkspk.exe)
+endif()
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_GNU ${SDK_DIR}/nuttx/scripts/ramconfig.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+
+#------------------------------------
+# BOARD Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ # Spresense uses NuttX libraries
+ add_library(${BOARD_TARGET} INTERFACE)
+
+ target_include_directories(${BOARD_TARGET} INTERFACE
+ ${SDK_DIR}/nuttx/include
+ ${SDK_DIR}/nuttx/arch
+ ${SDK_DIR}/nuttx/arch/chip
+ ${SDK_DIR}/nuttx/arch/os
+ ${SDK_DIR}/sdk/include
+ )
+
+ target_compile_definitions(${BOARD_TARGET} INTERFACE
+ CONFIG_HAVE_DOUBLE
+ main=spresense_main
+ )
+
+ target_compile_options(${BOARD_TARGET} INTERFACE
+ -pipe
+ -std=gnu11
+ -fno-builtin
+ -fno-strength-reduce
+ -fomit-frame-pointer
+ -Wno-error=undef
+ -Wno-error=cast-align
+ -Wno-error=unused-parameter
+ -Wno-error=shadow
+ -Wno-error=redundant-decls
+ )
+
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_CXD56)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/sony/cxd56/dcd_cxd56.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ target_link_libraries(${TARGET} PUBLIC
+ ${SDK_DIR}/nuttx/libs/libapps.a
+ ${SDK_DIR}/nuttx/libs/libnuttx.a
+ gcc # Compiler runtime support for FP operations like __aeabi_dmul
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -Xlinker --entry=__start
+ -nostartfiles
+ -nodefaultlibs
+ -Wl,--gc-sections
+ -u spresense_main
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ -Xlinker --entry=__start
+ -nostartfiles
+ -nodefaultlibs
+ -u spresense_main
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ # Build mkspk tool
+ add_custom_command(OUTPUT ${MKSPK}
+ COMMAND $(MAKE) -C ${TOP}/hw/mcu/sony/cxd56/mkspk
+ COMMENT "Building mkspk tool"
+ )
+
+ # Create .spk file
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.spk
+ COMMAND ${MKSPK} -c 2 $<TARGET_FILE:${TARGET}> nuttx ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.spk
+ DEPENDS ${TARGET} ${MKSPK}
+ COMMENT "Creating ${TARGET}.spk"
+ )
+endfunction()
diff --git a/hw/bsp/spresense/board.mk b/hw/bsp/cxd56/family.mk
index 24f39d2b6..adfe9ee82 100644
--- a/hw/bsp/spresense/board.mk
+++ b/hw/bsp/cxd56/family.mk
@@ -1,3 +1,5 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
# Platforms are: Linux, Darwin, MSYS, CYGWIN
PLATFORM := $(firstword $(subst _, ,$(shell uname -s 2>/dev/null)))
@@ -12,19 +14,11 @@ else
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 \
@@ -32,6 +26,8 @@ CFLAGS += \
-Wno-error=unused-parameter \
-DCFG_TUSB_MCU=OPT_MCU_CXD56 \
+CPU_CORE ?= cortex-m4
+
# suppress following warnings from mcu driver
# lwip/src/core/raw.c:334:43: error: declaration of 'recv' shadows a global declaration
CFLAGS += -Wno-error=shadow -Wno-error=redundant-decls
@@ -48,6 +44,7 @@ INC += \
$(SPRESENSE_SDK)/nuttx/arch/chip \
$(SPRESENSE_SDK)/nuttx/arch/os \
$(SPRESENSE_SDK)/sdk/include \
+ $(TOP)/$(BOARD_PATH)
LIBS += \
$(SPRESENSE_SDK)/nuttx/libs/libapps.a \
@@ -69,7 +66,5 @@ $(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 $<
+# For freeRTOS port source
+FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM4F
diff --git a/hw/bsp/da1469x/family.cmake b/hw/bsp/da1469x/family.cmake
index 20d6cbc44..40070ba10 100644
--- a/hw/bsp/da1469x/family.cmake
+++ b/hw/bsp/da1469x/family.cmake
@@ -10,28 +10,24 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS DA1469X CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/da1469x.ld)
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/gcc_startup_da1469x.S)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- endif ()
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/da1469x.ld)
+endif ()
+if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
+set(STARTUP_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/gcc_startup_da1469x.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+endif ()
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${MCU_DIR}/src/system_da1469x.c
${MCU_DIR}/src/da1469x_clock.c
${MCU_DIR}/src/hal_gpio.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_compile_options(${BOARD_TARGET} PUBLIC -mthumb-interwork)
target_compile_definitions(${BOARD_TARGET} PUBLIC
@@ -46,31 +42,11 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_DIR}/mdk
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_DIR}/mdk
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
-
function(family_flash_jlink_dialog TARGET)
set(JLINKEXE JLinkExe)
set(JLINK_IF swd)
@@ -107,32 +83,42 @@ endfunction()
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_DA1469X)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/dialog/da146xx/dcd_da146xx.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_DA1469X)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/dialog/da146xx/dcd_da146xx.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/efm32/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/efm32/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..0b3e7cd2d
--- /dev/null
+++ b/hw/bsp/efm32/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,150 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "em_device.h"
+#endif
+
+/* Cortex-M4F port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*8*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+// EFM32GG12B has 3 priority bits
+#define configPRIO_BITS 3
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#endif
diff --git a/hw/bsp/efm32/boards/sltb009a/board.cmake b/hw/bsp/efm32/boards/sltb009a/board.cmake
new file mode 100644
index 000000000..7a84950b6
--- /dev/null
+++ b/hw/bsp/efm32/boards/sltb009a/board.cmake
@@ -0,0 +1,8 @@
+set(EFM32_FAMILY efm32gg12b)
+set(EFM32_MCU EFM32GG12B810F1024GM64)
+set(JLINK_DEVICE ${EFM32_MCU})
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ )
+endfunction()
diff --git a/hw/bsp/efm32/boards/sltb009a/board.h b/hw/bsp/efm32/boards/sltb009a/board.h
new file mode 100644
index 000000000..8ed6abe9f
--- /dev/null
+++ b/hw/bsp/efm32/boards/sltb009a/board.h
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#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
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/efm32/boards/sltb009a/board.mk b/hw/bsp/efm32/boards/sltb009a/board.mk
new file mode 100644
index 000000000..4b3e2a4e5
--- /dev/null
+++ b/hw/bsp/efm32/boards/sltb009a/board.mk
@@ -0,0 +1,9 @@
+EFM32_FAMILY = efm32gg12b
+EFM32_MCU = EFM32GG12B810F1024GM64
+JLINK_DEVICE = $(EFM32_MCU)
+
+CFLAGS += \
+ -D$(EFM32_MCU) \
+
+# For flash-jlink target
+flash: flash-jlink
diff --git a/hw/bsp/sltb009a/sltb009a.c b/hw/bsp/efm32/family.c
index 23ef6d7cd..39166bc4d 100644
--- a/hw/bsp/sltb009a/sltb009a.c
+++ b/hw/bsp/efm32/family.c
@@ -25,7 +25,8 @@
* This file is part of the TinyUSB stack.
*/
-#include "../board_api.h"
+#include "bsp/board_api.h"
+#include "board.h"
#include "em_device.h"
@@ -33,16 +34,6 @@
/* 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 */
/*--------------------------------------------------------------------*/
@@ -82,6 +73,7 @@ void UsageFault_Handler(void)
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void)
{
@@ -91,12 +83,12 @@ void _init(void)
/* Initing Funcs */
/*--------------------------------------------------------------------*/
-void emu_init(uint8_t immediate_switch)
+static 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)
+static void emu_reg_init(float target_voltage)
{
if(target_voltage < 2300.f || target_voltage >= 3800.f)
return;
@@ -108,7 +100,7 @@ void emu_reg_init(float target_voltage)
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)
+static 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;
@@ -279,7 +271,7 @@ void emu_dcdc_init(float target_voltage, float max_ln_current, float max_lp_curr
EMU->PWRCTRL = EMU_PWRCTRL_REGPWRSEL_DVDD | EMU_PWRCTRL_ANASW_AVDD;
}
-void cmu_hfxo_startup_calib(uint16_t ib_trim, uint16_t c_tune)
+static void cmu_hfxo_startup_calib(uint16_t ib_trim, uint16_t c_tune)
{
if(CMU->STATUS & CMU_STATUS_HFXOENS)
return;
@@ -287,7 +279,7 @@ void cmu_hfxo_startup_calib(uint16_t ib_trim, uint16_t c_tune)
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)
+static void cmu_hfxo_steady_calib(uint16_t ib_trim, uint16_t c_tune)
{
if(CMU->STATUS & CMU_STATUS_HFXOENS)
return;
@@ -295,7 +287,7 @@ void cmu_hfxo_steady_calib(uint16_t ib_trim, uint16_t c_tune)
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)
+static void cmu_hfrco_calib(uint32_t calibration)
{
if(CMU->STATUS & CMU_STATUS_DPLLENS)
return;
@@ -307,7 +299,7 @@ void cmu_hfrco_calib(uint32_t calibration)
while(CMU->SYNCBUSY & CMU_SYNCBUSY_HFRCOBSY);
}
-void cmu_ushfrco_calib(uint8_t enable, uint32_t calibration)
+static void cmu_ushfrco_calib(uint8_t enable, uint32_t calibration)
{
if(CMU->USBCRCTRL & CMU_USBCRCTRL_USBCREN)
return;
@@ -334,7 +326,7 @@ void cmu_ushfrco_calib(uint8_t enable, uint32_t calibration)
}
}
-void cmu_auxhfrco_calib(uint8_t enable, uint32_t calibration)
+static void cmu_auxhfrco_calib(uint8_t enable, uint32_t calibration)
{
if(!enable)
{
@@ -359,7 +351,7 @@ void cmu_auxhfrco_calib(uint8_t enable, uint32_t calibration)
}
-void cmu_init(void)
+static void cmu_init(void)
{
// Change SDIO clock to HFXO if HFRCO selected and disable it
CMU->SDIOCTRL = CMU_SDIOCTRL_SDIOCLKDIS | CMU_SDIOCTRL_SDIOCLKSEL_HFXO;
@@ -441,7 +433,7 @@ void cmu_init(void)
CMU->LFECLKSEL = CMU_LFECLKSEL_LFE_ULFRCO;
}
-void systick_init(void)
+static void systick_init(void)
{
SysTick->LOAD = (72000000 / 1000) - 1;
SysTick->VAL = 0;
@@ -450,7 +442,7 @@ void systick_init(void)
SCB->SHP[11] = 7 << (8 - __NVIC_PRIO_BITS); // Set priority 3,1 (min)
}
-void gpio_init(void)
+static void gpio_init(void)
{
CMU->HFBUSCLKEN0 |= CMU_HFBUSCLKEN0_GPIO;
diff --git a/hw/bsp/efm32/family.cmake b/hw/bsp/efm32/family.cmake
new file mode 100644
index 000000000..8c521eee0
--- /dev/null
+++ b/hw/bsp/efm32/family.cmake
@@ -0,0 +1,91 @@
+include_guard()
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# EFM32_FAMILY should be set by board.cmake (e.g. efm32gg12b)
+string(TOUPPER ${EFM32_FAMILY} EFM32_FAMILY_UPPER)
+set(SILABS_CMSIS ${TOP}/hw/mcu/silabs/cmsis-dfp-${EFM32_FAMILY}/Device/SiliconLabs/${EFM32_FAMILY_UPPER})
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+
+set(FAMILY_MCUS EFM32GG CACHE INTERNAL "")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_GNU ${SILABS_CMSIS}/Source/GCC/${EFM32_FAMILY}.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SILABS_CMSIS}/Source/GCC/startup_${EFM32_FAMILY}.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${SILABS_CMSIS}/Source/system_${EFM32_FAMILY}.c
+ )
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMSIS_5}/CMSIS/Core/Include
+ ${SILABS_CMSIS}/Include
+ )
+
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __STARTUP_CLEAR_BSS
+ __START=main
+ ${EFM32_MCU}
+ )
+
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_EFM32GG)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ # Flashing
+ family_add_bin_hex(${TARGET})
+ family_flash_jlink(${TARGET})
+endfunction()
diff --git a/hw/bsp/sltb009a/board.mk b/hw/bsp/efm32/family.mk
index 5dd7a158f..f115b6bd4 100644
--- a/hw/bsp/sltb009a/board.mk
+++ b/hw/bsp/efm32/family.mk
@@ -1,3 +1,5 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
CFLAGS += \
-flto \
-mthumb \
@@ -7,38 +9,31 @@ CFLAGS += \
-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
+CPU_CORE ?= cortex-m4
-SILABS_FAMILY = efm32gg12b
-SILABS_CMSIS = hw/mcu/silabs/cmsis-dfp-$(SILABS_FAMILY)/Device/SiliconLabs/$(shell echo $(SILABS_FAMILY) | tr a-z A-Z)
+# EFM32_FAMILY should be set by board.mk (e.g. efm32gg12b)
+SILABS_CMSIS = hw/mcu/silabs/cmsis-dfp-$(EFM32_FAMILY)/Device/SiliconLabs/$(shell echo $(EFM32_FAMILY) | tr a-z A-Z)
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
# All source paths should be relative to the top level.
-LD_FILE = $(SILABS_CMSIS)/Source/GCC/$(SILABS_FAMILY).ld
+LD_FILE = $(SILABS_CMSIS)/Source/GCC/$(EFM32_FAMILY).ld
SRC_C += \
- $(SILABS_CMSIS)/Source/system_$(SILABS_FAMILY).c \
+ $(SILABS_CMSIS)/Source/system_$(EFM32_FAMILY).c \
src/portable/synopsys/dwc2/dcd_dwc2.c \
src/portable/synopsys/dwc2/hcd_dwc2.c \
src/portable/synopsys/dwc2/dwc2_common.c \
SRC_S += \
- $(SILABS_CMSIS)/Source/GCC/startup_$(SILABS_FAMILY).S
+ $(SILABS_CMSIS)/Source/GCC/startup_$(EFM32_FAMILY).S
INC += \
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/$(SILABS_CMSIS)/Include \
- $(TOP)/hw/bsp/$(BOARD)
+ $(TOP)/$(BOARD_PATH)
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM4F
-
-# For flash-jlink target
-JLINK_DEVICE = EFM32GG12B810F1024
-
-flash: flash-jlink
diff --git a/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt b/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt
index 00e288bad..2f529dd68 100644
--- a/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt
+++ b/hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt
@@ -1,12 +1,12 @@
idf_build_get_property(target IDF_TARGET)
+include(CMakePrintHelpers)
-set(srcs)
-set(includes_public)
-set(compile_options)
-set(tusb_src "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src")
+set(tusb_src ${CMAKE_CURRENT_LIST_DIR}/../../../../../src)
+get_filename_component(tusb_src ${tusb_src} ABSOLUTE)
+include(${tusb_src}/CMakeLists.txt)
string(TOUPPER OPT_MCU_${target} tusb_mcu)
-list(APPEND compile_definitions
+set(compile_definitions
CFG_TUSB_MCU=${tusb_mcu}
CFG_TUSB_OS=OPT_OS_FREERTOS
BOARD_TUD_RHPORT=${RHPORT_DEVICE}
@@ -23,35 +23,11 @@ if (target STREQUAL esp32p4)
)
endif ()
+tinyusb_sources_get(srcs)
list(APPEND srcs
- # common
- ${tusb_src}/tusb.c
- ${tusb_src}/common/tusb_fifo.c
- # device
- ${tusb_src}/device/usbd.c
- ${tusb_src}/device/usbd_control.c
- ${tusb_src}/class/audio/audio_device.c
- ${tusb_src}/class/cdc/cdc_device.c
- ${tusb_src}/class/dfu/dfu_device.c
- ${tusb_src}/class/dfu/dfu_rt_device.c
- ${tusb_src}/class/hid/hid_device.c
- ${tusb_src}/class/midi/midi_device.c
- ${tusb_src}/class/msc/msc_device.c
- ${tusb_src}/class/net/ecm_rndis_device.c
- ${tusb_src}/class/net/ncm_device.c
- ${tusb_src}/class/usbtmc/usbtmc_device.c
- ${tusb_src}/class/vendor/vendor_device.c
- ${tusb_src}/class/video/video_device.c
${tusb_src}/portable/synopsys/dwc2/dcd_dwc2.c
${tusb_src}/portable/synopsys/dwc2/hcd_dwc2.c
${tusb_src}/portable/synopsys/dwc2/dwc2_common.c
- # host
- ${tusb_src}/host/usbh.c
- ${tusb_src}/host/hub.c
- ${tusb_src}/class/cdc/cdc_host.c
- ${tusb_src}/class/hid/hid_host.c
- ${tusb_src}/class/msc/msc_host.c
- ${tusb_src}/class/vendor/vendor_host.c
)
# use max3421 as host controller
@@ -73,7 +49,6 @@ if(DEFINED CFLAGS_CLI)
list(APPEND compile_definitions ${CFLAGS_CLI})
endif()
-
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${tusb_src}
REQUIRES src
@@ -81,4 +56,3 @@ idf_component_register(SRCS ${srcs}
)
target_compile_definitions(${COMPONENT_LIB} PUBLIC ${compile_definitions})
-target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-error=format)
diff --git a/hw/bsp/f1c100s/family.cmake b/hw/bsp/f1c100s/family.cmake
index 211c6645c..5522eeec7 100644
--- a/hw/bsp/f1c100s/family.cmake
+++ b/hw/bsp/f1c100s/family.cmake
@@ -11,25 +11,21 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS F1C100S CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/f1c100s.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_DIR}/machine/start.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/f1c100s.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_DIR}/machine/start.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/lib/malloc.c
${SDK_DIR}/lib/printf.c
@@ -43,70 +39,70 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/machine/sys-mmu.c
${SDK_DIR}/machine/sys-spi-flash.c
${SDK_DIR}/machine/f1c100s-intc.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
-
target_compile_definitions(${BOARD_TARGET} PUBLIC
__ARM32_ARCH__=5
+ __ARM926EJS__
+ )
+ target_compile_options(${BOARD_TARGET} PUBLIC
+ -ffreestanding
+ -std=gnu99
+ -mno-thumb-interwork
+ -Wno-float-equal
+ -Wno-unused-parameter
+ -Wno-error=array-bounds
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/include
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -lgcc
- --specs=nosys.specs --specs=nano.specs
- "LINKER:--defsym=__bss_end__=__bss_end"
- "LINKER:--defsym=__bss_start__=__bss_start"
- "LINKER:--defsym=end=__bss_end"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_F1C100S)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/sunxi/dcd_sunxi_musb.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_F1C100S)
- target_sources(${TARGET} PRIVATE
- ${TOP}/src/portable/sunxi/dcd_sunxi_musb.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_libraries(${TARGET} PUBLIC
+ gcc
+ )
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ "LINKER:--defsym=__bss_end__=__bss_end"
+ "LINKER:--defsym=__bss_start__=__bss_start"
+ "LINKER:--defsym=end=__bss_end"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/family_rules.mk b/hw/bsp/family_rules.mk
new file mode 100644
index 000000000..ccf49dd0e
--- /dev/null
+++ b/hw/bsp/family_rules.mk
@@ -0,0 +1,177 @@
+# ---------------------------------------
+# Common make rules for all examples
+# ---------------------------------------
+
+# Set all as default goal
+.DEFAULT_GOAL := all
+
+# ---------------- GNU Make Start -----------------------
+# ESP32-Sx and RP2040 has its own CMake build system
+ifeq (,$(findstring $(FAMILY),espressif rp2040))
+
+# ---------------------------------------
+# Rules
+# ---------------------------------------
+
+all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size
+
+uf2: $(BUILD)/$(PROJECT).uf2
+
+# We set vpath to point to the top of the tree so that the source files
+# can be located. By following this scheme, it allows a single build rule
+# to be used to compile all .c files.
+vpath %.c . $(TOP)
+vpath %.s . $(TOP)
+vpath %.S . $(TOP)
+
+include ${TOP}/examples/build_system/make/toolchain/$(TOOLCHAIN)_rules.mk
+
+# ---------------------------------------
+# Compiler Flags
+# ---------------------------------------
+
+CFLAGS += $(addprefix -I,$(INC))
+
+# Verbose mode
+ifeq ("$(V)","1")
+$(info CFLAGS $(CFLAGS) ) $(info )
+$(info LDFLAGS $(LDFLAGS)) $(info )
+$(info ASFLAGS $(ASFLAGS)) $(info )
+endif
+
+
+OBJ_DIRS = $(sort $(dir $(OBJ)))
+$(OBJ): | $(OBJ_DIRS)
+$(OBJ_DIRS):
+ifeq ($(CMDEXE),1)
+ -@$(MKDIR) $(subst /,\,$@)
+else
+ @$(MKDIR) -p $@
+endif
+
+# UF2 generation, iMXRT need to strip to text only before conversion
+ifneq ($(FAMILY),imxrt)
+$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex
+ @echo CREATE $@
+ $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $^
+endif
+
+copy-artifact: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex $(BUILD)/$(PROJECT).uf2
+
+endif
+# ---------------- GNU Make End -----------------------
+
+.PHONY: clean
+clean:
+ifeq ($(CMDEXE),1)
+ rd /S /Q $(subst /,\,$(BUILD))
+else
+ $(RM) -rf $(BUILD)
+endif
+
+# get depenecies
+.PHONY: get-deps
+get-deps:
+ $(PYTHON) $(TOP)/tools/get_deps.py ${FAMILY}
+
+.PHONY: size
+size: $(BUILD)/$(PROJECT).elf
+ -@echo ''
+ @$(SIZE) $<
+ -@echo ''
+
+# linkermap must be install previously at https://github.com/hathach/linkermap
+linkermap: $(BUILD)/$(PROJECT).elf
+ @linkermap -v $<.map
+
+# ---------------------------------------
+# Flash Targets
+# ---------------------------------------
+
+# --------------- Jlink -----------------
+ifeq ($(OS),Windows_NT)
+ JLINKEXE = JLink.exe
+else
+ JLINKEXE = JLinkExe
+endif
+
+# Jlink Interface
+JLINK_IF ?= swd
+
+# Jlink script
+$(BUILD)/$(BOARD).jlink: $(BUILD)/$(PROJECT).hex
+ @echo halt > $@
+ @echo loadfile $^ >> $@
+ @echo r >> $@
+ @echo go >> $@
+ @echo exit >> $@
+
+# Flash using jlink
+flash-jlink: $(BUILD)/$(BOARD).jlink
+ $(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $<
+
+# --------------- stm32 cube programmer -----------------
+# Flash STM32 MCU using stlink with STM32 Cube Programmer CLI
+flash-stlink: $(BUILD)/$(PROJECT).elf
+ STM32_Programmer_CLI --connect port=swd --write $< --go
+
+# --------------- xfel -----------------
+$(BUILD)/$(PROJECT)-sunxi.bin: $(BUILD)/$(PROJECT).bin
+ $(PYTHON) $(TOP)/tools/mksunxi.py $< $@
+
+flash-xfel: $(BUILD)/$(PROJECT)-sunxi.bin
+ xfel spinor write 0 $<
+ xfel reset
+
+# --------------- pyocd -----------------
+PYOCD_OPTION ?=
+flash-pyocd: $(BUILD)/$(PROJECT).hex
+ pyocd flash -t $(PYOCD_TARGET) $(PYOCD_OPTION) $<
+ #pyocd reset -t $(PYOCD_TARGET)
+
+# --------------- openocd -----------------
+OPENOCD_OPTION ?=
+flash-openocd: $(BUILD)/$(PROJECT).elf
+ openocd $(OPENOCD_OPTION) -c "program $< verify reset exit"
+
+# --------------- openocd-wch -----------------
+# wch-linke is not supported yet in official openOCD yet. We need to either use
+# 1. download openocd as part of mounriver studio http://www.mounriver.com/download or
+# 2. compiled from https://github.com/hathach/riscv-openocd-wch or
+# https://github.com/dragonlock2/miscboards/blob/main/wch/SDK/riscv-openocd.tar.xz
+# with ./configure --disable-werror --enable-wlinke --enable-ch347=no
+OPENOCD_WCH ?= /home/${USER}/app/riscv-openocd-wch/src/openocd
+OPENOCD_WCH_OPTION ?=
+flash-openocd-wch: $(BUILD)/$(PROJECT).elf
+ $(OPENOCD_WCH) $(OPENOCD_WCH_OPTION) -c init -c halt -c "flash write_image $<" -c reset -c exit
+
+# --------------- wlink-rs -----------------
+# flash with https://github.com/ch32-rs/wlink
+WLINK_RS ?= wlink
+flash-wlink-rs: $(BUILD)/$(PROJECT).elf
+ $(WLINK_RS) flash $<
+
+# --------------- dfu-util -----------------
+DFU_UTIL_OPTION ?= -a 0
+flash-dfu-util: $(BUILD)/$(PROJECT).bin
+ dfu-util -R $(DFU_UTIL_OPTION) -D $<
+
+# --------------- Black Magic -----------------
+# This symlink is created by https://github.com/blacksphere/blackmagic/blob/master/driver/99-blackmagic.rules
+BMP ?= /dev/ttyBmpGdb
+
+flash-bmp: $(BUILD)/$(PROJECT).elf
+ $(GDB) --batch -ex 'target extended-remote $(BMP)' -ex 'monitor swdp_scan' -ex 'attach 1' -ex load $<
+
+debug-bmp: $(BUILD)/$(PROJECT).elf
+ $(GDB) -ex 'target extended-remote $(BMP)' -ex 'monitor swdp_scan' -ex 'attach 1' $<
+
+# --------------- TI Uniflash -----------------
+DSLITE ?= dslite.sh
+flash-uniflash: $(BUILD)/$(PROJECT).hex
+ ${DSLITE} ${UNIFLASH_OPTION} -f $<
+
+# Print out the value of a make variable.
+# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
+print-%:
+ @echo $* = $($*)
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index 9ec80df91..2b9612186 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -1,6 +1,8 @@
include_guard(GLOBAL)
include(CMakePrintHelpers)
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+#set(CMAKE_C_STANDARD 11)
# TOP is path to root directory
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../..")
@@ -8,36 +10,99 @@ get_filename_component(TOP ${TOP} ABSOLUTE)
set(UF2CONV_PY ${TOP}/tools/uf2/utils/uf2conv.py)
-#-------------------------------------------------------------
-# RTOS
-#-------------------------------------------------------------
-if (NOT DEFINED RTOS)
- set(RTOS noos CACHE STRING "RTOS")
-endif ()
+function(family_resolve_board BOARD_NAME BOARD_PATH_OUT)
+ if ("${BOARD_NAME}" STREQUAL "")
+ message(FATAL_ERROR "You must set BOARD (e.g. metro_m4_express, raspberry_pi_pico). Use -DBOARD=xxx on the cmake command line.")
+ endif()
+
+ file(GLOB _board_paths
+ LIST_DIRECTORIES true
+ RELATIVE ${TOP}/hw/bsp
+ ${TOP}/hw/bsp/*/boards/*
+ )
+
+ set(_hint_names "")
+ foreach(_board_path ${_board_paths})
+ get_filename_component(_board_name ${_board_path} NAME)
+ if (_board_name STREQUAL "${BOARD_NAME}")
+ set(${BOARD_PATH_OUT} ${_board_path} PARENT_SCOPE)
+ return()
+ endif()
+ string(FIND "${_board_name}" "${BOARD_NAME}" _pos)
+ if (_pos EQUAL 0)
+ list(APPEND _hint_names ${_board_name})
+ endif()
+ endforeach()
+
+ if (_hint_names)
+ list(REMOVE_DUPLICATES _hint_names)
+ list(SORT _hint_names)
+ list(JOIN _hint_names ", " _hint_str)
+ message(FATAL_ERROR "BOARD '${BOARD_NAME}' not found. Boards with the same prefix:\n${_hint_str}")
+ else()
+ message(FATAL_ERROR "BOARD '${BOARD_NAME}' not found under hw/bsp/*/boards")
+ endif()
+endfunction()
#-------------------------------------------------------------
# Toolchain
-# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER=
+# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER= or ENV{CC}=
#-------------------------------------------------------------
-# Detect toolchain based on CMAKE_C_COMPILER
-if (DEFINED CMAKE_C_COMPILER)
- string(FIND ${CMAKE_C_COMPILER} "iccarm" IS_IAR)
- string(FIND ${CMAKE_C_COMPILER} "clang" IS_CLANG)
- string(FIND ${CMAKE_C_COMPILER} "gcc" IS_GCC)
+function(detect_compiler COMPILER_PATH RESULT)
+ string(FIND ${COMPILER_PATH} "iccarm" IS_IAR)
+ string(FIND ${COMPILER_PATH} "clang" IS_CLANG)
+ string(FIND ${COMPILER_PATH} "gcc" IS_GCC)
if (NOT IS_IAR EQUAL -1)
- set(TOOLCHAIN iar)
+ set(${RESULT} iar PARENT_SCOPE)
elseif (NOT IS_CLANG EQUAL -1)
- set(TOOLCHAIN clang)
+ set(${RESULT} clang PARENT_SCOPE)
elseif (NOT IS_GCC EQUAL -1)
- set(TOOLCHAIN gcc)
+ set(${RESULT} gcc PARENT_SCOPE)
endif ()
+endfunction()
+
+# Detect toolchain based on CMAKE_C_COMPILER or ENV{CC}
+if (DEFINED CMAKE_C_COMPILER)
+ detect_compiler(${CMAKE_C_COMPILER} TOOLCHAIN)
+elseif (DEFINED ENV{CC})
+ detect_compiler($ENV{CC} TOOLCHAIN)
endif ()
if (NOT DEFINED TOOLCHAIN)
set(TOOLCHAIN gcc)
endif ()
+set(WARN_FLAGS_GNU
+ -Wall
+ -Wextra
+ -Werror
+ -Wfatal-errors
+ -Wdouble-promotion
+ -Wstrict-prototypes
+ -Wstrict-overflow
+ -Werror-implicit-function-declaration
+ -Wfloat-equal
+ -Wundef
+ -Wshadow
+ -Wwrite-strings
+ -Wsign-compare
+ -Wmissing-format-attribute
+ -Wunreachable-code
+ -Wcast-align
+ -Wcast-function-type
+ -Wcast-qual
+ -Wnull-dereference
+ -Wuninitialized
+ -Wunused
+ -Wunused-function
+ -Wreturn-type
+ -Wredundant-decls
+ -Wmissing-prototypes
+# -Wconversion
+ )
+set(WARN_FLAGS_Clang ${WARN_FLAGS_GNU})
+
# Optimization
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
@@ -47,21 +112,8 @@ endif ()
# FAMILY and BOARD
#-------------------------------------------------------------
if (NOT DEFINED FAMILY)
- if (NOT DEFINED BOARD)
- message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif).
- You can do this via -DFAMILY=xxx on the cmake command line")
- endif ()
+ family_resolve_board("${BOARD}" BOARD_PATH)
- # Find path contains BOARD
- file(GLOB BOARD_PATH LIST_DIRECTORIES true
- RELATIVE ${TOP}/hw/bsp
- ${TOP}/hw/bsp/*/boards/${BOARD}
- )
- if (NOT BOARD_PATH)
- message(FATAL_ERROR "Could not detect FAMILY from BOARD=${BOARD}")
- endif ()
-
- # replace / with ; so that we can get the first element as FAMILY
string(REPLACE "/" ";" BOARD_PATH ${BOARD_PATH})
list(GET BOARD_PATH 0 FAMILY)
set(FAMILY ${FAMILY} CACHE STRING "Board family")
@@ -86,12 +138,21 @@ if (NOT NO_WARN_RWX_SEGMENTS_SUPPORTED)
endif()
#----------------------------------
-# Zephyr
+# RTOS
#----------------------------------
+if (NOT DEFINED RTOS)
+ set(RTOS noos CACHE STRING "RTOS")
+endif ()
+
if (RTOS STREQUAL zephyr)
set(BOARD_ROOT ${TOP}/hw/bsp/${FAMILY})
set(ZEPHYR_BOARD_ALIASES ${CMAKE_CURRENT_LIST_DIR}/zephyr_board_aliases.cmake)
find_package(Zephyr REQUIRED HINTS ${TOP}/zephyr)
+ list(REMOVE_ITEM WARN_FLAGS_GNU
+ -Wredundant-decls
+ -Wundef
+ -Wcast-align
+ )
endif ()
#-------------------------------------------------------------
@@ -166,6 +227,9 @@ endfunction()
# Common Target Configure
# Most families use these settings except rp2040 and espressif
#-------------------------------------------------------------
+function(family_add_board BOARD_TARGET)
+ # empty function, should be redefined in FAMILY/family.cmake
+endfunction()
# Add RTOS to example
function(family_add_rtos TARGET RTOS)
@@ -191,6 +255,22 @@ endfunction()
# Add common configuration to example
function(family_configure_common TARGET RTOS)
+ # Add board target
+ set(BOARD_TARGET board_${BOARD})
+ if (NOT RTOS STREQUAL zephyr)
+ if (NOT TARGET ${BOARD_TARGET})
+ family_add_board(${BOARD_TARGET})
+ set_target_properties(${BOARD_TARGET} PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
+ SKIP_LINTING ON # need cmake 4.2
+ )
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_target_properties(${BOARD_TARGET} PROPERTIES COMPILE_OPTIONS -w)
+ endif ()
+ endif ()
+ target_link_libraries(${TARGET} PUBLIC ${BOARD_TARGET})
+ endif ()
+
family_add_rtos(${TARGET} ${RTOS})
# Add BOARD_${BOARD} define
@@ -220,39 +300,14 @@ function(family_configure_common TARGET RTOS)
target_sources(${TARGET} PUBLIC ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
target_include_directories(${TARGET} PUBLIC ${TOP}/lib/SEGGER_RTT/RTT)
# target_compile_definitions(${TARGET} PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
+ set_source_files_properties(${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c PROPERTIES SKIP_LINTING ON)
endif ()
else ()
target_compile_definitions(${TARGET} PUBLIC LOGGER_UART)
endif ()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_compile_options(${TARGET} PRIVATE
- -Wall
- -Wextra
- #-Werror
- -Wfatal-errors
- -Wdouble-promotion
- -Wstrict-prototypes
- -Wstrict-overflow
- -Werror-implicit-function-declaration
- -Wfloat-equal
- -Wundef
- -Wshadow
- -Wwrite-strings
- -Wsign-compare
- -Wmissing-format-attribute
- -Wunreachable-code
- -Wcast-align
- -Wcast-function-type
- -Wcast-qual
- -Wnull-dereference
- -Wuninitialized
- -Wunused
- -Wunused-function
- -Wreturn-type
- -Wredundant-decls
- -Wmissing-prototypes
- )
+ target_compile_options(${TARGET} PRIVATE ${WARN_FLAGS_${CMAKE_C_COMPILER_ID}})
target_link_options(${TARGET} PUBLIC "LINKER:-Map=$<TARGET_FILE:${TARGET}>.map")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0
AND NO_WARN_RWX_SEGMENTS_SUPPORTED AND (NOT RTOS STREQUAL zephyr))
@@ -260,6 +315,21 @@ function(family_configure_common TARGET RTOS)
endif ()
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${TARGET} PUBLIC "LINKER:--map=$<TARGET_FILE:${TARGET}>.map")
+
+ if (IAR_CSTAT)
+ # link time analysis with C-STAT
+ add_custom_command(TARGET ${TARGET} POST_BUILD
+ COMMAND ${CMAKE_C_ICSTAT}
+ --db=${CMAKE_BINARY_DIR}/cstat.db
+ link_analyze -- ${CMAKE_LINKER} $<TARGET_OBJECTS:${TARGET}>
+ COMMAND_EXPAND_LISTS
+ )
+ # generate C-STAT report
+ add_custom_command(TARGET ${TARGET} POST_BUILD
+ COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/cstat_report
+ COMMAND ireport --db=${CMAKE_BINARY_DIR}/cstat.db --full --project ${TARGET} --output ${CMAKE_CURRENT_BINARY_DIR}/cstat_report/index.html
+ )
+ endif ()
endif ()
# run size after build
@@ -273,8 +343,8 @@ endfunction()
# Add tinyusb to target
function(family_add_tinyusb TARGET OPT_MCU)
- # tinyusb's CMakeList.txt
- add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
+ # tinyusb's CMakeLists.txt
+ include(${TOP}/src/CMakeLists.txt)
# Add TinyUSB sources, include and common define
tinyusb_target_add(${TARGET})
@@ -347,56 +417,6 @@ function(family_example_missing_dependency TARGET DEPENDENCY)
endfunction()
#----------------------------------
-# RPI specific: refactor later
-#----------------------------------
-function(family_add_default_example_warnings TARGET)
- target_compile_options(${TARGET} PUBLIC
- -Wall
- -Wextra
- -Werror
- -Wfatal-errors
- -Wdouble-promotion
- -Wfloat-equal
- # FIXME commented out because of https://github.com/raspberrypi/pico-sdk/issues/1468
- #-Wshadow
- -Wwrite-strings
- -Wsign-compare
- -Wmissing-format-attribute
- -Wunreachable-code
- -Wcast-align
- -Wcast-qual
- -Wnull-dereference
- -Wuninitialized
- -Wunused
- -Wredundant-decls
- #-Wstrict-prototypes
- #-Werror-implicit-function-declaration
- #-Wundef
- )
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
- target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
- endif()
-
- # GCC 10
- if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
- target_compile_options(${TARGET} PUBLIC -Wconversion)
- endif()
-
- # GCC 8
- if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
- target_compile_options(${TARGET} PUBLIC -Wcast-function-type -Wstrict-overflow)
- endif()
-
- # GCC 6
- if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
- target_compile_options(${TARGET} PUBLIC -Wno-strict-aliasing)
- endif()
- endif()
-endfunction()
-
-#----------------------------------
# Flashing target
#----------------------------------
@@ -532,6 +552,18 @@ function(family_flash_openocd_adi TARGET)
family_flash_openocd(${TARGET})
endfunction()
+# Add flash openocd-nuvoton target
+# compiled from https://github.com/OpenNuvoton/OpenOCD-Nuvoton
+function(family_flash_openocd_nuvoton TARGET)
+ if (NOT DEFINED OPENOCD)
+ set(OPENOCD $ENV{HOME}/app/OpenOCD-Nuvoton/src/openocd)
+ set(OPENOCD_OPTION2 "-s $ENV{HOME}/app/OpenOCD-Nuvoton/tcl")
+ endif ()
+
+ family_flash_openocd(${TARGET})
+endfunction()
+
+
# Add flash with https://github.com/ch32-rs/wlink
function(family_flash_wlink_rs TARGET)
if (NOT DEFINED WLINK_RS)
diff --git a/hw/bsp/family_support.mk b/hw/bsp/family_support.mk
new file mode 100644
index 000000000..db410a657
--- /dev/null
+++ b/hw/bsp/family_support.mk
@@ -0,0 +1,173 @@
+# ---------------------------------------
+# Common make definition for all examples
+# ---------------------------------------
+
+# upper helper function
+to_upper = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$(subst -,_,$(1))))))))))))))))))))))))))))
+
+#-------------------------------------------------------------
+# Toolchain
+# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
+#-------------------------------------------------------------
+ifneq (,$(findstring clang,$(CC)))
+ TOOLCHAIN = clang
+else ifneq (,$(findstring iccarm,$(CC)))
+ TOOLCHAIN = iar
+else ifneq (,$(findstring gcc,$(CC)))
+ TOOLCHAIN = gcc
+endif
+
+# Default to GCC
+ifndef TOOLCHAIN
+ TOOLCHAIN = gcc
+endif
+
+#-------------- TOP and EXAMPLE_PATH ------------
+
+# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree.
+# $(lastword $(MAKEFILE_LIST)) returns the name of this makefile relative to where make was invoked.
+THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
+
+# Set TOP to an absolute path
+TOP = $(abspath $(subst family_support.mk,../..,$(THIS_MAKEFILE)))
+
+# Set EXAMPLE_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc
+EXAMPLE_PATH = $(subst $(TOP)/,,$(abspath .))
+
+#-------------- Linux/Windows ------------
+# Detect whether shell style is windows or not
+# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069
+ifeq '$(findstring ;,$(PATH))' ';'
+# PATH contains semicolon - so we're definitely on Windows.
+CMDEXE := 1
+
+# makefile shell commands should use syntax for DOS CMD, not unix sh
+# Force DOS command shell on Windows.
+SHELL := cmd.exe
+endif
+
+ifeq ($(CMDEXE),1)
+ CP = copy
+ RM = del
+ MKDIR = mkdir
+ PYTHON = python
+else
+ CP = cp
+ RM = rm
+ MKDIR = mkdir
+ PYTHON = python3
+endif
+
+# Build directory
+BUILD := _build/$(BOARD)
+
+PROJECT := $(notdir $(CURDIR))
+
+#-------------------------------------------------------------
+# Family and Board
+#-------------------------------------------------------------
+BOARD_PATH := $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD)))
+FAMILY := $(word 3, $(subst /, ,$(BOARD_PATH)))
+FAMILY_PATH = hw/bsp/$(FAMILY)
+
+ifeq ($(BOARD_PATH),)
+ $(info You must provide a BOARD parameter with 'BOARD=')
+ $(error Invalid BOARD specified)
+endif
+
+# Include Family and Board specific defs
+include $(TOP)/$(FAMILY_PATH)/family.mk
+SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
+
+#-------------------------------------------------------------
+# Source files and compiler flags
+#-------------------------------------------------------------
+# tinyusb makefile
+include $(TOP)/src/tinyusb.mk
+SRC_C += $(TINYUSB_SRC_C)
+
+# Include all source C in family & board folder
+SRC_C += hw/bsp/board.c
+SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c))
+
+INC += \
+ $(TOP)/$(FAMILY_PATH) \
+ $(TOP)/src \
+ $(TOP)/hw \
+
+BOARD_UPPER = $(call to_upper,$(BOARD))
+CFLAGS += -DBOARD_$(BOARD_UPPER)
+
+ifdef CFLAGS_CLI
+ CFLAGS += $(CFLAGS_CLI)
+endif
+
+# use max3421 as host controller
+ifeq (${MAX3421_HOST},1)
+ SRC_C += src/portable/analog/max3421/hcd_max3421.c
+ CFLAGS += -DCFG_TUH_MAX3421=1
+endif
+
+# Log level is mapped to TUSB DEBUG option
+ifneq ($(LOG),)
+ CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
+endif
+
+# Logger: default is uart, can be set to rtt or swo
+ifeq ($(LOGGER),rtt)
+ CFLAGS += -DLOGGER_RTT
+ #CFLAGS += -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
+ INC += $(TOP)/lib/SEGGER_RTT/RTT
+ SRC_C += lib/SEGGER_RTT/RTT/SEGGER_RTT.c
+endif
+ifeq ($(LOGGER),swo)
+ CFLAGS += -DLOGGER_SWO
+else
+ CFLAGS += -DLOGGER_UART
+endif
+
+# CPU specific flags
+ifdef CPU_CORE
+ include ${TOP}/examples/build_system/make/cpu/$(CPU_CORE).mk
+endif
+
+# toolchain specific
+include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN).mk
+
+#---------------------- FreeRTOS -----------------------
+FREERTOS_SRC = lib/FreeRTOS-Kernel
+FREERTOS_PORTABLE_PATH = $(FREERTOS_SRC)/portable/$(if $(findstring iar,$(TOOLCHAIN)),IAR,GCC)
+
+ifeq ($(RTOS),freertos)
+ SRC_C += \
+ $(FREERTOS_SRC)/list.c \
+ $(FREERTOS_SRC)/queue.c \
+ $(FREERTOS_SRC)/tasks.c \
+ $(FREERTOS_SRC)/timers.c \
+ $(subst $(TOP)/,,$(wildcard $(TOP)/$(FREERTOS_PORTABLE_SRC)/*.c))
+
+ SRC_S += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FREERTOS_PORTABLE_SRC)/*.s))
+ INC += \
+ $(TOP)/hw/bsp/$(FAMILY)/FreeRTOSConfig \
+ $(TOP)/$(FREERTOS_SRC)/include \
+ $(TOP)/$(FREERTOS_PORTABLE_SRC)
+
+ CFLAGS += -DCFG_TUSB_OS=OPT_OS_FREERTOS
+
+ # Suppress FreeRTOSConfig.h warnings
+ CFLAGS_GCC += -Wno-error=redundant-decls
+
+ # Suppress FreeRTOS source warnings
+ CFLAGS_GCC += -Wno-error=cast-qual
+
+ # FreeRTOS (lto + Os) linker issue
+ LDFLAGS_GCC += -Wl,--undefined=vTaskSwitchContext
+endif
+
+#---------------- Helper ----------------
+check_defined = \
+ $(strip $(foreach 1,$1, \
+ $(call __check_defined,$1,$(strip $(value 2)))))
+__check_defined = \
+ $(if $(value $1),, \
+ $(error Undefined make flag: $1$(if $2, ($2))))
diff --git a/hw/bsp/fomu/family.c b/hw/bsp/fomu/family.c
index 61943cb01..9d7977bea 100644
--- a/hw/bsp/fomu/family.c
+++ b/hw/bsp/fomu/family.c
@@ -38,7 +38,6 @@
//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+
-
void fomu_error(uint32_t line)
{
(void)line;
diff --git a/hw/bsp/fomu/family.cmake b/hw/bsp/fomu/family.cmake
index 639373695..ac3c0c446 100644
--- a/hw/bsp/fomu/family.cmake
+++ b/hw/bsp/fomu/family.cmake
@@ -10,80 +10,68 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/riscv_${TO
set(FAMILY_MCUS VALENTYUSB_EPTRI CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/fomu.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/crt0-vexriscv.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fomu.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/crt0-vexriscv.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
-
- add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} INTERFACE)
+ target_include_directories(${BOARD_TARGET} INTERFACE
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/include
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for MSP432E4")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_VALENTYUSB_EPTRI)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/valentyusb/eptri/dcd_eptri.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_VALENTYUSB_EPTRI)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/valentyusb/eptri/dcd_eptri.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/fomu/family.mk b/hw/bsp/fomu/family.mk
index 69a546964..c29b1c70f 100644
--- a/hw/bsp/fomu/family.mk
+++ b/hw/bsp/fomu/family.mk
@@ -27,7 +27,7 @@ FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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 $@
+ python $(TOP)/$(FAMILY_PATH)/dfu.py -b $^ -D 0x1209:0x5bf0 $@
flash: $(BUILD)/$(PROJECT).dfu
dfu-util -D $^
diff --git a/hw/bsp/gd32vf103/family.cmake b/hw/bsp/gd32vf103/family.cmake
index a47871b38..76f520ea8 100644
--- a/hw/bsp/gd32vf103/family.cmake
+++ b/hw/bsp/gd32vf103/family.cmake
@@ -15,34 +15,30 @@ set(FAMILY_MCUS GD32VF103 CACHE INTERNAL "")
set(JLINK_IF jtag)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- message(FATAL_ERROR "LD_FILE_GNU is not defined")
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU
- ${SOC_DIR}/Common/Source/GCC/startup_gd32vf103.S
- ${SOC_DIR}/Common/Source/GCC/intexc_gd32vf103.S
- )
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+message(FATAL_ERROR "LD_FILE_GNU is not defined")
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU
+${SOC_DIR}/Common/Source/GCC/startup_gd32vf103.S
+${SOC_DIR}/Common/Source/GCC/intexc_gd32vf103.S
+)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/system_gd32vf103.c
${SOC_DIR}/Common/Source/Drivers/gd32vf103_rcu.c
${SOC_DIR}/Common/Source/Drivers/gd32vf103_gpio.c
${SOC_DIR}/Common/Source/Drivers/Usb/gd32vf103_usb_hw.c
${SOC_DIR}/Common/Source/Drivers/gd32vf103_usart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/NMSIS/Core/Include
@@ -61,33 +57,17 @@ function(add_board_target BOARD_TARGET)
-mcmodel=medlow
-mstrict-align
)
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for MSP432E4")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_GD32VF103)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${SOC_DIR}/Common/Source/Stubs/sbrk.c
@@ -96,24 +76,45 @@ function(family_configure_example TARGET RTOS)
${SOC_DIR}/Common/Source/Stubs/fstat.c
${SOC_DIR}/Common/Source/Stubs/lseek.c
${SOC_DIR}/Common/Source/Stubs/read.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_GD32VF103)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${SOC_DIR}/Common/Source/Stubs/sbrk.c
+ ${SOC_DIR}/Common/Source/Stubs/close.c
+ ${SOC_DIR}/Common/Source/Stubs/isatty.c
+ ${SOC_DIR}/Common/Source/Stubs/fstat.c
+ ${SOC_DIR}/Common/Source/Stubs/lseek.c
+ ${SOC_DIR}/Common/Source/Stubs/read.c
+ PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/imxrt/family.c b/hw/bsp/imxrt/family.c
index 9cd59b7d7..84b083e29 100644
--- a/hw/bsp/imxrt/family.c
+++ b/hw/bsp/imxrt/family.c
@@ -249,6 +249,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit(int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/imxrt/family.cmake b/hw/bsp/imxrt/family.cmake
index feec4973f..11cc00983 100644
--- a/hw/bsp/imxrt/family.cmake
+++ b/hw/bsp/imxrt/family.cmake
@@ -16,29 +16,25 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS MIMXRT1XXX CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx${MCU_CORE}_flexspi_nor.ld)
- set(LD_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/iar/${MCU_VARIANT}xxxxx${MCU_CORE}_flexspi_nor.icf)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx${MCU_CORE}_flexspi_nor.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED LD_FILE_IAR)
+set(LD_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/iar/${MCU_VARIANT}xxxxx${MCU_CORE}_flexspi_nor.icf)
+endif ()
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT_WITH_CORE}.S)
- set(STARTUP_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/iar/startup_${MCU_VARIANT_WITH_CORE}.s)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT_WITH_CORE}.S)
+set(STARTUP_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/iar/startup_${MCU_VARIANT_WITH_CORE}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board/clock_config.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board/pin_mux.c
${SDK_DIR}/drivers/common/fsl_common.c
@@ -60,10 +56,9 @@ function(add_board_target BOARD_TARGET)
endif()
endforeach()
-
target_compile_definitions(${BOARD_TARGET} PUBLIC
__STARTUP_CLEAR_BSS
- CFG_TUSB_MEM_SECTION=__attribute__\(\(section\(\"NonCacheable\"\)\)\)
+ [=[CFG_TUSB_MEM_SECTION=__attribute__((section("NonCacheable")))]=]
)
if (NOT M4 STREQUAL "1")
@@ -88,9 +83,31 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_MIMXRT1XXX)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
+ ${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
+ ${TOP}/src/portable/ehci/ehci.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
+ target_link_options(${TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
-nostartfiles
--specs=nosys.specs --specs=nano.specs
@@ -99,48 +116,23 @@ function(add_board_target BOARD_TARGET)
-Wl,-ug_boot_data
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
+ target_link_options(${TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
-Wl,-uimage_vector_table
-Wl,-ug_boot_data
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
+ target_link_options(${TARGET} PUBLIC
"LINKER:--config=${LD_FILE_IAR}"
)
endif ()
-endfunction()
-
-
-#------------------------------------
-# Functions
-#------------------------------------
-function(family_configure_example TARGET RTOS)
- family_configure_common(${TARGET} ${RTOS})
-
- # Board target
- add_board_target(board_${BOARD})
-
- target_sources(${TARGET} PUBLIC
- # BSP
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
- )
- target_include_directories(${TARGET} PUBLIC
- # family, hw, board
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
- )
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_MIMXRT1XXX)
- target_sources(${TARGET} PRIVATE
- ${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
- ${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
- ${TOP}/src/portable/ehci/ehci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/kinetis_k/family.c b/hw/bsp/kinetis_k/family.c
index 59d80fa18..816c5c87e 100644
--- a/hw/bsp/kinetis_k/family.c
+++ b/hw/bsp/kinetis_k/family.c
@@ -159,6 +159,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit (int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/kinetis_k/family.cmake b/hw/bsp/kinetis_k/family.cmake
index ce91777c9..e1b5c221e 100644
--- a/hw/bsp/kinetis_k/family.cmake
+++ b/hw/bsp/kinetis_k/family.cmake
@@ -18,21 +18,17 @@ set(FAMILY_MCUS KINETIS_K CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${SDK_DIR}/drivers/gpio/fsl_gpio.c
${SDK_DIR}/drivers/uart/fsl_uart.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
@@ -54,63 +50,53 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_KINETIS_K)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/chipidea/ci_fs/dcd_ci_fs.c
+ ${TOP}/src/portable/nxp/khci/hcd_khci.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_KINETIS_K)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/chipidea/ci_fs/dcd_ci_fs.c
- ${TOP}/src/portable/nxp/khci/hcd_khci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
-
- if (DEFINED TEENSY_MCU)
- family_flash_teensy(${TARGET})
- endif ()
+ family_flash_teensy(${TARGET})
endfunction()
diff --git a/hw/bsp/kinetis_k32l2/family.c b/hw/bsp/kinetis_k32l2/family.c
index 2fcc1b2af..2062b8b18 100644
--- a/hw/bsp/kinetis_k32l2/family.c
+++ b/hw/bsp/kinetis_k32l2/family.c
@@ -167,6 +167,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit (int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/kinetis_k32l2/family.cmake b/hw/bsp/kinetis_k32l2/family.cmake
index 946614a03..110335ab2 100644
--- a/hw/bsp/kinetis_k32l2/family.cmake
+++ b/hw/bsp/kinetis_k32l2/family.cmake
@@ -14,21 +14,17 @@ set(FAMILY_MCUS KINETIS_K32L CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${SDK_DIR}/drivers/gpio/fsl_gpio.c
${SDK_DIR}/drivers/lpuart/fsl_lpuart.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
@@ -49,63 +45,53 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_KINETIS_K32L)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/khci/dcd_khci.c
+ ${TOP}/src/portable/nxp/khci/hcd_khci.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_KINETIS_K32L)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/khci/dcd_khci.c
- ${TOP}/src/portable/nxp/khci/hcd_khci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_flash_jlink(${TARGET})
family_add_bin_hex(${TARGET})
-
- if (DEFINED TEENSY_MCU)
- family_flash_teensy(${TARGET})
- endif ()
+ family_flash_teensy(${TARGET})
endfunction()
diff --git a/hw/bsp/kinetis_kl/family.c b/hw/bsp/kinetis_kl/family.c
index fe864f3a0..000006372 100644
--- a/hw/bsp/kinetis_kl/family.c
+++ b/hw/bsp/kinetis_kl/family.c
@@ -159,6 +159,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit (int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/kinetis_kl/family.cmake b/hw/bsp/kinetis_kl/family.cmake
index 51a646258..230a3057d 100644
--- a/hw/bsp/kinetis_kl/family.cmake
+++ b/hw/bsp/kinetis_kl/family.cmake
@@ -18,20 +18,16 @@ set(FAMILY_MCUS KINETIS_KL CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${SDK_DIR}/drivers/gpio/fsl_gpio.c
${SDK_DIR}/drivers/lpsci/fsl_lpsci.c
${SDK_DIR}/drivers/uart/fsl_uart.c
@@ -53,57 +49,50 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/drivers/uart
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_KINETIS_KL)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/chipidea/ci_fs/dcd_ci_fs.c
+ ${TOP}/src/portable/nxp/khci/hcd_khci.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_KINETIS_KL)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/chipidea/ci_fs/dcd_ci_fs.c
- ${TOP}/src/portable/nxp/khci/hcd_khci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/lpc11/boards/lpcxpresso11u68/board.cmake b/hw/bsp/lpc11/boards/lpcxpresso11u68/board.cmake
index b7393cb2f..36296fb54 100644
--- a/hw/bsp/lpc11/boards/lpcxpresso11u68/board.cmake
+++ b/hw/bsp/lpc11/boards/lpcxpresso11u68/board.cmake
@@ -5,7 +5,7 @@ set(PYOCD_TARGET LPC11U68)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/lpc11u68.ld)
function(update_board TARGET)
- target_sources(${TARGET} PUBLIC
+ target_sources(${TARGET} PRIVATE
${SDK_DIR}/src/gpio_${LPC_FAMILY}.c
${SDK_DIR}/src/syscon_${LPC_FAMILY}.c
)
diff --git a/hw/bsp/lpc11/family.cmake b/hw/bsp/lpc11/family.cmake
index 6781b20c6..fceafcf61 100644
--- a/hw/bsp/lpc11/family.cmake
+++ b/hw/bsp/lpc11/family.cmake
@@ -21,11 +21,7 @@ set(FAMILY_MCUS LPC11UXX CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/../gcc/cr_startup_lpc${LPC_FAMILY}.c
${SDK_DIR}/src/chip_${LPC_FAMILY}.c
@@ -48,24 +44,7 @@ function(add_board_target BOARD_TARGET)
update_board(${BOARD_TARGET})
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_compile_options(${BOARD_TARGET} PUBLIC
- -nostdlib
- -Wno-error=incompatible-pointer-types
- )
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
+ set_target_properties(${BOARD_TARGET} PROPERTIES COMPILE_FLAGS "-Wno-incompatible-pointer-types")
endfunction()
@@ -74,16 +53,14 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
-
- # Board target
- add_board_target(board_${BOARD})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC11UXX)
#---------- Port Specific ----------
# These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
)
target_include_directories(${TARGET} PUBLIC
# family, hw, board
@@ -92,14 +69,24 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC11UXX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(${TARGET} PUBLIC
+ -nostdlib
+ -Wno-error=incompatible-pointer-types
+ )
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/lpc13/family.cmake b/hw/bsp/lpc13/family.cmake
index e3c0b18c7..6a66cfe95 100644
--- a/hw/bsp/lpc13/family.cmake
+++ b/hw/bsp/lpc13/family.cmake
@@ -18,11 +18,7 @@ set(FAMILY_MCUS LPC13XX CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/../gcc/cr_startup_lpc${LPC_FAMILY}.c
${SDK_DIR}/src/chip_${LPC_FAMILY}.c
@@ -68,17 +64,18 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC13XX)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
)
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+
target_include_directories(${TARGET} PUBLIC
# family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -86,15 +83,6 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC13XX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
-
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/lpc15/family.cmake b/hw/bsp/lpc15/family.cmake
index 761c5a619..8de26421d 100644
--- a/hw/bsp/lpc15/family.cmake
+++ b/hw/bsp/lpc15/family.cmake
@@ -18,11 +18,7 @@ set(FAMILY_MCUS LPC15XX CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/../gcc/cr_startup_lpc${LPC_FAMILY}.c
${SDK_DIR}/src/chip_${LPC_FAMILY}.c
@@ -70,17 +66,18 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC15XX)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
)
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+
target_include_directories(${TARGET} PUBLIC
# family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -88,15 +85,6 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC15XX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
-
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/lpc17/family.c b/hw/bsp/lpc17/family.c
index 7d3231f6a..1edab6cd4 100644
--- a/hw/bsp/lpc17/family.c
+++ b/hw/bsp/lpc17/family.c
@@ -96,7 +96,11 @@ void board_init(void) {
// 0x1B // Host + Device + OTG + AHB
};
- uint32_t const clk_en = CFG_TUD_ENABLED ? USBCLK_DEVCIE : USBCLK_HOST;
+#if CFG_TUD_ENABLED
+ uint32_t const clk_en = USBCLK_DEVCIE;
+#else
+ uint32_t const clk_en = USBCLK_HOST;
+#endif
LPC_USB->OTGClkCtrl = clk_en;
while ((LPC_USB->OTGClkSt & clk_en) != clk_en) {}
diff --git a/hw/bsp/lpc17/family.cmake b/hw/bsp/lpc17/family.cmake
index 771a0f405..919b8f3bc 100644
--- a/hw/bsp/lpc17/family.cmake
+++ b/hw/bsp/lpc17/family.cmake
@@ -17,11 +17,7 @@ set(FAMILY_MCUS LPC175X_6X CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/../gcc/cr_startup_lpc175x_6x.c
${SDK_DIR}/src/chip_17xx_40xx.c
@@ -67,17 +63,19 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC175X_6X)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+ ${TOP}/src/portable/ohci/ohci.c
)
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+
target_include_directories(${TARGET} PUBLIC
# family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -85,17 +83,6 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC175X_6X)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
- ${TOP}/src/portable/nxp/lpc17_40/hcd_lpc17_40.c
- ${TOP}/src/portable/ohci/ohci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
-
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/lpc17/family.mk b/hw/bsp/lpc17/family.mk
index e8d707ea5..f1ed1a7d0 100644
--- a/hw/bsp/lpc17/family.mk
+++ b/hw/bsp/lpc17/family.mk
@@ -20,7 +20,6 @@ LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
- src/portable/nxp/lpc17_40/hcd_lpc17_40.c \
src/portable/ohci/ohci.c \
$(MCU_DIR)/../gcc/cr_startup_lpc175x_6x.c \
$(MCU_DIR)/src/chip_17xx_40xx.c \
diff --git a/hw/bsp/lpc18/family.cmake b/hw/bsp/lpc18/family.cmake
index 6af1149bf..27ee00f4c 100644
--- a/hw/bsp/lpc18/family.cmake
+++ b/hw/bsp/lpc18/family.cmake
@@ -17,11 +17,7 @@ set(FAMILY_MCUS LPC18XX CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/../gcc/cr_startup_lpc18xx.c
${SDK_DIR}/src/chip_18xx_43xx.c
@@ -65,16 +61,14 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC18XX)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
+ ${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
+ ${TOP}/src/portable/ehci/ehci.c
)
target_include_directories(${TARGET} PUBLIC
# family, hw, board
@@ -83,17 +77,6 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC18XX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
- ${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
- ${TOP}/src/portable/ehci/ehci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
-
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/lpc40/family.cmake b/hw/bsp/lpc40/family.cmake
index 3a680eae6..01430bbb1 100644
--- a/hw/bsp/lpc40/family.cmake
+++ b/hw/bsp/lpc40/family.cmake
@@ -17,11 +17,7 @@ set(FAMILY_MCUS LPC40XX CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/../gcc/cr_startup_lpc40xx.c
${SDK_DIR}/src/chip_17xx_40xx.c
@@ -68,17 +64,19 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC40XX)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
+ ${TOP}/src/portable/ohci/ohci.c
)
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+
target_include_directories(${TARGET} PUBLIC
# family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -86,17 +84,6 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC40XX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
- ${TOP}/src/portable/nxp/lpc17_40/hcd_lpc17_40.c
- ${TOP}/src/portable/ohci/ohci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
-
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/lpc40/family.mk b/hw/bsp/lpc40/family.mk
index c72631235..c21923000 100644
--- a/hw/bsp/lpc40/family.mk
+++ b/hw/bsp/lpc40/family.mk
@@ -18,7 +18,6 @@ LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
# All source paths should be relative to the top level.
SRC_C += \
src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
- src/portable/nxp/lpc17_40/hcd_lpc17_40.c \
src/portable/ohci/ohci.c \
$(MCU_DIR)/../gcc/cr_startup_lpc40xx.c \
$(MCU_DIR)/src/chip_17xx_40xx.c \
diff --git a/hw/bsp/lpc43/family.cmake b/hw/bsp/lpc43/family.cmake
index 23c4aecea..878b0eecc 100644
--- a/hw/bsp/lpc43/family.cmake
+++ b/hw/bsp/lpc43/family.cmake
@@ -14,22 +14,18 @@ set(FAMILY_MCUS LPC43XX CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${SDK_DIR}/../gcc/cr_startup_lpc43xx.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${SDK_DIR}/../iar/iar_startup_lpc18xx43xx.s)
- set(LD_FILE_IAR ${SDK_DIR}/../iar/linker/lpc18xx_43xx_ldscript_iflash.icf)
+set(STARTUP_FILE_GNU ${SDK_DIR}/../gcc/cr_startup_lpc43xx.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${SDK_DIR}/../iar/iar_startup_lpc18xx43xx.s)
+set(LD_FILE_IAR ${SDK_DIR}/../iar/linker/lpc18xx_43xx_ldscript_iflash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${SDK_DIR}/src/chip_18xx_43xx.c
${SDK_DIR}/src/clock_18xx_43xx.c
${SDK_DIR}/src/fpu_init.c
@@ -50,60 +46,51 @@ function(add_board_target BOARD_TARGET)
update_board(${BOARD_TARGET})
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_compile_options(${BOARD_TARGET} PUBLIC
- -nostdlib
- -Wno-error=incompatible-pointer-types
- )
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
+ # warning by LPCOpen
+ if (TOOLCHAIN STREQUAL "gcc" OR TOOLCHAIN STREQUAL "clang")
+ set_target_properties(${BOARD_TARGET} PROPERTIES COMPILE_FLAGS -Wno-error=incompatible-pointer-types)
endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC43XX)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
+ ${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
+ ${TOP}/src/portable/ehci/ehci.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC43XX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/chipidea/ci_hs/dcd_ci_hs.c
- ${TOP}/src/portable/chipidea/ci_hs/hcd_ci_hs.c
- ${TOP}/src/portable/ehci/ehci.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/lpc51/family.c b/hw/bsp/lpc51/family.c
index 0afe33d41..c963b76bd 100644
--- a/hw/bsp/lpc51/family.c
+++ b/hw/bsp/lpc51/family.c
@@ -138,6 +138,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit (int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/lpc51/family.cmake b/hw/bsp/lpc51/family.cmake
index 09d97d256..1823b64fc 100644
--- a/hw/bsp/lpc51/family.cmake
+++ b/hw/bsp/lpc51/family.cmake
@@ -13,26 +13,22 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS LPC51 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}_flash.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}_flash.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
# driver
${SDK_DIR}/drivers/lpc_gpio/fsl_gpio.c
${SDK_DIR}/drivers/flexcomm/fsl_flexcomm.c
@@ -62,57 +58,49 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC51)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
-
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC51)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/lpc54/family.c b/hw/bsp/lpc54/family.c
index 9b9b5841b..094866d9b 100644
--- a/hw/bsp/lpc54/family.c
+++ b/hw/bsp/lpc54/family.c
@@ -233,6 +233,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit (int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/lpc54/family.cmake b/hw/bsp/lpc54/family.cmake
index 66320870a..c6145bd41 100644
--- a/hw/bsp/lpc54/family.cmake
+++ b/hw/bsp/lpc54/family.cmake
@@ -20,26 +20,22 @@ endif()
set(HOST_PORT $<NOT:${PORT}>)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
# driver
${SDK_DIR}/drivers/lpc_gpio/fsl_gpio.c
${SDK_DIR}/drivers/common/fsl_common_arm.c
@@ -90,63 +86,49 @@ function(add_board_target BOARD_TARGET)
endif ()
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC54)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
-
- # https://github.com/gsteiert/sct_neopixel/pull/1
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set_source_files_properties(${TOP}/lib/sct_neopixel/sct_neopixel.c PROPERTIES
- COMPILE_FLAGS "-Wno-unused-parameter")
- endif ()
-
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC54)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/lpc55/boards/double_m33_express/board.cmake b/hw/bsp/lpc55/boards/double_m33_express/board.cmake
index 3324ce888..186655b5a 100644
--- a/hw/bsp/lpc55/boards/double_m33_express/board.cmake
+++ b/hw/bsp/lpc55/boards/double_m33_express/board.cmake
@@ -7,11 +7,6 @@ set(NXPLINK_DEVICE LPC55S69:LPCXpresso55S69)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/LPC55S69_cm33_core0_uf2.ld)
-# Device port default to PORT1 Highspeed
-if (NOT DEFINED PORT)
- set(PORT 1)
-endif()
-
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
CPU_LPC55S69JBD100_cm33_core0
diff --git a/hw/bsp/lpc55/boards/lpcxpresso55s28/board.cmake b/hw/bsp/lpc55/boards/lpcxpresso55s28/board.cmake
index b3d0c3349..d935b70e6 100644
--- a/hw/bsp/lpc55/boards/lpcxpresso55s28/board.cmake
+++ b/hw/bsp/lpc55/boards/lpcxpresso55s28/board.cmake
@@ -5,11 +5,6 @@ set(JLINK_DEVICE LPC55S28)
set(PYOCD_TARGET LPC55S28)
set(NXPLINK_DEVICE LPC55S28:LPCXpresso55S28)
-# Device port default to PORT1 Highspeed
-if (NOT DEFINED PORT)
- set(PORT 1)
-endif()
-
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
CPU_LPC55S28JBD100
diff --git a/hw/bsp/lpc55/boards/lpcxpresso55s69/board.cmake b/hw/bsp/lpc55/boards/lpcxpresso55s69/board.cmake
index b52ec2f9d..f46775b27 100644
--- a/hw/bsp/lpc55/boards/lpcxpresso55s69/board.cmake
+++ b/hw/bsp/lpc55/boards/lpcxpresso55s69/board.cmake
@@ -5,11 +5,6 @@ set(JLINK_DEVICE LPC55S69_M33_0)
set(PYOCD_TARGET LPC55S69)
set(NXPLINK_DEVICE LPC55S69:LPCXpresso55S69)
-# Device port default to PORT1 Highspeed
-if (NOT DEFINED PORT)
- set(PORT 1)
-endif()
-
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
CPU_LPC55S69JBD100_cm33_core0
diff --git a/hw/bsp/lpc55/family.c b/hw/bsp/lpc55/family.c
index dbf8d71b7..f1ef58926 100644
--- a/hw/bsp/lpc55/family.c
+++ b/hw/bsp/lpc55/family.c
@@ -55,6 +55,7 @@
#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_MODE_PULLUP 0x20u /*!<@brief Selects pull-up function */
#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
@@ -197,13 +198,14 @@ void board_init(void) {
USART_Init(UART_DEV, &uart_config, 12000000);
#endif
- // USB VBUS
+#if (CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 0) || (CFG_TUH_ENABLED && BOARD_TUH_RHPORT == 0)
/* PORT0 PIN22 configured as USB0_VBUS */
IOCON_PinMuxSet(IOCON, 0U, 22U, IOCON_PIO_DIG_FUNC7_EN);
-
-#if defined(BOARD_TUD_RHPORT) && BOARD_TUD_RHPORT == 0
// Port0 is Full Speed
+ NVIC_ClearPendingIRQ(USB0_IRQn);
+ NVIC_ClearPendingIRQ(USB0_NEEDCLK_IRQn);
+
/* Turn on USB0 Phy */
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY);
@@ -212,21 +214,55 @@ void board_init(void) {
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);
+ if (CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 0) {
+ // 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 manual, 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));
+ } else {
+ const uint32_t port1_pin12_config = (/* Pin is configured as USB0_PORTPWRN */
+ IOCON_PIO_FUNC4 |
+ /* Selects pull-up function */
+ IOCON_PIO_MODE_PULLUP |
+ /* Standard mode, output slew rate control is enabled */
+ IOCON_PIO_SLEW_STANDARD |
+ /* Input function is not inverted */
+ IOCON_PIO_INV_DI |
+ /* Enables digital function */
+ IOCON_PIO_DIGITAL_EN |
+ /* Open drain is disabled */
+ IOCON_PIO_OPENDRAIN_DI);
+ /* PORT1 PIN12 (coords: 67) is configured as USB0_PORTPWRN */
+ IOCON_PinMuxSet(IOCON, 1U, 12U, port1_pin12_config);
- /*According to reference manual, 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
+ const uint32_t port0_pin28_config = (/* Pin is configured as USB0_OVERCURRENTN */
+ IOCON_PIO_FUNC7 |
+ /* Selects pull-up function */
+ IOCON_PIO_MODE_PULLUP |
+ /* Standard mode, output slew rate control is enabled */
+ IOCON_PIO_SLEW_STANDARD |
+ /* Input function is not inverted */
+ IOCON_PIO_INV_DI |
+ /* Enables digital function */
+ IOCON_PIO_DIGITAL_EN |
+ /* Open drain is disabled */
+ IOCON_PIO_OPENDRAIN_DI);
+ /* PORT0 PIN28 (coords: 66) is configured as USB0_OVERCURRENTN */
+ IOCON_PinMuxSet(IOCON, 0U, 28U, port0_pin28_config);
- /* enable USB Device clock */
- CLOCK_EnableUsbfs0DeviceClock(kCLOCK_UsbfsSrcFro, CLOCK_GetFreq(kCLOCK_FroHf));
+ CLOCK_EnableUsbfs0HostClock(kCLOCK_UsbfsSrcPll1, 48000000U);
+ USBFSH->PORTMODE &= ~USBFSH_PORTMODE_DEV_ENABLE_MASK;
+ }
#endif
-#if defined(BOARD_TUD_RHPORT) && BOARD_TUD_RHPORT == 1
+#if (CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 1) || (CFG_TUH_ENABLED && BOARD_TUH_RHPORT == 1)
// Port1 is High Speed
/* Turn on USB1 Phy */
@@ -266,9 +302,9 @@ void board_init(void) {
// phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
// USBPHY->TX = phytx;
- ARM_MPU_SetMemAttr(0, 0x44); // Normal memory, non-cacheable (inner and outer)
- ARM_MPU_SetRegion(0, ARM_MPU_RBAR(0x40100000, ARM_MPU_SH_NON, 0, 1, 1), ARM_MPU_RLAR(0x40104000, 0));
- ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk | MPU_CTRL_HFNMIENA_Msk);
+ ARM_MPU_SetMemAttr(0, 0x44); // Normal memory, non-cacheable (inner and outer)
+ ARM_MPU_SetRegion(0, ARM_MPU_RBAR(0x40100000, ARM_MPU_SH_NON, 0, 1, 1), ARM_MPU_RLAR(0x40104000, 0));
+ ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk | MPU_CTRL_HFNMIENA_Msk);
#endif
}
@@ -333,6 +369,7 @@ TU_ATTR_UNUSED void _start(void) {
#ifdef __clang__
void _exit (int __status) {
+ (void) __status;
while (1) {}
}
#endif
diff --git a/hw/bsp/lpc55/family.cmake b/hw/bsp/lpc55/family.cmake
index a89548635..1f18f9bad 100644
--- a/hw/bsp/lpc55/family.cmake
+++ b/hw/bsp/lpc55/family.cmake
@@ -12,34 +12,48 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS LPC55 CACHE INTERNAL "")
-if (NOT DEFINED PORT)
- set(PORT 0)
-endif()
+# ----------------------
+# Port & Speed Selection
+# ----------------------
-# Host port will be the other port if available
-set(HOST_PORT $<NOT:${PORT}>)
+# default device port to USB1 highspeed, host to USB0 fullspeed
+if (NOT DEFINED RHPORT_DEVICE)
+ set(RHPORT_DEVICE 1)
+endif ()
+if (NOT DEFINED RHPORT_HOST)
+ set(RHPORT_HOST 0)
+endif ()
+
+# port 0 is fullspeed, port 1 is highspeed
+set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED)
+
+if (NOT DEFINED RHPORT_DEVICE_SPEED)
+ list(GET RHPORT_SPEED ${RHPORT_DEVICE} RHPORT_DEVICE_SPEED)
+endif ()
+if (NOT DEFINED RHPORT_HOST_SPEED)
+ list(GET RHPORT_SPEED ${RHPORT_HOST} RHPORT_HOST_SPEED)
+endif ()
+
+cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
+if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
# driver
${SDK_DIR}/drivers/lpc_gpio/fsl_gpio.c
${SDK_DIR}/drivers/common/fsl_common_arm.c
@@ -67,86 +81,73 @@ function(add_board_target BOARD_TARGET)
)
target_compile_definitions(${BOARD_TARGET} PUBLIC
CFG_TUSB_MEM_ALIGN=TU_ATTR_ALIGNED\(64\)
- BOARD_TUD_RHPORT=${PORT}
- BOARD_TUH_RHPORT=${HOST_PORT}
+ BOARD_TUD_RHPORT=${RHPORT_DEVICE}
+ BOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED}
+ BOARD_TUH_RHPORT=${RHPORT_HOST}
+ BOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED}
__STARTUP_CLEAR_BSS
)
# Port 0 is Fullspeed, Port 1 is Highspeed. Port1 controller can only access USB_SRAM
- if (PORT EQUAL 1)
+ if (RHPORT_DEVICE EQUAL 1)
target_compile_definitions(${BOARD_TARGET} PUBLIC
- BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
- BOARD_TUH_MAX_SPEED=OPT_MODE_FULL_SPEED
CFG_TUD_MEM_SECTION=__attribute__\(\(section\(\"m_usb_global\"\)\)\)
)
- else ()
+ elseif (RHPORT_HOST EQUAL 1)
target_compile_definitions(${BOARD_TARGET} PUBLIC
- BOARD_TUD_MAX_SPEED=OPT_MODE_FULL_SPEED
- BOARD_TUH_MAX_SPEED=OPT_MODE_HIGH_SPEED
CFG_TUH_MEM_SECTION=__attribute__\(\(section\(\"m_usb_global\"\)\)\)
)
endif ()
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_LPC55)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
- # external driver
${TOP}/lib/sct_neopixel/sct_neopixel.c
+ ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+ ${TOP}/src/portable/ohci/ohci.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
-
- # https://github.com/gsteiert/sct_neopixel/pull/1
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set_source_files_properties(${TOP}/lib/sct_neopixel/sct_neopixel.c PROPERTIES
- COMPILE_FLAGS "-Wno-unused-parameter")
- endif ()
-
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_LPC55)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ set_source_files_properties(${TOP}/lib/sct_neopixel/sct_neopixel.c
+ PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes -Wno-unused-parameter")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/maxim/family.c b/hw/bsp/maxim/family.c
index 0ef6b8c4d..92b5adb6d 100644
--- a/hw/bsp/maxim/family.c
+++ b/hw/bsp/maxim/family.c
@@ -31,6 +31,7 @@
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-prototypes" // _mxc_crit_get_state()
+#pragma GCC diagnostic ignored "-Wredundant-decls"
#endif
#include "gpio.h"
@@ -154,6 +155,7 @@ uint32_t board_button_read(void) {
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
#if defined(MAX32650)
// USN is 13 bytes on this device
+ (void) max_len;
MXC_SYS_GetUSN(id, 13);
return 13;
#else
diff --git a/hw/bsp/maxim/family.cmake b/hw/bsp/maxim/family.cmake
index 75daec753..d890113e6 100644
--- a/hw/bsp/maxim/family.cmake
+++ b/hw/bsp/maxim/family.cmake
@@ -38,26 +38,21 @@ else()
endif()
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/GCC/startup_${MAX_DEVICE}.S)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MAX_DEVICE}.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/GCC/startup_${MAX_DEVICE}.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${MAX_DEVICE}.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
# Common
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/heap.c
${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/system_${MAX_DEVICE}.c
${MSDK_LIB}/PeriphDrivers/Source/SYS/mxc_assert.c
@@ -139,53 +134,51 @@ function(add_board_target BOARD_TARGET)
-Wno-error=strict-prototypes
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${MAX_DEVICE_UPPER})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${MAX_DEVICE_UPPER})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/mentor/musb/dcd_musb.c
- )
- target_compile_options(${TARGET} PRIVATE
- -Wno-error=strict-prototypes
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ # warnings caused by MSDK headers
+ target_compile_options(${TARGET} PRIVATE -Wno-error=strict-prototypes)
+ if (${MAX_DEVICE} STREQUAL "max78002")
+ target_compile_options(${TARGET} PRIVATE -Wno-error=redundant-decls)
+ endif ()
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/board.cmake b/hw/bsp/mcx/boards/frdm_mcxa153/board.cmake
index 7cd8991e6..e6619992f 100644
--- a/hw/bsp/mcx/boards/frdm_mcxa153/board.cmake
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/board.cmake
@@ -14,8 +14,11 @@ function(update_board TARGET)
BOARD_TUD_MAX_SPEED=OPT_MODE_FULL_SPEED
CFG_EXAMPLE_VIDEO_READONLY
)
- target_sources(${TARGET} PUBLIC
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/clock_config.c
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/pin_mux.c
+ target_sources(${TARGET} PRIVATE
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/board/clock_config.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/board/pin_mux.c
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/board
)
endfunction()
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/board.mk b/hw/bsp/mcx/boards/frdm_mcxa153/board.mk
index af8416d8e..34558b43e 100644
--- a/hw/bsp/mcx/boards/frdm_mcxa153/board.mk
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/board.mk
@@ -6,6 +6,14 @@ CPU_CORE = cortex-m33-nodsp-nofp
CFLAGS += \
-DCPU_MCXA153VLH \
-DCFG_TUSB_MCU=OPT_MCU_MCXA15 \
+ -DCFG_EXAMPLE_VIDEO_READONLY
+
+SRC_C += \
+ ${BOARD_PATH}/board/clock_config.c \
+ ${BOARD_PATH}/board/pin_mux.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH)/board
JLINK_DEVICE = MCXA153
PYOCD_TARGET = MCXA153
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/clock_config.c b/hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.c
index 5a132dc67..599110d7a 100644
--- a/hw/bsp/mcx/boards/frdm_mcxa153/clock_config.c
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2023 NXP
+ * Copyright 2025 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -25,11 +25,12 @@
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
!!GlobalInfo
-product: Clocks v12.0
+product: Clocks v18.0
processor: MCXA153
package_id: MCXA153VLH
mcu_data: ksdk2_0
-processor_version: 0.13.0
+processor_version: 25.09.10
+board: FRDM-MCXA153
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
@@ -45,13 +46,14 @@ processor_version: 0.13.0
* Variables
******************************************************************************/
/* System clock frequency. */
-//extern uint32_t SystemCoreClock;
+extern uint32_t SystemCoreClock;
/*******************************************************************************
************************ BOARD_InitBootClocks function ************************
******************************************************************************/
void BOARD_InitBootClocks(void)
{
+ BOARD_BootClockFRO96M();
}
/*******************************************************************************
@@ -68,9 +70,13 @@ outputs:
- {id: MAIN_clock.outFreq, value: 12 MHz}
- {id: Slow_clock.outFreq, value: 3 MHz}
- {id: System_clock.outFreq, value: 12 MHz}
+- {id: TRACE_clock.outFreq, value: 12 MHz}
+- {id: UTICK_clock.outFreq, value: 1 MHz}
+- {id: WWDT0_clock.outFreq, value: 1 MHz}
settings:
- {id: SCGMode, value: SIRC}
-- {id: FRO_HF_PERIPHERALS_EN_CFG, value: Disabled}
+- {id: MRCC.FREQMEREFCLKSEL.sel, value: MRCC.aoi0_out0}
+- {id: MRCC.FREQMETARGETCLKSEL.sel, value: MRCC.aoi0_out0}
- {id: MRCC.OSTIMERCLKSEL.sel, value: VBAT.CLK16K_1}
- {id: SCG.SCSSEL.sel, value: SCG.SIRC}
- {id: SCG_FIRCCSR_FIRCEN_CFG, value: Disabled}
@@ -106,6 +112,9 @@ void BOARD_BootClockFRO12M(void)
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
}
+
+ /*!< Set up system dividers */
+ CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /* !< Switch MAIN_CLK to FRO12M */
@@ -125,9 +134,11 @@ void BOARD_BootClockFRO12M(void)
}
/*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kCPU_CLK_to_TRACE); /* !< Switch TRACE to CPU_CLK */
/*!< Set up dividers */
- CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivTRACE, 1U); /* !< Set TRACECLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivWWDT0, 1U); /* !< Set WWDT0CLKDIV divider to value 1 */
/* Set SystemCoreClock variable */
SystemCoreClock = BOARD_BOOTCLOCKFRO12M_CORE_CLOCK;
@@ -149,9 +160,14 @@ outputs:
- {id: MAIN_clock.outFreq, value: 48 MHz}
- {id: Slow_clock.outFreq, value: 6 MHz}
- {id: System_clock.outFreq, value: 24 MHz}
+- {id: TRACE_clock.outFreq, value: 24 MHz}
+- {id: UTICK_clock.outFreq, value: 1 MHz}
+- {id: WWDT0_clock.outFreq, value: 1 MHz}
settings:
+- {id: MRCC.FREQMEREFCLKSEL.sel, value: MRCC.aoi0_out0}
+- {id: MRCC.FREQMETARGETCLKSEL.sel, value: MRCC.aoi0_out0}
- {id: MRCC.OSTIMERCLKSEL.sel, value: VBAT.CLK16K_1}
-- {id: SYSCON.AHBCLKDIV.scale, value: '2', locked: true}
+- {id: SYSCON.AHBCLKDIV.scale, value: '2'}
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
@@ -184,6 +200,11 @@ void BOARD_BootClockFRO24M(void)
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
}
+
+ /*!< Set up system dividers */
+ CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 2U); /* !< Set AHBCLKDIV divider to value 2 */
+ CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+
CLOCK_SetupFROHFClocking(48000000U); /*!< Enable FRO HF(48MHz) output */
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
@@ -205,10 +226,21 @@ void BOARD_BootClockFRO24M(void)
}
/*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kCPU_CLK_to_TRACE); /* !< Switch TRACE to CPU_CLK */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0); /* !< Switch LPSPI0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1); /* !< Switch LPSPI1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPI2C0); /* !< Switch LPI2C0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART0); /* !< Switch LPUART0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART1); /* !< Switch LPUART1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART2); /* !< Switch LPUART2 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPTMR0); /* !< Switch LPTMR0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_I3C0FCLK); /* !< Switch I3C0FCLK to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP0); /* !< Switch CMP0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP1); /* !< Switch CMP1 to FRO_HF_DIV */
/*!< Set up dividers */
- CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 2U); /* !< Set AHBCLKDIV divider to value 2 */
- CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivTRACE, 1U); /* !< Set TRACECLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivWWDT0, 1U); /* !< Set WWDT0CLKDIV divider to value 1 */
/* Set SystemCoreClock variable */
SystemCoreClock = BOARD_BOOTCLOCKFRO24M_CORE_CLOCK;
@@ -230,7 +262,12 @@ outputs:
- {id: MAIN_clock.outFreq, value: 48 MHz}
- {id: Slow_clock.outFreq, value: 12 MHz}
- {id: System_clock.outFreq, value: 48 MHz}
+- {id: TRACE_clock.outFreq, value: 48 MHz}
+- {id: UTICK_clock.outFreq, value: 1 MHz}
+- {id: WWDT0_clock.outFreq, value: 1 MHz}
settings:
+- {id: MRCC.FREQMEREFCLKSEL.sel, value: MRCC.aoi0_out0}
+- {id: MRCC.FREQMETARGETCLKSEL.sel, value: MRCC.aoi0_out0}
- {id: MRCC.OSTIMERCLKSEL.sel, value: VBAT.CLK16K_1}
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
@@ -264,6 +301,11 @@ void BOARD_BootClockFRO48M(void)
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
}
+
+ /*!< Set up system dividers */
+ CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+
CLOCK_SetupFROHFClocking(48000000U); /*!< Enable FRO HF(48MHz) output */
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
@@ -285,10 +327,21 @@ void BOARD_BootClockFRO48M(void)
}
/*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kCPU_CLK_to_TRACE); /* !< Switch TRACE to CPU_CLK */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0); /* !< Switch LPSPI0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1); /* !< Switch LPSPI1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPI2C0); /* !< Switch LPI2C0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART0); /* !< Switch LPUART0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART1); /* !< Switch LPUART1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART2); /* !< Switch LPUART2 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPTMR0); /* !< Switch LPTMR0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_I3C0FCLK); /* !< Switch I3C0FCLK to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP0); /* !< Switch CMP0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP1); /* !< Switch CMP1 to FRO_HF_DIV */
/*!< Set up dividers */
- CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
- CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivTRACE, 1U); /* !< Set TRACECLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivWWDT0, 1U); /* !< Set WWDT0CLKDIV divider to value 1 */
/* Set SystemCoreClock variable */
SystemCoreClock = BOARD_BOOTCLOCKFRO48M_CORE_CLOCK;
@@ -310,8 +363,13 @@ outputs:
- {id: MAIN_clock.outFreq, value: 64 MHz}
- {id: Slow_clock.outFreq, value: 16 MHz}
- {id: System_clock.outFreq, value: 64 MHz}
+- {id: TRACE_clock.outFreq, value: 64 MHz}
+- {id: UTICK_clock.outFreq, value: 1 MHz}
+- {id: WWDT0_clock.outFreq, value: 1 MHz}
settings:
- {id: VDD_CORE, value: voltage_1v1}
+- {id: MRCC.FREQMEREFCLKSEL.sel, value: MRCC.aoi0_out0}
+- {id: MRCC.FREQMETARGETCLKSEL.sel, value: MRCC.aoi0_out0}
- {id: MRCC.FROHFDIV.scale, value: '1', locked: true}
- {id: MRCC.OSTIMERCLKSEL.sel, value: VBAT.CLK16K_1}
- {id: SYSCON.AHBCLKDIV.scale, value: '1', locked: true}
@@ -349,6 +407,11 @@ void BOARD_BootClockFRO64M(void)
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
}
+
+ /*!< Set up system dividers */
+ CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+
CLOCK_SetupFROHFClocking(64000000U); /*!< Enable FRO HF(64MHz) output */
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
@@ -370,10 +433,21 @@ void BOARD_BootClockFRO64M(void)
}
/*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kCPU_CLK_to_TRACE); /* !< Switch TRACE to CPU_CLK */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0); /* !< Switch LPSPI0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1); /* !< Switch LPSPI1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPI2C0); /* !< Switch LPI2C0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART0); /* !< Switch LPUART0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART1); /* !< Switch LPUART1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART2); /* !< Switch LPUART2 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPTMR0); /* !< Switch LPTMR0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_I3C0FCLK); /* !< Switch I3C0FCLK to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP0); /* !< Switch CMP0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP1); /* !< Switch CMP1 to FRO_HF_DIV */
/*!< Set up dividers */
- CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
- CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivTRACE, 1U); /* !< Set TRACECLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivWWDT0, 1U); /* !< Set WWDT0CLKDIV divider to value 1 */
/* Set SystemCoreClock variable */
SystemCoreClock = BOARD_BOOTCLOCKFRO64M_CORE_CLOCK;
@@ -385,6 +459,7 @@ void BOARD_BootClockFRO64M(void)
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
!!Configuration
name: BOARD_BootClockFRO96M
+called_from_default_init: true
outputs:
- {id: CLK_1M_clock.outFreq, value: 1 MHz}
- {id: CLK_48M_clock.outFreq, value: 48 MHz}
@@ -395,12 +470,14 @@ outputs:
- {id: MAIN_clock.outFreq, value: 96 MHz}
- {id: Slow_clock.outFreq, value: 24 MHz}
- {id: System_clock.outFreq, value: 96 MHz}
+- {id: TRACE_clock.outFreq, value: 96 MHz}
+- {id: UTICK_clock.outFreq, value: 1 MHz}
+- {id: WWDT0_clock.outFreq, value: 1 MHz}
settings:
- {id: VDD_CORE, value: voltage_1v1}
-- {id: CLKOUTDIV_HALT, value: Enable}
-- {id: MRCC.FROHFDIV.scale, value: '1', locked: true}
+- {id: MRCC.FREQMEREFCLKSEL.sel, value: MRCC.aoi0_out0}
+- {id: MRCC.FREQMETARGETCLKSEL.sel, value: MRCC.aoi0_out0}
- {id: MRCC.OSTIMERCLKSEL.sel, value: VBAT.CLK16K_1}
-- {id: SYSCON.AHBCLKDIV.scale, value: '1', locked: true}
sources:
- {id: SCG.FIRC.outFreq, value: 96 MHz}
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
@@ -435,6 +512,11 @@ void BOARD_BootClockFRO96M(void)
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
}
+
+ /*!< Set up system dividers */
+ CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+
CLOCK_SetupFROHFClocking(96000000U); /*!< Enable FRO HF(96MHz) output */
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
@@ -456,10 +538,21 @@ void BOARD_BootClockFRO96M(void)
}
/*!< Set up clock selectors - Attach clocks to the peripheries */
+ CLOCK_AttachClk(kCPU_CLK_to_TRACE); /* !< Switch TRACE to CPU_CLK */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI0); /* !< Switch LPSPI0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPSPI1); /* !< Switch LPSPI1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPI2C0); /* !< Switch LPI2C0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART0); /* !< Switch LPUART0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART1); /* !< Switch LPUART1 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPUART2); /* !< Switch LPUART2 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_LPTMR0); /* !< Switch LPTMR0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_I3C0FCLK); /* !< Switch I3C0FCLK to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP0); /* !< Switch CMP0 to FRO_HF_DIV */
+ CLOCK_AttachClk(kFRO_HF_DIV_to_CMP1); /* !< Switch CMP1 to FRO_HF_DIV */
/*!< Set up dividers */
- CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
- CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivTRACE, 1U); /* !< Set TRACECLKDIV divider to value 1 */
+ CLOCK_SetClockDiv(kCLOCK_DivWWDT0, 1U); /* !< Set WWDT0CLKDIV divider to value 1 */
/* Set SystemCoreClock variable */
SystemCoreClock = BOARD_BOOTCLOCKFRO96M_CORE_CLOCK;
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.h b/hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.h
new file mode 100644
index 000000000..d609eb468
--- /dev/null
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/board/clock_config.h
@@ -0,0 +1,385 @@
+/*
+ * Copyright 2025 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/***********************************************************************************************************************
+ * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
+ * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
+ **********************************************************************************************************************/
+
+#ifndef _CLOCK_CONFIG_H_
+#define _CLOCK_CONFIG_H_
+
+#include "fsl_common.h"
+
+/*******************************************************************************
+ * Definitions
+ ******************************************************************************/
+
+/*******************************************************************************
+ ************************ BOARD_InitBootClocks function ************************
+ ******************************************************************************/
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus*/
+
+/*!
+ * @brief This function executes default configuration of clocks.
+ *
+ */
+void BOARD_InitBootClocks(void);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus*/
+
+/*******************************************************************************
+ ******************** Configuration BOARD_BootClockFRO12M **********************
+ ******************************************************************************/
+/*******************************************************************************
+ * Definitions for BOARD_BootClockFRO12M configuration
+ ******************************************************************************/
+#define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK 12000000U /*!< Core clock frequency: 12000000Hz */
+
+/* Clock outputs (values are in Hz): */
+#define BOARD_BOOTCLOCKFRO12M_ADC0_CLOCK 0UL /* Clock consumers of ADC0_clock output : ADC0 */
+#define BOARD_BOOTCLOCKFRO12M_CLK16K_0_CLOCK 0UL /* Clock consumers of CLK16K_0_clock output : CMP0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO12M_CLK16K_1_CLOCK 0UL /* Clock consumers of CLK16K_1_clock output : CMP1, LPTMR0, WAKETIMER0 */
+#define BOARD_BOOTCLOCKFRO12M_CLKOUT_CLOCK 0UL /* Clock consumers of CLKOUT_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_CLK_1M_CLOCK 1000000UL /* Clock consumers of CLK_1M_clock output : CMC */
+#define BOARD_BOOTCLOCKFRO12M_CLK_48M_CLOCK 0UL /* Clock consumers of CLK_48M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_CLK_IN_CLOCK 0UL /* Clock consumers of CLK_IN_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_CMP0FDIV_CLOCK 0UL /* Clock consumers of CMP0FDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO12M_CMP0RRDIV_CLOCK 0UL /* Clock consumers of CMP0RRDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO12M_CMP1FDIV_CLOCK 0UL /* Clock consumers of CMP1FDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO12M_CMP1RRDIV_CLOCK 0UL /* Clock consumers of CMP1RRDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO12M_CPU_CLOCK 12000000UL /* Clock consumers of CPU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_CTIMER0_CLOCK 0UL /* Clock consumers of CTIMER0_clock output : CTIMER0 */
+#define BOARD_BOOTCLOCKFRO12M_CTIMER1_CLOCK 0UL /* Clock consumers of CTIMER1_clock output : CTIMER1 */
+#define BOARD_BOOTCLOCKFRO12M_CTIMER2_CLOCK 0UL /* Clock consumers of CTIMER2_clock output : CTIMER2 */
+#define BOARD_BOOTCLOCKFRO12M_FREQME_REFERENCE_CLOCK 0UL /* Clock consumers of FREQME_reference_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO12M_FREQME_TARGET_CLOCK 0UL /* Clock consumers of FREQME_target_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO12M_FRO_12M_CLOCK 12000000UL /* Clock consumers of FRO_12M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_FRO_HF_DIV_CLOCK 0UL /* Clock consumers of FRO_HF_DIV_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_FRO_HF_CLOCK 0UL /* Clock consumers of FRO_HF_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_I3C_FCLK_CLOCK 0UL /* Clock consumers of I3C_FCLK_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO12M_I3C_SLOW_TC_CLOCK 0UL /* Clock consumers of I3C_SLOW_TC_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO12M_I3C_SLOW_CLOCK 0UL /* Clock consumers of I3C_SLOW_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO12M_LPI2C0_CLOCK 0UL /* Clock consumers of LPI2C0_clock output : LPI2C0 */
+#define BOARD_BOOTCLOCKFRO12M_LPSPI0_CLOCK 0UL /* Clock consumers of LPSPI0_clock output : LPSPI0 */
+#define BOARD_BOOTCLOCKFRO12M_LPSPI1_CLOCK 0UL /* Clock consumers of LPSPI1_clock output : LPSPI1 */
+#define BOARD_BOOTCLOCKFRO12M_LPTMR0_CLOCK 0UL /* Clock consumers of LPTMR0_clock output : LPTMR0 */
+#define BOARD_BOOTCLOCKFRO12M_LPUART0_CLOCK 0UL /* Clock consumers of LPUART0_clock output : LPUART0 */
+#define BOARD_BOOTCLOCKFRO12M_LPUART1_CLOCK 0UL /* Clock consumers of LPUART1_clock output : LPUART1 */
+#define BOARD_BOOTCLOCKFRO12M_LPUART2_CLOCK 0UL /* Clock consumers of LPUART2_clock output : LPUART2 */
+#define BOARD_BOOTCLOCKFRO12M_MAIN_CLOCK 12000000UL /* Clock consumers of MAIN_clock output : FLEXPWM0 */
+#define BOARD_BOOTCLOCKFRO12M_OSTIMER_CLOCK 0UL /* Clock consumers of OSTIMER_clock output : OSTIMER0 */
+#define BOARD_BOOTCLOCKFRO12M_FIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.FIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_SIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.SIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_SLOW_CLOCK 3000000UL /* Clock consumers of Slow_clock output : AOI0, CMC, CMP0, LPTMR0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO12M_SYSTEM_CLOCK 12000000UL /* Clock consumers of System_clock output : ADC0, CMP1, CTIMER0, CTIMER1, CTIMER2, DMA0, FLEXPWM0, FREQME0, GPIO0, GPIO1, GPIO2, GPIO3, I3C0, INPUTMUX0, LPI2C0, LPSPI0, LPSPI1, LPUART0, LPUART1, LPUART2, OSTIMER0, PORT0, PORT1, PORT2, PORT3, QDC0, SWD, SysTick, USB0, UTICK0, WWDT0 */
+#define BOARD_BOOTCLOCKFRO12M_TRACE_CLOCK 12000000UL /* Clock consumers of TRACE_clock output : SWD */
+#define BOARD_BOOTCLOCKFRO12M_USB0_CLOCK 0UL /* Clock consumers of USB0_clock output : USB0 */
+#define BOARD_BOOTCLOCKFRO12M_UTICK_CLOCK 1000000UL /* Clock consumers of UTICK_clock output : UTICK0 */
+#define BOARD_BOOTCLOCKFRO12M_WUU_CLOCK 0UL /* Clock consumers of WUU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO12M_WWDT0_CLOCK 1000000UL /* Clock consumers of WWDT0_clock output : WWDT0 */
+
+
+/*******************************************************************************
+ * API for BOARD_BootClockFRO12M configuration
+ ******************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus*/
+
+/*!
+ * @brief This function executes configuration of clocks.
+ *
+ */
+void BOARD_BootClockFRO12M(void);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus*/
+
+/*******************************************************************************
+ ******************** Configuration BOARD_BootClockFRO24M **********************
+ ******************************************************************************/
+/*******************************************************************************
+ * Definitions for BOARD_BootClockFRO24M configuration
+ ******************************************************************************/
+#define BOARD_BOOTCLOCKFRO24M_CORE_CLOCK 24000000U /*!< Core clock frequency: 24000000Hz */
+
+/* Clock outputs (values are in Hz): */
+#define BOARD_BOOTCLOCKFRO24M_ADC0_CLOCK 0UL /* Clock consumers of ADC0_clock output : ADC0 */
+#define BOARD_BOOTCLOCKFRO24M_CLK16K_0_CLOCK 0UL /* Clock consumers of CLK16K_0_clock output : CMP0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO24M_CLK16K_1_CLOCK 0UL /* Clock consumers of CLK16K_1_clock output : CMP1, LPTMR0, WAKETIMER0 */
+#define BOARD_BOOTCLOCKFRO24M_CLKOUT_CLOCK 0UL /* Clock consumers of CLKOUT_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_CLK_1M_CLOCK 1000000UL /* Clock consumers of CLK_1M_clock output : CMC */
+#define BOARD_BOOTCLOCKFRO24M_CLK_48M_CLOCK 48000000UL /* Clock consumers of CLK_48M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_CLK_IN_CLOCK 0UL /* Clock consumers of CLK_IN_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_CMP0FDIV_CLOCK 0UL /* Clock consumers of CMP0FDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO24M_CMP0RRDIV_CLOCK 0UL /* Clock consumers of CMP0RRDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO24M_CMP1FDIV_CLOCK 0UL /* Clock consumers of CMP1FDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO24M_CMP1RRDIV_CLOCK 0UL /* Clock consumers of CMP1RRDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO24M_CPU_CLOCK 24000000UL /* Clock consumers of CPU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_CTIMER0_CLOCK 0UL /* Clock consumers of CTIMER0_clock output : CTIMER0 */
+#define BOARD_BOOTCLOCKFRO24M_CTIMER1_CLOCK 0UL /* Clock consumers of CTIMER1_clock output : CTIMER1 */
+#define BOARD_BOOTCLOCKFRO24M_CTIMER2_CLOCK 0UL /* Clock consumers of CTIMER2_clock output : CTIMER2 */
+#define BOARD_BOOTCLOCKFRO24M_FREQME_REFERENCE_CLOCK 0UL /* Clock consumers of FREQME_reference_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO24M_FREQME_TARGET_CLOCK 0UL /* Clock consumers of FREQME_target_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO24M_FRO_12M_CLOCK 12000000UL /* Clock consumers of FRO_12M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_FRO_HF_DIV_CLOCK 48000000UL /* Clock consumers of FRO_HF_DIV_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_FRO_HF_CLOCK 48000000UL /* Clock consumers of FRO_HF_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_I3C_FCLK_CLOCK 0UL /* Clock consumers of I3C_FCLK_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO24M_I3C_SLOW_TC_CLOCK 0UL /* Clock consumers of I3C_SLOW_TC_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO24M_I3C_SLOW_CLOCK 0UL /* Clock consumers of I3C_SLOW_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO24M_LPI2C0_CLOCK 0UL /* Clock consumers of LPI2C0_clock output : LPI2C0 */
+#define BOARD_BOOTCLOCKFRO24M_LPSPI0_CLOCK 0UL /* Clock consumers of LPSPI0_clock output : LPSPI0 */
+#define BOARD_BOOTCLOCKFRO24M_LPSPI1_CLOCK 0UL /* Clock consumers of LPSPI1_clock output : LPSPI1 */
+#define BOARD_BOOTCLOCKFRO24M_LPTMR0_CLOCK 0UL /* Clock consumers of LPTMR0_clock output : LPTMR0 */
+#define BOARD_BOOTCLOCKFRO24M_LPUART0_CLOCK 0UL /* Clock consumers of LPUART0_clock output : LPUART0 */
+#define BOARD_BOOTCLOCKFRO24M_LPUART1_CLOCK 0UL /* Clock consumers of LPUART1_clock output : LPUART1 */
+#define BOARD_BOOTCLOCKFRO24M_LPUART2_CLOCK 0UL /* Clock consumers of LPUART2_clock output : LPUART2 */
+#define BOARD_BOOTCLOCKFRO24M_MAIN_CLOCK 48000000UL /* Clock consumers of MAIN_clock output : FLEXPWM0 */
+#define BOARD_BOOTCLOCKFRO24M_OSTIMER_CLOCK 0UL /* Clock consumers of OSTIMER_clock output : OSTIMER0 */
+#define BOARD_BOOTCLOCKFRO24M_FIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.FIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_SIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.SIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_SLOW_CLOCK 6000000UL /* Clock consumers of Slow_clock output : AOI0, CMC, CMP0, LPTMR0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO24M_SYSTEM_CLOCK 24000000UL /* Clock consumers of System_clock output : ADC0, CMP1, CTIMER0, CTIMER1, CTIMER2, DMA0, FLEXPWM0, FREQME0, GPIO0, GPIO1, GPIO2, GPIO3, I3C0, INPUTMUX0, LPI2C0, LPSPI0, LPSPI1, LPUART0, LPUART1, LPUART2, OSTIMER0, PORT0, PORT1, PORT2, PORT3, QDC0, SWD, SysTick, USB0, UTICK0, WWDT0 */
+#define BOARD_BOOTCLOCKFRO24M_TRACE_CLOCK 24000000UL /* Clock consumers of TRACE_clock output : SWD */
+#define BOARD_BOOTCLOCKFRO24M_USB0_CLOCK 0UL /* Clock consumers of USB0_clock output : USB0 */
+#define BOARD_BOOTCLOCKFRO24M_UTICK_CLOCK 1000000UL /* Clock consumers of UTICK_clock output : UTICK0 */
+#define BOARD_BOOTCLOCKFRO24M_WUU_CLOCK 0UL /* Clock consumers of WUU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO24M_WWDT0_CLOCK 1000000UL /* Clock consumers of WWDT0_clock output : WWDT0 */
+
+
+/*******************************************************************************
+ * API for BOARD_BootClockFRO24M configuration
+ ******************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus*/
+
+/*!
+ * @brief This function executes configuration of clocks.
+ *
+ */
+void BOARD_BootClockFRO24M(void);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus*/
+
+/*******************************************************************************
+ ******************** Configuration BOARD_BootClockFRO48M **********************
+ ******************************************************************************/
+/*******************************************************************************
+ * Definitions for BOARD_BootClockFRO48M configuration
+ ******************************************************************************/
+#define BOARD_BOOTCLOCKFRO48M_CORE_CLOCK 48000000U /*!< Core clock frequency: 48000000Hz */
+
+/* Clock outputs (values are in Hz): */
+#define BOARD_BOOTCLOCKFRO48M_ADC0_CLOCK 0UL /* Clock consumers of ADC0_clock output : ADC0 */
+#define BOARD_BOOTCLOCKFRO48M_CLK16K_0_CLOCK 0UL /* Clock consumers of CLK16K_0_clock output : CMP0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO48M_CLK16K_1_CLOCK 0UL /* Clock consumers of CLK16K_1_clock output : CMP1, LPTMR0, WAKETIMER0 */
+#define BOARD_BOOTCLOCKFRO48M_CLKOUT_CLOCK 0UL /* Clock consumers of CLKOUT_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_CLK_1M_CLOCK 1000000UL /* Clock consumers of CLK_1M_clock output : CMC */
+#define BOARD_BOOTCLOCKFRO48M_CLK_48M_CLOCK 48000000UL /* Clock consumers of CLK_48M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_CLK_IN_CLOCK 0UL /* Clock consumers of CLK_IN_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_CMP0FDIV_CLOCK 0UL /* Clock consumers of CMP0FDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO48M_CMP0RRDIV_CLOCK 0UL /* Clock consumers of CMP0RRDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO48M_CMP1FDIV_CLOCK 0UL /* Clock consumers of CMP1FDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO48M_CMP1RRDIV_CLOCK 0UL /* Clock consumers of CMP1RRDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO48M_CPU_CLOCK 48000000UL /* Clock consumers of CPU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_CTIMER0_CLOCK 0UL /* Clock consumers of CTIMER0_clock output : CTIMER0 */
+#define BOARD_BOOTCLOCKFRO48M_CTIMER1_CLOCK 0UL /* Clock consumers of CTIMER1_clock output : CTIMER1 */
+#define BOARD_BOOTCLOCKFRO48M_CTIMER2_CLOCK 0UL /* Clock consumers of CTIMER2_clock output : CTIMER2 */
+#define BOARD_BOOTCLOCKFRO48M_FREQME_REFERENCE_CLOCK 0UL /* Clock consumers of FREQME_reference_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO48M_FREQME_TARGET_CLOCK 0UL /* Clock consumers of FREQME_target_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO48M_FRO_12M_CLOCK 12000000UL /* Clock consumers of FRO_12M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_FRO_HF_DIV_CLOCK 48000000UL /* Clock consumers of FRO_HF_DIV_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_FRO_HF_CLOCK 48000000UL /* Clock consumers of FRO_HF_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_I3C_FCLK_CLOCK 0UL /* Clock consumers of I3C_FCLK_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO48M_I3C_SLOW_TC_CLOCK 0UL /* Clock consumers of I3C_SLOW_TC_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO48M_I3C_SLOW_CLOCK 0UL /* Clock consumers of I3C_SLOW_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO48M_LPI2C0_CLOCK 0UL /* Clock consumers of LPI2C0_clock output : LPI2C0 */
+#define BOARD_BOOTCLOCKFRO48M_LPSPI0_CLOCK 0UL /* Clock consumers of LPSPI0_clock output : LPSPI0 */
+#define BOARD_BOOTCLOCKFRO48M_LPSPI1_CLOCK 0UL /* Clock consumers of LPSPI1_clock output : LPSPI1 */
+#define BOARD_BOOTCLOCKFRO48M_LPTMR0_CLOCK 0UL /* Clock consumers of LPTMR0_clock output : LPTMR0 */
+#define BOARD_BOOTCLOCKFRO48M_LPUART0_CLOCK 0UL /* Clock consumers of LPUART0_clock output : LPUART0 */
+#define BOARD_BOOTCLOCKFRO48M_LPUART1_CLOCK 0UL /* Clock consumers of LPUART1_clock output : LPUART1 */
+#define BOARD_BOOTCLOCKFRO48M_LPUART2_CLOCK 0UL /* Clock consumers of LPUART2_clock output : LPUART2 */
+#define BOARD_BOOTCLOCKFRO48M_MAIN_CLOCK 48000000UL /* Clock consumers of MAIN_clock output : FLEXPWM0 */
+#define BOARD_BOOTCLOCKFRO48M_OSTIMER_CLOCK 0UL /* Clock consumers of OSTIMER_clock output : OSTIMER0 */
+#define BOARD_BOOTCLOCKFRO48M_FIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.FIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_SIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.SIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_SLOW_CLOCK 12000000UL /* Clock consumers of Slow_clock output : AOI0, CMC, CMP0, LPTMR0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO48M_SYSTEM_CLOCK 48000000UL /* Clock consumers of System_clock output : ADC0, CMP1, CTIMER0, CTIMER1, CTIMER2, DMA0, FLEXPWM0, FREQME0, GPIO0, GPIO1, GPIO2, GPIO3, I3C0, INPUTMUX0, LPI2C0, LPSPI0, LPSPI1, LPUART0, LPUART1, LPUART2, OSTIMER0, PORT0, PORT1, PORT2, PORT3, QDC0, SWD, SysTick, USB0, UTICK0, WWDT0 */
+#define BOARD_BOOTCLOCKFRO48M_TRACE_CLOCK 48000000UL /* Clock consumers of TRACE_clock output : SWD */
+#define BOARD_BOOTCLOCKFRO48M_USB0_CLOCK 0UL /* Clock consumers of USB0_clock output : USB0 */
+#define BOARD_BOOTCLOCKFRO48M_UTICK_CLOCK 1000000UL /* Clock consumers of UTICK_clock output : UTICK0 */
+#define BOARD_BOOTCLOCKFRO48M_WUU_CLOCK 0UL /* Clock consumers of WUU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO48M_WWDT0_CLOCK 1000000UL /* Clock consumers of WWDT0_clock output : WWDT0 */
+
+
+/*******************************************************************************
+ * API for BOARD_BootClockFRO48M configuration
+ ******************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus*/
+
+/*!
+ * @brief This function executes configuration of clocks.
+ *
+ */
+void BOARD_BootClockFRO48M(void);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus*/
+
+/*******************************************************************************
+ ******************** Configuration BOARD_BootClockFRO64M **********************
+ ******************************************************************************/
+/*******************************************************************************
+ * Definitions for BOARD_BootClockFRO64M configuration
+ ******************************************************************************/
+#define BOARD_BOOTCLOCKFRO64M_CORE_CLOCK 64000000U /*!< Core clock frequency: 64000000Hz */
+
+/* Clock outputs (values are in Hz): */
+#define BOARD_BOOTCLOCKFRO64M_ADC0_CLOCK 0UL /* Clock consumers of ADC0_clock output : ADC0 */
+#define BOARD_BOOTCLOCKFRO64M_CLK16K_0_CLOCK 0UL /* Clock consumers of CLK16K_0_clock output : CMP0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO64M_CLK16K_1_CLOCK 0UL /* Clock consumers of CLK16K_1_clock output : CMP1, LPTMR0, WAKETIMER0 */
+#define BOARD_BOOTCLOCKFRO64M_CLKOUT_CLOCK 0UL /* Clock consumers of CLKOUT_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_CLK_1M_CLOCK 1000000UL /* Clock consumers of CLK_1M_clock output : CMC */
+#define BOARD_BOOTCLOCKFRO64M_CLK_48M_CLOCK 48000000UL /* Clock consumers of CLK_48M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_CLK_IN_CLOCK 0UL /* Clock consumers of CLK_IN_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_CMP0FDIV_CLOCK 0UL /* Clock consumers of CMP0FDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO64M_CMP0RRDIV_CLOCK 0UL /* Clock consumers of CMP0RRDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO64M_CMP1FDIV_CLOCK 0UL /* Clock consumers of CMP1FDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO64M_CMP1RRDIV_CLOCK 0UL /* Clock consumers of CMP1RRDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO64M_CPU_CLOCK 64000000UL /* Clock consumers of CPU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_CTIMER0_CLOCK 0UL /* Clock consumers of CTIMER0_clock output : CTIMER0 */
+#define BOARD_BOOTCLOCKFRO64M_CTIMER1_CLOCK 0UL /* Clock consumers of CTIMER1_clock output : CTIMER1 */
+#define BOARD_BOOTCLOCKFRO64M_CTIMER2_CLOCK 0UL /* Clock consumers of CTIMER2_clock output : CTIMER2 */
+#define BOARD_BOOTCLOCKFRO64M_FREQME_REFERENCE_CLOCK 0UL /* Clock consumers of FREQME_reference_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO64M_FREQME_TARGET_CLOCK 0UL /* Clock consumers of FREQME_target_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO64M_FRO_12M_CLOCK 12000000UL /* Clock consumers of FRO_12M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_FRO_HF_DIV_CLOCK 64000000UL /* Clock consumers of FRO_HF_DIV_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_FRO_HF_CLOCK 64000000UL /* Clock consumers of FRO_HF_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_I3C_FCLK_CLOCK 0UL /* Clock consumers of I3C_FCLK_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO64M_I3C_SLOW_TC_CLOCK 0UL /* Clock consumers of I3C_SLOW_TC_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO64M_I3C_SLOW_CLOCK 0UL /* Clock consumers of I3C_SLOW_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO64M_LPI2C0_CLOCK 0UL /* Clock consumers of LPI2C0_clock output : LPI2C0 */
+#define BOARD_BOOTCLOCKFRO64M_LPSPI0_CLOCK 0UL /* Clock consumers of LPSPI0_clock output : LPSPI0 */
+#define BOARD_BOOTCLOCKFRO64M_LPSPI1_CLOCK 0UL /* Clock consumers of LPSPI1_clock output : LPSPI1 */
+#define BOARD_BOOTCLOCKFRO64M_LPTMR0_CLOCK 0UL /* Clock consumers of LPTMR0_clock output : LPTMR0 */
+#define BOARD_BOOTCLOCKFRO64M_LPUART0_CLOCK 0UL /* Clock consumers of LPUART0_clock output : LPUART0 */
+#define BOARD_BOOTCLOCKFRO64M_LPUART1_CLOCK 0UL /* Clock consumers of LPUART1_clock output : LPUART1 */
+#define BOARD_BOOTCLOCKFRO64M_LPUART2_CLOCK 0UL /* Clock consumers of LPUART2_clock output : LPUART2 */
+#define BOARD_BOOTCLOCKFRO64M_MAIN_CLOCK 64000000UL /* Clock consumers of MAIN_clock output : FLEXPWM0 */
+#define BOARD_BOOTCLOCKFRO64M_OSTIMER_CLOCK 0UL /* Clock consumers of OSTIMER_clock output : OSTIMER0 */
+#define BOARD_BOOTCLOCKFRO64M_FIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.FIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_SIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.SIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_SLOW_CLOCK 16000000UL /* Clock consumers of Slow_clock output : AOI0, CMC, CMP0, LPTMR0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO64M_SYSTEM_CLOCK 64000000UL /* Clock consumers of System_clock output : ADC0, CMP1, CTIMER0, CTIMER1, CTIMER2, DMA0, FLEXPWM0, FREQME0, GPIO0, GPIO1, GPIO2, GPIO3, I3C0, INPUTMUX0, LPI2C0, LPSPI0, LPSPI1, LPUART0, LPUART1, LPUART2, OSTIMER0, PORT0, PORT1, PORT2, PORT3, QDC0, SWD, SysTick, USB0, UTICK0, WWDT0 */
+#define BOARD_BOOTCLOCKFRO64M_TRACE_CLOCK 64000000UL /* Clock consumers of TRACE_clock output : SWD */
+#define BOARD_BOOTCLOCKFRO64M_USB0_CLOCK 0UL /* Clock consumers of USB0_clock output : USB0 */
+#define BOARD_BOOTCLOCKFRO64M_UTICK_CLOCK 1000000UL /* Clock consumers of UTICK_clock output : UTICK0 */
+#define BOARD_BOOTCLOCKFRO64M_WUU_CLOCK 0UL /* Clock consumers of WUU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO64M_WWDT0_CLOCK 1000000UL /* Clock consumers of WWDT0_clock output : WWDT0 */
+
+
+/*******************************************************************************
+ * API for BOARD_BootClockFRO64M configuration
+ ******************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus*/
+
+/*!
+ * @brief This function executes configuration of clocks.
+ *
+ */
+void BOARD_BootClockFRO64M(void);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus*/
+
+/*******************************************************************************
+ ******************** Configuration BOARD_BootClockFRO96M **********************
+ ******************************************************************************/
+/*******************************************************************************
+ * Definitions for BOARD_BootClockFRO96M configuration
+ ******************************************************************************/
+#define BOARD_BOOTCLOCKFRO96M_CORE_CLOCK 96000000U /*!< Core clock frequency: 96000000Hz */
+
+/* Clock outputs (values are in Hz): */
+#define BOARD_BOOTCLOCKFRO96M_ADC0_CLOCK 0UL /* Clock consumers of ADC0_clock output : ADC0 */
+#define BOARD_BOOTCLOCKFRO96M_CLK16K_0_CLOCK 0UL /* Clock consumers of CLK16K_0_clock output : CMP0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO96M_CLK16K_1_CLOCK 0UL /* Clock consumers of CLK16K_1_clock output : CMP1, LPTMR0, WAKETIMER0 */
+#define BOARD_BOOTCLOCKFRO96M_CLKOUT_CLOCK 0UL /* Clock consumers of CLKOUT_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_CLK_1M_CLOCK 1000000UL /* Clock consumers of CLK_1M_clock output : CMC */
+#define BOARD_BOOTCLOCKFRO96M_CLK_48M_CLOCK 48000000UL /* Clock consumers of CLK_48M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_CLK_IN_CLOCK 0UL /* Clock consumers of CLK_IN_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_CMP0FDIV_CLOCK 0UL /* Clock consumers of CMP0FDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO96M_CMP0RRDIV_CLOCK 0UL /* Clock consumers of CMP0RRDIV_clock output : CMP0 */
+#define BOARD_BOOTCLOCKFRO96M_CMP1FDIV_CLOCK 0UL /* Clock consumers of CMP1FDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO96M_CMP1RRDIV_CLOCK 0UL /* Clock consumers of CMP1RRDIV_clock output : CMP1 */
+#define BOARD_BOOTCLOCKFRO96M_CPU_CLOCK 96000000UL /* Clock consumers of CPU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_CTIMER0_CLOCK 0UL /* Clock consumers of CTIMER0_clock output : CTIMER0 */
+#define BOARD_BOOTCLOCKFRO96M_CTIMER1_CLOCK 0UL /* Clock consumers of CTIMER1_clock output : CTIMER1 */
+#define BOARD_BOOTCLOCKFRO96M_CTIMER2_CLOCK 0UL /* Clock consumers of CTIMER2_clock output : CTIMER2 */
+#define BOARD_BOOTCLOCKFRO96M_FREQME_REFERENCE_CLOCK 0UL /* Clock consumers of FREQME_reference_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO96M_FREQME_TARGET_CLOCK 0UL /* Clock consumers of FREQME_target_clock output : FREQME0 */
+#define BOARD_BOOTCLOCKFRO96M_FRO_12M_CLOCK 12000000UL /* Clock consumers of FRO_12M_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_FRO_HF_DIV_CLOCK 96000000UL /* Clock consumers of FRO_HF_DIV_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_FRO_HF_CLOCK 96000000UL /* Clock consumers of FRO_HF_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_I3C_FCLK_CLOCK 0UL /* Clock consumers of I3C_FCLK_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO96M_I3C_SLOW_TC_CLOCK 0UL /* Clock consumers of I3C_SLOW_TC_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO96M_I3C_SLOW_CLOCK 0UL /* Clock consumers of I3C_SLOW_clock output : I3C0 */
+#define BOARD_BOOTCLOCKFRO96M_LPI2C0_CLOCK 0UL /* Clock consumers of LPI2C0_clock output : LPI2C0 */
+#define BOARD_BOOTCLOCKFRO96M_LPSPI0_CLOCK 0UL /* Clock consumers of LPSPI0_clock output : LPSPI0 */
+#define BOARD_BOOTCLOCKFRO96M_LPSPI1_CLOCK 0UL /* Clock consumers of LPSPI1_clock output : LPSPI1 */
+#define BOARD_BOOTCLOCKFRO96M_LPTMR0_CLOCK 0UL /* Clock consumers of LPTMR0_clock output : LPTMR0 */
+#define BOARD_BOOTCLOCKFRO96M_LPUART0_CLOCK 0UL /* Clock consumers of LPUART0_clock output : LPUART0 */
+#define BOARD_BOOTCLOCKFRO96M_LPUART1_CLOCK 0UL /* Clock consumers of LPUART1_clock output : LPUART1 */
+#define BOARD_BOOTCLOCKFRO96M_LPUART2_CLOCK 0UL /* Clock consumers of LPUART2_clock output : LPUART2 */
+#define BOARD_BOOTCLOCKFRO96M_MAIN_CLOCK 96000000UL /* Clock consumers of MAIN_clock output : FLEXPWM0 */
+#define BOARD_BOOTCLOCKFRO96M_OSTIMER_CLOCK 0UL /* Clock consumers of OSTIMER_clock output : OSTIMER0 */
+#define BOARD_BOOTCLOCKFRO96M_FIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.FIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_SIRC_TRIM_CLOCK 0UL /* Clock consumers of SCG.SIRC_TRIM_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_SLOW_CLOCK 24000000UL /* Clock consumers of Slow_clock output : AOI0, CMC, CMP0, LPTMR0, WAKETIMER0, WUU0 */
+#define BOARD_BOOTCLOCKFRO96M_SYSTEM_CLOCK 96000000UL /* Clock consumers of System_clock output : ADC0, CMP1, CTIMER0, CTIMER1, CTIMER2, DMA0, FLEXPWM0, FREQME0, GPIO0, GPIO1, GPIO2, GPIO3, I3C0, INPUTMUX0, LPI2C0, LPSPI0, LPSPI1, LPUART0, LPUART1, LPUART2, OSTIMER0, PORT0, PORT1, PORT2, PORT3, QDC0, SWD, SysTick, USB0, UTICK0, WWDT0 */
+#define BOARD_BOOTCLOCKFRO96M_TRACE_CLOCK 96000000UL /* Clock consumers of TRACE_clock output : SWD */
+#define BOARD_BOOTCLOCKFRO96M_USB0_CLOCK 0UL /* Clock consumers of USB0_clock output : USB0 */
+#define BOARD_BOOTCLOCKFRO96M_UTICK_CLOCK 1000000UL /* Clock consumers of UTICK_clock output : UTICK0 */
+#define BOARD_BOOTCLOCKFRO96M_WUU_CLOCK 0UL /* Clock consumers of WUU_clock output : N/A */
+#define BOARD_BOOTCLOCKFRO96M_WWDT0_CLOCK 1000000UL /* Clock consumers of WWDT0_clock output : WWDT0 */
+
+
+/*******************************************************************************
+ * API for BOARD_BootClockFRO96M configuration
+ ******************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus*/
+
+/*!
+ * @brief This function executes configuration of clocks.
+ *
+ */
+void BOARD_BootClockFRO96M(void);
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus*/
+
+#endif /* _CLOCK_CONFIG_H_ */
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.c b/hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.c
new file mode 100644
index 000000000..58b0f47e9
--- /dev/null
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.c
@@ -0,0 +1,492 @@
+/*
+ * Copyright 2025 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/***********************************************************************************************************************
+ * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
+ * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
+ **********************************************************************************************************************/
+
+/* clang-format off */
+/*
+ * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
+!!GlobalInfo
+product: Pins v17.0
+processor: MCXA153
+package_id: MCXA153VLH
+mcu_data: ksdk2_0
+processor_version: 25.09.10
+board: FRDM-MCXA153
+external_user_signals: {}
+ * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
+ */
+/* clang-format on */
+
+#include "fsl_common.h"
+#include "fsl_port.h"
+#include "fsl_gpio.h"
+#include "pin_mux.h"
+
+/* FUNCTION ************************************************************************************************************
+ *
+ * Function Name : BOARD_InitBootPins
+ * Description : Calls initialization functions.
+ *
+ * END ****************************************************************************************************************/
+void BOARD_InitBootPins(void)
+{
+ BOARD_InitDEBUG_UARTPins();
+ BOARD_InitLEDsPins();
+ BOARD_InitBUTTONsPins();
+}
+
+/* clang-format off */
+/*
+ * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
+BOARD_InitDEBUG_UARTPins:
+- options: {callFromInitBoot: 'true', coreID: cm33_core0, enableClock: 'true'}
+- pin_list:
+ - {pin_num: '51', peripheral: LPUART0, signal: RX, pin_signal: P0_2/TDO/SWO/LPUART0_RXD/LPSPI0_SCK/CT0_MAT0/UTICK_CAP0/I3C0_PUR, slew_rate: fast, open_drain: disable,
+ drive_strength: high, pull_select: down, pull_enable: disable, input_buffer: enable, invert_input: normal}
+ - {pin_num: '52', peripheral: LPUART0, signal: TX, pin_signal: P0_3/TDI/LPUART0_TXD/LPSPI0_SDO/CT0_MAT1/UTICK_CAP1/CMP0_OUT/CMP1_IN1, slew_rate: fast, open_drain: disable,
+ drive_strength: low, pull_select: up, pull_enable: enable, input_buffer: enable, invert_input: normal}
+ * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
+ */
+/* clang-format on */
+
+/* FUNCTION ************************************************************************************************************
+ *
+ * Function Name : BOARD_InitDEBUG_UARTPins
+ * Description : Configures pin routing and optionally pin electrical features.
+ *
+ * END ****************************************************************************************************************/
+void BOARD_InitDEBUG_UARTPins(void)
+{
+ /* Write to PORT0: Peripheral clock is enabled */
+ CLOCK_EnableClock(kCLOCK_GatePORT0);
+ /* LPUART0 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kLPUART0_RST_SHIFT_RSTn);
+ /* PORT0 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kPORT0_RST_SHIFT_RSTn);
+
+ const port_pin_config_t DEBUG_UART_RX = {/* Internal pull-up/down resistor is disabled */
+ .pullSelect = kPORT_PullDisable,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* High drive strength is configured */
+ .driveStrength = kPORT_HighDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as LPUART0_RXD */
+ .mux = kPORT_MuxAlt2,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT0_2 (pin 51) is configured as LPUART0_RXD */
+ PORT_SetPinConfig(BOARD_INITDEBUG_UARTPINS_DEBUG_UART_RX_PORT, BOARD_INITDEBUG_UARTPINS_DEBUG_UART_RX_PIN, &DEBUG_UART_RX);
+
+ const port_pin_config_t DEBUG_UART_TX = {/* Internal pull-up resistor is enabled */
+ .pullSelect = kPORT_PullUp,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* Low drive strength is configured */
+ .driveStrength = kPORT_LowDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as LPUART0_TXD */
+ .mux = kPORT_MuxAlt2,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT0_3 (pin 52) is configured as LPUART0_TXD */
+ PORT_SetPinConfig(BOARD_INITDEBUG_UARTPINS_DEBUG_UART_TX_PORT, BOARD_INITDEBUG_UARTPINS_DEBUG_UART_TX_PIN, &DEBUG_UART_TX);
+}
+
+/* clang-format off */
+/*
+ * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
+BOARD_InitSWD_DEBUGPins:
+- options: {callFromInitBoot: 'false', coreID: cm33_core0, enableClock: 'true'}
+- pin_list:
+ - {pin_num: '50', peripheral: SWD, signal: SWCLK, pin_signal: P0_1/TCLK/SWCLK/LPUART0_CTS_B/LPSPI0_SDI/CT_INP1, slew_rate: fast, open_drain: disable, drive_strength: low,
+ pull_select: down, pull_enable: enable, input_buffer: enable, invert_input: normal}
+ - {pin_num: '49', peripheral: SWD, signal: SWDIO, pin_signal: P0_0/TMS/SWDIO/LPUART0_RTS_B/LPSPI0_PCS0/CT_INP0, slew_rate: fast, open_drain: disable, drive_strength: high,
+ pull_select: up, pull_enable: enable, input_buffer: enable, invert_input: normal}
+ - {pin_num: '51', peripheral: SWD, signal: SWO, pin_signal: P0_2/TDO/SWO/LPUART0_RXD/LPSPI0_SCK/CT0_MAT0/UTICK_CAP0/I3C0_PUR, slew_rate: fast, open_drain: disable,
+ drive_strength: high, pull_select: down, pull_enable: disable, input_buffer: enable, invert_input: normal}
+ * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
+ */
+/* clang-format on */
+
+/* FUNCTION ************************************************************************************************************
+ *
+ * Function Name : BOARD_InitSWD_DEBUGPins
+ * Description : Configures pin routing and optionally pin electrical features.
+ *
+ * END ****************************************************************************************************************/
+void BOARD_InitSWD_DEBUGPins(void)
+{
+ /* Write to PORT0: Peripheral clock is enabled */
+ CLOCK_EnableClock(kCLOCK_GatePORT0);
+ /* PORT0 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kPORT0_RST_SHIFT_RSTn);
+ /* LPUART0 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kLPUART0_RST_SHIFT_RSTn);
+
+ const port_pin_config_t DEBUG_SWD_SWDIO = {/* Internal pull-up resistor is enabled */
+ .pullSelect = kPORT_PullUp,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* High drive strength is configured */
+ .driveStrength = kPORT_HighDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as SWDIO */
+ .mux = kPORT_MuxAlt1,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT0_0 (pin 49) is configured as SWDIO */
+ PORT_SetPinConfig(BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDIO_PORT, BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDIO_PIN, &DEBUG_SWD_SWDIO);
+
+ const port_pin_config_t DEBUG_SWD_SWDCLK = {/* Internal pull-down resistor is enabled */
+ .pullSelect = kPORT_PullDown,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* Low drive strength is configured */
+ .driveStrength = kPORT_LowDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as SWCLK */
+ .mux = kPORT_MuxAlt1,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT0_1 (pin 50) is configured as SWCLK */
+ PORT_SetPinConfig(BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDCLK_PORT, BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDCLK_PIN, &DEBUG_SWD_SWDCLK);
+
+ const port_pin_config_t DEBUG_UART_RX = {/* Internal pull-up/down resistor is disabled */
+ .pullSelect = kPORT_PullDisable,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* High drive strength is configured */
+ .driveStrength = kPORT_HighDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as SWO */
+ .mux = kPORT_MuxAlt1,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT0_2 (pin 51) is configured as SWO */
+ PORT_SetPinConfig(BOARD_INITSWD_DEBUGPINS_DEBUG_UART_RX_PORT, BOARD_INITSWD_DEBUGPINS_DEBUG_UART_RX_PIN, &DEBUG_UART_RX);
+}
+
+/* clang-format off */
+/*
+ * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
+BOARD_InitLEDsPins:
+- options: {callFromInitBoot: 'true', coreID: cm33_core0, enableClock: 'true'}
+- pin_list:
+ - {pin_num: '37', peripheral: GPIO3, signal: 'GPIO, 13', pin_signal: P3_13/LPUART2_CTS_B/CT1_MAT3/PWM0_X1, direction: OUTPUT, gpio_init_state: 'true', slew_rate: fast,
+ open_drain: disable, drive_strength: low, pull_select: up, pull_enable: disable, input_buffer: enable, invert_input: normal}
+ - {pin_num: '38', peripheral: GPIO3, signal: 'GPIO, 12', pin_signal: P3_12/LPUART2_RTS_B/CT1_MAT2/PWM0_X0, direction: OUTPUT, gpio_init_state: 'true', slew_rate: fast,
+ open_drain: disable, drive_strength: low, pull_select: up, pull_enable: disable, input_buffer: enable, invert_input: normal}
+ - {pin_num: '46', peripheral: GPIO3, signal: 'GPIO, 0', pin_signal: P3_0/WUU0_IN22/TRIG_IN0/CT_INP16/PWM0_A0, direction: OUTPUT, gpio_init_state: 'true', slew_rate: fast,
+ open_drain: disable, drive_strength: low, pull_select: up, pull_enable: disable, passive_filter: disable, input_buffer: enable, invert_input: normal}
+ * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
+ */
+/* clang-format on */
+
+/* FUNCTION ************************************************************************************************************
+ *
+ * Function Name : BOARD_InitLEDsPins
+ * Description : Configures pin routing and optionally pin electrical features.
+ *
+ * END ****************************************************************************************************************/
+void BOARD_InitLEDsPins(void)
+{
+ /* Write to GPIO3: Peripheral clock is enabled */
+ CLOCK_EnableClock(kCLOCK_GateGPIO3);
+ /* Write to PORT3: Peripheral clock is enabled */
+ CLOCK_EnableClock(kCLOCK_GatePORT3);
+ /* GPIO3 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kGPIO3_RST_SHIFT_RSTn);
+ /* PORT3 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kPORT3_RST_SHIFT_RSTn);
+
+ gpio_pin_config_t LED_BLUE_config = {
+ .pinDirection = kGPIO_DigitalOutput,
+ .outputLogic = 1U
+ };
+ /* Initialize GPIO functionality on pin PIO3_0 (pin 46) */
+ GPIO_PinInit(BOARD_INITLEDSPINS_LED_BLUE_GPIO, BOARD_INITLEDSPINS_LED_BLUE_PIN, &LED_BLUE_config);
+
+ gpio_pin_config_t LED_RED_config = {
+ .pinDirection = kGPIO_DigitalOutput,
+ .outputLogic = 1U
+ };
+ /* Initialize GPIO functionality on pin PIO3_12 (pin 38) */
+ GPIO_PinInit(BOARD_INITLEDSPINS_LED_RED_GPIO, BOARD_INITLEDSPINS_LED_RED_PIN, &LED_RED_config);
+
+ gpio_pin_config_t LED_GREEN_config = {
+ .pinDirection = kGPIO_DigitalOutput,
+ .outputLogic = 1U
+ };
+ /* Initialize GPIO functionality on pin PIO3_13 (pin 37) */
+ GPIO_PinInit(BOARD_INITLEDSPINS_LED_GREEN_GPIO, BOARD_INITLEDSPINS_LED_GREEN_PIN, &LED_GREEN_config);
+
+ /* PORT3_0 (pin 46) is configured as P3_0 */
+ PORT_SetPinMux(BOARD_INITLEDSPINS_LED_BLUE_PORT, BOARD_INITLEDSPINS_LED_BLUE_PIN, kPORT_MuxAlt0);
+
+ PORT3->PCR[0] =
+ ((PORT3->PCR[0] &
+ /* Mask bits to zero which are setting */
+ (~(PORT_PCR_PS_MASK | PORT_PCR_PE_MASK | PORT_PCR_SRE_MASK | PORT_PCR_PFE_MASK | PORT_PCR_ODE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_IBE_MASK | PORT_PCR_INV_MASK)))
+
+ /* Pull Select: Enables internal pullup resistor. */
+ | PORT_PCR_PS(PCR_PS_ps1)
+
+ /* Pull Enable: Disables. */
+ | PORT_PCR_PE(PCR_PE_pe0)
+
+ /* Slew Rate Enable: Fast. */
+ | PORT_PCR_SRE(PCR_SRE_sre0)
+
+ /* Passive Filter Enable: Disables. */
+ | PORT_PCR_PFE(PCR_PFE_pfe0)
+
+ /* Open Drain Enable: Disables. */
+ | PORT_PCR_ODE(PCR_ODE_ode0)
+
+ /* Drive Strength Enable: Low. */
+ | PORT_PCR_DSE(PCR_DSE_dse0)
+
+ /* Input Buffer Enable: Enables. */
+ | PORT_PCR_IBE(PCR_IBE_ibe1)
+
+ /* Invert Input: Does not invert. */
+ | PORT_PCR_INV(PCR_INV_inv0));
+
+ /* PORT3_12 (pin 38) is configured as P3_12 */
+ PORT_SetPinMux(BOARD_INITLEDSPINS_LED_RED_PORT, BOARD_INITLEDSPINS_LED_RED_PIN, kPORT_MuxAlt0);
+
+ PORT3->PCR[12] =
+ ((PORT3->PCR[12] &
+ /* Mask bits to zero which are setting */
+ (~(PORT_PCR_PS_MASK | PORT_PCR_PE_MASK | PORT_PCR_SRE_MASK | PORT_PCR_ODE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_IBE_MASK | PORT_PCR_INV_MASK)))
+
+ /* Pull Select: Enables internal pullup resistor. */
+ | PORT_PCR_PS(PCR_PS_ps1)
+
+ /* Pull Enable: Disables. */
+ | PORT_PCR_PE(PCR_PE_pe0)
+
+ /* Slew Rate Enable: Fast. */
+ | PORT_PCR_SRE(PCR_SRE_sre0)
+
+ /* Open Drain Enable: Disables. */
+ | PORT_PCR_ODE(PCR_ODE_ode0)
+
+ /* Drive Strength Enable: Low. */
+ | PORT_PCR_DSE(PCR_DSE_dse0)
+
+ /* Input Buffer Enable: Enables. */
+ | PORT_PCR_IBE(PCR_IBE_ibe1)
+
+ /* Invert Input: Does not invert. */
+ | PORT_PCR_INV(PCR_INV_inv0));
+
+ /* PORT3_13 (pin 37) is configured as P3_13 */
+ PORT_SetPinMux(BOARD_INITLEDSPINS_LED_GREEN_PORT, BOARD_INITLEDSPINS_LED_GREEN_PIN, kPORT_MuxAlt0);
+
+ PORT3->PCR[13] =
+ ((PORT3->PCR[13] &
+ /* Mask bits to zero which are setting */
+ (~(PORT_PCR_PS_MASK | PORT_PCR_PE_MASK | PORT_PCR_SRE_MASK | PORT_PCR_ODE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_IBE_MASK | PORT_PCR_INV_MASK)))
+
+ /* Pull Select: Enables internal pullup resistor. */
+ | PORT_PCR_PS(PCR_PS_ps1)
+
+ /* Pull Enable: Disables. */
+ | PORT_PCR_PE(PCR_PE_pe0)
+
+ /* Slew Rate Enable: Fast. */
+ | PORT_PCR_SRE(PCR_SRE_sre0)
+
+ /* Open Drain Enable: Disables. */
+ | PORT_PCR_ODE(PCR_ODE_ode0)
+
+ /* Drive Strength Enable: Low. */
+ | PORT_PCR_DSE(PCR_DSE_dse0)
+
+ /* Input Buffer Enable: Enables. */
+ | PORT_PCR_IBE(PCR_IBE_ibe1)
+
+ /* Invert Input: Does not invert. */
+ | PORT_PCR_INV(PCR_INV_inv0));
+}
+
+/* clang-format off */
+/*
+ * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
+BOARD_InitBUTTONsPins:
+- options: {callFromInitBoot: 'true', coreID: cm33_core0, enableClock: 'true'}
+- pin_list:
+ - {pin_num: '1', peripheral: GPIO1, signal: 'GPIO, 7', pin_signal: P1_7/WUU0_IN9/TRIG_OUT2/LPUART2_CTS_B/CT_INP7/ADC0_A23, slew_rate: fast, open_drain: disable,
+ drive_strength: low, pull_select: down, pull_enable: disable, input_buffer: enable, invert_input: normal}
+ - {pin_num: '8', peripheral: GPIO1, signal: 'GPIO, 29', pin_signal: P1_29/RESET_B/SPC_LPREQ, slew_rate: fast, open_drain: enable, drive_strength: low, pull_select: up,
+ pull_enable: enable, passive_filter: enable, pull_value: low, input_buffer: enable, invert_input: normal}
+ - {pin_num: '32', peripheral: GPIO3, signal: 'GPIO, 29', pin_signal: P3_29/WUU0_IN27/ISPMODE_N/CT_INP3/ADC0_A14, slew_rate: fast, open_drain: disable, drive_strength: low,
+ pull_select: up, pull_enable: enable, input_buffer: enable, invert_input: normal}
+ * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
+ */
+/* clang-format on */
+
+/* FUNCTION ************************************************************************************************************
+ *
+ * Function Name : BOARD_InitBUTTONsPins
+ * Description : Configures pin routing and optionally pin electrical features.
+ *
+ * END ****************************************************************************************************************/
+void BOARD_InitBUTTONsPins(void)
+{
+ /* Write to PORT1: Peripheral clock is enabled */
+ CLOCK_EnableClock(kCLOCK_GatePORT1);
+ /* Write to PORT3: Peripheral clock is enabled */
+ CLOCK_EnableClock(kCLOCK_GatePORT3);
+ /* GPIO1 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kGPIO1_RST_SHIFT_RSTn);
+ /* PORT1 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kPORT1_RST_SHIFT_RSTn);
+ /* GPIO3 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kGPIO3_RST_SHIFT_RSTn);
+ /* PORT3 peripheral is released from reset */
+ RESET_ReleasePeripheralReset(kPORT3_RST_SHIFT_RSTn);
+
+ const port_pin_config_t SW1 = {/* Internal pull-up resistor is enabled */
+ .pullSelect = kPORT_PullUp,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is enabled */
+ .passiveFilterEnable = kPORT_PassiveFilterEnable,
+ /* Open drain output is enabled */
+ .openDrainEnable = kPORT_OpenDrainEnable,
+ /* Low drive strength is configured */
+ .driveStrength = kPORT_LowDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as P1_29 */
+ .mux = kPORT_MuxAlt0,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT1_29 (pin 8) is configured as P1_29 */
+ PORT_SetPinConfig(BOARD_INITBUTTONSPINS_SW1_PORT, BOARD_INITBUTTONSPINS_SW1_PIN, &SW1);
+
+ const port_pin_config_t SW3 = {/* Internal pull-up/down resistor is disabled */
+ .pullSelect = kPORT_PullDisable,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* Low drive strength is configured */
+ .driveStrength = kPORT_LowDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as P1_7 */
+ .mux = kPORT_MuxAlt0,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT1_7 (pin 1) is configured as P1_7 */
+ PORT_SetPinConfig(BOARD_INITBUTTONSPINS_SW3_PORT, BOARD_INITBUTTONSPINS_SW3_PIN, &SW3);
+
+ const port_pin_config_t ISP = {/* Internal pull-up resistor is enabled */
+ .pullSelect = kPORT_PullUp,
+ /* Low internal pull resistor value is selected. */
+ .pullValueSelect = kPORT_LowPullResistor,
+ /* Fast slew rate is configured */
+ .slewRate = kPORT_FastSlewRate,
+ /* Passive input filter is disabled */
+ .passiveFilterEnable = kPORT_PassiveFilterDisable,
+ /* Open drain output is disabled */
+ .openDrainEnable = kPORT_OpenDrainDisable,
+ /* Low drive strength is configured */
+ .driveStrength = kPORT_LowDriveStrength,
+ /* Normal drive strength is configured */
+ .driveStrength1 = kPORT_NormalDriveStrength,
+ /* Pin is configured as P3_29 */
+ .mux = kPORT_MuxAlt0,
+ /* Digital input enabled */
+ .inputBuffer = kPORT_InputBufferEnable,
+ /* Digital input is not inverted */
+ .invertInput = kPORT_InputNormal,
+ /* Pin Control Register fields [15:0] are not locked */
+ .lockRegister = kPORT_UnlockRegister};
+ /* PORT3_29 (pin 32) is configured as P3_29 */
+ PORT_SetPinConfig(BOARD_INITBUTTONSPINS_ISP_PORT, BOARD_INITBUTTONSPINS_ISP_PIN, &ISP);
+}
+/***********************************************************************************************************************
+ * EOF
+ **********************************************************************************************************************/
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.h b/hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.h
new file mode 100644
index 000000000..4a42f266d
--- /dev/null
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/board/pin_mux.h
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2025 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/***********************************************************************************************************************
+ * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
+ * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
+ **********************************************************************************************************************/
+
+#ifndef _PIN_MUX_H_
+#define _PIN_MUX_H_
+
+/*!
+ * @addtogroup pin_mux
+ * @{
+ */
+
+/***********************************************************************************************************************
+ * API
+ **********************************************************************************************************************/
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*!
+ * @brief Calls initialization functions.
+ *
+ */
+void BOARD_InitBootPins(void);
+
+/*! @name PORT0_2 (number 51), P0_2/SWO/J25[3]/J18[6]
+ @{ */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITDEBUG_UARTPINS_DEBUG_UART_RX_PORT PORT0 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITDEBUG_UARTPINS_DEBUG_UART_RX_PIN 2U /*!<@brief PORT pin number */
+#define BOARD_INITDEBUG_UARTPINS_DEBUG_UART_RX_PIN_MASK (1U << 2U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT0_3 (number 52), P0_3/J25[1]/J18[8]
+ @{ */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITDEBUG_UARTPINS_DEBUG_UART_TX_PORT PORT0 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITDEBUG_UARTPINS_DEBUG_UART_TX_PIN 3U /*!<@brief PORT pin number */
+#define BOARD_INITDEBUG_UARTPINS_DEBUG_UART_TX_PIN_MASK (1U << 3U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*!
+ * @brief Configures pin routing and optionally pin electrical features.
+ *
+ */
+void BOARD_InitDEBUG_UARTPins(void);
+
+/*! @name PORT0_1 (number 50), P0_1/SWCLK/JP10[2]/J18[4]
+ @{ */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDCLK_PORT PORT0 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDCLK_PIN 1U /*!<@brief PORT pin number */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDCLK_PIN_MASK (1U << 1U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT0_0 (number 49), P0_0/SWDIO/J18[2]
+ @{ */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDIO_PORT PORT0 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDIO_PIN 0U /*!<@brief PORT pin number */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_SWD_SWDIO_PIN_MASK (1U << 0U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT0_2 (number 51), P0_2/SWO/J25[3]/J18[6]
+ @{ */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_UART_RX_PORT PORT0 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_UART_RX_PIN 2U /*!<@brief PORT pin number */
+#define BOARD_INITSWD_DEBUGPINS_DEBUG_UART_RX_PIN_MASK (1U << 2U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*!
+ * @brief Configures pin routing and optionally pin electrical features.
+ *
+ */
+void BOARD_InitSWD_DEBUGPins(void);
+
+#define PCR_DSE_dse0 0x00u /*!<@brief Drive Strength Enable: Low */
+#define PCR_IBE_ibe1 0x01u /*!<@brief Input Buffer Enable: Enables */
+#define PCR_INV_inv0 0x00u /*!<@brief Invert Input: Does not invert */
+#define PCR_ODE_ode0 0x00u /*!<@brief Open Drain Enable: Disables */
+#define PCR_PE_pe0 0x00u /*!<@brief Pull Enable: Disables */
+#define PCR_PFE_pfe0 0x00u /*!<@brief Passive Filter Enable: Disables */
+#define PCR_PS_ps1 0x01u /*!<@brief Pull Select: Enables internal pullup resistor */
+#define PCR_SRE_sre0 0x00u /*!<@brief Slew Rate Enable: Fast */
+
+/*! @name PORT3_13 (number 37), P3_13/J1[14]
+ @{ */
+
+/* Symbols to be used with GPIO driver */
+#define BOARD_INITLEDSPINS_LED_GREEN_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
+#define BOARD_INITLEDSPINS_LED_GREEN_INIT_GPIO_VALUE 1U /*!<@brief GPIO output initial state */
+#define BOARD_INITLEDSPINS_LED_GREEN_GPIO_PIN 13U /*!<@brief GPIO pin number */
+#define BOARD_INITLEDSPINS_LED_GREEN_GPIO_PIN_MASK (1U << 13U) /*!<@brief GPIO pin mask */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITLEDSPINS_LED_GREEN_PORT PORT3 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITLEDSPINS_LED_GREEN_PIN 13U /*!<@brief PORT pin number */
+#define BOARD_INITLEDSPINS_LED_GREEN_PIN_MASK (1U << 13U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT3_12 (number 38), P3_12/J1[12]/J5[1]
+ @{ */
+
+/* Symbols to be used with GPIO driver */
+#define BOARD_INITLEDSPINS_LED_RED_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
+#define BOARD_INITLEDSPINS_LED_RED_INIT_GPIO_VALUE 1U /*!<@brief GPIO output initial state */
+#define BOARD_INITLEDSPINS_LED_RED_GPIO_PIN 12U /*!<@brief GPIO pin number */
+#define BOARD_INITLEDSPINS_LED_RED_GPIO_PIN_MASK (1U << 12U) /*!<@brief GPIO pin mask */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITLEDSPINS_LED_RED_PORT PORT3 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITLEDSPINS_LED_RED_PIN 12U /*!<@brief PORT pin number */
+#define BOARD_INITLEDSPINS_LED_RED_PIN_MASK (1U << 12U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT3_0 (number 46), P3_0/J1[8]
+ @{ */
+
+/* Symbols to be used with GPIO driver */
+#define BOARD_INITLEDSPINS_LED_BLUE_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
+#define BOARD_INITLEDSPINS_LED_BLUE_INIT_GPIO_VALUE 1U /*!<@brief GPIO output initial state */
+#define BOARD_INITLEDSPINS_LED_BLUE_GPIO_PIN 0U /*!<@brief GPIO pin number */
+#define BOARD_INITLEDSPINS_LED_BLUE_GPIO_PIN_MASK (1U << 0U) /*!<@brief GPIO pin mask */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITLEDSPINS_LED_BLUE_PORT PORT3 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITLEDSPINS_LED_BLUE_PIN 0U /*!<@brief PORT pin number */
+#define BOARD_INITLEDSPINS_LED_BLUE_PIN_MASK (1U << 0U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*!
+ * @brief Configures pin routing and optionally pin electrical features.
+ *
+ */
+void BOARD_InitLEDsPins(void);
+
+/*! @name PORT1_7 (number 1), P1_7/J1[1]
+ @{ */
+
+/* Symbols to be used with GPIO driver */
+#define BOARD_INITBUTTONSPINS_SW3_GPIO GPIO1 /*!<@brief GPIO peripheral base pointer */
+#define BOARD_INITBUTTONSPINS_SW3_GPIO_PIN 7U /*!<@brief GPIO pin number */
+#define BOARD_INITBUTTONSPINS_SW3_GPIO_PIN_MASK (1U << 7U) /*!<@brief GPIO pin mask */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITBUTTONSPINS_SW3_PORT PORT1 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITBUTTONSPINS_SW3_PIN 7U /*!<@brief PORT pin number */
+#define BOARD_INITBUTTONSPINS_SW3_PIN_MASK (1U << 7U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT1_29 (number 8), P1_29/J3[6]/J18[10]
+ @{ */
+
+/* Symbols to be used with GPIO driver */
+#define BOARD_INITBUTTONSPINS_SW1_GPIO GPIO1 /*!<@brief GPIO peripheral base pointer */
+#define BOARD_INITBUTTONSPINS_SW1_GPIO_PIN 29U /*!<@brief GPIO pin number */
+#define BOARD_INITBUTTONSPINS_SW1_GPIO_PIN_MASK (1U << 29U) /*!<@brief GPIO pin mask */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITBUTTONSPINS_SW1_PORT PORT1 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITBUTTONSPINS_SW1_PIN 29U /*!<@brief PORT pin number */
+#define BOARD_INITBUTTONSPINS_SW1_PIN_MASK (1U << 29U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*! @name PORT3_29 (number 32), P3_29/J18[7]/J4[11]
+ @{ */
+
+/* Symbols to be used with GPIO driver */
+#define BOARD_INITBUTTONSPINS_ISP_GPIO GPIO3 /*!<@brief GPIO peripheral base pointer */
+#define BOARD_INITBUTTONSPINS_ISP_GPIO_PIN 29U /*!<@brief GPIO pin number */
+#define BOARD_INITBUTTONSPINS_ISP_GPIO_PIN_MASK (1U << 29U) /*!<@brief GPIO pin mask */
+
+/* Symbols to be used with PORT driver */
+#define BOARD_INITBUTTONSPINS_ISP_PORT PORT3 /*!<@brief PORT peripheral base pointer */
+#define BOARD_INITBUTTONSPINS_ISP_PIN 29U /*!<@brief PORT pin number */
+#define BOARD_INITBUTTONSPINS_ISP_PIN_MASK (1U << 29U) /*!<@brief PORT pin mask */
+ /* @} */
+
+/*!
+ * @brief Configures pin routing and optionally pin electrical features.
+ *
+ */
+void BOARD_InitBUTTONsPins(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+/*!
+ * @}
+ */
+#endif /* _PIN_MUX_H_ */
+
+/***********************************************************************************************************************
+ * EOF
+ **********************************************************************************************************************/
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/clock_config.h b/hw/bsp/mcx/boards/frdm_mcxa153/clock_config.h
deleted file mode 100644
index aae811052..000000000
--- a/hw/bsp/mcx/boards/frdm_mcxa153/clock_config.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2023 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/***********************************************************************************************************************
- * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
- * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
- **********************************************************************************************************************/
-
-#ifndef _CLOCK_CONFIG_H_
-#define _CLOCK_CONFIG_H_
-
-#include "fsl_common.h"
-
-/*******************************************************************************
- * Definitions
- ******************************************************************************/
-
-/*******************************************************************************
- ************************ BOARD_InitBootClocks function ************************
- ******************************************************************************/
-
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus*/
-
-/*!
- * @brief This function executes default configuration of clocks.
- *
- */
-void BOARD_InitBootClocks(void);
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus*/
-
-/*******************************************************************************
- ******************** Configuration BOARD_BootClockFRO12M **********************
- ******************************************************************************/
-/*******************************************************************************
- * Definitions for BOARD_BootClockFRO12M configuration
- ******************************************************************************/
-#define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK 12000000U /*!< Core clock frequency: 12000000Hz */
-
-
-/*******************************************************************************
- * API for BOARD_BootClockFRO12M configuration
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus*/
-
-/*!
- * @brief This function executes configuration of clocks.
- *
- */
-void BOARD_BootClockFRO12M(void);
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus*/
-
-/*******************************************************************************
- ******************** Configuration BOARD_BootClockFRO24M **********************
- ******************************************************************************/
-/*******************************************************************************
- * Definitions for BOARD_BootClockFRO24M configuration
- ******************************************************************************/
-#define BOARD_BOOTCLOCKFRO24M_CORE_CLOCK 24000000U /*!< Core clock frequency: 24000000Hz */
-
-
-/*******************************************************************************
- * API for BOARD_BootClockFRO24M configuration
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus*/
-
-/*!
- * @brief This function executes configuration of clocks.
- *
- */
-void BOARD_BootClockFRO24M(void);
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus*/
-
-/*******************************************************************************
- ******************** Configuration BOARD_BootClockFRO48M **********************
- ******************************************************************************/
-/*******************************************************************************
- * Definitions for BOARD_BootClockFRO48M configuration
- ******************************************************************************/
-#define BOARD_BOOTCLOCKFRO48M_CORE_CLOCK 48000000U /*!< Core clock frequency: 48000000Hz */
-
-
-/*******************************************************************************
- * API for BOARD_BootClockFRO48M configuration
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus*/
-
-/*!
- * @brief This function executes configuration of clocks.
- *
- */
-void BOARD_BootClockFRO48M(void);
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus*/
-
-/*******************************************************************************
- ******************** Configuration BOARD_BootClockFRO64M **********************
- ******************************************************************************/
-/*******************************************************************************
- * Definitions for BOARD_BootClockFRO64M configuration
- ******************************************************************************/
-#define BOARD_BOOTCLOCKFRO64M_CORE_CLOCK 64000000U /*!< Core clock frequency: 64000000Hz */
-
-
-/*******************************************************************************
- * API for BOARD_BootClockFRO64M configuration
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus*/
-
-/*!
- * @brief This function executes configuration of clocks.
- *
- */
-void BOARD_BootClockFRO64M(void);
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus*/
-
-/*******************************************************************************
- ******************** Configuration BOARD_BootClockFRO96M **********************
- ******************************************************************************/
-/*******************************************************************************
- * Definitions for BOARD_BootClockFRO96M configuration
- ******************************************************************************/
-#define BOARD_BOOTCLOCKFRO96M_CORE_CLOCK 96000000U /*!< Core clock frequency: 96000000Hz */
-
-
-/*******************************************************************************
- * API for BOARD_BootClockFRO96M configuration
- ******************************************************************************/
-#if defined(__cplusplus)
-extern "C" {
-#endif /* __cplusplus*/
-
-/*!
- * @brief This function executes configuration of clocks.
- *
- */
-void BOARD_BootClockFRO96M(void);
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus*/
-
-#endif /* _CLOCK_CONFIG_H_ */
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/frdm_mcxa153.mex b/hw/bsp/mcx/boards/frdm_mcxa153/frdm_mcxa153.mex
new file mode 100644
index 000000000..43fea73db
--- /dev/null
+++ b/hw/bsp/mcx/boards/frdm_mcxa153/frdm_mcxa153.mex
@@ -0,0 +1,573 @@
+<?xml version="1.0" encoding= "UTF-8" ?>
+<configuration name="FRDM-MCXA153" xsi:schemaLocation="http://mcuxpresso.nxp.com/XSD/mex_configuration_19 http://mcuxpresso.nxp.com/XSD/mex_configuration_19.xsd" uuid="39087bef-8f98-40a9-aaf4-e556fb7a1ce1" version="19" xmlns="http://mcuxpresso.nxp.com/XSD/mex_configuration_19" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <common>
+ <processor>MCXA153</processor>
+ <package>MCXA153VLH</package>
+ <board>FRDM-MCXA153</board>
+ <mcu_data>ksdk2_0</mcu_data>
+ <cores selected="cm33_core0">
+ <core name="Cortex-M33" id="cm33_core0" description="M33 core"/>
+ </cores>
+ <description></description>
+ </common>
+ <preferences>
+ <validate_boot_init_only>true</validate_boot_init_only>
+ <generate_code_modified_registers_only>false</generate_code_modified_registers_only>
+ <custom_copyright>
+ <text>/*
+ * Copyright 2025 NXP
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+</text>
+ <enabled>true</enabled>
+ </custom_copyright>
+ <update_include_paths>true</update_include_paths>
+ <enable_parallel_routing>true</enable_parallel_routing>
+ <generate_registers_defines>false</generate_registers_defines>
+ </preferences>
+ <tools>
+ <pins name="Pins" version="17.0" enabled="true" update_project_code="true">
+ <generated_project_files>
+ <file path="board/pin_mux.c" update_enabled="true"/>
+ <file path="board/pin_mux.h" update_enabled="true"/>
+ </generated_project_files>
+ <pins_profile>
+ <processor_version>25.09.10</processor_version>
+ <external_user_signals>
+ <properties/>
+ </external_user_signals>
+ </pins_profile>
+ <functions_list>
+ <function name="BOARD_InitDEBUG_UARTPins">
+ <description>Configures pin routing and optionally pin electrical features.</description>
+ <options>
+ <callFromInitBoot>true</callFromInitBoot>
+ <coreID>cm33_core0</coreID>
+ <enableClock>true</enableClock>
+ </options>
+ <dependencies>
+ <dependency resourceType="Peripheral" resourceId="LPUART0" description="Peripheral LPUART0 signals are routed in the Pins Tool, but the peripheral is not initialized in the Peripherals Tool." problem_level="1" source="Pins:BOARD_InitDEBUG_UARTPins">
+ <feature name="initialized" evaluation="equal">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Pins initialization requires the COMMON Driver in the project." problem_level="2" source="Pins:BOARD_InitDEBUG_UARTPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.port" description="Pins initialization requires the PORT Driver in the project." problem_level="2" source="Pins:BOARD_InitDEBUG_UARTPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <pins>
+ <pin peripheral="LPUART0" signal="RX" pin_num="51" pin_signal="P0_2/TDO/SWO/LPUART0_RXD/LPSPI0_SCK/CT0_MAT0/UTICK_CAP0/I3C0_PUR">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="high"/>
+ <pin_feature name="pull_select" value="down"/>
+ <pin_feature name="pull_enable" value="disable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="LPUART0" signal="TX" pin_num="52" pin_signal="P0_3/TDI/LPUART0_TXD/LPSPI0_SDO/CT0_MAT1/UTICK_CAP1/CMP0_OUT/CMP1_IN1">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="enable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ </pins>
+ </function>
+ <function name="BOARD_InitSWD_DEBUGPins">
+ <description>Configures pin routing and optionally pin electrical features.</description>
+ <options>
+ <callFromInitBoot>false</callFromInitBoot>
+ <coreID>cm33_core0</coreID>
+ <enableClock>true</enableClock>
+ </options>
+ <dependencies>
+ <dependency resourceType="Peripheral" resourceId="SWD" description="Peripheral SWD signals are routed in the Pins Tool, but the peripheral is not initialized in the Peripherals Tool." problem_level="1" source="Pins:BOARD_InitSWD_DEBUGPins">
+ <feature name="initialized" evaluation="equal">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Pins initialization requires the COMMON Driver in the project." problem_level="2" source="Pins:BOARD_InitSWD_DEBUGPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.port" description="Pins initialization requires the PORT Driver in the project." problem_level="2" source="Pins:BOARD_InitSWD_DEBUGPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <pins>
+ <pin peripheral="SWD" signal="SWCLK" pin_num="50" pin_signal="P0_1/TCLK/SWCLK/LPUART0_CTS_B/LPSPI0_SDI/CT_INP1">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="down"/>
+ <pin_feature name="pull_enable" value="enable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="SWD" signal="SWDIO" pin_num="49" pin_signal="P0_0/TMS/SWDIO/LPUART0_RTS_B/LPSPI0_PCS0/CT_INP0">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="high"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="enable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="SWD" signal="SWO" pin_num="51" pin_signal="P0_2/TDO/SWO/LPUART0_RXD/LPSPI0_SCK/CT0_MAT0/UTICK_CAP0/I3C0_PUR">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="high"/>
+ <pin_feature name="pull_select" value="down"/>
+ <pin_feature name="pull_enable" value="disable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ </pins>
+ </function>
+ <function name="BOARD_InitLEDsPins">
+ <description>Configures pin routing and optionally pin electrical features.</description>
+ <options>
+ <callFromInitBoot>true</callFromInitBoot>
+ <coreID>cm33_core0</coreID>
+ <enableClock>true</enableClock>
+ </options>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Pins initialization requires the COMMON Driver in the project." problem_level="2" source="Pins:BOARD_InitLEDsPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.port" description="Pins initialization requires the PORT Driver in the project." problem_level="2" source="Pins:BOARD_InitLEDsPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.gpio" description="Pins initialization requires the GPIO Driver in the project." problem_level="2" source="Pins:BOARD_InitLEDsPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <pins>
+ <pin peripheral="GPIO3" signal="GPIO, 13" pin_num="37" pin_signal="P3_13/LPUART2_CTS_B/CT1_MAT3/PWM0_X1">
+ <pin_features>
+ <pin_feature name="direction" value="OUTPUT"/>
+ <pin_feature name="gpio_init_state" value="true"/>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="disable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="GPIO3" signal="GPIO, 12" pin_num="38" pin_signal="P3_12/LPUART2_RTS_B/CT1_MAT2/PWM0_X0">
+ <pin_features>
+ <pin_feature name="direction" value="OUTPUT"/>
+ <pin_feature name="gpio_init_state" value="true"/>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="disable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="GPIO3" signal="GPIO, 0" pin_num="46" pin_signal="P3_0/WUU0_IN22/TRIG_IN0/CT_INP16/PWM0_A0">
+ <pin_features>
+ <pin_feature name="direction" value="OUTPUT"/>
+ <pin_feature name="gpio_init_state" value="true"/>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="disable"/>
+ <pin_feature name="passive_filter" value="disable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ </pins>
+ </function>
+ <function name="BOARD_InitBUTTONsPins">
+ <description>Configures pin routing and optionally pin electrical features.</description>
+ <options>
+ <callFromInitBoot>true</callFromInitBoot>
+ <coreID>cm33_core0</coreID>
+ <enableClock>true</enableClock>
+ </options>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Pins initialization requires the COMMON Driver in the project." problem_level="2" source="Pins:BOARD_InitBUTTONsPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.port" description="Pins initialization requires the PORT Driver in the project." problem_level="2" source="Pins:BOARD_InitBUTTONsPins">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <pins>
+ <pin peripheral="GPIO1" signal="GPIO, 7" pin_num="1" pin_signal="P1_7/WUU0_IN9/TRIG_OUT2/LPUART2_CTS_B/CT_INP7/ADC0_A23">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="down"/>
+ <pin_feature name="pull_enable" value="disable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="GPIO1" signal="GPIO, 29" pin_num="8" pin_signal="P1_29/RESET_B/SPC_LPREQ">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="enable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="enable"/>
+ <pin_feature name="passive_filter" value="enable"/>
+ <pin_feature name="pull_value" value="low"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ <pin peripheral="GPIO3" signal="GPIO, 29" pin_num="32" pin_signal="P3_29/WUU0_IN27/ISPMODE_N/CT_INP3/ADC0_A14">
+ <pin_features>
+ <pin_feature name="slew_rate" value="fast"/>
+ <pin_feature name="open_drain" value="disable"/>
+ <pin_feature name="drive_strength" value="low"/>
+ <pin_feature name="pull_select" value="up"/>
+ <pin_feature name="pull_enable" value="enable"/>
+ <pin_feature name="input_buffer" value="enable"/>
+ <pin_feature name="invert_input" value="normal"/>
+ </pin_features>
+ </pin>
+ </pins>
+ </function>
+ </functions_list>
+ </pins>
+ <clocks name="Clocks" version="18.0" enabled="true" update_project_code="true">
+ <generated_project_files>
+ <file path="board/clock_config.c" update_enabled="true"/>
+ <file path="board/clock_config.h" update_enabled="true"/>
+ </generated_project_files>
+ <clocks_profile>
+ <processor_version>25.09.10</processor_version>
+ </clocks_profile>
+ <clock_configurations>
+ <clock_configuration name="BOARD_BootClockFRO12M" id_prefix="" prefix_user_defined="false">
+ <description></description>
+ <options/>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO12M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO12M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.mcx_spc" description="Clocks initialization requires the MCX_SPC Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO12M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <clock_sources/>
+ <clock_outputs>
+ <clock_output id="CLK_1M_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="CPU_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_12M_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="MAIN_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="Slow_clock.outFreq" value="3 MHz" locked="false" accuracy=""/>
+ <clock_output id="System_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="TRACE_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="UTICK_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="WWDT0_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ </clock_outputs>
+ <clock_settings>
+ <setting id="SCGMode" value="SIRC" locked="false"/>
+ <setting id="MRCC.FREQMEREFCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.FREQMETARGETCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.OSTIMERCLKSEL.sel" value="VBAT.CLK16K_1" locked="false"/>
+ <setting id="SCG.SCSSEL.sel" value="SCG.SIRC" locked="false"/>
+ <setting id="SCG_FIRCCSR_FIRCEN_CFG" value="Disabled" locked="false"/>
+ </clock_settings>
+ <called_from_default_init>false</called_from_default_init>
+ </clock_configuration>
+ <clock_configuration name="BOARD_BootClockFRO24M" id_prefix="" prefix_user_defined="false">
+ <description></description>
+ <options/>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO24M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO24M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.mcx_spc" description="Clocks initialization requires the MCX_SPC Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO24M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <clock_sources/>
+ <clock_outputs>
+ <clock_output id="CLK_1M_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="CLK_48M_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="CPU_clock.outFreq" value="24 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_12M_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_DIV_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="MAIN_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="Slow_clock.outFreq" value="6 MHz" locked="false" accuracy=""/>
+ <clock_output id="System_clock.outFreq" value="24 MHz" locked="false" accuracy=""/>
+ <clock_output id="TRACE_clock.outFreq" value="24 MHz" locked="false" accuracy=""/>
+ <clock_output id="UTICK_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="WWDT0_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ </clock_outputs>
+ <clock_settings>
+ <setting id="MRCC.FREQMEREFCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.FREQMETARGETCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.OSTIMERCLKSEL.sel" value="VBAT.CLK16K_1" locked="false"/>
+ <setting id="SYSCON.AHBCLKDIV.scale" value="2" locked="false"/>
+ </clock_settings>
+ <called_from_default_init>false</called_from_default_init>
+ </clock_configuration>
+ <clock_configuration name="BOARD_BootClockFRO48M" id_prefix="" prefix_user_defined="false">
+ <description></description>
+ <options/>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO48M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO48M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.mcx_spc" description="Clocks initialization requires the MCX_SPC Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO48M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <clock_sources/>
+ <clock_outputs>
+ <clock_output id="CLK_1M_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="CLK_48M_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="CPU_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_12M_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_DIV_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="MAIN_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="Slow_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="System_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="TRACE_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="UTICK_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="WWDT0_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ </clock_outputs>
+ <clock_settings>
+ <setting id="MRCC.FREQMEREFCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.FREQMETARGETCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.OSTIMERCLKSEL.sel" value="VBAT.CLK16K_1" locked="false"/>
+ </clock_settings>
+ <called_from_default_init>false</called_from_default_init>
+ </clock_configuration>
+ <clock_configuration name="BOARD_BootClockFRO64M" id_prefix="" prefix_user_defined="false">
+ <description></description>
+ <options/>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO64M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO64M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.mcx_spc" description="Clocks initialization requires the MCX_SPC Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO64M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <clock_sources>
+ <clock_source id="SCG.FIRC.outFreq" value="64 MHz" locked="false" enabled="false"/>
+ </clock_sources>
+ <clock_outputs>
+ <clock_output id="CLK_1M_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="CLK_48M_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="CPU_clock.outFreq" value="64 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_12M_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_DIV_clock.outFreq" value="64 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_clock.outFreq" value="64 MHz" locked="false" accuracy=""/>
+ <clock_output id="MAIN_clock.outFreq" value="64 MHz" locked="false" accuracy=""/>
+ <clock_output id="Slow_clock.outFreq" value="16 MHz" locked="false" accuracy=""/>
+ <clock_output id="System_clock.outFreq" value="64 MHz" locked="false" accuracy=""/>
+ <clock_output id="TRACE_clock.outFreq" value="64 MHz" locked="false" accuracy=""/>
+ <clock_output id="UTICK_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="WWDT0_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ </clock_outputs>
+ <clock_settings>
+ <setting id="VDD_CORE" value="voltage_1v1" locked="false"/>
+ <setting id="MRCC.FREQMEREFCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.FREQMETARGETCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.FROHFDIV.scale" value="1" locked="true"/>
+ <setting id="MRCC.OSTIMERCLKSEL.sel" value="VBAT.CLK16K_1" locked="false"/>
+ <setting id="SYSCON.AHBCLKDIV.scale" value="1" locked="true"/>
+ </clock_settings>
+ <called_from_default_init>false</called_from_default_init>
+ </clock_configuration>
+ <clock_configuration name="BOARD_BootClockFRO96M" id_prefix="" prefix_user_defined="false">
+ <description></description>
+ <options/>
+ <dependencies>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="Clocks initialization requires the COMMON Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO96M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.clock" description="Clocks initialization requires the CLOCK Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO96M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ <dependency resourceType="SWComponent" resourceId="platform.drivers.mcx_spc" description="Clocks initialization requires the MCX_SPC Driver in the project." problem_level="2" source="Clocks:BOARD_BootClockFRO96M">
+ <feature name="enabled" evaluation="equal" configuration="cm33_core0">
+ <data>true</data>
+ </feature>
+ </dependency>
+ </dependencies>
+ <clock_sources>
+ <clock_source id="SCG.FIRC.outFreq" value="96 MHz" locked="false" enabled="false"/>
+ </clock_sources>
+ <clock_outputs>
+ <clock_output id="CLK_1M_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="CLK_48M_clock.outFreq" value="48 MHz" locked="false" accuracy=""/>
+ <clock_output id="CPU_clock.outFreq" value="96 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_12M_clock.outFreq" value="12 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_DIV_clock.outFreq" value="96 MHz" locked="false" accuracy=""/>
+ <clock_output id="FRO_HF_clock.outFreq" value="96 MHz" locked="false" accuracy=""/>
+ <clock_output id="MAIN_clock.outFreq" value="96 MHz" locked="false" accuracy=""/>
+ <clock_output id="Slow_clock.outFreq" value="24 MHz" locked="false" accuracy=""/>
+ <clock_output id="System_clock.outFreq" value="96 MHz" locked="false" accuracy=""/>
+ <clock_output id="TRACE_clock.outFreq" value="96 MHz" locked="false" accuracy=""/>
+ <clock_output id="UTICK_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ <clock_output id="WWDT0_clock.outFreq" value="1 MHz" locked="false" accuracy=""/>
+ </clock_outputs>
+ <clock_settings>
+ <setting id="VDD_CORE" value="voltage_1v1" locked="false"/>
+ <setting id="MRCC.FREQMEREFCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.FREQMETARGETCLKSEL.sel" value="MRCC.aoi0_out0" locked="false"/>
+ <setting id="MRCC.OSTIMERCLKSEL.sel" value="VBAT.CLK16K_1" locked="false"/>
+ </clock_settings>
+ <called_from_default_init>true</called_from_default_init>
+ </clock_configuration>
+ </clock_configurations>
+ </clocks>
+ <dcdx name="DCDx" version="3.0" enabled="false" update_project_code="true">
+ <generated_project_files/>
+ <dcdx_profile>
+ <processor_version>N/A</processor_version>
+ </dcdx_profile>
+ <dcdx_configurations/>
+ </dcdx>
+ <periphs name="Peripherals" version="15.0" enabled="true" update_project_code="true">
+ <generated_project_files>
+ <file path="board/peripherals.c" update_enabled="true"/>
+ <file path="board/peripherals.h" update_enabled="true"/>
+ </generated_project_files>
+ <peripherals_profile>
+ <processor_version>25.09.10</processor_version>
+ </peripherals_profile>
+ <functional_groups>
+ <functional_group name="BOARD_InitPeripherals" uuid="e7964cfd-63b7-4756-a1af-71a53c49bda7" called_from_default_init="true" id_prefix="" core="cm33_core0">
+ <description></description>
+ <options/>
+ <dependencies/>
+ <instances>
+ <instance name="NVIC" uuid="6948572f-4bff-423f-8e78-3f0608580bb3" type="nvic" type_id="nvic" mode="general" peripheral="NVIC" enabled="true" comment="" custom_name_enabled="false" editing_lock="false">
+ <config_set name="nvic">
+ <array name="interrupt_table"/>
+ <array name="interrupts"/>
+ </config_set>
+ </instance>
+ </instances>
+ </functional_group>
+ </functional_groups>
+ <components>
+ <component name="system" uuid="3700167a-8497-4b9d-ad19-c395e5e33267" type_id="system">
+ <config_set_global name="global_system_definitions">
+ <setting name="user_definitions" value=""/>
+ <setting name="user_includes" value=""/>
+ <setting name="global_init" value=""/>
+ </config_set_global>
+ </component>
+ <component name="msg" uuid="faf79cc1-e0a0-4bf8-a803-42cf14e2a60a" type_id="msg">
+ <config_set_global name="global_messages"/>
+ </component>
+ <component name="generic_can" uuid="f1cb80d2-97a1-4bdd-ab65-0d3d8493019c" type_id="generic_can">
+ <config_set_global name="global_can"/>
+ </component>
+ <component name="uart_cmsis_common" uuid="a17f12aa-b188-417b-a499-c22892686ae2" type_id="uart_cmsis_common">
+ <config_set_global name="global_USART_CMSIS_common" quick_selection="default"/>
+ </component>
+ <component name="generic_uart" uuid="96c6481f-affb-44c4-9d6f-ebc972fcae38" type_id="generic_uart">
+ <config_set_global name="global_uart"/>
+ </component>
+ <component name="generic_enet" uuid="44df8b34-f20e-449a-8d2d-2cba12faf3f7" type_id="generic_enet">
+ <config_set_global name="global_enet"/>
+ </component>
+ <component name="gpio_adapter_common" uuid="2fe36bae-ef17-4655-9cf5-91cac6de7288" type_id="gpio_adapter_common">
+ <config_set_global name="global_gpio_adapter_common" quick_selection="default"/>
+ </component>
+ </components>
+ </periphs>
+ <tee name="TEE" version="10.0" enabled="false" update_project_code="true">
+ <generated_project_files/>
+ <tee_profile>
+ <processor_version>N/A</processor_version>
+ </tee_profile>
+ </tee>
+ </tools>
+</configuration>
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.c b/hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.c
deleted file mode 100644
index 47709951b..000000000
--- a/hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2023 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-/***********************************************************************************************************************
- * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
- * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
- **********************************************************************************************************************/
-
-/* clang-format off */
-/*
- * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
-!!GlobalInfo
-product: Pins v14.0
-processor: MCXA153
-package_id: MCXA153VLH
-mcu_data: ksdk2_0
-processor_version: 0.14.4
- * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
- */
-/* clang-format on */
-
-#include "fsl_common.h"
-#include "fsl_port.h"
-#include "pin_mux.h"
-
-/* FUNCTION ************************************************************************************************************
- *
- * Function Name : BOARD_InitBootPins
- * Description : Calls initialization functions.
- *
- * END ****************************************************************************************************************/
-void BOARD_InitBootPins(void)
-{
- BOARD_InitPins();
-}
-
-/* clang-format off */
-/*
- * TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
-BOARD_InitPins:
-- options: {callFromInitBoot: 'true', coreID: cm33_core0, enableClock: 'true'}
-- pin_list:
- - {pin_num: '51', peripheral: LPUART0, signal: RX, pin_signal: P0_2/TDO/SWO/LPUART0_RXD/LPSPI0_SCK/CT0_MAT0/UTICK_CAP0/I3C0_PUR, slew_rate: fast, open_drain: disable,
- drive_strength: low, pull_select: up, pull_enable: enable, input_buffer: enable, invert_input: normal}
- - {pin_num: '52', peripheral: LPUART0, signal: TX, pin_signal: P0_3/TDI/LPUART0_TXD/LPSPI0_SDO/CT0_MAT1/UTICK_CAP1/CMP0_OUT/CMP1_IN1, slew_rate: fast, open_drain: disable,
- drive_strength: low, pull_select: up, pull_enable: enable, input_buffer: enable, invert_input: normal}
- * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
- */
-/* clang-format on */
-
-/* FUNCTION ************************************************************************************************************
- *
- * Function Name : BOARD_InitPins
- * Description : Configures pin routing and optionally pin electrical features.
- *
- * END ****************************************************************************************************************/
-void BOARD_InitPins(void)
-{
- CLOCK_EnableClock(kCLOCK_GateGPIO3);
- /* Write to PORT3: Peripheral clock is enabled */
- CLOCK_EnableClock(kCLOCK_GatePORT3);
- /* GPIO3 peripheral is released from reset */
- RESET_ReleasePeripheralReset(kGPIO3_RST_SHIFT_RSTn);
- /* PORT3 peripheral is released from reset */
- RESET_ReleasePeripheralReset(kPORT3_RST_SHIFT_RSTn);
-
-
- /* Write to PORT0: Peripheral clock is enabled */
- CLOCK_EnableClock(kCLOCK_GatePORT0);
- /* LPUART0 peripheral is released from reset */
- RESET_ReleasePeripheralReset(kLPUART0_RST_SHIFT_RSTn);
- /* PORT0 peripheral is released from reset */
- RESET_ReleasePeripheralReset(kPORT0_RST_SHIFT_RSTn);
-
- const port_pin_config_t port0_2_pin51_config = {/* Internal pull-up resistor is enabled */
- kPORT_PullUp,
- /* Low internal pull resistor value is selected. */
- kPORT_LowPullResistor,
- /* Fast slew rate is configured */
- kPORT_FastSlewRate,
- /* Passive input filter is disabled */
- kPORT_PassiveFilterDisable,
- /* Open drain output is disabled */
- kPORT_OpenDrainDisable,
- /* Low drive strength is configured */
- kPORT_LowDriveStrength,
- /* Normal drive strength is configured */
- kPORT_NormalDriveStrength,
- /* Pin is configured as LPUART0_RXD */
- kPORT_MuxAlt2,
- /* Digital input enabled */
- kPORT_InputBufferEnable,
- /* Digital input is not inverted */
- kPORT_InputNormal,
- /* Pin Control Register fields [15:0] are not locked */
- kPORT_UnlockRegister};
- /* PORT0_2 (pin 51) is configured as LPUART0_RXD */
- PORT_SetPinConfig(PORT0, 2U, &port0_2_pin51_config);
-
- const port_pin_config_t port0_3_pin52_config = {/* Internal pull-up resistor is enabled */
- kPORT_PullUp,
- /* Low internal pull resistor value is selected. */
- kPORT_LowPullResistor,
- /* Fast slew rate is configured */
- kPORT_FastSlewRate,
- /* Passive input filter is disabled */
- kPORT_PassiveFilterDisable,
- /* Open drain output is disabled */
- kPORT_OpenDrainDisable,
- /* Low drive strength is configured */
- kPORT_LowDriveStrength,
- /* Normal drive strength is configured */
- kPORT_NormalDriveStrength,
- /* Pin is configured as LPUART0_TXD */
- kPORT_MuxAlt2,
- /* Digital input enabled */
- kPORT_InputBufferEnable,
- /* Digital input is not inverted */
- kPORT_InputNormal,
- /* Pin Control Register fields [15:0] are not locked */
- kPORT_UnlockRegister};
- /* PORT0_3 (pin 52) is configured as LPUART0_TXD */
- PORT_SetPinConfig(PORT0, 3U, &port0_3_pin52_config);
-}
-/***********************************************************************************************************************
- * EOF
- **********************************************************************************************************************/
diff --git a/hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.h b/hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.h
deleted file mode 100644
index 2c0e617a5..000000000
--- a/hw/bsp/mcx/boards/frdm_mcxa153/pin_mux.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2023 NXP
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-/***********************************************************************************************************************
- * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
- * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
- **********************************************************************************************************************/
-
-#ifndef _PIN_MUX_H_
-#define _PIN_MUX_H_
-
-/*!
- * @addtogroup pin_mux
- * @{
- */
-
-/***********************************************************************************************************************
- * API
- **********************************************************************************************************************/
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/*!
- * @brief Calls initialization functions.
- *
- */
-void BOARD_InitBootPins(void);
-
-/*!
- * @brief Configures pin routing and optionally pin electrical features.
- *
- */
-void BOARD_InitPins(void);
-
-#if defined(__cplusplus)
-}
-#endif
-
-/*!
- * @}
- */
-#endif /* _PIN_MUX_H_ */
-
-/***********************************************************************************************************************
- * EOF
- **********************************************************************************************************************/
diff --git a/hw/bsp/mcx/family.c b/hw/bsp/mcx/family.c
index 2dfefeb92..e1accf941 100644
--- a/hw/bsp/mcx/family.c
+++ b/hw/bsp/mcx/family.c
@@ -61,14 +61,9 @@ void USB0_IRQHandler(void) {
void board_init(void) {
- BOARD_InitPins();
-
+ BOARD_InitBootPins();
BOARD_InitBootClocks();
- #ifdef XTAL0_CLK_HZ
- CLOCK_SetupExtClocking(XTAL0_CLK_HZ);
- #endif
-
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
diff --git a/hw/bsp/mcx/family.cmake b/hw/bsp/mcx/family.cmake
index f857ed31a..d062cec16 100644
--- a/hw/bsp/mcx/family.cmake
+++ b/hw/bsp/mcx/family.cmake
@@ -23,27 +23,22 @@ endif()
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
- endif()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
-
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
+endif()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
# driver
${SDK_DIR}/drivers/gpio/fsl_gpio.c
${SDK_DIR}/drivers/common/fsl_common_arm.c
@@ -66,76 +61,63 @@ function(add_board_target BOARD_TARGET)
)
if (${FAMILY_MCUS} STREQUAL "MCXN9")
-
target_sources(${BOARD_TARGET} PRIVATE
- ${SDK_DIR}/drivers/lpflexcomm/fsl_lpflexcomm.c
- )
-
+ ${SDK_DIR}/drivers/lpflexcomm/fsl_lpflexcomm.c
+ )
target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}/drivers/lpflexcomm
- )
+ ${SDK_DIR}/drivers/lpflexcomm
+ )
elseif(${FAMILY_MCUS} STREQUAL "MCXA15")
-
-
endif()
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- #-nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ if (${FAMILY_MCUS} STREQUAL "MCXN9")
+ family_add_tinyusb(${TARGET} OPT_MCU_MCXN9)
+ elseif(${FAMILY_MCUS} STREQUAL "MCXA15")
+ family_add_tinyusb(${TARGET} OPT_MCU_MCXA15)
+ endif()
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/chipidea/$<IF:${PORT},ci_hs/dcd_ci_hs.c,ci_fs/dcd_ci_fs.c>
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- if (${FAMILY_MCUS} STREQUAL "MCXN9")
- family_add_tinyusb(${TARGET} OPT_MCU_MCXN9)
- elseif(${FAMILY_MCUS} STREQUAL "MCXA15")
- family_add_tinyusb(${TARGET} OPT_MCU_MCXA15)
- endif()
-
- target_sources(${TARGET} PUBLIC
- # TinyUSB: Port0 is chipidea FS, Port1 is chipidea HS
- ${TOP}/src/portable/chipidea/$<IF:${PORT},ci_hs/dcd_ci_hs.c,ci_fs/dcd_ci_fs.c>
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ #-nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/mcx/family.mk b/hw/bsp/mcx/family.mk
index a16f4b6c0..4321e654a 100644
--- a/hw/bsp/mcx/family.mk
+++ b/hw/bsp/mcx/family.mk
@@ -11,7 +11,7 @@ CFLAGS += \
-DBOARD_TUD_RHPORT=$(PORT) \
# mcu driver cause following warnings
-CFLAGS += -Wno-error=unused-parameter -Wno-error=old-style-declaration
+CFLAGS += -Wno-error=unused-parameter -Wno-error=old-style-declaration -Wno-error=redundant-decls
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
@@ -56,12 +56,9 @@ INC += \
$(TOP)/$(SDK_DIR)/drivers/ \
$(TOP)/$(SDK_DIR)/drivers/lpuart \
$(TOP)/$(SDK_DIR)/drivers/lpflexcomm \
- $(TOP)/$(SDK_DIR)/drivers/common\
- $(TOP)/$(SDK_DIR)/drivers/gpio\
- $(TOP)/$(SDK_DIR)/drivers/port\
- $(TOP)/hw/bsp/mcx/drivers/spc
-
-
-
+ $(TOP)/$(SDK_DIR)/drivers/common\
+ $(TOP)/$(SDK_DIR)/drivers/gpio\
+ $(TOP)/$(SDK_DIR)/drivers/port\
+ $(TOP)/hw/bsp/mcx/drivers/spc
SRC_S += $(SDK_DIR)/devices/$(MCU_VARIANT)/gcc/startup_$(MCU_CORE).S
diff --git a/hw/bsp/mm32/family.cmake b/hw/bsp/mm32/family.cmake
index 0561a63a0..04961d6c3 100644
--- a/hw/bsp/mm32/family.cmake
+++ b/hw/bsp/mm32/family.cmake
@@ -14,28 +14,23 @@ set(FAMILY_MCUS MM32F327X CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${SDK_DIR}/Source/GCC_StartAsm/startup_${MCU_VARIANT}_gcc.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${SDK_DIR}/Source/IAR_StartAsm/startup_${MCU_VARIANT}_iar.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- # set(LD_FILE_IAR )
+set(STARTUP_FILE_GNU ${SDK_DIR}/Source/GCC_StartAsm/startup_${MCU_VARIANT}_gcc.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${SDK_DIR}/Source/IAR_StartAsm/startup_${MCU_VARIANT}_iar.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+# set(LD_FILE_IAR )
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/Source/system_${MCU_VARIANT}.c
${SDK_DIR}/HAL_Lib/Src/hal_gpio.c
${SDK_DIR}/HAL_Lib/Src/hal_rcc.c
${SDK_DIR}/HAL_Lib/Src/hal_uart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMSIS_5}/CMSIS/Core/Include
@@ -44,56 +39,49 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_MM32F327X)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_MM32F327X)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/msp430/family.c b/hw/bsp/msp430/family.c
index a45bd5f93..390a9915e 100644
--- a/hw/bsp/msp430/family.c
+++ b/hw/bsp/msp430/family.c
@@ -35,8 +35,8 @@
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
-void __attribute__ ((interrupt(USB_UBM_VECTOR))) USB_UBM_ISR(void)
-{
+void USB_UBM_ISR(void) __attribute__ ((interrupt(USB_UBM_VECTOR)));
+void USB_UBM_ISR(void) {
tud_int_handler(0);
}
@@ -200,8 +200,9 @@ int board_uart_write(void const * buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TIMER0_A0_ISR (void)
-{
+
+void TIMER0_A0_ISR (void) __attribute__ ((interrupt(TIMER0_A0_VECTOR)));
+void TIMER0_A0_ISR (void) {
system_ticks++;
// TAxCCR0 CCIFG resets itself as soon as interrupt is invoked.
}
diff --git a/hw/bsp/msp430/family.cmake b/hw/bsp/msp430/family.cmake
index d9b4bf770..8b0dbeff4 100644
--- a/hw/bsp/msp430/family.cmake
+++ b/hw/bsp/msp430/family.cmake
@@ -15,11 +15,7 @@ set(FAMILY_MCUS MSP430x5xx CACHE INTERNAL "")
# BOARD_TARGET
#------------------------------------
# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} INTERFACE)
target_compile_definitions(${BOARD_TARGET} INTERFACE
CFG_TUD_ENDPOINT0_SIZE=8
@@ -32,17 +28,6 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} INTERFACE
- "LINKER:--script=${LD_FILE_GNU}"
- -L${SDK_DIR}
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} INTERFACE
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
@@ -51,16 +36,14 @@ endfunction()
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
-
- # Board target
- add_board_target(board_${BOARD})
+ family_add_tinyusb(${TARGET} OPT_MCU_MSP430x5xx)
#---------- Port Specific ----------
# These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
)
target_include_directories(${TARGET} PUBLIC
# family, hw, board
@@ -69,13 +52,16 @@ function(family_configure_example TARGET RTOS)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_MSP430x5xx)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -L${SDK_DIR}
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
# Flashing
family_add_bin_hex(${TARGET})
family_flash_msp430flasher(${TARGET})
diff --git a/hw/bsp/msp432e4/family.cmake b/hw/bsp/msp432e4/family.cmake
index f6939ecfe..6725eedac 100644
--- a/hw/bsp/msp432e4/family.cmake
+++ b/hw/bsp/msp432e4/family.cmake
@@ -14,27 +14,23 @@ set(FAMILY_MCUS MSP432E4 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${SDK_DIR}/Source/${MCU_VARIANT}.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- if (NOT DEFINED STARTUP_FILE_GNU)
- set(STARTUP_FILE_GNU ${SDK_DIR}/Source/startup_${MCU_VARIANT}_gcc.S)
- endif ()
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${SDK_DIR}/Source/${MCU_VARIANT}.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED STARTUP_FILE_GNU)
+set(STARTUP_FILE_GNU ${SDK_DIR}/Source/startup_${MCU_VARIANT}_gcc.S)
+endif ()
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/Source/system_${MCU_VARIANT}.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/Include
@@ -42,57 +38,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_compile_options(${BOARD_TARGET} PUBLIC
- -mslow-flash-data
- )
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for MSP432E4")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_MSP432E4)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ ${TOP}/src/portable/mentor/musb/hcd_musb.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_MSP432E4)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/mentor/musb/dcd_musb.c
- ${TOP}/src/portable/mentor/musb/hcd_musb.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(${TARGET} PUBLIC
+ -mslow-flash-data
+ )
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported for MSP432E4")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/nrf/boards/adafruit_clue/board.mk b/hw/bsp/nrf/boards/adafruit_clue/board.mk
index b80807963..e6fcdd9b0 100644
--- a/hw/bsp/nrf/boards/adafruit_clue/board.mk
+++ b/hw/bsp/nrf/boards/adafruit_clue/board.mk
@@ -2,7 +2,7 @@ MCU_VARIANT = nrf52840
CFLAGS += -DNRF52840_XXAA
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+LD_FILE = ${FAMILY_PATH}/linker/nrf52840_s140_v6.ld
$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
diff --git a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk
index b80807963..e6fcdd9b0 100644
--- a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk
+++ b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk
@@ -2,7 +2,7 @@ MCU_VARIANT = nrf52840
CFLAGS += -DNRF52840_XXAA
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+LD_FILE = ${FAMILY_PATH}/linker/nrf52840_s140_v6.ld
$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
diff --git a/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk b/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk
index 488f07b82..d33b3558a 100644
--- a/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk
+++ b/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk
@@ -5,7 +5,7 @@ CFLAGS += -DNRF52840_XXAA
MAX3421_HOST = 1
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+LD_FILE = ${FAMILY_PATH}/linker/nrf52840_s140_v6.ld
$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
diff --git a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk
index b80807963..e6fcdd9b0 100644
--- a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk
+++ b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk
@@ -2,7 +2,7 @@ MCU_VARIANT = nrf52840
CFLAGS += -DNRF52840_XXAA
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+LD_FILE = ${FAMILY_PATH}/linker/nrf52840_s140_v6.ld
$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
diff --git a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk
index b80807963..e6fcdd9b0 100644
--- a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk
+++ b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk
@@ -2,7 +2,7 @@ MCU_VARIANT = nrf52840
CFLAGS += -DNRF52840_XXAA
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+LD_FILE = ${FAMILY_PATH}/linker/nrf52840_s140_v6.ld
$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@
diff --git a/hw/bsp/nrf/boards/pca10100/board.cmake b/hw/bsp/nrf/boards/nrf52833dk/board.cmake
index a925dae80..a925dae80 100644
--- a/hw/bsp/nrf/boards/pca10100/board.cmake
+++ b/hw/bsp/nrf/boards/nrf52833dk/board.cmake
diff --git a/hw/bsp/nrf/boards/pca10100/board.h b/hw/bsp/nrf/boards/nrf52833dk/board.h
index 8aca6dce9..8aca6dce9 100644
--- a/hw/bsp/nrf/boards/pca10100/board.h
+++ b/hw/bsp/nrf/boards/nrf52833dk/board.h
diff --git a/hw/bsp/nrf/boards/pca10100/board.mk b/hw/bsp/nrf/boards/nrf52833dk/board.mk
index 5fba269b7..7cf00cbc1 100644
--- a/hw/bsp/nrf/boards/pca10100/board.mk
+++ b/hw/bsp/nrf/boards/nrf52833dk/board.mk
@@ -1,7 +1,7 @@
MCU_VARIANT = nrf52833
CFLAGS += -DNRF52833_XXAA
-LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52833_xxaa.ld
+LD_FILE = ${FAMILY_PATH}/linker/nrf52833_xxaa.ld
# flash using jlink
flash: flash-jlink
diff --git a/hw/bsp/nrf/boards/pca10056/board.cmake b/hw/bsp/nrf/boards/nrf52840dk/board.cmake
index 85314f3bc..85314f3bc 100644
--- a/hw/bsp/nrf/boards/pca10056/board.cmake
+++ b/hw/bsp/nrf/boards/nrf52840dk/board.cmake
diff --git a/hw/bsp/nrf/boards/pca10056/board.h b/hw/bsp/nrf/boards/nrf52840dk/board.h
index ec632e769..ec632e769 100644
--- a/hw/bsp/nrf/boards/pca10056/board.h
+++ b/hw/bsp/nrf/boards/nrf52840dk/board.h
diff --git a/hw/bsp/nrf/boards/pca10056/board.mk b/hw/bsp/nrf/boards/nrf52840dk/board.mk
index be2ed3314..d8bbd41f8 100644
--- a/hw/bsp/nrf/boards/pca10056/board.mk
+++ b/hw/bsp/nrf/boards/nrf52840dk/board.mk
@@ -1,7 +1,5 @@
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/hw/bsp/nrf/boards/pca10056/ozone/nrf52840.jdebug b/hw/bsp/nrf/boards/nrf52840dk/ozone/nrf52840.jdebug
index fa7ab9e23..fa7ab9e23 100644
--- a/hw/bsp/nrf/boards/pca10056/ozone/nrf52840.jdebug
+++ b/hw/bsp/nrf/boards/nrf52840dk/ozone/nrf52840.jdebug
diff --git a/hw/bsp/nrf/boards/pca10059/board.cmake b/hw/bsp/nrf/boards/nrf52840dongle/board.cmake
index c79eb5964..5ec769192 100644
--- a/hw/bsp/nrf/boards/pca10059/board.cmake
+++ b/hw/bsp/nrf/boards/nrf52840dongle/board.cmake
@@ -1,5 +1,5 @@
set(MCU_VARIANT nrf52840)
-set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/pca10059.ld)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
function(update_board TARGET)
endfunction()
diff --git a/hw/bsp/nrf/boards/pca10059/board.h b/hw/bsp/nrf/boards/nrf52840dongle/board.h
index 3b95481ad..3b95481ad 100644
--- a/hw/bsp/nrf/boards/pca10059/board.h
+++ b/hw/bsp/nrf/boards/nrf52840dongle/board.h
diff --git a/hw/bsp/nrf/boards/pca10059/board.mk b/hw/bsp/nrf/boards/nrf52840dongle/board.mk
index 0b82ecdbb..0b82ecdbb 100644
--- a/hw/bsp/nrf/boards/pca10059/board.mk
+++ b/hw/bsp/nrf/boards/nrf52840dongle/board.mk
diff --git a/hw/bsp/nrf/boards/pca10059/pca10059.ld b/hw/bsp/nrf/boards/nrf52840dongle/nrf52840dongle.ld
index adc80f3c4..32cc6eada 100644
--- a/hw/bsp/nrf/boards/pca10059/pca10059.ld
+++ b/hw/bsp/nrf/boards/nrf52840dongle/nrf52840dongle.ld
@@ -11,9 +11,3 @@ MEMORY
INCLUDE "nrf_common.ld"
-
-/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
-__tbss_start__ = __tbss_start;
-__tbss_end__ = __tbss_end;
-__sbss_start__ = __sbss_start;
-__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/boards/nrf5340dk/board.cmake b/hw/bsp/nrf/boards/nrf5340dk/board.cmake
new file mode 100644
index 000000000..fe766dd78
--- /dev/null
+++ b/hw/bsp/nrf/boards/nrf5340dk/board.cmake
@@ -0,0 +1,4 @@
+set(MCU_VARIANT nrf5340)
+
+function(update_board TARGET)
+endfunction()
diff --git a/hw/bsp/nrf/boards/pca10095/board.h b/hw/bsp/nrf/boards/nrf5340dk/board.h
index 1c7981049..1c7981049 100644
--- a/hw/bsp/nrf/boards/pca10095/board.h
+++ b/hw/bsp/nrf/boards/nrf5340dk/board.h
diff --git a/hw/bsp/nrf/boards/pca10095/board.mk b/hw/bsp/nrf/boards/nrf5340dk/board.mk
index 20580d619..972168fcd 100644
--- a/hw/bsp/nrf/boards/pca10095/board.mk
+++ b/hw/bsp/nrf/boards/nrf5340dk/board.mk
@@ -1,14 +1,9 @@
-CPU_CORE = cortex-m33
-MCU_VARIANT = nrf5340_application
+MCU_VARIANT = nrf5340
CFLAGS += -DNRF5340_XXAA -DNRF5340_XXAA_APPLICATION
# enable max3421 host driver for this board
MAX3421_HOST = 1
-LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf5340_xxaa_application.ld
-
-SRC_C += hw/mcu/nordic/nrfx/drivers/src/nrfx_usbreg.c
-
# caused by void SystemStoreFICRNS() (without void) in system_nrf5340_application.c
CFLAGS += -Wno-error=strict-prototypes
diff --git a/hw/bsp/nrf/boards/pca10095/ozone/nrf5340.jdebug b/hw/bsp/nrf/boards/nrf5340dk/ozone/nrf5340.jdebug
index 4ad0376a4..4ad0376a4 100644
--- a/hw/bsp/nrf/boards/pca10095/ozone/nrf5340.jdebug
+++ b/hw/bsp/nrf/boards/nrf5340dk/ozone/nrf5340.jdebug
diff --git a/hw/bsp/nrf/boards/nrf54h20dk/board.cmake b/hw/bsp/nrf/boards/nrf54h20dk/board.cmake
new file mode 100644
index 000000000..fca7a56d2
--- /dev/null
+++ b/hw/bsp/nrf/boards/nrf54h20dk/board.cmake
@@ -0,0 +1,11 @@
+set(MCU_VARIANT nrf54h20)
+
+function(update_board TARGET)
+ # temporarily, 54h20 has multiple sram sections
+ target_compile_definitions(${TARGET} PUBLIC
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+ target_sources(${TARGET} PRIVATE
+# ${NRFX_PATH}/drivers/src/nrfx_usbreg.c
+ )
+endfunction()
diff --git a/hw/bsp/nrf/boards/nrf54h20dk/board.h b/hw/bsp/nrf/boards/nrf54h20dk/board.h
new file mode 100644
index 000000000..c8ed5779f
--- /dev/null
+++ b/hw/bsp/nrf/boards/nrf54h20dk/board.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+/* metadata:
+ name: Nordic nRF54H20 DK
+ url: https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF5340-DK
+*/
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define _PINNUM(port, pin) ((port)*32 + (pin))
+
+// LED
+#define LED_PIN 28
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PIN 23
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 22
+#define UART_TX_PIN 20
+
+// SPI for USB host shield
+// Pin is correct but not working probably due to signal incompatible (1.8V 3v3) with MAC3421E !?
+//#define MAX3421_SCK_PIN _PINNUM(1, 15)
+//#define MAX3421_MOSI_PIN _PINNUM(1, 13)
+//#define MAX3421_MISO_PIN _PINNUM(1, 14)
+//#define MAX3421_CS_PIN _PINNUM(1, 12)
+//#define MAX3421_INTR_PIN _PINNUM(1, 11)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/nrf/boards/nrf54h20dk/board.mk b/hw/bsp/nrf/boards/nrf54h20dk/board.mk
new file mode 100644
index 000000000..c49b605e8
--- /dev/null
+++ b/hw/bsp/nrf/boards/nrf54h20dk/board.mk
@@ -0,0 +1,12 @@
+MCU_VARIANT = nrf54h20
+CFLAGS += -DNRF54H20_XXAA
+
+# enable max3421 host driver for this board
+MAX3421_HOST = 1
+
+# caused by void SystemStoreFICRNS() (without void) in system_nrf5340_application.c
+CFLAGS += -Wno-error=strict-prototypes
+
+# flash using jlink
+JLINK_DEVICE = nrf5340_xxaa_app
+flash: flash-jlink
diff --git a/hw/bsp/nrf/boards/pca10095/board.cmake b/hw/bsp/nrf/boards/pca10095/board.cmake
deleted file mode 100644
index 6d183dde6..000000000
--- a/hw/bsp/nrf/boards/pca10095/board.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-set(MCU_VARIANT nrf5340_application)
-
-function(update_board TARGET)
- target_sources(${TARGET} PRIVATE
- ${NRFX_PATH}/drivers/src/nrfx_usbreg.c
- )
-endfunction()
diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c
index 298ca2302..25062b18f 100644
--- a/hw/bsp/nrf/family.c
+++ b/hw/bsp/nrf/family.c
@@ -45,7 +45,9 @@
#include "nrfx.h"
#include "hal/nrf_gpio.h"
#include "nrfx_gpiote.h"
+#if !defined(NRF54H20_XXAA)
#include "nrfx_power.h"
+#endif
#include "nrfx_uarte.h"
#include "nrfx_spim.h"
@@ -58,21 +60,12 @@
#pragma GCC diagnostic pop
#endif
-
-// There is API changes between nrfx v2 and v3
-#if 85301 >= (10000*MDK_MAJOR_VERSION + 100*MDK_MINOR_VERSION + MDK_MICRO_VERSION)
- // note MDK 8.53.1 is also used by nrfx v3.0.0, just skip this version and use later 3.x
- #define NRFX_VER 2
-#else
- #define NRFX_VER 3
+// example only supports nrfx v3 for code simplicity
+#if !(defined(NRFX_CONFIG_API_VER_MAJOR) && NRFX_CONFIG_API_VER_MAJOR >= 3) && \
+ !(85301 >= (10000*MDK_MAJOR_VERSION + 100*MDK_MINOR_VERSION + MDK_MICRO_VERSION))
+ #error "Example requires nrfx v3.0.0 or later"
#endif
-//--------------------------------------------------------------------+
-// Forward USB interrupt events to TinyUSB IRQ Handler
-//--------------------------------------------------------------------+
-void USBD_IRQHandler(void) {
- tud_int_handler(0);
-}
/*------------------------------------------------------------------*/
/* MACRO TYPEDEF CONSTANT ENUM
@@ -85,50 +78,67 @@ enum {
USB_EVT_READY = 2
};
+// Forward USB interrupt events to TinyUSB IRQ Handler
+#if defined(NRF54H20_XXAA)
+#define USBD_IRQn USBHS_IRQn
+void USBHS_IRQHandler(void) {
+ tusb_int_handler(0, true);
+}
+
+static nrfx_uarte_t _uart_id = NRFX_UARTE_INSTANCE(120);
+
+#else
+
#ifdef NRF5340_XXAA
- #define LFCLK_SRC_RC CLOCK_LFCLKSRC_SRC_LFRC
- #define VBUSDETECT_Msk USBREG_USBREGSTATUS_VBUSDETECT_Msk
- #define OUTPUTRDY_Msk USBREG_USBREGSTATUS_OUTPUTRDY_Msk
- #define GPIOTE_IRQn GPIOTE1_IRQn
+#define LFCLK_SRC_RC CLOCK_LFCLKSRC_SRC_LFRC
+#define VBUSDETECT_Msk USBREG_USBREGSTATUS_VBUSDETECT_Msk
+#define OUTPUTRDY_Msk USBREG_USBREGSTATUS_OUTPUTRDY_Msk
+#define GPIOTE_IRQn GPIOTE1_IRQn
#else
- #define LFCLK_SRC_RC CLOCK_LFCLKSRC_SRC_RC
- #define VBUSDETECT_Msk POWER_USBREGSTATUS_VBUSDETECT_Msk
- #define OUTPUTRDY_Msk POWER_USBREGSTATUS_OUTPUTRDY_Msk
+#define LFCLK_SRC_RC CLOCK_LFCLKSRC_SRC_RC
+#define VBUSDETECT_Msk POWER_USBREGSTATUS_VBUSDETECT_Msk
+#define OUTPUTRDY_Msk POWER_USBREGSTATUS_OUTPUTRDY_Msk
#endif
static nrfx_uarte_t _uart_id = NRFX_UARTE_INSTANCE(0);
+void USBD_IRQHandler(void) {
+ tud_int_handler(0);
+}
+#endif
+
+
// 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);
+#if !defined(NRF54H20_XXAA)
// 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);
}
+#endif
//------------- Host using MAX2341E -------------//
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
static void max3421_init(void);
static nrfx_spim_t _spi = NRFX_SPIM_INSTANCE(1);
-
-#if NRFX_VER > 2
static nrfx_gpiote_t _gpiote = NRFX_GPIOTE_INSTANCE(0);
#endif
-#endif
-
//--------------------------------------------------------------------+
//
//--------------------------------------------------------------------+
void board_init(void) {
+#if !defined(NRF54H20_XXAA)
// 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 = LFCLK_SRC_RC;
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
+#endif
// LED
nrf_gpio_cfg_output(LED_PIN);
@@ -140,6 +150,7 @@ void board_init(void) {
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
+
#elif CFG_TUSB_OS == OPT_OS_ZEPHYR
#ifdef CONFIG_HAS_HW_NRF_USBREG
// IRQ_CONNECT(USBREGULATOR_IRQn, DT_IRQ(DT_INST(0, nordic_nrf_clock), priority), nrfx_isr, nrfx_usbreg_irq_handler, 0);
@@ -153,21 +164,6 @@ void board_init(void) {
#endif
// UART
- #if NRFX_VER <= 2
- 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,
- }
- };
- #else
nrfx_uarte_config_t uart_cfg = {
.txd_pin = UART_TX_PIN,
.rxd_pin = UART_RX_PIN,
@@ -181,7 +177,6 @@ void board_init(void) {
.parity = NRF_UARTE_PARITY_EXCLUDED,
}
};
- #endif
nrfx_uarte_init(&_uart_id, &uart_cfg, NULL);
@@ -191,6 +186,7 @@ void board_init(void) {
// 2 is highest for application
NVIC_SetPriority(USBD_IRQn, 2);
+#if !defined(NRF54H20_XXAA)
// 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;
@@ -234,6 +230,7 @@ void board_init(void) {
tusb_hal_nrf_power_event(USB_EVT_READY);
}
#endif
+#endif
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
max3421_init();
@@ -255,7 +252,9 @@ uint32_t board_button_read(void) {
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
-#ifdef NRF5340_XXAA
+#if defined(NRF54H20_XXAA)
+ uintptr_t did_addr = (uintptr_t) NRF_FICR->BLE.ADDR;
+#elif defined(NRF5340_XXAA)
uintptr_t did_addr = (uintptr_t) NRF_FICR->INFO.DEVICEID;
#else
uintptr_t did_addr = (uintptr_t) NRF_FICR->DEVICEID;
@@ -277,11 +276,7 @@ int board_uart_read(uint8_t* buf, int len) {
}
int board_uart_write(void const* buf, int len) {
- nrfx_err_t err = nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len
- #if NRFX_VER > 2
- ,0
- #endif
- );
+ nrfx_err_t err = nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len ,0);
return (NRFX_SUCCESS == err) ? len : 0;
}
@@ -352,18 +347,16 @@ void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) {
// API: SPI transfer with MAX3421E, must be implemented by application
//--------------------------------------------------------------------+
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
-
-#if NRFX_VER <= 2
-void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action ) {
- if (action != NRF_GPIOTE_POLARITY_HITOLO) return;
-#else
void max3421_int_handler(nrfx_gpiote_pin_t pin, nrfx_gpiote_trigger_t action, void* p_context) {
(void) p_context;
- if (action != NRFX_GPIOTE_TRIGGER_HITOLO) return;
-#endif
+ if (action != NRFX_GPIOTE_TRIGGER_HITOLO) {
+ return;
+ }
+ if (pin != MAX3421_INTR_PIN) {
+ return;
+ }
- if (pin != MAX3421_INTR_PIN) return;
- tuh_int_handler(1, true);
+ tusb_int_handler(1, true);
}
static void max3421_init(void) {
@@ -378,13 +371,8 @@ static void max3421_init(void) {
.sck_pin = MAX3421_SCK_PIN,
.mosi_pin = MAX3421_MOSI_PIN,
.miso_pin = MAX3421_MISO_PIN,
- #if NRFX_VER <= 2
- .ss_pin = NRFX_SPIM_PIN_NOT_USED,
- .frequency = NRF_SPIM_FREQ_4M,
- #else
.ss_pin = NRF_SPIM_PIN_NOT_CONNECTED,
.frequency = 4000000u,
- #endif
.ss_active_high = false,
.irq_priority = 3,
.orc = 0xFF,
@@ -398,14 +386,6 @@ static void max3421_init(void) {
TU_ASSERT(NRFX_SUCCESS == nrfx_spim_init(&_spi, &cfg, NULL, NULL), );
// max3421e interrupt pin
- #if NRFX_VER <= 2
- nrfx_gpiote_init(1);
- nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
- in_config.pull = NRF_GPIO_PIN_PULLUP;
- NVIC_SetPriority(GPIOTE_IRQn, 2);
- nrfx_gpiote_in_init(MAX3421_INTR_PIN, &in_config, max3421_int_handler);
- nrfx_gpiote_trigger_enable(MAX3421_INTR_PIN, true);
- #else
nrf_gpio_pin_pull_t intr_pull = NRF_GPIO_PIN_PULLUP;
nrfx_gpiote_trigger_config_t intr_trigger = {
.trigger = NRFX_GPIOTE_TRIGGER_HITOLO,
@@ -426,7 +406,6 @@ static void max3421_init(void) {
nrfx_gpiote_input_configure(&_gpiote, MAX3421_INTR_PIN, &intr_config);
nrfx_gpiote_trigger_enable(&_gpiote, MAX3421_INTR_PIN, true);
- #endif
}
// API to enable/disable MAX3421 INTR pin interrupt
diff --git a/hw/bsp/nrf/family.cmake b/hw/bsp/nrf/family.cmake
index 7d0a9f6de..4e999b636 100644
--- a/hw/bsp/nrf/family.cmake
+++ b/hw/bsp/nrf/family.cmake
@@ -10,57 +10,76 @@ if (NOT board_cmake_included)
endif ()
# toolchain set up
-if (MCU_VARIANT STREQUAL "nrf5340_application")
+if (MCU_VARIANT STREQUAL nrf5340 OR MCU_VARIANT STREQUAL nrf54h20)
set(CMAKE_SYSTEM_CPU cortex-m33 CACHE INTERNAL "System Processor")
- set(JLINK_DEVICE nrf5340_xxaa_app)
+ set(JLINK_DEVICE ${MCU_VARIANT}_xxaa_app)
else ()
set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
set(JLINK_DEVICE ${MCU_VARIANT}_xxaa)
endif ()
-set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+if (MCU_VARIANT STREQUAL "nrf54h20")
+ set(FAMILY_MCUS NRF54 CACHE INTERNAL "")
+else ()
+ set(FAMILY_MCUS NRF5X CACHE INTERNAL "")
+endif ()
-set(FAMILY_MCUS NRF5X CACHE INTERNAL "")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- if (MCU_VARIANT STREQUAL "nrf5340_application")
- set(MCU_VARIANT_XXAA "nrf5340_xxaa_application")
- else ()
- set(MCU_VARIANT_XXAA "${MCU_VARIANT}_xxaa")
- endif ()
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_XXAA}.ld)
- endif ()
+if (MCU_VARIANT STREQUAL nrf54h20)
+ set(LD_FILE_GNU_DEFAULT ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_xxaa_application.ld)
+ set(STARTUP_FILE_GNU ${NRFX_PATH}/mdk/gcc_startup_${MCU_VARIANT}_application.S)
+elseif (MCU_VARIANT STREQUAL nrf5340)
+ set(LD_FILE_GNU_DEFAULT ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_xxaa_application.ld)
+ set(STARTUP_FILE_GNU ${NRFX_PATH}/mdk/gcc_startup_${MCU_VARIANT}_application.S)
+else()
+ set(LD_FILE_GNU_DEFAULT ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_xxaa.ld)
+ set(STARTUP_FILE_GNU ${NRFX_PATH}/mdk/gcc_startup_${MCU_VARIANT}.S)
+endif ()
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${NRFX_PATH}/mdk/gcc_startup_${MCU_VARIANT}.S)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- endif ()
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${LD_FILE_GNU_DEFAULT})
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${NRFX_PATH}/helpers/nrfx_flag32_allocator.c
${NRFX_PATH}/drivers/src/nrfx_gpiote.c
${NRFX_PATH}/drivers/src/nrfx_power.c
${NRFX_PATH}/drivers/src/nrfx_spim.c
${NRFX_PATH}/drivers/src/nrfx_uarte.c
- ${NRFX_PATH}/mdk/system_${MCU_VARIANT}.c
${NRFX_PATH}/soc/nrfx_atomic.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
- string(TOUPPER "${MCU_VARIANT_XXAA}" MCU_VARIANT_XXAA_UPPER)
+
+ if (MCU_VARIANT STREQUAL nrf54h20)
+ target_sources(${BOARD_TARGET} PRIVATE
+ ${NRFX_PATH}/mdk/system_nrf54h.c
+ )
+ elseif (MCU_VARIANT STREQUAL nrf5340)
+ target_sources(${BOARD_TARGET} PRIVATE
+ ${NRFX_PATH}/mdk/system_${MCU_VARIANT}_application.c
+ ${NRFX_PATH}/drivers/src/nrfx_usbreg.c
+ )
+ target_compile_definitions(${BOARD_TARGET} PUBLIC NRF5340_XXAA_APPLICATION)
+ else()
+ target_sources(${BOARD_TARGET} PRIVATE
+ ${NRFX_PATH}/mdk/system_${MCU_VARIANT}.c
+ )
+ endif ()
+
+ string(TOUPPER ${MCU_VARIANT} MCU_VARIANT_UPPER)
target_compile_definitions(${BOARD_TARGET} PUBLIC
__STARTUP_CLEAR_BSS
CONFIG_GPIO_AS_PINRESET
- ${MCU_VARIANT_XXAA_UPPER}
+ ${MCU_VARIANT_UPPER}_XXAA
+ NRF_APPLICATION
)
if (TRACE_ETM STREQUAL "1")
@@ -77,27 +96,8 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_PATH}/mdk
- --specs=nosys.specs --specs=nano.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_PATH}/mdk
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
@@ -109,41 +109,55 @@ endfunction()
# )
#endfunction()
-
function(family_configure_example TARGET RTOS)
- # Board target
- if (NOT RTOS STREQUAL zephyr)
- add_board_target(board_${BOARD})
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
- endif ()
-
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${FAMILY_MCUS})
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PRIVATE
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nordic/nrf5x/dcd_nrf5x.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- if (RTOS STREQUAL zephyr AND DEFINED BOARD_ALIAS AND NOT BOARD STREQUAL BOARD_ALIAS)
- target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD_ALIAS})
+
+ if (NOT RTOS STREQUAL zephyr)
+ target_sources(${TARGET} PRIVATE ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -L${NRFX_PATH}/mdk
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -L${NRFX_PATH}/mdk
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
endif ()
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_NRF5X)
- target_sources(${TARGET} PRIVATE
- ${TOP}/src/portable/nordic/nrf5x/dcd_nrf5x.c
- )
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
-# family_add_bin_hex(${TARGET})
+ # family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
-# family_flash_adafruit_nrfutil(${TARGET})
+ # family_flash_adafruit_nrfutil(${TARGET})
endfunction()
diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk
index a8acb1624..2cead99db 100644
--- a/hw/bsp/nrf/family.mk
+++ b/hw/bsp/nrf/family.mk
@@ -4,11 +4,37 @@ NRFX_PATH = hw/mcu/nordic/nrfx
include $(TOP)/$(BOARD_PATH)/board.mk
-# nRF52 is cortex-m4, nRF53 is cortex-m33
-CPU_CORE ?= cortex-m4
+ifeq (${MCU_VARIANT},nrf54h20)
+ CPU_CORE = cortex-m33
+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF54
+ LD_FILE_DEFAULT = ${FAMILY_PATH}/linker/${MCU_VARIANT}_xxaa_application.ld
+ SRC_C += ${NRFX_PATH}/mdk/system_nrf54h.c
+ SRC_S += ${NRFX_PATH}/mdk/gcc_startup_$(MCU_VARIANT)_application.S
+ JLINK_DEVICE ?= $(MCU_VARIANT)_xxaa_app
+
+else
+ifeq (${MCU_VARIANT},nrf5340)
+ CPU_CORE = cortex-m33
+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X
+ LD_FILE_DEFAULT = ${FAMILY_PATH}/linker/${MCU_VARIANT}_xxaa_application.ld
+ SRC_C += ${NRFX_PATH}/mdk/system_$(MCU_VARIANT)_application.c \
+ ${NRFX_PATH}/drivers/src/nrfx_usbreg.c
+ SRC_S += ${NRFX_PATH}/mdk/gcc_startup_$(MCU_VARIANT)_application.S
+ JLINK_DEVICE ?= $(MCU_VARIANT)_xxaa_app
+
+else
+
+ CPU_CORE = cortex-m4
+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X
+ LD_FILE_DEFAULT = ${FAMILY_PATH}/linker/${MCU_VARIANT}_xxaa.ld
+ SRC_C += ${NRFX_PATH}/mdk/system_$(MCU_VARIANT).c
+ SRC_S += ${NRFX_PATH}/mdk/gcc_startup_$(MCU_VARIANT).S
+ JLINK_DEVICE ?= $(MCU_VARIANT)_xxaa
+endif
+endif
CFLAGS += \
- -DCFG_TUSB_MCU=OPT_MCU_NRF5X \
+ -DNRF_APPLICATION \
-DCONFIG_GPIO_AS_PINRESET \
-D__STARTUP_CLEAR_BSS
@@ -33,14 +59,20 @@ LDFLAGS_GCC += \
LDFLAGS_CLANG += \
-L$(TOP)/${NRFX_PATH}/mdk \
+ifndef LD_FILE
+LD_FILE = ${LD_FILE_DEFAULT}
+endif
+
SRC_C += \
src/portable/nordic/nrf5x/dcd_nrf5x.c \
+ src/portable/synopsys/dwc2/dwc2_common.c \
+ src/portable/synopsys/dwc2/dcd_dwc2.c \
+ src/portable/synopsys/dwc2/hcd_dwc2.c \
${NRFX_PATH}/helpers/nrfx_flag32_allocator.c \
${NRFX_PATH}/drivers/src/nrfx_gpiote.c \
${NRFX_PATH}/drivers/src/nrfx_power.c \
${NRFX_PATH}/drivers/src/nrfx_spim.c \
${NRFX_PATH}/drivers/src/nrfx_uarte.c \
- ${NRFX_PATH}/mdk/system_$(MCU_VARIANT).c \
${NRFX_PATH}/soc/nrfx_atomic.c
INC += \
@@ -53,9 +85,4 @@ INC += \
$(TOP)/${NRFX_PATH}/drivers/include \
$(TOP)/${NRFX_PATH}/drivers/src \
-SRC_S += ${NRFX_PATH}/mdk/gcc_startup_$(MCU_VARIANT).S
-
ASFLAGS += -D__HEAP_SIZE=0
-
-# For flash-jlink target
-JLINK_DEVICE ?= $(MCU_VARIANT)_xxaa
diff --git a/hw/bsp/nrf/linker/nrf52833_xxaa.ld b/hw/bsp/nrf/linker/nrf52833_xxaa.ld
index ae4d0e5b3..f4c46a3f1 100644
--- a/hw/bsp/nrf/linker/nrf52833_xxaa.ld
+++ b/hw/bsp/nrf/linker/nrf52833_xxaa.ld
@@ -12,9 +12,3 @@ MEMORY
INCLUDE "nrf_common.ld"
-
-/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
-__tbss_start__ = __tbss_start;
-__tbss_end__ = __tbss_end;
-__sbss_start__ = __sbss_start;
-__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf52840_s140_v6.ld b/hw/bsp/nrf/linker/nrf52840_s140_v6.ld
index 037a14196..1a2292269 100644
--- a/hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+++ b/hw/bsp/nrf/linker/nrf52840_s140_v6.ld
@@ -36,9 +36,3 @@ SECTIONS
} INSERT AFTER .data;
INCLUDE "nrf_common.ld"
-
-/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
-__tbss_start__ = __tbss_start;
-__tbss_end__ = __tbss_end;
-__sbss_start__ = __sbss_start;
-__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf52840_xxaa.ld b/hw/bsp/nrf/linker/nrf52840_xxaa.ld
index 2d20ba7ac..fcfe08a60 100644
--- a/hw/bsp/nrf/linker/nrf52840_xxaa.ld
+++ b/hw/bsp/nrf/linker/nrf52840_xxaa.ld
@@ -12,9 +12,3 @@ MEMORY
}
INCLUDE "nrf_common.ld"
-
-/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
-__tbss_start__ = __tbss_start;
-__tbss_end__ = __tbss_end;
-__sbss_start__ = __sbss_start;
-__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld b/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld
index 31762d0b2..7fd682a40 100644
--- a/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld
+++ b/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld
@@ -13,9 +13,3 @@ MEMORY
INCLUDE "nrf_common.ld"
-
-/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
-__tbss_start__ = __tbss_start;
-__tbss_end__ = __tbss_end;
-__sbss_start__ = __sbss_start;
-__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf54h20_xxaa_application.ld b/hw/bsp/nrf/linker/nrf54h20_xxaa_application.ld
new file mode 100644
index 000000000..0c8d7127a
--- /dev/null
+++ b/hw/bsp/nrf/linker/nrf54h20_xxaa_application.ld
@@ -0,0 +1,21 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+/*GROUP(-lgcc -lc) not compatible with clang*/
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0xE0A0000, LENGTH = 0x40000 /* Inside global MRAM0 */
+ FLASH1 (rx) : ORIGIN = 0x2F840000, LENGTH = 0x4000 /* OTP0 */
+ EXTFLASH (rx) : ORIGIN = 0x70000000, LENGTH = 0x20000000
+ RAM (rwx) : ORIGIN = 0x22000000, LENGTH = 0x8000
+ RAM1 (rwx) : ORIGIN = 0x2F000000, LENGTH = 0x80000 /* RAM00 */
+ RAM2 (rwx) : ORIGIN = 0x2F080000, LENGTH = 0x60000 /* RAM01 */
+ RAM3 (rwx) : ORIGIN = 0x2F880000, LENGTH = 0x10000 /* RAM20 */
+ RAM4 (rwx) : ORIGIN = 0x2F890000, LENGTH = 0x8000 /* RAM21 */
+ RAM5 (rwx) : ORIGIN = 0x2FC00000, LENGTH = 0x4000 /* RAM30 (low-speed) */
+ RAM6 (rwx) : ORIGIN = 0x2FC04000, LENGTH = 0x4000 /* RAM31 (low-speed) */
+}
+
+
+INCLUDE "nrf_common.ld"
diff --git a/hw/bsp/nrf/nrfx_config/nrfx_config.h b/hw/bsp/nrf/nrfx_config/nrfx_config.h
index fbec4192b..88431e42c 100644
--- a/hw/bsp/nrf/nrfx_config/nrfx_config.h
+++ b/hw/bsp/nrf/nrfx_config/nrfx_config.h
@@ -1,46 +1,111 @@
+/*
+ * Copyright (c) 2019 - 2025, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * 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.
+ */
+
#ifndef NRFX_CONFIG_H__
#define NRFX_CONFIG_H__
-#define NRFX_POWER_ENABLED 1
-#define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7
-
-#define NRFX_CLOCK_ENABLED 0
-#define NRFX_GPIOTE_ENABLED 1
-#define NRFX_GPIOTE0_ENABLED 1
-
-#define NRFX_UARTE_ENABLED 1
-#define NRFX_UARTE0_ENABLED 1
-
-#define NRFX_SPIM_ENABLED 1
-#define NRFX_SPIM1_ENABLED 1 // use SPI1 since nrf5340 share uart with spi
-
-#define NRFX_PRS_ENABLED 0
-#define NRFX_USBREG_ENABLED 1
+#include "nrfx_config_common.h"
#if defined(NRF51)
-#include <templates/nrfx_config_nrf51.h>
+ #include <templates/nrfx_config_nrf51.h>
#elif defined(NRF52805_XXAA)
-#include <templates/nrfx_config_nrf52805.h>
+ #include <templates/nrfx_config_nrf52805.h>
#elif defined(NRF52810_XXAA)
-#include <templates/nrfx_config_nrf52810.h>
+ #include <templates/nrfx_config_nrf52810.h>
#elif defined(NRF52811_XXAA)
-#include <templates/nrfx_config_nrf52811.h>
+ #include <templates/nrfx_config_nrf52811.h>
#elif defined(NRF52820_XXAA)
-#include <templates/nrfx_config_nrf52820.h>
+ #include <templates/nrfx_config_nrf52820.h>
#elif defined(NRF52832_XXAA) || defined (NRF52832_XXAB)
-#include <templates/nrfx_config_nrf52832.h>
+ #include <templates/nrfx_config_nrf52832.h>
#elif defined(NRF52833_XXAA)
-#include <templates/nrfx_config_nrf52833.h>
+ #include <templates/nrfx_config_nrf52833.h>
#elif defined(NRF52840_XXAA)
-#include <templates/nrfx_config_nrf52840.h>
+ #include <templates/nrfx_config_nrf52840.h>
#elif defined(NRF5340_XXAA_APPLICATION)
-#include <templates/nrfx_config_nrf5340_application.h>
+ #include <templates/nrfx_config_nrf5340_application.h>
#elif defined(NRF5340_XXAA_NETWORK)
#include <templates/nrfx_config_nrf5340_network.h>
+#elif defined(NRF54H20_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54h20_application.h>
+#elif defined(NRF54H20_XXAA) && defined(NRF_RADIOCORE)
+ #include <templates/nrfx_config_nrf54h20_radiocore.h>
+#elif defined(NRF54H20_XXAA) && defined(NRF_PPR)
+ #include <templates/nrfx_config_nrf54h20_ppr.h>
+#elif defined(NRF54H20_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf54h20_flpr.h>
+#elif defined(NRF54L05_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54l05_application.h>
+#elif defined(NRF54L05_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf54l05_flpr.h>
+#elif defined(NRF54L10_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54l10_application.h>
+#elif defined(NRF54L10_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf54l10_flpr.h>
+#elif defined(NRF54L15_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54l15_application.h>
+#elif defined(NRF54L15_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf54l15_flpr.h>
+#elif defined(NRF54LM20A_ENGA_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54lm20a_enga_application.h>
+#elif defined(NRF54LM20A_ENGA_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf54lm20a_enga_flpr.h>
+#elif defined(NRF54LS05B_ENGA_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54ls05b_application.h>
+#elif defined(NRF54LV10A_ENGA_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf54lv10a_enga_application.h>
+#elif defined(NRF54LV10A_ENGA_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf54lv10a_enga_flpr.h>
+#elif defined(NRF7120_ENGA_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf7120_application.h>
+#elif defined(NRF7120_ENGA_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf7120_flpr.h>
+#elif defined(NRF7120_ENGA_XXAA) && defined(NRF_LMAC)
+ #include <templates/nrfx_config_nrf7120_lmac.h>
+#elif defined(NRF7120_ENGA_XXAA) && defined(NRF_UMAC)
+ #include <templates/nrfx_config_nrf7120_umac.h>
#elif defined(NRF9120_XXAA) || defined(NRF9160_XXAA)
#include <templates/nrfx_config_nrf91.h>
+#elif defined(NRF9230_ENGB_XXAA) && defined(NRF_APPLICATION)
+ #include <templates/nrfx_config_nrf9230_engb_application.h>
+#elif defined(NRF9230_ENGB_XXAA) && defined(NRF_RADIOCORE)
+ #include <templates/nrfx_config_nrf9230_engb_radiocore.h>
+#elif defined(NRF9230_ENGB_XXAA) && defined(NRF_PPR)
+ #include <templates/nrfx_config_nrf9230_engb_ppr.h>
+#elif defined(NRF9230_ENGB_XXAA) && defined(NRF_FLPR)
+ #include <templates/nrfx_config_nrf9230_engb_flpr.h>
#else
- #error "Unknown device."
+ #include "nrfx_config_ext.h"
#endif
#endif // NRFX_CONFIG_H__
diff --git a/hw/bsp/nrf/nrfx_config/nrfx_config_common.h b/hw/bsp/nrf/nrfx_config/nrfx_config_common.h
new file mode 100644
index 000000000..a5a29bb8e
--- /dev/null
+++ b/hw/bsp/nrf/nrfx_config/nrfx_config_common.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2022 - 2025, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * 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.
+ */
+
+#ifndef NRFX_CONFIG_COMMON_H__
+#define NRFX_CONFIG_COMMON_H__
+
+#ifndef NRFX_CONFIG_H__
+#error "This file should not be included directly. Include nrfx_config.h instead."
+#endif
+
+/** @brief Symbol specifying major version of the nrfx API to be used. */
+#ifndef NRFX_CONFIG_API_VER_MAJOR
+#define NRFX_CONFIG_API_VER_MAJOR 3
+#endif
+
+/** @brief Symbol specifying minor version of the nrfx API to be used. */
+#ifndef NRFX_CONFIG_API_VER_MINOR
+#define NRFX_CONFIG_API_VER_MINOR 12
+#endif
+
+/** @brief Symbol specifying micro version of the nrfx API to be used. */
+#ifndef NRFX_CONFIG_API_VER_MICRO
+#define NRFX_CONFIG_API_VER_MICRO 0
+#endif
+
+//--------------------------------------------------------------------+
+//
+//--------------------------------------------------------------------+
+#define NRFX_CLOCK_ENABLED 0
+#define NRFX_UARTE_ENABLED 1
+
+#if defined(NRF54H20_XXAA)
+#define NRFX_UARTE120_ENABLED 1
+
+#else
+
+#define NRFX_POWER_ENABLED 1
+#define NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY 7
+
+#define NRFX_UARTE0_ENABLED 1
+
+#define NRFX_GPIOTE_ENABLED 1
+#define NRFX_GPIOTE0_ENABLED 1
+
+#define NRFX_SPIM_ENABLED 1
+#define NRFX_SPIM1_ENABLED 1 // use SPI1 since nrf5340 share uart with spi
+#endif
+
+#define NRFX_PRS_ENABLED 0
+#define NRFX_USBREG_ENABLED 1
+
+#define NRF_STATIC_INLINE static inline
+
+#endif /* NRFX_CONFIG_COMMON_H__ */
diff --git a/hw/bsp/nrf/nrfx_config/nrfx_config_ext.h b/hw/bsp/nrf/nrfx_config/nrfx_config_ext.h
new file mode 100644
index 000000000..e503e1399
--- /dev/null
+++ b/hw/bsp/nrf/nrfx_config/nrfx_config_ext.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2023 - 2025, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * 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.
+ */
+
+#ifndef NRFX_CONFIG_EXT_H__
+#define NRFX_CONFIG_EXT_H__
+
+#error "Unknown device."
+
+#endif // NRFX_CONFIG_EXT_H__
diff --git a/hw/bsp/saml2x/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/nuc100_120/FreeRTOSConfig/FreeRTOSConfig.h
index 6c9ecae2d..dfac55a91 100644
--- a/hw/bsp/saml2x/FreeRTOSConfig/FreeRTOSConfig.h
+++ b/hw/bsp/nuc100_120/FreeRTOSConfig/FreeRTOSConfig.h
@@ -44,16 +44,12 @@
// skip if included from IAR assembler
#ifndef __IASMARM__
- #include "sam.h"
+#include "NUC100Series.h"
#endif
-/* Cortex M23/M33 port configuration. */
+/* Cortex-M0 port configuration. */
#define configENABLE_MPU 0
-#if defined(__ARM_FP) && __ARM_FP >= 4
- #define configENABLE_FPU 1
-#else
- #define configENABLE_FPU 0
-#endif
+#define configENABLE_FPU 0
#define configENABLE_TRUSTZONE 0
#define configMINIMAL_SECURE_STACK_SIZE (1024)
@@ -131,6 +127,7 @@
//--------------------------------------------------------------------+
// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+// NUC121/125 has 2 priority bits
#define configPRIO_BITS 2
/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
diff --git a/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.cmake b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.cmake
new file mode 100644
index 000000000..02198d4c3
--- /dev/null
+++ b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.cmake
@@ -0,0 +1,5 @@
+set(JLINK_DEVICE NUC120LE3)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nuc120_flash.ld)
+
+function(update_board TARGET)
+endfunction()
diff --git a/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.h b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.h
new file mode 100644
index 000000000..b6f1adf30
--- /dev/null
+++ b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.h
@@ -0,0 +1,43 @@
+/*
+ * 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_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT PB
+#define LED_PIN 0
+#define LED_PIN_IO PB0
+#define LED_STATE_ON 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.mk b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.mk
new file mode 100644
index 000000000..5f8fa6d0b
--- /dev/null
+++ b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/board.mk
@@ -0,0 +1,2 @@
+JLINK_DEVICE = NUC120LE3
+LD_FILE = $(BOARD_PATH)/nuc120_flash.ld
diff --git a/hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/nuc120_flash.ld
index cab12c8b9..cab12c8b9 100644
--- a/hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld
+++ b/hw/bsp/nuc100_120/boards/nutiny_sdk_nuc120/nuc120_flash.ld
diff --git a/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c b/hw/bsp/nuc100_120/family.c
index 18a189d8c..d04dc6657 100644
--- a/hw/bsp/nutiny_sdk_nuc120/nutiny_sdk_nuc120.c
+++ b/hw/bsp/nuc100_120/family.c
@@ -25,6 +25,8 @@
*/
#include "bsp/board_api.h"
+#include "board.h"
+
#include "NUC100Series.h"
#include "clk.h"
#include "sys.h"
@@ -37,14 +39,6 @@ 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();
diff --git a/hw/bsp/nuc100_120/family.cmake b/hw/bsp/nuc100_120/family.cmake
new file mode 100644
index 000000000..b8f36bb9b
--- /dev/null
+++ b/hw/bsp/nuc100_120/family.cmake
@@ -0,0 +1,89 @@
+include_guard()
+
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+set(SDK_DIR ${TOP}/hw/mcu/nuvoton/nuc100_120)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+set(CMAKE_SYSTEM_CPU cortex-m0 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(OPENOCD_OPTION "-f interface/nulink.cfg -f target/numicroM0.cfg")
+
+set(FAMILY_MCUS NUC100 NUC120 CACHE INTERNAL "")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/Device/Nuvoton/NUC100Series/Source/GCC/startup_NUC100Series.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/Device/Nuvoton/NUC100Series/Source/system_NUC100Series.c
+ ${SDK_DIR}/StdDriver/src/clk.c
+ ${SDK_DIR}/StdDriver/src/gpio.c
+ ${SDK_DIR}/StdDriver/src/sys.c
+ ${SDK_DIR}/StdDriver/src/timer.c
+ ${SDK_DIR}/StdDriver/src/uart.c
+ )
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/Device/Nuvoton/NUC100Series/Include
+ ${SDK_DIR}/StdDriver/inc
+ ${SDK_DIR}/CMSIS/Include
+ )
+
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ CFG_EXAMPLE_MSC_READONLY
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_NUC120)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nuvoton/nuc120/dcd_nuc120.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}")
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC "LINKER:--config=${LD_FILE_IAR}")
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES
+ COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ family_flash_openocd_nuvoton(${TARGET})
+endfunction()
diff --git a/hw/bsp/nutiny_sdk_nuc120/board.mk b/hw/bsp/nuc100_120/family.mk
index d982bdc06..f9afb4f72 100644
--- a/hw/bsp/nutiny_sdk_nuc120/board.mk
+++ b/hw/bsp/nuc100_120/family.mk
@@ -1,16 +1,16 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
CFLAGS += \
-flto \
- -mthumb \
- -mabi=aapcs-linux \
- -mcpu=cortex-m0 \
-DCFG_EXAMPLE_MSC_READONLY \
-DCFG_EXAMPLE_VIDEO_READONLY \
-DCFG_TUSB_MCU=OPT_MCU_NUC120
+CPU_CORE ?= cortex-m0
+
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
-# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/nutiny_sdk_nuc120/nuc120_flash.ld
+# LD_FILE is defined in board.mk
SRC_C += \
src/portable/nuvoton/nuc120/dcd_nuc120.c \
@@ -27,15 +27,13 @@ SRC_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
+ $(TOP)/hw/mcu/nuvoton/nuc100_120/CMSIS/Include \
+ $(TOP)/$(BOARD_PATH)
-# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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
+OPENOCD_NUVOTON_PATH ?= $(HOME)/app/OpenOCD-Nuvoton
flash: $(BUILD)/$(PROJECT).elf
- openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
+ $(OPENOCD_NUVOTON_PATH)/src/openocd -s $(OPENOCD_NUVOTON_PATH)/tcl -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/hw/bsp/nuc121_125/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/nuc121_125/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..e8f120553
--- /dev/null
+++ b/hw/bsp/nuc121_125/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,150 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "NuMicro.h"
+#endif
+
+/* Cortex-M0 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 0
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+// NUC121/125 has 2 priority bits
+#define configPRIO_BITS 2
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#endif
diff --git a/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.cmake b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.cmake
new file mode 100644
index 000000000..bffeffc37
--- /dev/null
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.cmake
@@ -0,0 +1,6 @@
+set(NUC_SERIES nuc121)
+set(JLINK_DEVICE NUC121SC2AE)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nuc121_flash.ld)
+
+function(update_board TARGET)
+endfunction()
diff --git a/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.h b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.h
new file mode 100644
index 000000000..73e73d5b3
--- /dev/null
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.h
@@ -0,0 +1,43 @@
+/*
+ * 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_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT PB
+#define LED_PIN 4
+#define LED_PIN_IO PB4
+#define LED_STATE_ON 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.mk b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.mk
new file mode 100644
index 000000000..8c8b4aa11
--- /dev/null
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/board.mk
@@ -0,0 +1,3 @@
+NUC_SERIES = nuc121
+JLINK_DEVICE = NUC121SC2AE
+LD_FILE = $(BOARD_PATH)/nuc121_flash.ld
diff --git a/hw/bsp/nutiny_nuc121s/nuc121_flash.ld b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/nuc121_flash.ld
index 0c599a561..0c599a561 100644
--- a/hw/bsp/nutiny_nuc121s/nuc121_flash.ld
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc121/nuc121_flash.ld
diff --git a/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.cmake b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.cmake
new file mode 100644
index 000000000..7909c0a46
--- /dev/null
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.cmake
@@ -0,0 +1,6 @@
+set(NUC_SERIES nuc125)
+set(JLINK_DEVICE NUC125SC2AE)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nuc125_flash.ld)
+
+function(update_board TARGET)
+endfunction()
diff --git a/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.h b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.h
new file mode 100644
index 000000000..73e73d5b3
--- /dev/null
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.h
@@ -0,0 +1,43 @@
+/*
+ * 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_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT PB
+#define LED_PIN 4
+#define LED_PIN_IO PB4
+#define LED_STATE_ON 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.mk b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.mk
new file mode 100644
index 000000000..7f61b94f3
--- /dev/null
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/board.mk
@@ -0,0 +1,3 @@
+NUC_SERIES = nuc125
+JLINK_DEVICE = NUC125SC2AE
+LD_FILE = $(BOARD_PATH)/nuc125_flash.ld
diff --git a/hw/bsp/nutiny_nuc125s/nuc125_flash.ld b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/nuc125_flash.ld
index 0c599a561..0c599a561 100644
--- a/hw/bsp/nutiny_nuc125s/nuc125_flash.ld
+++ b/hw/bsp/nuc121_125/boards/nutiny_sdk_nuc125/nuc125_flash.ld
diff --git a/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c b/hw/bsp/nuc121_125/family.c
index 7cb9b2e69..089855207 100644
--- a/hw/bsp/nutiny_nuc121s/nutiny_nuc121.c
+++ b/hw/bsp/nuc121_125/family.c
@@ -25,6 +25,8 @@
*/
#include "bsp/board_api.h"
+#include "board.h"
+
#include "NuMicro.h"
#include "clk.h"
#include "sys.h"
@@ -38,12 +40,8 @@ void USBD_IRQHandler(void)
}
//--------------------------------------------------------------------+
-// MACRO TYPEDEF CONSTANT ENUM
+// Board Initialization
//--------------------------------------------------------------------+
-#define LED_PORT PB
-#define LED_PIN 4
-#define LED_PIN_IO PB4
-#define LED_STATE_ON 0
void board_init(void)
{
diff --git a/hw/bsp/nuc121_125/family.cmake b/hw/bsp/nuc121_125/family.cmake
new file mode 100644
index 000000000..ee52e9ce4
--- /dev/null
+++ b/hw/bsp/nuc121_125/family.cmake
@@ -0,0 +1,94 @@
+include_guard()
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+set(SDK_DIR ${TOP}/hw/mcu/nuvoton/nuc121_125)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m0 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(OPENOCD_OPTION "-f interface/nulink.cfg -f target/numicroM0.cfg")
+
+set(FAMILY_MCUS NUC121 CACHE INTERNAL "")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/Device/Nuvoton/NUC121/Source/GCC/startup_NUC121.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ # Common sources for all NUC12x
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/Device/Nuvoton/NUC121/Source/system_NUC121.c
+ ${SDK_DIR}/StdDriver/src/clk.c
+ ${SDK_DIR}/StdDriver/src/gpio.c
+ ${SDK_DIR}/StdDriver/src/fmc.c
+ ${SDK_DIR}/StdDriver/src/sys.c
+ ${SDK_DIR}/StdDriver/src/timer.c
+ )
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/Device/Nuvoton/NUC121/Include
+ ${SDK_DIR}/StdDriver/inc
+ ${SDK_DIR}/CMSIS/Include
+ )
+
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __ARM_FEATURE_DSP=0
+ USE_ASSERT=0
+ CFG_EXAMPLE_MSC_READONLY
+ )
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_NUC121)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nuvoton/nuc121/dcd_nuc121.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}")
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC "LINKER:--config=${LD_FILE_IAR}")
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES
+ COMPILE_FLAGS "-Wno-missing-prototypes -Wno-redundant-decls")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ family_flash_openocd_nuvoton(${TARGET})
+endfunction()
diff --git a/hw/bsp/nutiny_nuc121s/board.mk b/hw/bsp/nuc121_125/family.mk
index 06c47d544..f46dac6e4 100644
--- a/hw/bsp/nutiny_nuc121s/board.mk
+++ b/hw/bsp/nuc121_125/family.mk
@@ -1,30 +1,34 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
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
+CPU_CORE ?= cortex-m0
+
# mcu driver cause following warnings
CFLAGS += -Wno-error=redundant-decls
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ --specs=nosys.specs --specs=nano.specs
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/nuc121_flash.ld
+# LD_FILE is defined in board.mk
+# Common sources for all NUC12x variants
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/fmc.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
+ hw/mcu/nuvoton/nuc121_125/StdDriver/src/timer.c
+
+# Additional sources are added in board.mk if needed (e.g., fmc, sys, timer, uart for NUC121)
SRC_S += \
hw/mcu/nuvoton/nuc121_125/Device/Nuvoton/NUC121/Source/GCC/startup_NUC121.S
@@ -32,15 +36,14 @@ SRC_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
+ $(TOP)/hw/mcu/nuvoton/nuc121_125/CMSIS/Include \
+ $(TOP)/$(BOARD_PATH)
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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
+OPENOCD_NUVOTON_PATH ?= $(HOME)/app/OpenOCD-Nuvoton
flash: $(BUILD)/$(PROJECT).elf
- openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
+ $(OPENOCD_NUVOTON_PATH)/src/openocd -s $(OPENOCD_NUVOTON_PATH)/tcl -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/hw/bsp/nuc126/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/nuc126/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..e8f120553
--- /dev/null
+++ b/hw/bsp/nuc126/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,150 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "NuMicro.h"
+#endif
+
+/* Cortex-M0 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 0
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+// NUC121/125 has 2 priority bits
+#define configPRIO_BITS 2
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#endif
diff --git a/hw/bsp/nuc126/boards/nutiny_nuc126v/board.cmake b/hw/bsp/nuc126/boards/nutiny_nuc126v/board.cmake
new file mode 100644
index 000000000..8d5c73e02
--- /dev/null
+++ b/hw/bsp/nuc126/boards/nutiny_nuc126v/board.cmake
@@ -0,0 +1,5 @@
+set(JLINK_DEVICE NUC126VG4AE)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nuc126_flash.ld)
+
+function(update_board TARGET)
+endfunction()
diff --git a/hw/bsp/nuc126/boards/nutiny_nuc126v/board.h b/hw/bsp/nuc126/boards/nutiny_nuc126v/board.h
new file mode 100644
index 000000000..82b2c1bd5
--- /dev/null
+++ b/hw/bsp/nuc126/boards/nutiny_nuc126v/board.h
@@ -0,0 +1,46 @@
+/*
+ * 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_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#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)
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/nuc126/boards/nutiny_nuc126v/board.mk b/hw/bsp/nuc126/boards/nutiny_nuc126v/board.mk
new file mode 100644
index 000000000..3050ea162
--- /dev/null
+++ b/hw/bsp/nuc126/boards/nutiny_nuc126v/board.mk
@@ -0,0 +1,2 @@
+JLINK_DEVICE = NUC126VG4AE
+LD_FILE = $(BOARD_PATH)/nuc126_flash.ld
diff --git a/hw/bsp/nutiny_nuc126v/nuc126_flash.ld b/hw/bsp/nuc126/boards/nutiny_nuc126v/nuc126_flash.ld
index b23890b4b..b23890b4b 100644
--- a/hw/bsp/nutiny_nuc126v/nuc126_flash.ld
+++ b/hw/bsp/nuc126/boards/nutiny_nuc126v/nuc126_flash.ld
diff --git a/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c b/hw/bsp/nuc126/family.c
index 9974127a8..f992fcab4 100644
--- a/hw/bsp/nutiny_nuc126v/nutiny_nuc126.c
+++ b/hw/bsp/nuc126/family.c
@@ -25,6 +25,8 @@
*/
#include "bsp/board_api.h"
+#include "board.h"
+
#include "NuMicro.h"
#include "clk.h"
#include "sys.h"
@@ -37,17 +39,6 @@ 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)
diff --git a/hw/bsp/nuc126/family.cmake b/hw/bsp/nuc126/family.cmake
new file mode 100644
index 000000000..d0f99ba1a
--- /dev/null
+++ b/hw/bsp/nuc126/family.cmake
@@ -0,0 +1,97 @@
+include_guard()
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+set(SDK_DIR ${TOP}/hw/mcu/nuvoton/nuc126)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m0 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(OPENOCD_OPTION "-f interface/nulink.cfg -f target/numicroM0.cfg")
+
+set(FAMILY_MCUS NUC126 CACHE INTERNAL "")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/Device/Nuvoton/NUC126/Source/GCC/startup_NUC126.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/Device/Nuvoton/NUC126/Source/system_NUC126.c
+ ${SDK_DIR}/StdDriver/src/clk.c
+ ${SDK_DIR}/StdDriver/src/crc.c
+ ${SDK_DIR}/StdDriver/src/gpio.c
+ ${SDK_DIR}/StdDriver/src/rtc.c
+ ${SDK_DIR}/StdDriver/src/sys.c
+ ${SDK_DIR}/StdDriver/src/timer.c
+ ${SDK_DIR}/StdDriver/src/uart.c
+ )
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/Device/Nuvoton/NUC126/Include
+ ${SDK_DIR}/StdDriver/inc
+ ${SDK_DIR}/CMSIS/Include
+ )
+
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __ARM_FEATURE_DSP=0
+ USE_ASSERT=0
+ CFG_EXAMPLE_VIDEO_READONLY
+ __CORTEX_SC=0
+ )
+
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_NUC126)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nuvoton/nuc121/dcd_nuc121.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}")
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC "LINKER:--config=${LD_FILE_IAR}")
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES
+ COMPILE_FLAGS "-Wno-missing-prototypes -Wno-redundant-decls")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ family_flash_openocd_nuvoton(${TARGET})
+endfunction()
diff --git a/hw/bsp/nutiny_nuc126v/board.mk b/hw/bsp/nuc126/family.mk
index e87d1aad0..37df7aaab 100644
--- a/hw/bsp/nutiny_nuc126v/board.mk
+++ b/hw/bsp/nuc126/family.mk
@@ -1,21 +1,22 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
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
+CPU_CORE ?= cortex-m0
+
# mcu driver cause following warnings
CFLAGS += -Wno-error=redundant-decls
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/nuc126_flash.ld
+# LD_FILE is defined in board.mk
SRC_C += \
src/portable/nuvoton/nuc121/dcd_nuc121.c \
@@ -34,15 +35,14 @@ SRC_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
+ $(TOP)/hw/mcu/nuvoton/nuc126/CMSIS/Include \
+ $(TOP)/$(BOARD_PATH)
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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
+OPENOCD_NUVOTON_PATH ?= $(HOME)/app/OpenOCD-Nuvoton
flash: $(BUILD)/$(PROJECT).elf
- openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
+ $(OPENOCD_NUVOTON_PATH)/src/openocd -s $(OPENOCD_NUVOTON_PATH)/tcl -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit"
diff --git a/hw/bsp/nuc505/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/nuc505/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..a44beb767
--- /dev/null
+++ b/hw/bsp/nuc505/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,150 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+#include "NUC505Series.h"
+#endif
+
+/* Cortex-M4F port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*8*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+// NUC505 has 3 priority bits
+#define configPRIO_BITS 3
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#endif
diff --git a/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.cmake b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.cmake
new file mode 100644
index 000000000..2ece10e33
--- /dev/null
+++ b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.cmake
@@ -0,0 +1,5 @@
+set(JLINK_DEVICE NUC505YO13Y)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nuc505_flashtoram.ld)
+
+function(update_board TARGET)
+endfunction()
diff --git a/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.h b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.h
new file mode 100644
index 000000000..ec3c15f46
--- /dev/null
+++ b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.h
@@ -0,0 +1,42 @@
+/*
+ * 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_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT PC
+#define LED_PIN 3
+#define LED_STATE_ON 0
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
diff --git a/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.mk b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.mk
new file mode 100644
index 000000000..f189de163
--- /dev/null
+++ b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/board.mk
@@ -0,0 +1,2 @@
+JLINK_DEVICE = NUC505YO13Y
+LD_FILE = $(BOARD_PATH)/nuc505_flashtoram.ld
diff --git a/hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/nuc505_flashtoram.ld
index 53d385cd0..53d385cd0 100644
--- a/hw/bsp/nutiny_sdk_nuc505/nuc505_flashtoram.ld
+++ b/hw/bsp/nuc505/boards/nutiny_sdk_nuc505/nuc505_flashtoram.ld
diff --git a/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c b/hw/bsp/nuc505/family.c
index 3ec0066a3..00ed92310 100644
--- a/hw/bsp/nutiny_sdk_nuc505/nutiny_sdk_nuc505.c
+++ b/hw/bsp/nuc505/family.c
@@ -25,6 +25,7 @@
*/
#include "bsp/board_api.h"
+#include "board.h"
#include "NUC505Series.h"
//--------------------------------------------------------------------+
@@ -38,9 +39,6 @@ void USBD_IRQHandler(void)
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
-#define LED_PORT PC
-#define LED_PIN 3
-#define LED_STATE_ON 0
void board_init(void)
{
diff --git a/hw/bsp/nuc505/family.cmake b/hw/bsp/nuc505/family.cmake
new file mode 100644
index 000000000..581cad4d0
--- /dev/null
+++ b/hw/bsp/nuc505/family.cmake
@@ -0,0 +1,93 @@
+include_guard()
+
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+set(SDK_DIR ${TOP}/hw/mcu/nuvoton/nuc505)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(OPENOCD_OPTION "-f interface/nulink.cfg -f target/numicroM4.cfg")
+
+set(FAMILY_MCUS NUC505 CACHE INTERNAL "")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/Device/Nuvoton/NUC505Series/Source/GCC/startup_NUC505Series.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/Device/Nuvoton/NUC505Series/Source/system_NUC505Series.c
+ ${SDK_DIR}/StdDriver/src/adc.c
+ ${SDK_DIR}/StdDriver/src/clk.c
+ ${SDK_DIR}/StdDriver/src/gpio.c
+ ${SDK_DIR}/StdDriver/src/i2c.c
+ ${SDK_DIR}/StdDriver/src/i2s.c
+ ${SDK_DIR}/StdDriver/src/pwm.c
+ ${SDK_DIR}/StdDriver/src/rtc.c
+ ${SDK_DIR}/StdDriver/src/spi.c
+ ${SDK_DIR}/StdDriver/src/spim.c
+ ${SDK_DIR}/StdDriver/src/sys.c
+ ${SDK_DIR}/StdDriver/src/timer.c
+ ${SDK_DIR}/StdDriver/src/uart.c
+ ${SDK_DIR}/StdDriver/src/wdt.c
+ ${SDK_DIR}/StdDriver/src/wwdt.c
+ )
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/Device/Nuvoton/NUC505Series/Include
+ ${SDK_DIR}/StdDriver/inc
+ ${SDK_DIR}/CMSIS/Include
+ )
+
+ update_board(${BOARD_TARGET})
+endfunction()
+
+
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_NUC505)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/nuvoton/nuc505/dcd_nuc505.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}")
+ target_compile_options(${TARGET} PRIVATE -Wno-redundant-decls)
+
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC "LINKER:--config=${LD_FILE_IAR}")
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES
+ COMPILE_FLAGS "-Wno-missing-prototypes -Wno-redundant-decls")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ family_flash_openocd_nuvoton(${TARGET})
+endfunction()
diff --git a/hw/bsp/nutiny_sdk_nuc505/board.mk b/hw/bsp/nuc505/family.mk
index 1dc8b244e..e1f25e2db 100644
--- a/hw/bsp/nutiny_sdk_nuc505/board.mk
+++ b/hw/bsp/nuc505/family.mk
@@ -1,19 +1,17 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
CFLAGS += \
-flto \
- -mthumb \
- -mabi=aapcs-linux \
- -mcpu=cortex-m4 \
- -mfloat-abi=hard \
- -mfpu=fpv4-sp-d16 \
-DCFG_TUSB_MCU=OPT_MCU_NUC505
+CPU_CORE ?= cortex-m4
+
# mcu driver cause following warnings
CFLAGS += -Wno-error=redundant-decls
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
-# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/nuc505_flashtoram.ld
+# LD_FILE is defined in board.mk
SRC_C += \
src/portable/nuvoton/nuc505/dcd_nuc505.c \
@@ -39,25 +37,19 @@ SRC_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
+ $(TOP)/hw/mcu/nuvoton/nuc505/CMSIS/Include \
+ $(TOP)/$(BOARD_PATH)
-# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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
+OPENOCD_NUVOTON_PATH ?= $(HOME)/app/OpenOCD-Nuvoton
flash: $(BUILD)/$(PROJECT).elf
- openocd -f interface/nulink.cfg -f target/numicroM4.cfg -c "program $< reset exit"
+ $(OPENOCD_NUVOTON_PATH)/src/openocd -s $(OPENOCD_NUVOTON_PATH)/tcl -f interface/nulink.cfg -f target/numicroM4.cfg -c "program $< reset exit"
diff --git a/hw/bsp/nutiny_nuc125s/board.mk b/hw/bsp/nutiny_nuc125s/board.mk
deleted file mode 100644
index 50b9d866a..000000000
--- a/hw/bsp/nutiny_nuc125s/board.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-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
-
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=redundant-decls
-
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
-
-# 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_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c b/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c
deleted file mode 100644
index 7cb9b2e69..000000000
--- a/hw/bsp/nutiny_nuc125s/nutiny_nuc125.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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_api.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/hw/bsp/ra/family.cmake b/hw/bsp/ra/family.cmake
index 42a32631c..c5b1d1a1a 100644
--- a/hw/bsp/ra/family.cmake
+++ b/hw/bsp/ra/family.cmake
@@ -38,124 +38,100 @@ endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- ${FSP_RA}/src/bsp/cmsis/Device/RENESAS/Source/startup.c
- ${FSP_RA}/src/bsp/cmsis/Device/RENESAS/Source/system.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_clocks.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_common.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_delay.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_group_irq.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_guard.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_io.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_irq.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_register_protection.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_sbrk.c
- ${FSP_RA}/src/bsp/mcu/all/bsp_security.c
- ${FSP_RA}/src/r_ioport/r_ioport.c
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_gen/common_data.c
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_gen/pin_data.c
- )
-
- target_compile_options(${BOARD_TARGET} PUBLIC
- -ffreestanding
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_cfg/fsp_cfg
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_cfg/fsp_cfg/bsp
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_gen
- ${CMSIS_DIR}/CMSIS/Core/Include
- ${FSP_RA}/inc
- ${FSP_RA}/inc/api
- ${FSP_RA}/inc/instances
- ${FSP_RA}/src/bsp/cmsis/Device/RENESAS/Include
- ${FSP_RA}/src/bsp/mcu/all
- ${FSP_RA}/src/bsp/mcu/${MCU_VARIANT}
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- BOARD_TUD_RHPORT=${RHPORT_DEVICE}
- BOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED}
- BOARD_TUH_RHPORT=${RHPORT_HOST}
- BOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED}
- )
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/script/fsp.ld)
+endif ()
- update_board(${BOARD_TARGET})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${FSP_RA}/src/bsp/cmsis/Device/RENESAS/Source/startup.c
+ ${FSP_RA}/src/bsp/cmsis/Device/RENESAS/Source/system.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_clocks.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_common.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_delay.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_group_irq.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_guard.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_io.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_irq.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_register_protection.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_sbrk.c
+ ${FSP_RA}/src/bsp/mcu/all/bsp_security.c
+ ${FSP_RA}/src/r_ioport/r_ioport.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_gen/common_data.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_gen/pin_data.c
+ )
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/script/fsp.ld)
- endif ()
+ target_compile_options(${BOARD_TARGET} PUBLIC
+ -ffreestanding
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_cfg/fsp_cfg
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_cfg/fsp_cfg/bsp
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/ra_gen
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ ${FSP_RA}/inc
+ ${FSP_RA}/inc/api
+ ${FSP_RA}/inc/instances
+ ${FSP_RA}/src/bsp/cmsis/Device/RENESAS/Include
+ ${FSP_RA}/src/bsp/mcu/all
+ ${FSP_RA}/src/bsp/mcu/${MCU_VARIANT}
+ )
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ BOARD_TUD_RHPORT=${RHPORT_DEVICE}
+ BOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED}
+ BOARD_TUH_RHPORT=${RHPORT_HOST}
+ BOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED}
+ )
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- # linker file
- "LINKER:--script=${LD_FILE_GNU}"
- -L${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/script
- -Wl,--defsym=end=__bss_end__
- -nostartfiles
- --specs=nano.specs --specs=nosys.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
- endif ()
+ update_board(${BOARD_TARGET})
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_RAXXX)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
- # Explicitly added bsp_rom_registers here, otherwise MCU can be bricked if g_bsp_rom_registers is dropped by linker
${FSP_RA}/src/bsp/mcu/all/bsp_rom_registers.c
+ ${TOP}/src/portable/renesas/rusb2/dcd_rusb2.c
+ ${TOP}/src/portable/renesas/rusb2/hcd_rusb2.c
+ ${TOP}/src/portable/renesas/rusb2/rusb2_common.c
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
)
- target_compile_options(${TARGET} PUBLIC
- -Wno-error=undef
- -Wno-error=strict-prototypes
- )
-
-# # RA has custom freertos port
-# if (NOT TARGET freertos_kernel_port)
-# add_library(freertos_kernel_port STATIC)
-# target_sources(freertos_kernel_port PUBLIC ${FSP_RA}/src/rm_freertos_port/port.c)
-# target_include_directories(freertos_kernel_port PUBLIC ${FSP_RA}/src/rm_freertos_port)
-#
-# target_link_libraries(freertos_kernel_port PUBLIC freertos_kernel)
-# endif ()
-
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_RAXXX)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/renesas/rusb2/dcd_rusb2.c
- ${TOP}/src/portable/renesas/rusb2/hcd_rusb2.c
- ${TOP}/src/portable/renesas/rusb2/rusb2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ # linker file
+ "LINKER:--script=${LD_FILE_GNU}"
+ -L${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/script
+ -Wl,--defsym=end=__bss_end__
+ -nostartfiles
+ --specs=nano.specs --specs=nosys.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${FSP_RA}/src/bsp/mcu/all/bsp_rom_registers.c PROPERTIES COMPILE_FLAGS "-Wno-undef")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
# Flashing
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c
index 989140e02..a51b3f758 100644
--- a/hw/bsp/rp2040/family.c
+++ b/hw/bsp/rp2040/family.c
@@ -92,7 +92,7 @@ static uart_inst_t *uart_inst;
//
// 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)(void) {
+static bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
const uint CS_PIN_INDEX = 1;
// Must disable interrupts, as interrupt handlers may be in flash, and we
@@ -105,7 +105,9 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
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) {}
+ for (volatile int i = 0; i < 1000; ++i) {
+ __nop();
+ }
// The HI GPIO registers in SIO can observe and control the 6 QSPI pins.
// Note the button pulls the pin *low* when pressed.
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
index 2182e9ad1..5d6d8b40e 100644
--- a/hw/bsp/rp2040/family.cmake
+++ b/hw/bsp/rp2040/family.cmake
@@ -95,6 +95,7 @@ target_sources(tinyusb_device_base INTERFACE
${TOP}/src/class/hid/hid_device.c
${TOP}/src/class/midi/midi_device.c
${TOP}/src/class/msc/msc_device.c
+ ${TOP}/src/class/mtp/mtp_device.c
${TOP}/src/class/net/ecm_rndis_device.c
${TOP}/src/class/net/ncm_device.c
${TOP}/src/class/usbtmc/usbtmc_device.c
@@ -183,6 +184,43 @@ endif()
#------------------------------------
# Functions
#------------------------------------
+function(family_add_default_example_warnings TARGET)
+ # Apply warnings to all TinyUSB interface library sources as well as examples sources
+ # we cannot set compile options for target since it will not propagate to INTERFACE sources then picosdk files
+ foreach(TINYUSB_TARGET IN ITEMS tinyusb_common_base tinyusb_device_base tinyusb_host_base tinyusb_host_max3421 tinyusb_bsp)
+ get_target_property(TINYUSB_SOURCES ${TINYUSB_TARGET} INTERFACE_SOURCES)
+ set_source_files_properties(${TINYUSB_SOURCES} PROPERTIES COMPILE_OPTIONS "${WARN_FLAGS_${CMAKE_C_COMPILER_ID}}")
+ endforeach()
+
+ # Also apply to example sources, but filter out any source files from lib/ (e.g. fatfs)
+ get_target_property(EXAMPLE_SOURCES ${TARGET} SOURCES)
+ set(FILTERED_SOURCES "")
+ foreach(SOURCE_FILE IN LISTS EXAMPLE_SOURCES)
+ string(FIND "${SOURCE_FILE}" "${TOP}/lib" FOUND_POS)
+ if(FOUND_POS EQUAL -1)
+ list(APPEND FILTERED_SOURCES ${SOURCE_FILE})
+ endif()
+ endforeach()
+ set_source_files_properties(${FILTERED_SOURCES} PROPERTIES COMPILE_OPTIONS "${WARN_FLAGS_${CMAKE_C_COMPILER_ID}}")
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND NO_WARN_RWX_SEGMENTS_SUPPORTED)
+ target_link_options(${TARGET} PRIVATE "LINKER:--no-warn-rwx-segments")
+ endif()
+
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
+ target_compile_options(${TARGET} PRIVATE -Wconversion)
+ endif()
+
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
+ target_compile_options(${TARGET} PRIVATE -Wcast-function-type -Wstrict-overflow)
+ endif()
+
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
+ target_compile_options(${TARGET} PRIVATE -Wno-strict-aliasing)
+ endif()
+ endif()
+endfunction()
function(family_configure_target TARGET RTOS)
if (RTOS STREQUAL noos OR RTOS STREQUAL "")
@@ -203,7 +241,7 @@ function(family_configure_target TARGET RTOS)
pico_enable_stdio_uart(${TARGET} 1)
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_board${RTOS_SUFFIX} tinyusb_additions)
- family_flash_openocd(${TARGET})
+ family_flash_openocd(${TARGET})
family_flash_jlink(${TARGET})
endfunction()
@@ -358,34 +396,9 @@ function(suppress_tinyusb_warnings)
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
)
foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
- set_source_files_properties(
- ${SOURCE_FILE}
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
+ set_source_files_properties(${SOURCE_FILE} PROPERTIES COMPILE_FLAGS "-Wno-conversion")
endforeach()
endif()
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
- COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds")
- endif()
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual")
-
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_in.c
- ${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_out.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion")
-
- set_source_files_properties(
- ${PICO_TINYUSB_PATH}/lib/networking/dnserver.c
- ${PICO_TINYUSB_PATH}/lib/networking/dhserver.c
- ${PICO_TINYUSB_PATH}/lib/networking/rndis_reports.c
- PROPERTIES
- COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
if (TARGET tinyusb_pico_pio_usb)
set_source_files_properties(
diff --git a/hw/bsp/samd11/family.c b/hw/bsp/samd11/family.c
index 79ca9de02..62e060c8e 100644
--- a/hw/bsp/samd11/family.c
+++ b/hw/bsp/samd11/family.c
@@ -155,12 +155,11 @@ uint32_t board_millis(void)
return system_ticks;
}
-void _init(void)
-{
+void _init(void);
+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/hw/bsp/samd11/family.cmake b/hw/bsp/samd11/family.cmake
index 965b1cfb5..982cef792 100644
--- a/hw/bsp/samd11/family.cmake
+++ b/hw/bsp/samd11/family.cmake
@@ -14,29 +14,22 @@ set(FAMILY_MCUS SAMD11 CACHE INTERNAL "")
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -f target/at91samdXX.cfg")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/gcc/system_${SAM_FAMILY}.c
${SDK_DIR}/hal/src/hal_atomic.c
${SDK_DIR}/hpl/gclk/hpl_gclk.c
${SDK_DIR}/hpl/pm/hpl_pm.c
${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}
@@ -54,59 +47,49 @@ function(add_board_target BOARD_TARGET)
OSC32K_OVERWRITE_CALIBRATION=0
CFG_EXAMPLE_MSC_READONLY
CFG_EXAMPLE_VIDEO_READONLY
+ CFG_EXAMPLE_MTP_READONLY
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_SAMD11)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/microchip/samd/dcd_samd.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_SAMD11)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/microchip/samd/dcd_samd.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/samd11/family.mk b/hw/bsp/samd11/family.mk
index c41a0dd37..6f89a2d66 100644
--- a/hw/bsp/samd11/family.mk
+++ b/hw/bsp/samd11/family.mk
@@ -8,6 +8,7 @@ CFLAGS += \
-DOSC32K_OVERWRITE_CALIBRATION=0 \
-DCFG_EXAMPLE_MSC_READONLY \
-DCFG_EXAMPLE_VIDEO_READONLY \
+ -DCFG_EXAMPLE_MTP_READONLY \
-DCFG_TUSB_MCU=OPT_MCU_SAMD11
# suppress warning caused by vendor mcu driver
diff --git a/hw/bsp/samd21/boards/seeeduino_xiao/board.cmake b/hw/bsp/samd21/boards/seeeduino_xiao/board.cmake
deleted file mode 100644
index c1a612936..000000000
--- a/hw/bsp/samd21/boards/seeeduino_xiao/board.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-set(JLINK_DEVICE ATSAMD21G18)
-set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
-
-function(update_board TARGET)
- target_compile_definitions(${TARGET} PUBLIC
- __SAMD21G18A__
- CFG_EXAMPLE_VIDEO_READONLY
- )
-endfunction()
diff --git a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.cmake b/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.cmake
deleted file mode 100644
index c1a612936..000000000
--- a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-set(JLINK_DEVICE ATSAMD21G18)
-set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
-
-function(update_board TARGET)
- target_compile_definitions(${TARGET} PUBLIC
- __SAMD21G18A__
- CFG_EXAMPLE_VIDEO_READONLY
- )
-endfunction()
diff --git a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.mk b/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.mk
deleted file mode 100644
index d6c9150b3..000000000
--- a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-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/hw/bsp/samd21/family.cmake b/hw/bsp/samd21/family.cmake
deleted file mode 100644
index 3c600318e..000000000
--- a/hw/bsp/samd21/family.cmake
+++ /dev/null
@@ -1,110 +0,0 @@
-include_guard()
-
-set(SDK_DIR ${TOP}/hw/mcu/microchip/samd21)
-
-# include board specific
-include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
-
-# toolchain set up
-set(CMAKE_SYSTEM_CPU cortex-m0plus CACHE INTERNAL "System Processor")
-set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
-
-set(FAMILY_MCUS SAMD21 CACHE INTERNAL "")
-set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -f target/at91samdXX.cfg")
-
-#------------------------------------
-# BOARD_TARGET
-#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_samd21.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
-
- add_library(${BOARD_TARGET} STATIC
- ${SDK_DIR}/gcc/system_samd21.c
- ${SDK_DIR}/hpl/gclk/hpl_gclk.c
- ${SDK_DIR}/hpl/pm/hpl_pm.c
- ${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c
- ${SDK_DIR}/hal/src/hal_atomic.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}
- ${SDK_DIR}/config
- ${SDK_DIR}/include
- ${SDK_DIR}/hal/include
- ${SDK_DIR}/hal/utils/include
- ${SDK_DIR}/hpl/pm
- ${SDK_DIR}/hpl/port
- ${SDK_DIR}/hri
- ${SDK_DIR}/CMSIS/Include
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- CONF_DFLL_OVERWRITE_CALIBRATION=0
- )
-
- update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
-endfunction()
-
-
-#------------------------------------
-# Functions
-#------------------------------------
-function(family_configure_example TARGET RTOS)
- family_configure_common(${TARGET} ${RTOS})
-
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
- target_sources(${TARGET} PUBLIC
- # BSP
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
- )
- target_include_directories(${TARGET} PUBLIC
- # family, hw, board
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
- )
-
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_SAMD21)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/microchip/samd/dcd_samd.c
- ${TOP}/src/portable/microchip/samd/hcd_samd.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
- # Flashing
- family_add_bin_hex(${TARGET})
- family_flash_jlink(${TARGET})
- #family_flash_openocd(${TARGET})
-endfunction()
diff --git a/hw/bsp/samd21/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/samd2x_l2x/FreeRTOSConfig/FreeRTOSConfig.h
index 6c9ecae2d..6c9ecae2d 100644
--- a/hw/bsp/samd21/FreeRTOSConfig/FreeRTOSConfig.h
+++ b/hw/bsp/samd2x_l2x/FreeRTOSConfig/FreeRTOSConfig.h
diff --git a/hw/bsp/samd21/boards/atsamd21_xpro/board.cmake b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.cmake
index 46a3880ed..1f6dd9e4f 100644
--- a/hw/bsp/samd21/boards/atsamd21_xpro/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21J18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/samd21j18a_flash.ld)
diff --git a/hw/bsp/samd21/boards/atsamd21_xpro/board.h b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.h
index 82ab321cf..82ab321cf 100644
--- a/hw/bsp/samd21/boards/atsamd21_xpro/board.h
+++ b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.h
diff --git a/hw/bsp/samd21/boards/atsamd21_xpro/board.mk b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.mk
index 4be547a1b..9127a79e7 100644
--- a/hw/bsp/samd21/boards/atsamd21_xpro/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21J18A__ -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/samd21j18a_flash.ld
index d9b086f9c..d9b086f9c 100644
--- a/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld
+++ b/hw/bsp/samd2x_l2x/boards/atsamd21_xpro/samd21j18a_flash.ld
diff --git a/hw/bsp/saml2x/boards/atsaml21_xpro/board.cmake b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.cmake
index 874b741cc..874b741cc 100644
--- a/hw/bsp/saml2x/boards/atsaml21_xpro/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.cmake
diff --git a/hw/bsp/saml2x/boards/atsaml21_xpro/board.h b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.h
index b93b4e591..b93b4e591 100644
--- a/hw/bsp/saml2x/boards/atsaml21_xpro/board.h
+++ b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.h
diff --git a/hw/bsp/saml2x/boards/atsaml21_xpro/board.mk b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.mk
index 4ebfa7e71..4ebfa7e71 100644
--- a/hw/bsp/saml2x/boards/atsaml21_xpro/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/board.mk
diff --git a/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/saml21j18b_flash.ld
index f9523451b..f9523451b 100644
--- a/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld
+++ b/hw/bsp/samd2x_l2x/boards/atsaml21_xpro/saml21j18b_flash.ld
diff --git a/hw/bsp/samd21/boards/circuitplayground_express/board.cmake b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/circuitplayground_express/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21G18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
diff --git a/hw/bsp/samd21/boards/circuitplayground_express/board.h b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.h
index bfe2d9951..bfe2d9951 100644
--- a/hw/bsp/samd21/boards/circuitplayground_express/board.h
+++ b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.h
diff --git a/hw/bsp/samd21/boards/feather_m0_express/board.mk b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/circuitplayground_express.ld
index ce7aff80b..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld
+++ b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/circuitplayground_express.ld
diff --git a/hw/bsp/samd21/boards/curiosity_nano/board.cmake b/hw/bsp/samd2x_l2x/boards/curiosity_nano/board.cmake
index ff779c0fd..be744a130 100644
--- a/hw/bsp/samd21/boards/curiosity_nano/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/curiosity_nano/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE atsamd21g17a)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/samd21g17a_flash.ld)
diff --git a/hw/bsp/samd21/boards/curiosity_nano/board.h b/hw/bsp/samd2x_l2x/boards/curiosity_nano/board.h
index a2a7385a4..a2a7385a4 100644
--- a/hw/bsp/samd21/boards/curiosity_nano/board.h
+++ b/hw/bsp/samd2x_l2x/boards/curiosity_nano/board.h
diff --git a/hw/bsp/samd21/boards/curiosity_nano/board.mk b/hw/bsp/samd2x_l2x/boards/curiosity_nano/board.mk
index 112fb6946..b7ebc867e 100644
--- a/hw/bsp/samd21/boards/curiosity_nano/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/curiosity_nano/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G17A__ -DCFG_EXAMPLE_MSC_READONLY -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld b/hw/bsp/samd2x_l2x/boards/curiosity_nano/samd21g17a_flash.ld
index e03a4ce60..e03a4ce60 100644
--- a/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld
+++ b/hw/bsp/samd2x_l2x/boards/curiosity_nano/samd21g17a_flash.ld
diff --git a/hw/bsp/samd21/boards/cynthion_d21/board.cmake b/hw/bsp/samd2x_l2x/boards/cynthion_d21/board.cmake
index fb54b7561..ae739b215 100644
--- a/hw/bsp/samd21/boards/cynthion_d21/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/cynthion_d21/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21G18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/samd21g18a_flash.ld)
diff --git a/hw/bsp/samd21/boards/cynthion_d21/board.h b/hw/bsp/samd2x_l2x/boards/cynthion_d21/board.h
index 83782bc65..83782bc65 100644
--- a/hw/bsp/samd21/boards/cynthion_d21/board.h
+++ b/hw/bsp/samd2x_l2x/boards/cynthion_d21/board.h
diff --git a/hw/bsp/samd21/boards/cynthion_d21/board.mk b/hw/bsp/samd2x_l2x/boards/cynthion_d21/board.mk
index 52c9d60cb..05ca9cb5d 100644
--- a/hw/bsp/samd21/boards/cynthion_d21/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/cynthion_d21/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
LD_FILE = $(BOARD_PATH)/samd21g18a_flash.ld
diff --git a/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld b/hw/bsp/samd2x_l2x/boards/cynthion_d21/samd21g18a_flash.ld
index 95d71b9e3..95d71b9e3 100644
--- a/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld
+++ b/hw/bsp/samd2x_l2x/boards/cynthion_d21/samd21g18a_flash.ld
diff --git a/hw/bsp/samd21/boards/itsybitsy_m0/board.cmake b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21G18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
diff --git a/hw/bsp/samd21/boards/feather_m0_express/board.h b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.h
index 6fe13eb30..6fe13eb30 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/board.h
+++ b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.h
diff --git a/hw/bsp/samd21/boards/itsybitsy_m0/board.mk b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld b/hw/bsp/samd2x_l2x/boards/feather_m0_express/feather_m0_express.ld
index ce7aff80b..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
+++ b/hw/bsp/samd2x_l2x/boards/feather_m0_express/feather_m0_express.ld
diff --git a/hw/bsp/samd21/boards/metro_m0_express/board.cmake b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/metro_m0_express/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21G18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
diff --git a/hw/bsp/samd21/boards/itsybitsy_m0/board.h b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.h
index d901b2ea4..d901b2ea4 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/board.h
+++ b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.h
diff --git a/hw/bsp/samd21/boards/metro_m0_express/board.mk b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/metro_m0_express/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/itsybitsy_m0.ld
index ce7aff80b..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld
+++ b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/itsybitsy_m0.ld
diff --git a/hw/bsp/samd21/boards/feather_m0_express/board.cmake b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21G18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
diff --git a/hw/bsp/samd21/boards/metro_m0_express/board.h b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.h
index 726de3259..726de3259 100644
--- a/hw/bsp/samd21/boards/metro_m0_express/board.h
+++ b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.h
diff --git a/hw/bsp/samd21/boards/circuitplayground_express/board.mk b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/circuitplayground_express/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld b/hw/bsp/samd2x_l2x/boards/metro_m0_express/metro_m0_express.ld
index ce7aff80b..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld
+++ b/hw/bsp/samd2x_l2x/boards/metro_m0_express/metro_m0_express.ld
diff --git a/hw/bsp/samd21/boards/qtpy/board.cmake b/hw/bsp/samd2x_l2x/boards/qtpy/board.cmake
index f6cd446dd..958944620 100644
--- a/hw/bsp/samd21/boards/qtpy/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/qtpy/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21E18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
diff --git a/hw/bsp/samd21/boards/qtpy/board.h b/hw/bsp/samd2x_l2x/boards/qtpy/board.h
index b1cf338e4..b1cf338e4 100644
--- a/hw/bsp/samd21/boards/qtpy/board.h
+++ b/hw/bsp/samd2x_l2x/boards/qtpy/board.h
diff --git a/hw/bsp/samd21/boards/qtpy/board.mk b/hw/bsp/samd2x_l2x/boards/qtpy/board.mk
index 6cefa84c3..4009c8a38 100644
--- a/hw/bsp/samd21/boards/qtpy/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/qtpy/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
# For Adafruit QT Py board
CFLAGS += -D__SAMD21E18A__ -DCFG_EXAMPLE_VIDEO_READONLY
diff --git a/hw/bsp/samd21/boards/qtpy/qtpy.ld b/hw/bsp/samd2x_l2x/boards/qtpy/qtpy.ld
index ce7aff80b..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/qtpy/qtpy.ld
+++ b/hw/bsp/samd2x_l2x/boards/qtpy/qtpy.ld
diff --git a/hw/bsp/saml2x/boards/saml22_feather/board.cmake b/hw/bsp/samd2x_l2x/boards/saml22_feather/board.cmake
index 7fd79d2ce..7fd79d2ce 100644
--- a/hw/bsp/saml2x/boards/saml22_feather/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/saml22_feather/board.cmake
diff --git a/hw/bsp/saml2x/boards/saml22_feather/board.h b/hw/bsp/samd2x_l2x/boards/saml22_feather/board.h
index f8660c3f8..f8660c3f8 100644
--- a/hw/bsp/saml2x/boards/saml22_feather/board.h
+++ b/hw/bsp/samd2x_l2x/boards/saml22_feather/board.h
diff --git a/hw/bsp/saml2x/boards/saml22_feather/board.mk b/hw/bsp/samd2x_l2x/boards/saml22_feather/board.mk
index c7817ff70..c7817ff70 100644
--- a/hw/bsp/saml2x/boards/saml22_feather/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/saml22_feather/board.mk
diff --git a/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld b/hw/bsp/samd2x_l2x/boards/saml22_feather/saml22_feather.ld
index a04305be7..a04305be7 100644
--- a/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld
+++ b/hw/bsp/samd2x_l2x/boards/saml22_feather/saml22_feather.ld
diff --git a/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.cmake b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.cmake
new file mode 100644
index 000000000..dedc07594
--- /dev/null
+++ b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.cmake
@@ -0,0 +1,10 @@
+set(SAM_FAMILY samd21)
+set(JLINK_DEVICE ATSAMD21G18)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ __SAMD21G18A__
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+endfunction()
diff --git a/hw/bsp/samd21/boards/seeeduino_xiao/board.h b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.h
index 1c434c68c..1c434c68c 100644
--- a/hw/bsp/samd21/boards/seeeduino_xiao/board.h
+++ b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.h
diff --git a/hw/bsp/samd21/boards/seeeduino_xiao/board.mk b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.mk
index 1c888da3a..0afe37f12 100644
--- a/hw/bsp/samd21/boards/seeeduino_xiao/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21G18A__ -DCFG_EXAMPLE_VIDEO_READONLY
LD_FILE = $(BOARD_PATH)/$(BOARD).ld
diff --git a/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/seeeduino_xiao.ld
index 0d0c4e6c4..0d0c4e6c4 100644
--- a/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld
+++ b/hw/bsp/samd2x_l2x/boards/seeeduino_xiao/seeeduino_xiao.ld
diff --git a/hw/bsp/saml2x/boards/sensorwatch_m0/board.cmake b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.cmake
index 67d26475f..67d26475f 100644
--- a/hw/bsp/saml2x/boards/sensorwatch_m0/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.cmake
diff --git a/hw/bsp/saml2x/boards/sensorwatch_m0/board.h b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.h
index 502c799db..502c799db 100644
--- a/hw/bsp/saml2x/boards/sensorwatch_m0/board.h
+++ b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.h
diff --git a/hw/bsp/saml2x/boards/sensorwatch_m0/board.mk b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.mk
index c7817ff70..c7817ff70 100644
--- a/hw/bsp/saml2x/boards/sensorwatch_m0/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/board.mk
diff --git a/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/sensorwatch_m0.ld
index a04305be7..a04305be7 100644
--- a/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld
+++ b/hw/bsp/samd2x_l2x/boards/sensorwatch_m0/sensorwatch_m0.ld
diff --git a/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.cmake b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.cmake
new file mode 100644
index 000000000..dedc07594
--- /dev/null
+++ b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.cmake
@@ -0,0 +1,10 @@
+set(SAM_FAMILY samd21)
+set(JLINK_DEVICE ATSAMD21G18)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ __SAMD21G18A__
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+endfunction()
diff --git a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.h b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.h
index a05cf5e4e..a05cf5e4e 100644
--- a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/board.h
+++ b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.h
diff --git a/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.mk b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.mk
new file mode 100644
index 000000000..f4211e6c8
--- /dev/null
+++ b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/board.mk
@@ -0,0 +1,11 @@
+SAM_FAMILY = samd21
+
+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/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld
index 0754a8e9c..0754a8e9c 100644
--- a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld
+++ b/hw/bsp/samd2x_l2x/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld
diff --git a/hw/bsp/samd21/boards/trinket_m0/board.cmake b/hw/bsp/samd2x_l2x/boards/trinket_m0/board.cmake
index f6cd446dd..958944620 100644
--- a/hw/bsp/samd21/boards/trinket_m0/board.cmake
+++ b/hw/bsp/samd2x_l2x/boards/trinket_m0/board.cmake
@@ -1,3 +1,4 @@
+set(SAM_FAMILY samd21)
set(JLINK_DEVICE ATSAMD21E18)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
diff --git a/hw/bsp/samd21/boards/trinket_m0/board.h b/hw/bsp/samd2x_l2x/boards/trinket_m0/board.h
index 01ad83089..01ad83089 100644
--- a/hw/bsp/samd21/boards/trinket_m0/board.h
+++ b/hw/bsp/samd2x_l2x/boards/trinket_m0/board.h
diff --git a/hw/bsp/samd21/boards/trinket_m0/board.mk b/hw/bsp/samd2x_l2x/boards/trinket_m0/board.mk
index 6addf13b7..201259288 100644
--- a/hw/bsp/samd21/boards/trinket_m0/board.mk
+++ b/hw/bsp/samd2x_l2x/boards/trinket_m0/board.mk
@@ -1,3 +1,5 @@
+SAM_FAMILY = samd21
+
CFLAGS += -D__SAMD21E18A__ -DCFG_EXAMPLE_VIDEO_READONLY
# All source paths should be relative to the top level.
diff --git a/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld b/hw/bsp/samd2x_l2x/boards/trinket_m0/trinket_m0.ld
index ce7aff80b..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld
+++ b/hw/bsp/samd2x_l2x/boards/trinket_m0/trinket_m0.ld
diff --git a/hw/bsp/samd21/family.c b/hw/bsp/samd2x_l2x/family.c
index 14e60e917..67da1294e 100644
--- a/hw/bsp/samd21/family.c
+++ b/hw/bsp/samd2x_l2x/family.c
@@ -39,28 +39,57 @@
#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"
+
+// SAMD21 specific includes
+#if defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) || \
+ defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) || \
+ defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__)
+ #define SAMD21_FAMILY
+ #include "hri/hri_nvmctrl_d21.h"
+ #include "hpl_pm_config.h"
+ #include "hpl/pm/hpl_pm_base.h"
+#endif
+
+// SAML21/22 specific includes
+#if defined(__SAML21E15B__) || defined(__SAML21E16B__) || defined(__SAML21E17B__) || defined(__SAML21E18B__) || \
+ defined(__SAML21G16B__) || defined(__SAML21G17B__) || defined(__SAML21G18B__) || \
+ defined(__SAML21J16B__) || defined(__SAML21J17B__) || defined(__SAML21J18B__) || \
+ defined(__SAML22G16A__) || defined(__SAML22G17A__) || defined(__SAML22G18A__) || \
+ defined(__SAML22J16A__) || defined(__SAML22J17A__) || defined(__SAML22J18A__) || \
+ defined(__SAML22N16A__) || defined(__SAML22N17A__) || defined(__SAML22N18A__)
+ #define SAML2X_FAMILY
+ #include "hpl_mclk_config.h"
+#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
-static inline void board_vbus_set(uint8_t rhport, bool state) TU_ATTR_UNUSED;
#include "board.h"
+// board_vbus_set is defined in board.h for boards that support it
+#if !defined(board_vbus_set)
+ #define board_vbus_set(rhport, state) do { (void)(rhport); (void)(state); } while(0)
+#endif
+
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
+#ifdef SAMD21_FAMILY
/* 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)
+#endif
+
+#ifdef SAML2X_FAMILY
+/* 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
+#endif
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
@@ -86,7 +115,8 @@ static void max3421_init(void);
#endif
void board_init(void) {
- // Clock init ( follow hpl_init.c )
+#ifdef SAMD21_FAMILY
+ // Clock init for SAMD21 ( follow hpl_init.c )
hri_nvmctrl_set_CTRLB_RWS_bf(NVMCTRL, 2);
_pm_init();
@@ -96,6 +126,28 @@ void board_init(void) {
#endif
_sysctrl_init_referenced_generators();
_gclk_init_generators_by_fref(_GCLK_INIT_LAST);
+#endif
+
+#ifdef SAML2X_FAMILY
+ // Clock init for SAML2x ( 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
+#endif
// Update SystemCoreClock since it is hard coded with asf4 and not correct
// Init 1ms tick timer (samd SystemCoreClock may not correct)
@@ -126,9 +178,17 @@ void board_init(void) {
/* USB Clock init
* The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
* for low speed and full speed operation. */
+#ifdef SAMD21_FAMILY
_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);
+#endif
+
+#ifdef SAML2X_FAMILY
+ 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);
+#endif
// USB Pin Init
gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
@@ -141,6 +201,7 @@ void board_init(void) {
gpio_set_pin_function(PIN_PA24, PINMUX_PA24G_USB_DM);
gpio_set_pin_function(PIN_PA25, PINMUX_PA25G_USB_DP);
+#ifdef SAMD21_FAMILY
// 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;
@@ -149,6 +210,7 @@ void board_init(void) {
gpio_set_pin_function(PIN_PA19, PINMUX_PA19F_TCC0_WO3);
_gclk_enable_channel(TCC0_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
+#endif
#if CFG_TUH_ENABLED
#if CFG_TUH_MAX3421
@@ -203,9 +265,17 @@ static void uart_init(void)
#error "UART_RX_PIN not supported"
#endif
+#ifdef SAMD21_FAMILY
// setup clock (48MHz)
_pm_enable_bus_clock(PM_BUS_APBC, SERCOM0);
_gclk_enable_channel(SERCOM0_GCLK_ID_CORE, GCLK_CLKCTRL_GEN_GCLK0_Val);
+#endif
+
+#ifdef SAML2X_FAMILY
+ // setup clock (48MHz)
+ hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+ hri_mclk_set_APBCMASK_SERCOM0_bit(MCLK);
+#endif
SERCOM0->USART.CTRLA.bit.SWRST = 1; /* reset SERCOM & enable config */
while(SERCOM0->USART.SYNCBUSY.bit.SWRST);
@@ -304,14 +374,24 @@ static void max3421_init(void) {
// MAX3421E max SPI clock is 26MHz however SAMD can only work reliably at 12 Mhz
uint32_t const baudrate = 12000000u;
+#ifdef SAMD21_FAMILY
// Enable the APB clock for SERCOM
PM->APBCMASK.reg |= 1u << (PM_APBCMASK_SERCOM0_Pos + MAX3421_SERCOM_ID);
// Configure GCLK for SERCOM
-// GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID_SERCOM4_CORE | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_CLKEN;
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID(GCLK_CLKCTRL_ID_SERCOM0_CORE_Val + MAX3421_SERCOM_ID) |
GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_CLKEN;
while (GCLK->STATUS.bit.SYNCBUSY);
+#endif
+
+#ifdef SAML2X_FAMILY
+ // Enable the APB clock for SERCOM
+ hri_mclk_set_APBCMASK_reg(MCLK, 1u << (MCLK_APBCMASK_SERCOM0_Pos + MAX3421_SERCOM_ID));
+
+ // Configure GCLK for SERCOM
+ hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE + MAX3421_SERCOM_ID,
+ GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+#endif
Sercom* sercom = MAX3421_SERCOM;
@@ -332,7 +412,7 @@ static void max3421_init(void) {
// Set the baud rate
sercom->SPI.BAUD.reg = (uint8_t) (SystemCoreClock / (2 * baudrate) - 1);
- // Configure PA12 as MOSI (PAD0), PA13 as SCK (PAD1), PA14 as MISO (PAD2), function C (sercom)
+ // Configure SPI pins
gpio_set_pin_direction(MAX3421_SCK_PIN, GPIO_DIRECTION_OUT);
gpio_set_pin_pull_mode(MAX3421_SCK_PIN, GPIO_PULL_OFF);
gpio_set_pin_function(MAX3421_SCK_PIN, MAX3421_SERCOM_FUNCTION);
@@ -355,14 +435,24 @@ static void max3421_init(void) {
//------------- External Interrupt -------------//
+#ifdef SAMD21_FAMILY
// Enable the APB clock for EIC (External Interrupt Controller)
PM->APBAMASK.reg |= PM_APBAMASK_EIC;
// Configure GCLK for EIC
GCLK->CLKCTRL.reg = GCLK_CLKCTRL_ID_EIC | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_CLKEN;
while (GCLK->STATUS.bit.SYNCBUSY);
+#endif
+
+#ifdef SAML2X_FAMILY
+ // Enable the APB clock for EIC
+ hri_mclk_set_APBAMASK_EIC_bit(MCLK);
- // Configure PA20 as an input with function A (external interrupt)
+ // Configure GCLK for EIC
+ hri_gclk_write_PCHCTRL_reg(GCLK, EIC_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK1_Val | GCLK_PCHCTRL_CHEN);
+#endif
+
+ // Configure interrupt pin as an input with function A (external interrupt)
gpio_set_pin_direction(MAX3421_INTR_PIN, GPIO_DIRECTION_IN);
gpio_set_pin_pull_mode(MAX3421_INTR_PIN, GPIO_PULL_UP);
gpio_set_pin_function(MAX3421_INTR_PIN, 0);
@@ -451,3 +541,10 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const* tx_buf, uint8_t* rx
}
#endif
+
+// Stub for libc init array (required by SAML21/SAML22)
+#ifdef SAML2X_FAMILY
+void _init(void);
+void _init(void) {
+}
+#endif
diff --git a/hw/bsp/samd2x_l2x/family.cmake b/hw/bsp/samd2x_l2x/family.cmake
new file mode 100644
index 000000000..76371ccdc
--- /dev/null
+++ b/hw/bsp/samd2x_l2x/family.cmake
@@ -0,0 +1,148 @@
+include_guard()
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# Determine which SAM family based on board configuration
+# SAM_FAMILY should be set by board.cmake (samd21, saml21, or saml22)
+if(NOT DEFINED SAM_FAMILY)
+ # Default to samd21 if not specified for backward compatibility
+ set(SAM_FAMILY samd21)
+endif()
+
+set(SDK_DIR ${TOP}/hw/mcu/microchip/${SAM_FAMILY})
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m0plus CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+
+set(FAMILY_MCUS SAMD21 SAML2X CACHE INTERNAL "")
+set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -f target/at91samdXX.cfg")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ # Common sources for all SAM families
+ set(COMMON_SOURCES
+ ${SDK_DIR}/gcc/system_${SAM_FAMILY}.c
+ ${SDK_DIR}/hal/src/hal_atomic.c
+ ${SDK_DIR}/hpl/gclk/hpl_gclk.c
+ )
+
+ # Family-specific sources
+ if(SAM_FAMILY STREQUAL "samd21")
+ list(APPEND COMMON_SOURCES
+ ${SDK_DIR}/hpl/pm/hpl_pm.c
+ ${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c
+ )
+ else()
+ # SAML21/SAML22
+ list(APPEND COMMON_SOURCES
+ ${SDK_DIR}/hpl/mclk/hpl_mclk.c
+ ${SDK_DIR}/hpl/osc32kctrl/hpl_osc32kctrl.c
+ ${SDK_DIR}/hpl/oscctrl/hpl_oscctrl.c
+ ${SDK_DIR}/hpl/pm/hpl_pm.c
+ )
+ endif()
+
+ add_library(${BOARD_TARGET} STATIC ${COMMON_SOURCES})
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}
+ ${SDK_DIR}/config
+ ${SDK_DIR}/include
+ ${SDK_DIR}/hal/include
+ ${SDK_DIR}/hal/utils/include
+ ${SDK_DIR}/hpl/pm
+ ${SDK_DIR}/hpl/port
+ ${SDK_DIR}/hri
+ ${CMSIS_5}/CMSIS/Core/Include
+ )
+
+ # Family-specific compile definitions
+ if(SAM_FAMILY STREQUAL "samd21")
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ CONF_DFLL_OVERWRITE_CALIBRATION=0
+ )
+ else()
+ # SAML21/SAML22
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ CONF_OSC32K_CALIB_ENABLE=0
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+ endif()
+
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+
+ # Determine MCU option based on SAM_FAMILY
+ if(SAM_FAMILY STREQUAL "samd21")
+ set(MCU_OPTION OPT_MCU_SAMD21)
+ elseif(SAM_FAMILY STREQUAL "saml21")
+ set(MCU_OPTION OPT_MCU_SAML21)
+ elseif(SAM_FAMILY STREQUAL "saml22")
+ set(MCU_OPTION OPT_MCU_SAML22)
+ else()
+ message(FATAL_ERROR "Unknown SAM_FAMILY: ${SAM_FAMILY}")
+ endif()
+ family_add_tinyusb(${TARGET} ${MCU_OPTION})
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/microchip/samd/dcd_samd.c
+ ${TOP}/src/portable/microchip/samd/hcd_samd.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ # Add HCD support for SAMD21 (has host capability)
+ if(SAM_FAMILY STREQUAL "samd21")
+ target_sources(${TARGET} PUBLIC
+ ${TOP}/src/portable/microchip/samd/hcd_samd.c
+ )
+ endif()
+
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ # Flashing
+ family_add_bin_hex(${TARGET})
+ family_flash_jlink(${TARGET})
+ #family_flash_openocd(${TARGET})
+endfunction()
diff --git a/hw/bsp/samd21/family.mk b/hw/bsp/samd2x_l2x/family.mk
index a2c37b2b6..dca440ddd 100644
--- a/hw/bsp/samd21/family.mk
+++ b/hw/bsp/samd2x_l2x/family.mk
@@ -1,13 +1,37 @@
UF2_FAMILY_ID = 0x68ed2b88
-SDK_DIR = hw/mcu/microchip/samd21
include $(TOP)/$(BOARD_PATH)/board.mk
+
+# SAM_FAMILY should be set by board.mk (samd21, saml21, or saml22)
+ifeq ($(SAM_FAMILY),)
+ # Default to samd21 if not specified for backward compatibility
+ SAM_FAMILY = samd21
+endif
+
+SDK_DIR = hw/mcu/microchip/$(SAM_FAMILY)
CPU_CORE ?= cortex-m0plus
+# Common CFLAGS
CFLAGS += \
-flto \
- -DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
- -DCFG_TUSB_MCU=OPT_MCU_SAMD21
+
+# Family-specific CFLAGS
+ifeq ($(SAM_FAMILY),samd21)
+ CFLAGS += \
+ -DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMD21
+else
+ # SAML21/SAML22
+ CFLAGS += \
+ -DCONF_OSC32K_CALIB_ENABLE=0 \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+
+ ifeq ($(SAM_FAMILY),saml21)
+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAML21
+ else ifeq ($(SAM_FAMILY),saml22)
+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAML22
+ endif
+endif
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=redundant-decls
@@ -21,15 +45,30 @@ LDFLAGS_GCC += \
LDFLAGS_CLANG +=
+# Common source files
SRC_C += \
src/portable/microchip/samd/dcd_samd.c \
- src/portable/microchip/samd/hcd_samd.c \
- ${SDK_DIR}/gcc/gcc/startup_samd21.c \
- ${SDK_DIR}/gcc/system_samd21.c \
+ ${SDK_DIR}/gcc/gcc/startup_$(SAM_FAMILY).c \
+ ${SDK_DIR}/gcc/system_$(SAM_FAMILY).c \
${SDK_DIR}/hal/src/hal_atomic.c \
${SDK_DIR}/hpl/gclk/hpl_gclk.c \
- ${SDK_DIR}/hpl/pm/hpl_pm.c \
- ${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c \
+
+# Family-specific source files
+ifeq ($(SAM_FAMILY),samd21)
+ SRC_C += \
+ src/portable/microchip/samd/hcd_samd.c \
+ ${SDK_DIR}/hpl/pm/hpl_pm.c \
+ ${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c \
+
+else
+ # SAML21/SAML22
+ SRC_C += \
+ ${SDK_DIR}/hpl/mclk/hpl_mclk.c \
+ ${SDK_DIR}/hpl/osc32kctrl/hpl_osc32kctrl.c \
+ ${SDK_DIR}/hpl/oscctrl/hpl_oscctrl.c \
+ ${SDK_DIR}/hpl/pm/hpl_pm.c \
+
+endif
INC += \
$(TOP)/$(BOARD_PATH) \
diff --git a/hw/bsp/samd5x_e5x/family.c b/hw/bsp/samd5x_e5x/family.c
index d53aa00d6..df6f19d0f 100644
--- a/hw/bsp/samd5x_e5x/family.c
+++ b/hw/bsp/samd5x_e5x/family.c
@@ -179,7 +179,7 @@ size_t board_get_unique_id(uint8_t id[], size_t max_len) {
for (int i = 0; i < 4; i++) {
uint32_t did = *((uint32_t const*) did_addr[i]);
did = TU_BSWAP32(did); // swap endian to match samd51 uf2 bootloader
- memcpy(id + i * 4, &did, 4);
+ memcpy(id + i * 4, &did, sizeof(uint32_t));
}
return 16;
diff --git a/hw/bsp/samd5x_e5x/family.cmake b/hw/bsp/samd5x_e5x/family.cmake
index 516290593..bb022ab76 100644
--- a/hw/bsp/samd5x_e5x/family.cmake
+++ b/hw/bsp/samd5x_e5x/family.cmake
@@ -13,22 +13,16 @@ set(FAMILY_MCUS SAMD51 SAME54 CACHE INTERNAL "")
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -c \"set CHIPNAME samd51\" -f target/atsame5x.cfg")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/gcc/system_${SAM_FAMILY}.c
${SDK_DIR}/hal/src/hal_atomic.c
@@ -36,7 +30,6 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/hpl/mclk/hpl_mclk.c
${SDK_DIR}/hpl/osc32kctrl/hpl_osc32kctrl.c
${SDK_DIR}/hpl/oscctrl/hpl_oscctrl.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}
@@ -50,55 +43,46 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_SAMD51)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/microchip/samd/dcd_samd.c
+ ${TOP}/src/portable/microchip/samd/hcd_samd.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_SAMD51)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/microchip/samd/dcd_samd.c
- ${TOP}/src/portable/microchip/samd/hcd_samd.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/same70_qmtech/board.mk b/hw/bsp/same70_qmtech/board.mk
deleted file mode 100644
index 7e949e135..000000000
--- a/hw/bsp/same70_qmtech/board.mk
+++ /dev/null
@@ -1,59 +0,0 @@
-ASF_DIR = hw/mcu/microchip/same70
-
-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=redundant-decls
-
-# SAM driver is flooded with -Wcast-qual which slow down complication significantly
-CFLAGS_SKIP += -Wcast-qual
-
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
-
-# 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_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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/hw/bsp/same70_qmtech/same70_qmtech.c b/hw/bsp/same70_qmtech/same70_qmtech.c
deleted file mode 100644
index e5f0da198..000000000
--- a/hw/bsp/same70_qmtech/same70_qmtech.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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_api.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/hw/bsp/same70_xplained/board.mk b/hw/bsp/same70_xplained/board.mk
deleted file mode 100644
index 2d97ecdc1..000000000
--- a/hw/bsp/same70_xplained/board.mk
+++ /dev/null
@@ -1,67 +0,0 @@
-ASF_DIR = hw/mcu/microchip/same70
-
-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=redundant-decls
-
-SPEED ?= high
-
-ifeq ($(SPEED), high)
- CFLAGS += -DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
-else
- CFLAGS += -DBOARD_TUD_MAX_SPEED=OPT_MODE_FULL_SPEED
-endif
-
-# SAM driver is flooded with -Wcast-qual which slow down complication significantly
-CFLAGS_SKIP += -Wcast-qual
-
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
-
-# 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_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/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/hw/bsp/same70_xplained/same70_xplained.c b/hw/bsp/same70_xplained/same70_xplained.c
deleted file mode 100644
index f532c6927..000000000
--- a/hw/bsp/same70_xplained/same70_xplained.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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_api.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/hw/bsp/same7x/boards/same70_qmtech/board.cmake b/hw/bsp/same7x/boards/same70_qmtech/board.cmake
new file mode 100644
index 000000000..cde4c3da6
--- /dev/null
+++ b/hw/bsp/same7x/boards/same70_qmtech/board.cmake
@@ -0,0 +1,8 @@
+set(JLINK_DEVICE SAME70N19B)
+set(LD_FILE_GNU ${TOP}/hw/mcu/microchip/same70/same70b/gcc/gcc/same70q21b_flash.ld)
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ __SAME70N19B__
+ )
+endfunction()
diff --git a/hw/bsp/same7x/boards/same70_qmtech/board.h b/hw/bsp/same7x/boards/same70_qmtech/board.h
new file mode 100644
index 000000000..09c2c93a9
--- /dev/null
+++ b/hw/bsp/same7x/boards/same70_qmtech/board.h
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+/* metadata:
+ name: SAME70 QMTech
+ manufacturer: Microchip
+ url: https://www.aliexpress.com/item/1005003173783268.html
+*/
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LED_PIN GPIO(GPIO_PORTA, 15)
+#define LED_STATE_ON 1
+#define LED_PORT_CLOCK ID_PIOB
+
+#define BUTTON_PIN GPIO(GPIO_PORTA, 21)
+#define BUTTON_STATE_ACTIVE 0
+#define BUTTON_PORT_CLOCK ID_PIOA
+
+#define UART_TX_PIN GPIO(GPIO_PORTB, 1)
+#define UART_TX_FUNCTION MUX_PB4D_USART1_TXD1
+#define UART_RX_PIN GPIO(GPIO_PORTB, 0)
+#define UART_RX_FUNCTION MUX_PA21A_USART1_RXD1
+#define UART_PORT_CLOCK ID_USART1
+#define BOARD_USART USART1
+
+static inline void board_vbus_set(uint8_t rhport, bool state) {
+ (void) rhport;
+ (void) state;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/same7x/boards/same70_qmtech/board.mk b/hw/bsp/same7x/boards/same70_qmtech/board.mk
new file mode 100644
index 000000000..09ae98860
--- /dev/null
+++ b/hw/bsp/same7x/boards/same70_qmtech/board.mk
@@ -0,0 +1,3 @@
+CFLAGS += -D__SAME70N19B__
+
+JLINK_DEVICE = SAME70N19B
diff --git a/hw/bsp/same70_qmtech/hpl_pmc_config.h b/hw/bsp/same7x/boards/same70_qmtech/hpl_pmc_config.h
index 387aaa5df..387aaa5df 100644
--- a/hw/bsp/same70_qmtech/hpl_pmc_config.h
+++ b/hw/bsp/same7x/boards/same70_qmtech/hpl_pmc_config.h
diff --git a/hw/bsp/same70_qmtech/hpl_usart_config.h b/hw/bsp/same7x/boards/same70_qmtech/hpl_usart_config.h
index 50ca3f15c..50ca3f15c 100644
--- a/hw/bsp/same70_qmtech/hpl_usart_config.h
+++ b/hw/bsp/same7x/boards/same70_qmtech/hpl_usart_config.h
diff --git a/hw/bsp/same70_qmtech/hpl_xdmac_config.h b/hw/bsp/same7x/boards/same70_qmtech/hpl_xdmac_config.h
index a3d62c6fc..a3d62c6fc 100644
--- a/hw/bsp/same70_qmtech/hpl_xdmac_config.h
+++ b/hw/bsp/same7x/boards/same70_qmtech/hpl_xdmac_config.h
diff --git a/hw/bsp/same70_qmtech/peripheral_clk_config.h b/hw/bsp/same7x/boards/same70_qmtech/peripheral_clk_config.h
index 84756f5ac..84756f5ac 100644
--- a/hw/bsp/same70_qmtech/peripheral_clk_config.h
+++ b/hw/bsp/same7x/boards/same70_qmtech/peripheral_clk_config.h
diff --git a/hw/bsp/same7x/boards/same70_xplained/board.cmake b/hw/bsp/same7x/boards/same70_xplained/board.cmake
new file mode 100644
index 000000000..b226b6c4f
--- /dev/null
+++ b/hw/bsp/same7x/boards/same70_xplained/board.cmake
@@ -0,0 +1,8 @@
+set(JLINK_DEVICE SAME70Q21B)
+set(LD_FILE_GNU ${TOP}/hw/mcu/microchip/same70/same70b/gcc/gcc/same70q21b_flash.ld)
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ __SAME70Q21B__
+ )
+endfunction()
diff --git a/hw/bsp/same7x/boards/same70_xplained/board.h b/hw/bsp/same7x/boards/same70_xplained/board.h
new file mode 100644
index 000000000..85e23deb8
--- /dev/null
+++ b/hw/bsp/same7x/boards/same70_xplained/board.h
@@ -0,0 +1,64 @@
+/*
+ * 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 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.
+ */
+
+/* metadata:
+ name: SAME70 Xplained
+ manufacturer: Microchip
+ url: https://www.microchip.com/en-us/development-tool/atsame70-xpld
+*/
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LED_PIN GPIO(GPIO_PORTC, 8)
+#define LED_STATE_ON 1
+#define LED_PORT_CLOCK ID_PIOC
+
+#define BUTTON_PIN GPIO(GPIO_PORTA, 11)
+#define BUTTON_STATE_ACTIVE 0
+#define BUTTON_PORT_CLOCK ID_PIOA
+
+#define UART_TX_PIN GPIO(GPIO_PORTB, 4)
+#define UART_TX_FUNCTION MUX_PB4D_USART1_TXD1
+#define UART_RX_PIN GPIO(GPIO_PORTA, 21)
+#define UART_RX_FUNCTION MUX_PA21A_USART1_RXD1
+#define UART_PORT_CLOCK ID_USART1
+#define BOARD_USART USART1
+
+static inline void board_vbus_set(uint8_t rhport, bool state) {
+ (void) rhport;
+ (void) state;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/same7x/boards/same70_xplained/board.mk b/hw/bsp/same7x/boards/same70_xplained/board.mk
new file mode 100644
index 000000000..ca23a9be5
--- /dev/null
+++ b/hw/bsp/same7x/boards/same70_xplained/board.mk
@@ -0,0 +1,3 @@
+CFLAGS += -D__SAME70Q21B__
+
+JLINK_DEVICE = SAME70Q21B
diff --git a/hw/bsp/same70_xplained/hpl_pmc_config.h b/hw/bsp/same7x/boards/same70_xplained/hpl_pmc_config.h
index 387aaa5df..387aaa5df 100644
--- a/hw/bsp/same70_xplained/hpl_pmc_config.h
+++ b/hw/bsp/same7x/boards/same70_xplained/hpl_pmc_config.h
diff --git a/hw/bsp/same70_xplained/hpl_usart_config.h b/hw/bsp/same7x/boards/same70_xplained/hpl_usart_config.h
index 50ca3f15c..50ca3f15c 100644
--- a/hw/bsp/same70_xplained/hpl_usart_config.h
+++ b/hw/bsp/same7x/boards/same70_xplained/hpl_usart_config.h
diff --git a/hw/bsp/same70_xplained/hpl_xdmac_config.h b/hw/bsp/same7x/boards/same70_xplained/hpl_xdmac_config.h
index a3d62c6fc..a3d62c6fc 100644
--- a/hw/bsp/same70_xplained/hpl_xdmac_config.h
+++ b/hw/bsp/same7x/boards/same70_xplained/hpl_xdmac_config.h
diff --git a/hw/bsp/same70_xplained/peripheral_clk_config.h b/hw/bsp/same7x/boards/same70_xplained/peripheral_clk_config.h
index 84756f5ac..84756f5ac 100644
--- a/hw/bsp/same70_xplained/peripheral_clk_config.h
+++ b/hw/bsp/same7x/boards/same70_xplained/peripheral_clk_config.h
diff --git a/hw/bsp/same7x/family.c b/hw/bsp/same7x/family.c
new file mode 100644
index 000000000..572c83588
--- /dev/null
+++ b/hw/bsp/same7x/family.c
@@ -0,0 +1,196 @@
+/*
+ * 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 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.
+ */
+
+/* metadata:
+ manufacturer: Microchip
+*/
+
+#include "bsp/board_api.h"
+#include "sam.h"
+
+#include "hal/include/hal_gpio.h"
+#include "hal/include/hal_init.h"
+#include "hal/include/hal_usart_async.h"
+#include "hpl/pmc/hpl_pmc.h"
+#include "hpl/usart/hpl_usart_base.h"
+#include "peripheral_clk_config.h"
+
+static inline void board_vbus_set(uint8_t rhport, bool state);
+void _init(void);
+#include "board.h"
+
+#ifndef LED_STATE_ON
+ #define LED_STATE_ON 1
+#endif
+
+#ifndef LED_PORT_CLOCK
+ #define LED_PORT_CLOCK ID_PIOA
+#endif
+
+#ifndef BUTTON_PORT_CLOCK
+ #define BUTTON_PORT_CLOCK ID_PIOA
+#endif
+
+#ifndef UART_PORT_CLOCK
+ #define UART_PORT_CLOCK ID_USART1
+#endif
+
+#ifndef BOARD_USART
+ #define BOARD_USART USART1
+#endif
+
+#ifndef BOARD_UART_DESCRIPTOR
+ #define BOARD_UART_DESCRIPTOR edbg_com
+#endif
+
+#ifndef BOARD_UART_BUFFER
+ #define BOARD_UART_BUFFER edbg_com_buffer
+#endif
+
+#ifndef BUTTON_STATE_ACTIVE
+ #define BUTTON_STATE_ACTIVE 0
+#endif
+
+#ifndef UART_TX_FUNCTION
+ #define UART_TX_FUNCTION MUX_PB4D_USART1_TXD1
+#endif
+
+#ifndef UART_RX_FUNCTION
+ #define UART_RX_FUNCTION MUX_PA21A_USART1_RXD1
+#endif
+
+#ifndef UART_BUFFER_SIZE
+ #define UART_BUFFER_SIZE 64
+#endif
+
+#define LED_STATE_OFF (1 - LED_STATE_ON)
+
+static struct usart_async_descriptor BOARD_UART_DESCRIPTOR;
+static uint8_t BOARD_UART_BUFFER[UART_BUFFER_SIZE];
+static volatile bool uart_busy = false;
+
+static void tx_complete_cb(const struct usart_async_descriptor *const io_descr) {
+ (void) io_descr;
+ uart_busy = false;
+}
+
+void board_init(void) {
+ init_mcu();
+
+ /* Disable Watchdog */
+ hri_wdt_set_MR_WDDIS_bit(WDT);
+
+#ifdef LED_PIN
+ _pmc_enable_periph_clock(LED_PORT_CLOCK);
+ gpio_set_pin_level(LED_PIN, LED_STATE_OFF);
+ gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+ gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
+#endif
+
+#ifdef BUTTON_PIN
+ _pmc_enable_periph_clock(BUTTON_PORT_CLOCK);
+ 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);
+ gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
+#endif
+
+ _pmc_enable_periph_clock(UART_PORT_CLOCK);
+ gpio_set_pin_function(UART_RX_PIN, UART_RX_FUNCTION);
+ gpio_set_pin_function(UART_TX_PIN, UART_TX_FUNCTION);
+
+ usart_async_init(&BOARD_UART_DESCRIPTOR, BOARD_USART, BOARD_UART_BUFFER, sizeof(BOARD_UART_BUFFER), _usart_get_usart_async());
+ usart_async_set_baud_rate(&BOARD_UART_DESCRIPTOR, CFG_BOARD_UART_BAUDRATE);
+ usart_async_register_callback(&BOARD_UART_DESCRIPTOR, USART_ASYNC_TXC_CB, tx_complete_cb);
+ usart_async_enable(&BOARD_UART_DESCRIPTOR);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer (SystemCoreClock may not be correct after init)
+ SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+
+ // Enable USB clock
+ _pmc_enable_periph_clock(ID_USBHS);
+
+#if CFG_TUH_ENABLED
+ board_vbus_set(0, true);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// USB Interrupt Handler
+//--------------------------------------------------------------------+
+void USBHS_Handler(void) {
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+#ifdef LED_PIN
+ gpio_set_pin_level(LED_PIN, state ? LED_STATE_ON : LED_STATE_OFF);
+#else
+ (void) state;
+#endif
+}
+
+uint32_t board_button_read(void) {
+#ifdef BUTTON_PIN
+ return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+#else
+ return 0;
+#endif
+}
+
+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 (uart_busy) {}
+ uart_busy = true;
+
+ io_write(&BOARD_UART_DESCRIPTOR.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
+
+void _init(void) {
+}
diff --git a/hw/bsp/same7x/family.cmake b/hw/bsp/same7x/family.cmake
new file mode 100644
index 000000000..a9c9de413
--- /dev/null
+++ b/hw/bsp/same7x/family.cmake
@@ -0,0 +1,98 @@
+include_guard()
+
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+set(SDK_DIR ${TOP}/hw/mcu/microchip/same70)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m7 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+
+set(FAMILY_MCUS SAMX7X CACHE INTERNAL "")
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+set(STARTUP_FILE_GNU ${SDK_DIR}/same70b/gcc/gcc/startup_same70q21b.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/same70b/gcc/system_same70q21b.c
+ ${SDK_DIR}/hpl/core/hpl_init.c
+ ${SDK_DIR}/hpl/usart/hpl_usart.c
+ ${SDK_DIR}/hpl/pmc/hpl_pmc.c
+ ${SDK_DIR}/hal/src/hal_usart_async.c
+ ${SDK_DIR}/hal/src/hal_io.c
+ ${SDK_DIR}/hal/src/hal_atomic.c
+ ${SDK_DIR}/hal/utils/src/utils_ringbuffer.c
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}
+ ${SDK_DIR}/config
+ ${SDK_DIR}/same70b/include
+ ${SDK_DIR}/hal/include
+ ${SDK_DIR}/hal/utils/include
+ ${SDK_DIR}/hpl/core
+ ${SDK_DIR}/hpl/pio
+ ${SDK_DIR}/hpl/pmc
+ ${SDK_DIR}/hri
+ ${SDK_DIR}/CMSIS/Core/Include
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ update_board(${BOARD_TARGET})
+
+ target_compile_options(${BOARD_TARGET} PUBLIC
+ -Wno-error=unused-parameter
+ -Wno-error=cast-align
+ -Wno-error=redundant-decls
+ -Wno-error=cast-qual
+ )
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_SAMX7X)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/microchip/samx7x/dcd_samx7x.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+ family_add_bin_hex(${TARGET})
+ family_flash_jlink(${TARGET})
+endfunction()
diff --git a/hw/bsp/same7x/family.mk b/hw/bsp/same7x/family.mk
new file mode 100644
index 000000000..c8fa74d71
--- /dev/null
+++ b/hw/bsp/same7x/family.mk
@@ -0,0 +1,56 @@
+SDK_DIR = hw/mcu/microchip/same70
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+CPU_CORE ?= cortex-m7
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv4-sp-d16 \
+ -nostdlib -nostartfiles \
+ -DCFG_TUSB_MCU=OPT_MCU_SAMX7X
+
+# suppress following warnings from mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=redundant-decls
+
+# SAM driver is flooded with -Wcast-qual which slows down compilation significantly
+CFLAGS_SKIP += -Wcast-qual
+
+LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+
+# All source paths should be relative to the top level.
+LD_FILE = $(SDK_DIR)/same70b/gcc/gcc/same70q21b_flash.ld
+
+SRC_C += \
+ src/portable/microchip/samx7x/dcd_samx7x.c \
+ $(SDK_DIR)/same70b/gcc/gcc/startup_same70q21b.c \
+ $(SDK_DIR)/same70b/gcc/system_same70q21b.c \
+ $(SDK_DIR)/hpl/core/hpl_init.c \
+ $(SDK_DIR)/hpl/usart/hpl_usart.c \
+ $(SDK_DIR)/hpl/pmc/hpl_pmc.c \
+ $(SDK_DIR)/hal/src/hal_usart_async.c \
+ $(SDK_DIR)/hal/src/hal_io.c \
+ $(SDK_DIR)/hal/src/hal_atomic.c \
+ $(SDK_DIR)/hal/utils/src/utils_ringbuffer.c
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(SDK_DIR) \
+ $(TOP)/$(SDK_DIR)/config \
+ $(TOP)/$(SDK_DIR)/same70b/include \
+ $(TOP)/$(SDK_DIR)/hal/include \
+ $(TOP)/$(SDK_DIR)/hal/utils/include \
+ $(TOP)/$(SDK_DIR)/hpl/core \
+ $(TOP)/$(SDK_DIR)/hpl/pio \
+ $(TOP)/$(SDK_DIR)/hpl/pmc \
+ $(TOP)/$(SDK_DIR)/hri \
+ $(TOP)/$(SDK_DIR)/CMSIS/Core/Include
+
+# For freeRTOS port source
+FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM7
+
+# For flash-jlink target
+flash: $(BUILD)/$(PROJECT).bin
+ edbg --verbose -t same70 -pv -f $<
diff --git a/hw/bsp/samg/family.c b/hw/bsp/samg/family.c
index 8db429e79..234dc0ec0 100644
--- a/hw/bsp/samg/family.c
+++ b/hw/bsp/samg/family.c
@@ -154,6 +154,7 @@ uint32_t board_millis(void) {
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
+void _init(void);
void _init(void) {
}
diff --git a/hw/bsp/samg/family.cmake b/hw/bsp/samg/family.cmake
index eb00c8c52..c07e20b90 100644
--- a/hw/bsp/samg/family.cmake
+++ b/hw/bsp/samg/family.cmake
@@ -14,29 +14,22 @@ set(FAMILY_MCUS SAMG CACHE INTERNAL "")
set(OPENOCD_OPTION "-f board/atmel_samg55_xplained_pro.cfg")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/${SAM_FAMILY}/gcc/gcc/startup_${SAM_FAMILY}.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/${SAM_FAMILY}/gcc/gcc/startup_${SAM_FAMILY}.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/${SAM_FAMILY}/gcc/system_${SAM_FAMILY}.c
${SDK_DIR}/hal/src/hal_atomic.c
${SDK_DIR}/hpl/core/hpl_init.c
${SDK_DIR}/hpl/usart/hpl_usart.c
${SDK_DIR}/hpl/pmc/hpl_pmc.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -51,59 +44,47 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/hri
${SDK_DIR}/CMSIS/Core/Include
)
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- )
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_SAMG)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/microchip/samg/dcd_samg.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_SAMG)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/microchip/samg/dcd_samg.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/saml2x/family.c b/hw/bsp/saml2x/family.c
deleted file mode 100644
index cdc65baf1..000000000
--- a/hw/bsp/saml2x/family.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.
- */
-
-/* metadata:
- manufacturer: Microchip
-*/
-
-#include "sam.h"
-
-// Suppress warning caused by mcu driver
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
-#include "hal/include/hal_gpio.h"
-#include "hal/include/hal_init.h"
-#include "hpl/gclk/hpl_gclk_base.h"
-#include "hpl_mclk_config.h"
-
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif
-
-#include "bsp/board_api.h"
-#include "board.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/hw/bsp/saml2x/family.cmake b/hw/bsp/saml2x/family.cmake
deleted file mode 100644
index 49f2e3e75..000000000
--- a/hw/bsp/saml2x/family.cmake
+++ /dev/null
@@ -1,115 +0,0 @@
-include_guard()
-
-# include board specific
-include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
-
-set(SDK_DIR ${TOP}/hw/mcu/microchip/${SAM_FAMILY})
-set(CMSIS_5 ${TOP}/lib/CMSIS_5)
-
-# toolchain set up
-set(CMAKE_SYSTEM_CPU cortex-m0plus CACHE INTERNAL "System Processor")
-set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
-
-set(FAMILY_MCUS SAML21 SAML22 CACHE INTERNAL "")
-set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -f target/at91samdXX.cfg")
-
-#------------------------------------
-# BOARD_TARGET
-#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
-
- add_library(${BOARD_TARGET} STATIC
- ${SDK_DIR}/gcc/system_${SAM_FAMILY}.c
- ${SDK_DIR}/hal/src/hal_atomic.c
- ${SDK_DIR}/hpl/gclk/hpl_gclk.c
- ${SDK_DIR}/hpl/mclk/hpl_mclk.c
- ${SDK_DIR}/hpl/osc32kctrl/hpl_osc32kctrl.c
- ${SDK_DIR}/hpl/oscctrl/hpl_oscctrl.c
- ${SDK_DIR}/hpl/pm/hpl_pm.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}
- ${SDK_DIR}/config
- ${SDK_DIR}/include
- ${SDK_DIR}/hal/include
- ${SDK_DIR}/hal/utils/include
- ${SDK_DIR}/hpl/pm
- ${SDK_DIR}/hpl/port
- ${SDK_DIR}/hri
- ${CMSIS_5}/CMSIS/Core/Include
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- CONF_OSC32K_CALIB_ENABLE=0
- CFG_EXAMPLE_VIDEO_READONLY
- )
-
- update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
-endfunction()
-
-
-#------------------------------------
-# Functions
-#------------------------------------
-function(family_configure_example TARGET RTOS)
- family_configure_common(${TARGET} ${RTOS})
-
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
- target_sources(${TARGET} PUBLIC
- # BSP
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
- )
- target_include_directories(${TARGET} PUBLIC
- # family, hw, board
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
- )
-
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_SAML22)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/microchip/samd/dcd_samd.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
-
-
- # Flashing
- family_add_bin_hex(${TARGET})
- family_flash_jlink(${TARGET})
- #family_flash_openocd(${TARGET})
-endfunction()
diff --git a/hw/bsp/saml2x/family.mk b/hw/bsp/saml2x/family.mk
deleted file mode 100644
index 65dfe5032..000000000
--- a/hw/bsp/saml2x/family.mk
+++ /dev/null
@@ -1,53 +0,0 @@
-UF2_FAMILY_ID = 0x68ed2b88
-SDK_DIR = hw/mcu/microchip/$(SAM_FAMILY)
-
-include $(TOP)/$(BOARD_PATH)/board.mk
-CPU_CORE ?= cortex-m0plus
-
-CFLAGS += \
- -flto \
- -DCONF_OSC32K_CALIB_ENABLE=0 \
- -DCFG_TUSB_MCU=OPT_MCU_SAML22 \
- -DCFG_EXAMPLE_VIDEO_READONLY \
-
-# suppress warning caused by vendor mcu driver
-CFLAGS += -Wno-error=redundant-decls
-
-# SAM driver is flooded with -Wcast-qual which slow down complication significantly
-CFLAGS_SKIP += -Wcast-qual
-
-LDFLAGS_GCC += \
- -nostdlib -nostartfiles \
- --specs=nosys.specs --specs=nano.specs \
-
-SRC_C += \
- src/portable/microchip/samd/dcd_samd.c \
- $(SDK_DIR)/gcc/gcc/startup_$(SAM_FAMILY).c \
- $(SDK_DIR)/gcc/system_$(SAM_FAMILY).c \
- $(SDK_DIR)/hal/src/hal_atomic.c \
- $(SDK_DIR)/hpl/gclk/hpl_gclk.c \
- $(SDK_DIR)/hpl/mclk/hpl_mclk.c \
- $(SDK_DIR)/hpl/osc32kctrl/hpl_osc32kctrl.c \
- $(SDK_DIR)/hpl/oscctrl/hpl_oscctrl.c \
- $(SDK_DIR)/hpl/pm/hpl_pm.c \
-
-INC += \
- $(TOP)/$(BOARD_PATH) \
- $(TOP)/${SDK_DIR} \
- $(TOP)/${SDK_DIR}/config \
- $(TOP)/${SDK_DIR}/include \
- $(TOP)/${SDK_DIR}/hal/include \
- $(TOP)/${SDK_DIR}/hal/utils/include \
- $(TOP)/${SDK_DIR}/hpl/pm/ \
- $(TOP)/${SDK_DIR}/hpl/port \
- $(TOP)/${SDK_DIR}/hri \
- $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
-
-# 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/hw/bsp/stm32c0/family.cmake b/hw/bsp/stm32c0/family.cmake
index c6a90fff6..90d5322b7 100644
--- a/hw/bsp/stm32c0/family.cmake
+++ b/hw/bsp/stm32c0/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32C0 CACHE INTERNAL "")
set(OPENOCD_OPTION "-f interface/stlink.cfg -f target/stm32c0x.cfg")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -46,7 +42,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_dma.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -59,56 +54,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32C0)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${TOP}/src/portable/st/typec/typec_stm32.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32C0)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- ${TOP}/src/portable/st/typec/typec_stm32.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32f0/family.cmake b/hw/bsp/stm32f0/family.cmake
index 12c7b592c..ee73ae872 100644
--- a/hw/bsp/stm32f0/family.cmake
+++ b/hw/bsp/stm32f0/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32F0 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -43,7 +39,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -57,55 +52,49 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32F0)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32F0)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32f1/family.cmake b/hw/bsp/stm32f1/family.cmake
index cbb9c3568..064f32096 100644
--- a/hw/bsp/stm32f1/family.cmake
+++ b/hw/bsp/stm32f1/family.cmake
@@ -18,24 +18,20 @@ set(FAMILY_MCUS STM32F1 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
-#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
# Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_IAR)
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
- endif ()
+#------------------------------------
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED LD_FILE_IAR)
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+endif ()
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -44,7 +40,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -52,59 +47,51 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
- #target_compile_options(${BOARD_TARGET} PUBLIC)
- #target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32F1)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32F1)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32f2/family.cmake b/hw/bsp/stm32f2/family.cmake
index dc6bc2885..7152a0679 100644
--- a/hw/bsp/stm32f2/family.cmake
+++ b/hw/bsp/stm32f2/family.cmake
@@ -18,24 +18,20 @@ set(FAMILY_MCUS STM32F2 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if (NOT DEFINED LD_FILE_IAR)
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
- endif ()
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED LD_FILE_IAR)
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+endif ()
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -44,7 +40,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -52,61 +47,53 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
- #target_compile_options(${BOARD_TARGET} PUBLIC)
- #target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32F2)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32F2)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32f3/family.cmake b/hw/bsp/stm32f3/family.cmake
index 0ba2920d5..7c9e97e62 100644
--- a/hw/bsp/stm32f3/family.cmake
+++ b/hw/bsp/stm32f3/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32F3 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -42,7 +38,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -54,55 +49,49 @@ function(add_board_target BOARD_TARGET)
#target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32F3)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32F3)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32f4/family.c b/hw/bsp/stm32f4/family.c
index 260927903..6e02b0575 100644
--- a/hw/bsp/stm32f4/family.c
+++ b/hw/bsp/stm32f4/family.c
@@ -54,7 +54,7 @@ void OTG_HS_IRQHandler(void) {
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
#ifdef UART_DEV
-UART_HandleTypeDef UartHandle = {
+static UART_HandleTypeDef UartHandle = {
.Instance = UART_DEV,
.Init = {
.BaudRate = CFG_BOARD_UART_BAUDRATE,
diff --git a/hw/bsp/stm32f4/family.cmake b/hw/bsp/stm32f4/family.cmake
index db5736192..0d3d9ec93 100644
--- a/hw/bsp/stm32f4/family.cmake
+++ b/hw/bsp/stm32f4/family.cmake
@@ -40,22 +40,18 @@ endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -66,7 +62,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -82,57 +77,51 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32F4)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32F4)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c
index bf2d28e42..38dfaa3bc 100644
--- a/hw/bsp/stm32f7/family.c
+++ b/hw/bsp/stm32f7/family.c
@@ -46,7 +46,7 @@ typedef struct {
//--------------------------------------------------------------------+
#ifdef UART_DEV
-UART_HandleTypeDef UartHandle = {
+static UART_HandleTypeDef UartHandle = {
.Instance = UART_DEV,
.Init = {
.BaudRate = CFG_BOARD_UART_BAUDRATE,
diff --git a/hw/bsp/stm32f7/family.cmake b/hw/bsp/stm32f7/family.cmake
index 1a3365332..d405753d4 100644
--- a/hw/bsp/stm32f7/family.cmake
+++ b/hw/bsp/stm32f7/family.cmake
@@ -40,22 +40,18 @@ endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -68,7 +64,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -84,57 +79,51 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32F7)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32F7)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32g0/family.cmake b/hw/bsp/stm32g0/family.cmake
index 4da26f27e..572f0e644 100644
--- a/hw/bsp/stm32g0/family.cmake
+++ b/hw/bsp/stm32g0/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32G0 CACHE INTERNAL "")
set(OPENOCD_OPTION "-f interface/stlink.cfg -f target/stm32g0x.cfg")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -46,7 +42,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_dma.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -54,60 +49,52 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
-# target_compile_options(${BOARD_TARGET} PUBLIC)
-# target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32G0)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${TOP}/src/portable/st/typec/typec_stm32.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32G0)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- ${TOP}/src/portable/st/typec/typec_stm32.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32g4/family.cmake b/hw/bsp/stm32g4/family.cmake
index 5ec9926fe..7e8b319b8 100644
--- a/hw/bsp/stm32g4/family.cmake
+++ b/hw/bsp/stm32g4/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32G4 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -44,7 +40,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -54,56 +49,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32G4)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${TOP}/src/portable/st/typec/typec_stm32.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32G4)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- ${TOP}/src/portable/st/typec/typec_stm32.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32h5/family.cmake b/hw/bsp/stm32h5/family.cmake
index 1df6bcb90..6e63c4072 100644
--- a/hw/bsp/stm32h5/family.cmake
+++ b/hw/bsp/stm32h5/family.cmake
@@ -18,24 +18,20 @@ set(FAMILY_MCUS STM32H5 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif ()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- string(REPLACE "stm32h" "STM32H" MCU_VARIANT_UPPER ${MCU_VARIANT})
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+string(REPLACE "stm32h" "STM32H" MCU_VARIANT_UPPER ${MCU_VARIANT})
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -48,7 +44,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_dma.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -58,56 +53,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32H5)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${TOP}/src/portable/st/typec/typec_stm32.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32H5)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- ${TOP}/src/portable/st/typec/typec_stm32.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32h7/boards/stm32h743eval/board.cmake b/hw/bsp/stm32h7/boards/stm32h743eval/board.cmake
index 02c6bf5fa..78a821298 100644
--- a/hw/bsp/stm32h7/boards/stm32h743eval/board.cmake
+++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.cmake
@@ -15,7 +15,7 @@ if (NOT DEFINED RHPORT_HOST)
endif()
function(update_board TARGET)
- target_sources(${TARGET} PUBLIC
+ target_sources(${TARGET} PRIVATE
${ST_MFXSTM32L152}/mfxstm32l152.c
${ST_MFXSTM32L152}/mfxstm32l152_reg.c
)
diff --git a/hw/bsp/stm32h7/boards/stm32h743eval/board.h b/hw/bsp/stm32h7/boards/stm32h743eval/board.h
index 7c3f6414a..96bfc24e1 100644
--- a/hw/bsp/stm32h7/boards/stm32h743eval/board.h
+++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.h
@@ -61,7 +61,7 @@ static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_4, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
- .active_state = 1
+ .active_state = 0
},
{ // Button
.port = GPIOC,
@@ -214,6 +214,10 @@ static int32_t i2c_writereg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint
return 0;
}
+static int32_t i2c_get_tick(void) {
+ return (int32_t) HAL_GetTick();
+}
+
static inline void board_init2(void) {
// IO control via MFX
MFXSTM32L152_IO_t io_ctx;
@@ -221,7 +225,7 @@ static inline void board_init2(void) {
io_ctx.DeInit = board_i2c_deinit;
io_ctx.ReadReg = i2c_readreg;
io_ctx.WriteReg = i2c_writereg;
- io_ctx.GetTick = (MFXSTM32L152_GetTick_Func) HAL_GetTick;
+ io_ctx.GetTick = i2c_get_tick;
uint16_t i2c_addr[] = { 0x84, 0x86 };
for(uint8_t i = 0U; i < 2U; i++) {
diff --git a/hw/bsp/stm32h7/family.c b/hw/bsp/stm32h7/family.c
index 382b878b7..7b618b2e4 100644
--- a/hw/bsp/stm32h7/family.c
+++ b/hw/bsp/stm32h7/family.c
@@ -49,7 +49,7 @@ typedef struct {
//--------------------------------------------------------------------+
#ifdef UART_DEV
-UART_HandleTypeDef UartHandle = {
+static UART_HandleTypeDef UartHandle = {
.Instance = UART_DEV,
.Init = {
.BaudRate = CFG_BOARD_UART_BAUDRATE,
@@ -127,11 +127,11 @@ void board_init(void) {
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
- SysTick_Config(SystemCoreClock / 1000);
+ SysTick_Config(SystemCoreClock / 1000u);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
// Explicitly disable systick to prevent its ISR runs before scheduler start
- SysTick->CTRL &= ~1U;
+ SysTick->CTRL &= ~1UL;
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
#ifdef USB_OTG_FS_PERIPH_BASE
diff --git a/hw/bsp/stm32h7/family.cmake b/hw/bsp/stm32h7/family.cmake
index b4f0bebbf..8b6086356 100644
--- a/hw/bsp/stm32h7/family.cmake
+++ b/hw/bsp/stm32h7/family.cmake
@@ -41,24 +41,22 @@ endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if(NOT DEFINED LD_FILE_IAR)
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
- endif()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if(NOT DEFINED LD_FILE_IAR)
+ set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+endif()
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+# only need to be built ONCE for all examples
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -73,7 +71,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -89,57 +86,43 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32H7)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32H7)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC "LINKER:--script=${LD_FILE_GNU}")
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC -nostartfiles --specs=nosys.specs --specs=nano.specs)
+ endif ()
+
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC "LINKER:--config=${LD_FILE_IAR}")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.cmake b/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.cmake
index aae820aee..7b3456585 100644
--- a/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.cmake
+++ b/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.cmake
@@ -1,5 +1,5 @@
set(MCU_VARIANT stm32h7s3xx)
-set(JLINK_DEVICE stm32h7s3xx)
+set(JLINK_DEVICE stm32h7s3l8)
set(LD_FILE_Clang ${LD_FILE_GNU})
diff --git a/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.mk b/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.mk
index 47055a108..40b15bc0e 100644
--- a/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.mk
+++ b/hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.mk
@@ -2,7 +2,7 @@ MCU_VARIANT = stm32h7s3xx
CFLAGS += -DSTM32H7S3xx
# For flash-jlink target
-JLINK_DEVICE = stm32h7s3xx
+JLINK_DEVICE = stm32h7s3l8
# flash target using on-board stlink
flash: flash-stlink
diff --git a/hw/bsp/stm32h7rs/family.c b/hw/bsp/stm32h7rs/family.c
index 80ac81125..6192f7a40 100644
--- a/hw/bsp/stm32h7rs/family.c
+++ b/hw/bsp/stm32h7rs/family.c
@@ -49,7 +49,7 @@ typedef struct {
//--------------------------------------------------------------------+
#ifdef UART_DEV
-UART_HandleTypeDef UartHandle = {
+static UART_HandleTypeDef UartHandle = {
.Instance = UART_DEV,
.Init = {
.BaudRate = CFG_BOARD_UART_BAUDRATE,
diff --git a/hw/bsp/stm32h7rs/family.cmake b/hw/bsp/stm32h7rs/family.cmake
index 40230ef12..1fd1cb057 100644
--- a/hw/bsp/stm32h7rs/family.cmake
+++ b/hw/bsp/stm32h7rs/family.cmake
@@ -40,27 +40,23 @@ endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- if(NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT}_flash.ld)
- endif()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if(NOT DEFINED LD_FILE_IAR)
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
- endif()
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+if(NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_flash.ld)
+endif()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if(NOT DEFINED LD_FILE_IAR)
+ set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+endif()
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -74,7 +70,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -92,56 +87,52 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32H7RS ${RTOS})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32H7RS ${RTOS})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32h7rs/family.mk b/hw/bsp/stm32h7rs/family.mk
index fba38448d..7082cc900 100644
--- a/hw/bsp/stm32h7rs/family.mk
+++ b/hw/bsp/stm32h7rs/family.mk
@@ -43,7 +43,7 @@ CFLAGS += \
-DBOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED} \
-DBOARD_TUH_RHPORT=${RHPORT_HOST} \
-DBOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED} \
- -DSEGGER_RTT_SECTION="noncacheable_buffer" \
+ -DSEGGER_RTT_SECTION="\"noncacheable_buffer\"" \
-DBUFFER_SIZE_UP=0x300 \
# GCC Flags
diff --git a/hw/bsp/stm32l0/family.cmake b/hw/bsp/stm32l0/family.cmake
index 954bdb158..b6b0139a0 100644
--- a/hw/bsp/stm32l0/family.cmake
+++ b/hw/bsp/stm32l0/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32L0 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -43,7 +39,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -58,55 +53,49 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32L0)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32L0)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32l4/boards/stm32l496nucleo/STM32L496ZGTX_FLASH.ld b/hw/bsp/stm32l4/boards/stm32l496nucleo/STM32L496ZGTX_FLASH.ld
new file mode 100644
index 000000000..fcd5daee3
--- /dev/null
+++ b/hw/bsp/stm32l4/boards/stm32l496nucleo/STM32L496ZGTX_FLASH.ld
@@ -0,0 +1,208 @@
+/*
+******************************************************************************
+**
+** @file : LinkerScript.ld
+**
+** @author : Auto-generated by STM32CubeIDE
+**
+** Abstract : Linker script for NUCLEO-L496ZG Board embedding STM32L496ZGTx Device from stm32l4 series
+** 1024Kbytes ROM
+** 256Kbytes RAM
+** 64Kbytes SRAM2
+**
+** 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) 2022 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)
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+ SRAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
+ ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+/* 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 */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> ROM
+
+ _sisram2 = LOADADDR(.sram2);
+
+ /* SRAM2 section
+ *
+ * IMPORTANT NOTE!
+ * If initialized variables will be placed in this section,
+ * the startup code needs to be modified to copy the init-values.
+ */
+ .sram2 :
+ {
+ . = ALIGN(4);
+ _ssram2 = .; /* create a global symbol at sram2 start */
+ *(.sram2)
+ *(.sram2*)
+
+ . = ALIGN(4);
+ _esram2 = .; /* create a global symbol at sram2 end */
+ } >SRAM2 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/hw/bsp/stm32l4/boards/stm32l496nucleo/board.cmake b/hw/bsp/stm32l4/boards/stm32l496nucleo/board.cmake
new file mode 100644
index 000000000..bfa8261b9
--- /dev/null
+++ b/hw/bsp/stm32l4/boards/stm32l496nucleo/board.cmake
@@ -0,0 +1,10 @@
+set(MCU_VARIANT stm32l496xx)
+set(JLINK_DEVICE stm32l496zg)
+
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32L496ZGTX_FLASH.ld)
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ STM32L496xx
+ )
+endfunction()
diff --git a/hw/bsp/stm32l4/boards/stm32l496nucleo/board.h b/hw/bsp/stm32l4/boards/stm32l496nucleo/board.h
new file mode 100644
index 000000000..607210cec
--- /dev/null
+++ b/hw/bsp/stm32l4/boards/stm32l496nucleo/board.h
@@ -0,0 +1,158 @@
+/*
+ * 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.
+ */
+
+/* metadata:
+ name: STM32 L496 Nucleo
+ url: https://www.st.com/en/evaluation-tools/nucleo-l496ZG-P.html
+*/
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#define LED_PORT GPIOB
+#define LED_PIN GPIO_PIN_7
+#define LED_STATE_ON 1
+
+// Not a real button
+#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) = 80000000
+ * HCLK(Hz) = 80000000
+ * AHB Prescaler = 1
+ * APB1 Prescaler = 1
+ * APB2 Prescaler = 1
+ * MSI Frequency(Hz) = 8000000
+ * PLL_M = 1
+ * PLL_N = 10
+ * PLL_Q = 2
+ * PLL_R = 2
+ * VDD(V) = 3.3
+ * @param None
+ * @retval None
+ */
+
+static inline void board_clock_init(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+
+ /** Configure the main internal regulator output voltage
+ */
+ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /** Configure LSE Drive Capability
+ */
+ HAL_PWR_EnableBkUpAccess();
+ __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
+
+ /** Initializes the RCC Oscillators according to the specified parameters
+ * in the RCC_OscInitTypeDef structure.
+ */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI;
+ RCC_OscInitStruct.HSIState = RCC_HSI_ON;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
+ RCC_OscInitStruct.PLL.PLLM = 1;
+ RCC_OscInitStruct.PLL.PLLN = 10;
+ 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 buses 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_4);
+
+ // /** Enable the SYSCFG APB clock
+ // */
+ // __HAL_RCC_CRS_CLK_ENABLE();
+ //
+ // /** Configures CRS
+ // */
+ // RCC_CRSInitTypeDef RCC_CRSInitStruct = {0};
+ // RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
+ // RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
+ // RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
+ // RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000,1000);
+ // RCC_CRSInitStruct.ErrorLimitValue = 34;
+ // RCC_CRSInitStruct.HSI48CalibrationValue = 32;
+ //
+ // HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
+
+ /* Select HSI48 output as USB clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ /* Select PLL output as UART clock source */
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
+ PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+}
+
+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/hw/bsp/stm32l4/boards/stm32l496nucleo/board.mk b/hw/bsp/stm32l4/boards/stm32l496nucleo/board.mk
new file mode 100644
index 000000000..bc0a63c1c
--- /dev/null
+++ b/hw/bsp/stm32l4/boards/stm32l496nucleo/board.mk
@@ -0,0 +1,13 @@
+CFLAGS += \
+ -DSTM32L496xx \
+
+# GCC
+SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l496xx.s
+LD_FILE_GCC = $(BOARD_PATH)/STM32L496ZGTX_FLASH.ld
+
+# IAR
+SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_stm32l496xx.s
+LD_FILE_IAR = $(ST_CMSIS)/Source/Templates/iar/linker/stm32l496xx_flash.icf
+
+# For flash-jlink target
+JLINK_DEVICE = stm32l496zg
diff --git a/hw/bsp/stm32l4/family.c b/hw/bsp/stm32l4/family.c
index 5c6ba5c61..114a6a483 100644
--- a/hw/bsp/stm32l4/family.c
+++ b/hw/bsp/stm32l4/family.c
@@ -145,7 +145,7 @@ void board_init(void) {
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.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
#if defined(USB_OTG_FS)
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
#else
diff --git a/hw/bsp/stm32l4/family.cmake b/hw/bsp/stm32l4/family.cmake
index eebcff4f3..5bc28dd5d 100644
--- a/hw/bsp/stm32l4/family.cmake
+++ b/hw/bsp/stm32l4/family.cmake
@@ -18,22 +18,18 @@ set(FAMILY_MCUS STM32L4 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -46,7 +42,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -54,62 +49,54 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
-# target_compile_options(${BOARD_TARGET} PUBLIC)
-# target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${FAMILY_MCUS})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${FAMILY_MCUS})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32n6/boards/stm32n6570dk/board.h b/hw/bsp/stm32n6/boards/stm32n6570dk/board.h
index a3d945f76..bbcad6340 100644
--- a/hw/bsp/stm32n6/boards/stm32n6570dk/board.h
+++ b/hw/bsp/stm32n6/boards/stm32n6570dk/board.h
@@ -97,7 +97,7 @@ static board_pindef_t board_pindef[] = {
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
-void SystemClock_Config(void) {
+static void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/* Configure the power domain */
@@ -214,7 +214,7 @@ static I2C_HandleTypeDef i2c_handle = {
}};
static TCPP0203_Object_t tcpp0203_obj = {0};
-int32_t board_tcpp0203_init(void) {
+static int32_t board_tcpp0203_init(void) {
board_pindef_t *pindef = &board_pindef[PINID_TCPP0203_EN];
HAL_GPIO_WritePin(pindef->port, pindef->pin_init.Pin, GPIO_PIN_SET);
@@ -231,16 +231,16 @@ int32_t board_tcpp0203_init(void) {
return 0;
}
-int32_t board_tcpp0203_deinit(void) {
+static int32_t board_tcpp0203_deinit(void) {
return 0;
}
-int32_t i2c_readreg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) {
+static int32_t i2c_readreg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) {
TU_ASSERT(HAL_OK == HAL_I2C_Mem_Read(&i2c_handle, DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length, 10000));
return 0;
}
-int32_t i2c_writereg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) {
+static int32_t i2c_writereg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) {
TU_ASSERT(HAL_OK == HAL_I2C_Mem_Write(&i2c_handle, DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length, 10000));
return 0;
}
diff --git a/hw/bsp/stm32n6/boards/stm32n657nucleo/board.h b/hw/bsp/stm32n6/boards/stm32n657nucleo/board.h
index 963ecad61..33c68f7cf 100644
--- a/hw/bsp/stm32n6/boards/stm32n657nucleo/board.h
+++ b/hw/bsp/stm32n6/boards/stm32n657nucleo/board.h
@@ -97,7 +97,7 @@ static board_pindef_t board_pindef[] = {
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
-void SystemClock_Config(void) {
+static void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/* Configure the power domain */
diff --git a/hw/bsp/stm32n6/family.c b/hw/bsp/stm32n6/family.c
index 1d0616d8e..58be4867d 100644
--- a/hw/bsp/stm32n6/family.c
+++ b/hw/bsp/stm32n6/family.c
@@ -62,7 +62,7 @@ typedef struct {
//--------------------------------------------------------------------+
#ifdef UART_DEV
-UART_HandleTypeDef UartHandle = {
+static UART_HandleTypeDef UartHandle = {
.Instance = UART_DEV,
.Init = {
.BaudRate = CFG_BOARD_UART_BAUDRATE,
diff --git a/hw/bsp/stm32n6/family.cmake b/hw/bsp/stm32n6/family.cmake
index 89e4989ad..6c7aaea61 100644
--- a/hw/bsp/stm32n6/family.cmake
+++ b/hw/bsp/stm32n6/family.cmake
@@ -38,27 +38,23 @@ endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- if(NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/${MCU_VARIANT}_axisram2_fsbl.ld)
- endif()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- if(NOT DEFINED LD_FILE_IAR)
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_axisram2_fsbl.icf)
- endif()
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+if(NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/${MCU_VARIANT}_axisram2_fsbl.ld)
+endif()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if(NOT DEFINED LD_FILE_IAR)
+ set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_axisram2_fsbl.icf)
+endif()
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}_fsbl.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -72,11 +68,10 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${CMSIS_5}/CMSIS/Core/Include
+ ${TOP}/lib/CMSIS_6/CMSIS/Core/Include
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
@@ -90,56 +85,53 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32N6 ${RTOS})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32N6 ${RTOS})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32n6/family.mk b/hw/bsp/stm32n6/family.mk
index 37087ed42..45554e251 100644
--- a/hw/bsp/stm32n6/family.mk
+++ b/hw/bsp/stm32n6/family.mk
@@ -76,7 +76,7 @@ SRC_C += \
INC += \
$(TOP)/$(BOARD_PATH) \
- $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
+ $(TOP)/lib/CMSIS_6/CMSIS/Core/Include \
$(TOP)/$(ST_CMSIS)/Include \
$(TOP)/$(ST_HAL_DRIVER)/Inc
diff --git a/hw/bsp/stm32u0/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32u0/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..b63275276
--- /dev/null
+++ b/hw/bsp/stm32u0/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "stm32u0xx.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 0
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 200 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS 2
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
+
+/* Interrupt priorities used by the kernel port layer itself. These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#endif
diff --git a/hw/bsp/stm32u0/boards/stm32u083cdk/STM32U083MCTx_FLASH.ld b/hw/bsp/stm32u0/boards/stm32u083cdk/STM32U083MCTx_FLASH.ld
new file mode 100644
index 000000000..c5ea72fb0
--- /dev/null
+++ b/hw/bsp/stm32u0/boards/stm32u083cdk/STM32U083MCTx_FLASH.ld
@@ -0,0 +1,176 @@
+/**
+ ******************************************************************************
+ * @file LinkerScript.ld
+ * @author Auto-generated by STM32CubeIDE
+ * @brief Linker script for STM32U083MCTx Device from STM32U0 series
+ * 256KBytes FLASH
+ * 40KBytes 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
+ *
+ * Copyright (c) 2023 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)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
+}
+
+/* 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 = 0x800; /* required amount of stack */
+
+/* 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/hw/bsp/stm32u0/boards/stm32u083cdk/board.cmake b/hw/bsp/stm32u0/boards/stm32u083cdk/board.cmake
new file mode 100644
index 000000000..945146810
--- /dev/null
+++ b/hw/bsp/stm32u0/boards/stm32u083cdk/board.cmake
@@ -0,0 +1,12 @@
+set(MCU_VARIANT stm32u083xx)
+set(JLINK_DEVICE stm32u083mc)
+
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32U083MCTx_FLASH.ld)
+set(LD_FILE_IAR ${CMAKE_CURRENT_LIST_DIR}/stm32u083xx_flash.icf)
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ STM32U083xx
+ CFG_EXAMPLE_VIDEO_READONLY
+ )
+endfunction()
diff --git a/hw/bsp/stm32u0/boards/stm32u083cdk/board.h b/hw/bsp/stm32u0/boards/stm32u083cdk/board.h
new file mode 100644
index 000000000..3030b1a1d
--- /dev/null
+++ b/hw/bsp/stm32u0/boards/stm32u083cdk/board.h
@@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+
+/* metadata:
+ name: STM32U083C-DK Discovery Kit
+ url: https://www.st.com/en/evaluation-tools/stm32u083c-dk.html
+*/
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED - using PA5 (Blue LED from CubeMX)
+#define LED_PORT GPIOA
+#define LED_PIN GPIO_PIN_5
+#define LED_STATE_ON 1
+
+// Button - using PC2 (from CubeMX generated code)
+#define BUTTON_PORT GPIOC
+#define BUTTON_PIN GPIO_PIN_2
+#define BUTTON_STATE_ACTIVE 0 // Active low (pressed = 0)
+
+// UART - using USART2 on PA2/PA3 (VCP TX/RX from CubeMX)
+#define UART_DEV USART2
+#define UART_CLK_EN __HAL_RCC_USART2_CLK_ENABLE
+#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_stm32u0_clock_init(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_CRSInitTypeDef RCC_CRSInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
+
+ /** Configure the main internal regulator output voltage
+ */
+ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
+
+ /** Initializes the RCC Oscillators according to the specified parameters
+ * in the RCC_OscInitTypeDef structure.
+ */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI48;
+ RCC_OscInitStruct.HSIState = RCC_HSI_ON;
+ RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
+ RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
+ RCC_OscInitStruct.PLL.PLLN = 8;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
+ RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;
+ 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);
+
+ /** Enable the CRS clock
+ */
+ __HAL_RCC_CRS_CLK_ENABLE();
+
+ /** Configures CRS
+ */
+ RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
+ RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
+ RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
+ RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000,1000);
+ RCC_CRSInitStruct.ErrorLimitValue = 34;
+ RCC_CRSInitStruct.HSI48CalibrationValue = 32;
+ HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
+
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2;
+ PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
+
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
+}
+
+static inline void board_vbus_sense_init(void)
+{
+ // USB VBUS sensing not required for device-only operation
+}
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/stm32u0/boards/stm32u083cdk/board.mk b/hw/bsp/stm32u0/boards/stm32u083cdk/board.mk
new file mode 100644
index 000000000..892854f54
--- /dev/null
+++ b/hw/bsp/stm32u0/boards/stm32u083cdk/board.mk
@@ -0,0 +1,13 @@
+MCU_VARIANT = stm32u083xx
+CFLAGS += \
+ -DSTM32U083xx
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/STM32U083MCTx_FLASH.ld
+LD_FILE_IAR = $(BOARD_PATH)/stm32u083xx_flash.icf
+
+# For flash-jlink target
+JLINK_DEVICE = STM32U083MC
+
+# flash target using on-board stlink
+flash: flash-stlink
diff --git a/hw/bsp/stm32u0/boards/stm32u083cdk/stm32u083xx_flash.icf b/hw/bsp/stm32u0/boards/stm32u083cdk/stm32u083xx_flash.icf
new file mode 100644
index 000000000..cfaa305af
--- /dev/null
+++ b/hw/bsp/stm32u0/boards/stm32u083cdk/stm32u083xx_flash.icf
@@ -0,0 +1,32 @@
+/*###ICF### Section handled by ICF editor, don't touch! ****/
+/*-Editor annotation file-*/
+/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
+/*-Specials-*/
+define symbol __ICFEDIT_intvec_start__ = 0x08000000;
+/*-Memory Regions-*/
+define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
+define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;
+define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
+define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
+
+/*-Sizes-*/
+define symbol __ICFEDIT_size_cstack__ = 0x800;
+define symbol __ICFEDIT_size_heap__ = 0x200;
+/**** End of ICF editor section. ###ICF###*/
+
+
+define memory mem with size = 4G;
+define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
+define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
+
+define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
+define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
+
+initialize by copy { readwrite };
+do not initialize { section .noinit };
+
+place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
+
+place in ROM_region { readonly };
+place in RAM_region { readwrite,
+ block CSTACK, block HEAP };
diff --git a/hw/bsp/stm32u0/family.c b/hw/bsp/stm32u0/family.c
new file mode 100644
index 000000000..bf2503865
--- /dev/null
+++ b/hw/bsp/stm32u0/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.
+ */
+
+/* metadata:
+ manufacturer: STMicroelectronics
+*/
+
+#include "stm32u0xx_hal.h"
+#include "bsp/board_api.h"
+#include "board.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_DRD_FS_IRQHandler(void) {
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+#ifdef UART_DEV
+UART_HandleTypeDef UartHandle;
+#endif
+
+void board_init(void) {
+ board_stm32u0_clock_init();
+
+ // Enable All GPIOs clocks
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+#ifdef GPIOD
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+#endif
+#ifdef GPIOE
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+#endif
+#ifdef GPIOF
+ __HAL_RCC_GPIOF_CLK_ENABLE();
+#endif
+#ifdef GPIOG
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+#endif
+#ifdef GPIOH
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+#endif
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ // 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 = 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);
+
+ UART_CLK_EN();
+ 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);
+#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_DRD_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#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_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_USB;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ // Enable VDDUSB
+ HAL_PWREx_EnableVddUSB();
+ // USB Clock enable
+ __HAL_RCC_USB_CLK_ENABLE();
+
+ board_vbus_sense_init();
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+ GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1-LED_STATE_ON));
+ HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
+}
+
+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) {
+#ifdef UART_DEV
+ (void) buf; (void) len;
+ return 0;
+#else
+ return 0;
+#endif
+}
+
+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;
+ 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 #0\n");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void) {
+
+}
diff --git a/hw/bsp/stm32u0/family.cmake b/hw/bsp/stm32u0/family.cmake
new file mode 100644
index 000000000..4f9b03109
--- /dev/null
+++ b/hw/bsp/stm32u0/family.cmake
@@ -0,0 +1,106 @@
+include_guard()
+
+set(ST_FAMILY u0)
+set(ST_PREFIX stm32${ST_FAMILY}xx)
+
+set(ST_HAL_DRIVER ${TOP}/hw/mcu/st/stm32${ST_FAMILY}xx_hal_driver)
+set(ST_CMSIS ${TOP}/hw/mcu/st/cmsis-device-${ST_FAMILY})
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# toolchain set up
+set(CMAKE_SYSTEM_CPU cortex-m0plus CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+
+set(FAMILY_MCUS STM32U0 CACHE INTERNAL "")
+
+
+#------------------------------------
+# Startup & Linker script
+#------------------------------------
+string(REPLACE "stm32u" "STM32U" MCU_VARIANT_UPPER ${MCU_VARIANT})
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+if (NOT DEFINED LD_FILE_IAR)
+ set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+endif ()
+
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
+ add_library(${BOARD_TARGET} STATIC
+ ${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_cortex.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr_ex.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
+ ${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMSIS_5}/CMSIS/Core/Include
+ ${ST_CMSIS}/Include
+ ${ST_HAL_DRIVER}/Inc
+ )
+ update_board(${BOARD_TARGET})
+endfunction()
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32U0)
+
+ target_sources(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
+
+ # Flashing
+ family_add_bin_hex(${TARGET})
+ family_flash_stlink(${TARGET})
+ family_flash_jlink(${TARGET})
+endfunction()
diff --git a/hw/bsp/stm32u0/family.mk b/hw/bsp/stm32u0/family.mk
new file mode 100644
index 000000000..d5a850050
--- /dev/null
+++ b/hw/bsp/stm32u0/family.mk
@@ -0,0 +1,50 @@
+ST_FAMILY = u0
+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
+CPU_CORE ?= cortex-m0plus
+
+CFLAGS += \
+ -DCFG_EXAMPLE_MSC_READONLY \
+ -DCFG_EXAMPLE_VIDEO_READONLY \
+ -DCFG_TUSB_MCU=OPT_MCU_STM32U0
+
+# mcu driver cause following warnings
+CFLAGS_GCC += \
+ -flto \
+ -Wno-error=unused-parameter \
+ -Wno-error=redundant-decls \
+ -Wno-error=cast-align \
+ -Wno-error=maybe-uninitialized \
+
+CFLAGS_CLANG += \
+ -Wno-error=parentheses-equality
+
+LDFLAGS_GCC += \
+ -nostdlib -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs
+
+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_pwr_ex.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
+
+# Startup
+SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_${MCU_VARIANT}.s
+SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_${MCU_VARIANT}.s
+
+# Linker
+LD_FILE_IAR ?= $(ST_CMSIS)/Source/Templates/iar/linker/$(MCU_VARIANT)_flash.icf
diff --git a/hw/bsp/stm32u0/stm32u0xx_hal_conf.h b/hw/bsp/stm32u0/stm32u0xx_hal_conf.h
new file mode 100644
index 000000000..ece5baf69
--- /dev/null
+++ b/hw/bsp/stm32u0/stm32u0xx_hal_conf.h
@@ -0,0 +1,337 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file stm32u0xx_hal_conf.h
+ * @author MCD Application Team
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2023 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.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32U0xx_HAL_CONF_H
+#define __STM32U0xx_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_CRS_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_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_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_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 */
+#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
+
+/* ########################## 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 4000000U /*!< 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 Multiple Speed oscillator (MSI) default value.
+ * This value is the default MSI range value after Reset.
+ */
+#if !defined (MSI32_VALUE)
+#define MSI32_VALUE 32000000U /*!< Value of the Internal oscillator in Hz*/
+#endif /* MSI32_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 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/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 /* 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 (3U) /*!< tick interrupt priority (lowest by default) */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 0U
+#define INSTRUCTION_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 */
+
+/* ################## Register callback feature configuration ############### */
+/**
+ * @brief Set below the peripheral configuration to "1U" to add the support
+ * of HAL callback registration/unregistration feature for the HAL
+ * driver(s). This allows user application to provide specific callback
+ * functions thanks to HAL_PPP_RegisterCallback() rather than overwriting
+ * the default weak callback functions (see each stm32u0xx_hal_ppp.h file
+ * for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef
+ * for each PPP peripheral).
+ */
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC 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_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_IWDG_REGISTER_CALLBACKS 0U /* IWDG 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_LCD_REGISTER_CALLBACKS 0U /* LCD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD 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_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD 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 */
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+#include "stm32u0xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+#include "stm32u0xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+#include "stm32u0xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+#include "stm32u0xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+#include "stm32u0xx_hal_adc.h"
+#include "stm32u0xx_hal_adc_ex.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_COMP_MODULE_ENABLED
+#include "stm32u0xx_hal_comp.h"
+#endif /* HAL_COMP_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+#include "stm32u0xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRS_MODULE_ENABLED
+#include "stm32u0xx_ll_crs.h"
+#endif /* HAL_CRS_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+#include "stm32u0xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+#include "stm32u0xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+#include "stm32u0xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+#include "stm32u0xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+#include "stm32u0xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+#include "stm32u0xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+#include "stm32u0xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+#ifdef HAL_LCD_MODULE_ENABLED
+#include "stm32u0xx_hal_lcd.h"
+#endif /* HAL_LCD_MODULE_ENABLED */
+
+#ifdef HAL_OPAMP_MODULE_ENABLED
+#include "stm32u0xx_hal_opamp.h"
+#endif /* HAL_OPAMP_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+#include "stm32u0xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+#include "stm32u0xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+#include "stm32u0xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+#include "stm32u0xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+#include "stm32u0xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_TSC_MODULE_ENABLED
+#include "stm32u0xx_ll_system.h"
+#include "stm32u0xx_hal_tsc.h"
+#endif /* HAL_TSC_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+#include "stm32u0xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+#include "stm32u0xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+#include "stm32u0xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+#include "stm32u0xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+#include "stm32u0xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_LCD_MODULE_ENABLED
+#include "stm32u0xx_hal_lcd.h"
+#endif /* HAL_LCD_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+#include "stm32u0xx_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 /* __STM32U0xx_HAL_CONF_H */
diff --git a/hw/bsp/stm32u5/family.cmake b/hw/bsp/stm32u5/family.cmake
index 7a5935961..70e0c313c 100644
--- a/hw/bsp/stm32u5/family.cmake
+++ b/hw/bsp/stm32u5/family.cmake
@@ -18,26 +18,22 @@ set(FAMILY_MCUS STM32U5 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
-
- string(REPLACE "stm32u" "STM32U" MCU_VARIANT_UPPER ${MCU_VARIANT})
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
- endif ()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+string(REPLACE "stm32u" "STM32U" MCU_VARIANT_UPPER ${MCU_VARIANT})
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
+endif ()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -49,7 +45,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -58,59 +53,52 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Inc
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32U5)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32U5)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- #${TOP}/src/portable/st/typec/typec_stm32.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32wb/family.cmake b/hw/bsp/stm32wb/family.cmake
index 0ea937257..1a96e3d7e 100644
--- a/hw/bsp/stm32wb/family.cmake
+++ b/hw/bsp/stm32wb/family.cmake
@@ -18,25 +18,21 @@ set(FAMILY_MCUS STM32WB CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}_cm4.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}_cm4.s)
-
- if (NOT DEFINED LD_FILE_GNU)
- set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/${MCU_VARIANT}_flash_cm4.ld)
- endif()
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash_cm4.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}_cm4.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}_cm4.s)
+if (NOT DEFINED LD_FILE_GNU)
+set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/${MCU_VARIANT}_flash_cm4.ld)
+endif()
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash_cm4.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -49,7 +45,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -57,59 +52,51 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
-# target_compile_options(${BOARD_TARGET} PUBLIC)
-# target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_${FAMILY_MCUS})
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_${FAMILY_MCUS})
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
diff --git a/hw/bsp/stm32wba/family.cmake b/hw/bsp/stm32wba/family.cmake
index 3f42879be..9628913cc 100644
--- a/hw/bsp/stm32wba/family.cmake
+++ b/hw/bsp/stm32wba/family.cmake
@@ -27,27 +27,23 @@ set(RHPORT_DEVICE_SPEED OPT_MODE_HIGH_SPEED)
set(RHPORT_HOST_SPEED OPT_MODE_HIGH_SPEED)
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- # STM32WBA HAL uses uppercase MCU_VARIANT (excluding the x's) for linking and lowercase MCU_VARIANT for startup.
- string(TOUPPER "${MCU_VARIANT}" UPPERCASE_MCU_VARIANT)
- string(REGEX REPLACE "X" "x" UPPERCASE_MCU_VARIANT "${UPPERCASE_MCU_VARIANT}")
-
- # Startup & Linker script
- set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+# STM32WBA HAL uses uppercase MCU_VARIANT (excluding the x's) for linking and lowercase MCU_VARIANT for startup.
+string(TOUPPER "${MCU_VARIANT}" UPPERCASE_MCU_VARIANT)
+string(REGEX REPLACE "X" "x" UPPERCASE_MCU_VARIANT "${UPPERCASE_MCU_VARIANT}")
- set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${UPPERCASE_MCU_VARIANT}_FLASH_ns.ld)
- set(LD_FILE_Clang ${LD_FILE_GNU})
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash_ns.icf)
+set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/linker/${UPPERCASE_MCU_VARIANT}_FLASH_ns.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash_ns.icf)
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -62,7 +58,6 @@ function(add_board_target BOARD_TARGET)
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pcd.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pcd_ex.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_ll_usb.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -72,60 +67,52 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_Clang}"
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_STM32WBA)
- target_compile_definitions(${TARGET} PUBLIC
- CFG_TUSB_MCU=OPT_MCU_STM32WBA
- )
-
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_STM32WBA)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
+
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/tm4c/family.cmake b/hw/bsp/tm4c/family.cmake
index e1cf94e96..12f0448a3 100644
--- a/hw/bsp/tm4c/family.cmake
+++ b/hw/bsp/tm4c/family.cmake
@@ -15,22 +15,18 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS TM4C123 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/Source/GCC/${MCU_VARIANT}_startup.c)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/Source/GCC/${MCU_VARIANT}_startup.c)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/Source/system_${MCU_VARIANT_UPPER}.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/Include/${MCU_VARIANT_UPPER}
@@ -38,55 +34,47 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs --specs=nano.specs
- -uvectors
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for MSP432E4")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_TM4C123)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ ${TOP}/src/portable/mentor/musb/hcd_musb.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_TM4C123)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/mentor/musb/dcd_musb.c
- ${TOP}/src/portable/mentor/musb/hcd_musb.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/xmc4000/family.cmake b/hw/bsp/xmc4000/family.cmake
index 6edd72caf..a8fa5351c 100644
--- a/hw/bsp/xmc4000/family.cmake
+++ b/hw/bsp/xmc4000/family.cmake
@@ -12,19 +12,16 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS XMC4000 CACHE INTERNAL "")
#------------------------------------
-# BOARD_TARGET
+# Startup & Linker script
#------------------------------------
-# only need to be built ONCE for all examples
-function(add_board_target BOARD_TARGET)
- if (TARGET ${BOARD_TARGET})
- return()
- endif()
-
- set(LD_FILE_Clang ${LD_FILE_GNU})
-
- set(STARTUP_FILE_GNU ${SDK_DIR}/CMSIS/Infineon/COMPONENT_${MCU_VARIANT}/Source/TOOLCHAIN_GCC_ARM/startup_${MCU_VARIANT}.S)
- set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+set(LD_FILE_Clang ${LD_FILE_GNU})
+set(STARTUP_FILE_GNU ${SDK_DIR}/CMSIS/Infineon/COMPONENT_${MCU_VARIANT}/Source/TOOLCHAIN_GCC_ARM/startup_${MCU_VARIANT}.S)
+set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+#------------------------------------
+# Board Target
+#------------------------------------
+function(family_add_board BOARD_TARGET)
add_library(${BOARD_TARGET} STATIC
${SDK_DIR}/CMSIS/Infineon/COMPONENT_${MCU_VARIANT}/Source/system_${MCU_VARIANT}.c
${SDK_DIR}/XMCLib/src/xmc_gpio.c
@@ -32,7 +29,6 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/XMCLib/src/xmc4_scu.c
${SDK_DIR}/XMCLib/src/xmc_usic.c
${SDK_DIR}/XMCLib/src/xmc_uart.c
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/CMSIS/Core/Include
@@ -41,57 +37,50 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- --specs=nosys.specs
- -nostartfiles
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
- message(FATAL_ERROR "Clang is not supported for MSP432E4")
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endfunction()
-
#------------------------------------
# Functions
#------------------------------------
function(family_configure_example TARGET RTOS)
family_configure_common(${TARGET} ${RTOS})
+ family_add_tinyusb(${TARGET} OPT_MCU_XMC4000)
- # Board target
- add_board_target(board_${BOARD})
-
- #---------- Port Specific ----------
- # These files are built for each example since it depends on example's tusb_config.h
target_sources(${TARGET} PUBLIC
- # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
${SDK_DIR}/Newlib/syscalls.c
+ ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
+ ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
)
target_include_directories(${TARGET} PUBLIC
- # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
)
- # Add TinyUSB target and port source
- family_add_tinyusb(${TARGET} OPT_MCU_XMC4000)
- target_sources(${TARGET} PUBLIC
- ${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/hcd_dwc2.c
- ${TOP}/src/portable/synopsys/dwc2/dwc2_common.c
- )
- target_link_libraries(${TARGET} PUBLIC board_${BOARD})
-
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "Clang is not supported")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
+ endif ()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set_source_files_properties(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes")
+ endif ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES
+ SKIP_LINTING ON
+ COMPILE_OPTIONS -w)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/zephyr_board_aliases.cmake b/hw/bsp/zephyr_board_aliases.cmake
index b60e97ef4..a60068208 100644
--- a/hw/bsp/zephyr_board_aliases.cmake
+++ b/hw/bsp/zephyr_board_aliases.cmake
@@ -1,2 +1,2 @@
-set(pca10056_BOARD_ALIAS nrf52840dk/nrf52840)
+set(nrf52840dk_BOARD_ALIAS nrf52840dk/nrf52840)
set(stm32n657nucleo_BOARD_ALIAS nucleo_n657x0_q)