summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-10-24 11:14:07 +0200
committerHiFiPhile <[email protected]>2025-10-24 11:16:07 +0200
commit4dd9122417bfbad51d38e4e6079d1823fdd05f6c (patch)
tree93603dfdb74fbbccbe925b5ac4eaa05e855f7742 /hw
parent190237741879145088535f214e4a1a7f21eff6af (diff)
parentac37176cec68a26a308c67b238cbf8901b3f1f29 (diff)
Merge remote-tracking branch 'upstream/master' into uac1
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'hw')
-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.cmake85
-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.cmake80
-rw-r--r--hw/bsp/at32f413/at32f413_int.h6
-rw-r--r--hw/bsp/at32f413/family.c2
-rw-r--r--hw/bsp/at32f413/family.cmake81
-rw-r--r--hw/bsp/at32f415/at32f415_int.h3
-rw-r--r--hw/bsp/at32f415/family.c2
-rw-r--r--hw/bsp/at32f415/family.cmake85
-rw-r--r--hw/bsp/at32f423/at32f423_int.h5
-rw-r--r--hw/bsp/at32f423/family.c2
-rw-r--r--hw/bsp/at32f423/family.cmake85
-rw-r--r--hw/bsp/at32f425/at32f425_int.h3
-rw-r--r--hw/bsp/at32f425/family.c2
-rw-r--r--hw/bsp/at32f425/family.cmake85
-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.cmake85
-rw-r--r--hw/bsp/board.c8
-rw-r--r--hw/bsp/broadcom_32bit/family.cmake88
-rw-r--r--hw/bsp/broadcom_64bit/family.cmake90
-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.cmake91
-rw-r--r--hw/bsp/ch32v20x/ch32v20x_it.h17
-rw-r--r--hw/bsp/ch32v20x/family.c3
-rw-r--r--hw/bsp/ch32v20x/family.cmake91
-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.cmake78
-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.cmake124
-rw-r--r--hw/bsp/cxd56/family.mk (renamed from hw/bsp/spresense/board.mk)19
-rw-r--r--hw/bsp/da1469x/family.cmake84
-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.cmake89
-rw-r--r--hw/bsp/efm32/family.mk (renamed from hw/bsp/sltb009a/board.mk)23
-rw-r--r--hw/bsp/f1c100s/family.cmake101
-rw-r--r--hw/bsp/family_rules.mk177
-rw-r--r--hw/bsp/family_support.cmake145
-rw-r--r--hw/bsp/family_support.mk173
-rw-r--r--hw/bsp/fomu/family.c1
-rw-r--r--hw/bsp/fomu/family.cmake84
-rw-r--r--hw/bsp/fomu/family.mk2
-rw-r--r--hw/bsp/gd32vf103/family.cmake81
-rw-r--r--hw/bsp/imxrt/family.c1
-rw-r--r--hw/bsp/imxrt/family.cmake97
-rw-r--r--hw/bsp/kinetis_k/family.c1
-rw-r--r--hw/bsp/kinetis_k/family.cmake80
-rw-r--r--hw/bsp/kinetis_k32l2/family.c1
-rw-r--r--hw/bsp/kinetis_k32l2/family.cmake80
-rw-r--r--hw/bsp/kinetis_kl/family.c1
-rw-r--r--hw/bsp/kinetis_kl/family.cmake73
-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.cmake32
-rw-r--r--hw/bsp/lpc18/family.cmake27
-rw-r--r--hw/bsp/lpc40/family.cmake32
-rw-r--r--hw/bsp/lpc43/family.cmake79
-rw-r--r--hw/bsp/lpc51/family.c1
-rw-r--r--hw/bsp/lpc51/family.cmake84
-rw-r--r--hw/bsp/lpc54/family.c1
-rw-r--r--hw/bsp/lpc54/family.cmake90
-rw-r--r--hw/bsp/lpc55/family.c1
-rw-r--r--hw/bsp/lpc55/family.cmake94
-rw-r--r--hw/bsp/maxim/family.c2
-rw-r--r--hw/bsp/maxim/family.cmake81
-rw-r--r--hw/bsp/mcx/family.cmake106
-rw-r--r--hw/bsp/mm32/family.cmake78
-rw-r--r--hw/bsp/msp430/family.c9
-rw-r--r--hw/bsp/msp430/family.cmake40
-rw-r--r--hw/bsp/msp432e4/family.cmake85
-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.cmake146
-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.cmake84
-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.cmake88
-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.cmake91
-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.cmake87
-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/samd11/family.c5
-rw-r--r--hw/bsp/samd11/family.cmake74
-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/metro_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/feather_m0_express/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/feather_m0_express/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/itsybitsy_m0/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/itsybitsy_m0/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/metro_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.cmake146
-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.cmake74
-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.cmake96
-rw-r--r--hw/bsp/same7x/family.mk56
-rw-r--r--hw/bsp/samg/family.c1
-rw-r--r--hw/bsp/samg/family.cmake75
-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.cmake79
-rw-r--r--hw/bsp/stm32f0/family.cmake77
-rw-r--r--hw/bsp/stm32f1/family.cmake83
-rw-r--r--hw/bsp/stm32f2/family.cmake87
-rw-r--r--hw/bsp/stm32f3/family.cmake77
-rw-r--r--hw/bsp/stm32f4/family.cmake81
-rw-r--r--hw/bsp/stm32f7/family.cmake81
-rw-r--r--hw/bsp/stm32g0/family.cmake81
-rw-r--r--hw/bsp/stm32g4/family.cmake79
-rw-r--r--hw/bsp/stm32h5/family.cmake83
-rw-r--r--hw/bsp/stm32h7/boards/stm32h743eval/board.cmake2
-rw-r--r--hw/bsp/stm32h7/boards/stm32h743eval/board.h6
-rw-r--r--hw/bsp/stm32h7/family.c2
-rw-r--r--hw/bsp/stm32h7/family.cmake77
-rw-r--r--hw/bsp/stm32h7rs/family.cmake93
-rw-r--r--hw/bsp/stm32l0/family.cmake77
-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.cmake85
-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.cmake96
-rw-r--r--hw/bsp/stm32n6/family.mk2
-rw-r--r--hw/bsp/stm32u0/family.cmake89
-rw-r--r--hw/bsp/stm32u5/family.cmake92
-rw-r--r--hw/bsp/stm32wb/family.cmake85
-rw-r--r--hw/bsp/stm32wba/family.cmake95
-rw-r--r--hw/bsp/tm4c/family.cmake72
-rw-r--r--hw/bsp/xmc4000/family.cmake73
-rw-r--r--hw/bsp/zephyr_board_aliases.cmake2
289 files changed, 6095 insertions, 4373 deletions
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..113bc0305 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,59 +69,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_${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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..5f539228d 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,57 +46,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_${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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..d62964730 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,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_${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)
# 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..35fad5a87 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,48 @@ 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)
# 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..36c0466de 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,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/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)
# 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..176595e12 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,48 @@ 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)
# 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..bdc7292d5 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,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/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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index e141664da..41e6eb1b8 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
@@ -180,9 +180,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 +201,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 +245,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/broadcom_32bit/family.cmake b/hw/bsp/broadcom_32bit/family.cmake
index 5e57d8b1e..d681e4426 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,61 +44,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}"
- "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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/broadcom_64bit/family.cmake b/hw/bsp/broadcom_64bit/family.cmake
index 1a088c2c0..1be5c95eb 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,63 +49,52 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..843b7f9d3 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,58 @@ 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)
# 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..1ce83bed9 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,54 @@ 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)
# 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..cbf86334e 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,55 +69,47 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_openocd_wch(${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..6cfe04d93
--- /dev/null
+++ b/hw/bsp/cxd56/family.cmake
@@ -0,0 +1,124 @@
+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)
+
+ # 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..473db6531 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,33 +83,41 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink_dialog(${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..36d88f071
--- /dev/null
+++ b/hw/bsp/efm32/family.cmake
@@ -0,0 +1,89 @@
+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)
+ # 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/f1c100s/family.cmake b/hw/bsp/f1c100s/family.cmake
index 211c6645c..78fc3c6c7 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,71 +39,68 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..7df1b154a 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}/../..")
@@ -9,35 +11,63 @@ 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 ()
-
-#-------------------------------------------------------------
# Toolchain
# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER=
#-------------------------------------------------------------
-# 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
+ )
+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)
@@ -48,8 +78,8 @@ endif ()
#-------------------------------------------------------------
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")
+ message(FATAL_ERROR "You must set a BOARD variable for the build (e.g. metro_m4_express, raspberry_pi_pico).
+ You can do this via -DBOARD=xxx on the cmake command line")
endif ()
# Find path contains BOARD
@@ -86,12 +116,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 +205,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 +233,17 @@ 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)
+ set_target_properties(${BOARD_TARGET} PROPERTIES SKIP_LINTING ON)
+ endif ()
+ target_link_libraries(${TARGET} PUBLIC ${BOARD_TARGET})
+ endif ()
+
family_add_rtos(${TARGET} ${RTOS})
# Add BOARD_${BOARD} define
@@ -220,39 +273,16 @@ 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 +290,19 @@ 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")
+
+ # 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/${TARGET}.html
+# )
endif ()
# run size after build
@@ -532,6 +575,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..18290d437 100644
--- a/hw/bsp/fomu/family.cmake
+++ b/hw/bsp/fomu/family.cmake
@@ -10,81 +10,67 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
endfunction()
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..c96882a75 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,25 +76,32 @@ 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 ()
+ set_source_files_properties(${STARTUP_FILE_${CMAKE_C_COMPILER_ID}} PROPERTIES SKIP_LINTING ON)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..7e21dd946 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
@@ -88,9 +84,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,49 +117,22 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..2ec5522d3 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,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}"
- --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)
# 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..022ddb424 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,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}"
- --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)
# 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..2640652ab 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,58 +49,49 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..92bcbff21 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,20 @@ 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/nxp/lpc17_40/hcd_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 +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_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/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..211846444 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,20 @@ 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/nxp/lpc17_40/hcd_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 +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_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/lpc43/family.cmake b/hw/bsp/lpc43/family.cmake
index 23c4aecea..5c68aaebf 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,49 @@ 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)
# 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..9e128ab82 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,58 +58,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}"
- --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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..3b16955da 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,64 +86,48 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/lpc55/family.c b/hw/bsp/lpc55/family.c
index dbf8d71b7..f0ded96a7 100644
--- a/hw/bsp/lpc55/family.c
+++ b/hw/bsp/lpc55/family.c
@@ -333,6 +333,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..6ebda4db9 100644
--- a/hw/bsp/lpc55/family.cmake
+++ b/hw/bsp/lpc55/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
@@ -88,66 +84,52 @@ 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_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
+ ${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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..07171b8d5 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,49 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/mcx/family.cmake b/hw/bsp/mcx/family.cmake
index f857ed31a..bff4c68a7 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,77 +61,62 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
diff --git a/hw/bsp/mm32/family.cmake b/hw/bsp/mm32/family.cmake
index 0561a63a0..20431e41c 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,57 +39,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_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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..582faad67 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,58 +38,49 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_msp430flasher(${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..0c19d2155 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,53 @@ 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)
# 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..594d29cd0
--- /dev/null
+++ b/hw/bsp/nuc100_120/family.cmake
@@ -0,0 +1,84 @@
+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
+ )
+ 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)
+ 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..1eb581347
--- /dev/null
+++ b/hw/bsp/nuc121_125/family.cmake
@@ -0,0 +1,88 @@
+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
+ )
+ 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)
+ 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..3226406da
--- /dev/null
+++ b/hw/bsp/nuc126/family.cmake
@@ -0,0 +1,91 @@
+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
+ )
+ 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)
+ 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..eb6048d5c
--- /dev/null
+++ b/hw/bsp/nuc505/family.cmake
@@ -0,0 +1,87 @@
+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
+ )
+ 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)
+ 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/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 e3dc23c35..6cfb8238b 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}
@@ -58,57 +51,44 @@ 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_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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
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/metro_m0_express/board.mk b/hw/bsp/samd2x_l2x/boards/circuitplayground_express/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/metro_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/feather_m0_express/board.cmake b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/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/feather_m0_express/board.mk b/hw/bsp/samd2x_l2x/boards/feather_m0_express/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/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/itsybitsy_m0/board.cmake b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/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/itsybitsy_m0/board.mk b/hw/bsp/samd2x_l2x/boards/itsybitsy_m0/board.mk
index d6c9150b3..f4211e6c8 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/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/metro_m0_express/board.cmake b/hw/bsp/samd2x_l2x/boards/metro_m0_express/board.cmake
index c1a612936..dedc07594 100644
--- a/hw/bsp/samd21/boards/metro_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..091016e64
--- /dev/null
+++ b/hw/bsp/samd2x_l2x/family.cmake
@@ -0,0 +1,146 @@
+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)
+ # 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.cmake b/hw/bsp/samd5x_e5x/family.cmake
index 516290593..d5de26244 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,56 +43,45 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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..cb11f21f3
--- /dev/null
+++ b/hw/bsp/same7x/family.cmake
@@ -0,0 +1,96 @@
+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)
+ 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..6d7a6ba7f 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,60 +44,46 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
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..37b743654 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,57 +54,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32f0/family.cmake b/hw/bsp/stm32f0/family.cmake
index 12c7b592c..6f90f1a7a 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,56 +52,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32f1/family.cmake b/hw/bsp/stm32f1/family.cmake
index cbb9c3568..f2acba3ff 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,60 +47,50 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32f2/family.cmake b/hw/bsp/stm32f2/family.cmake
index dc6bc2885..b08e93e3c 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,62 +47,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32f3/family.cmake b/hw/bsp/stm32f3/family.cmake
index 0ba2920d5..b9aea10db 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,56 +49,48 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32f4/family.cmake b/hw/bsp/stm32f4/family.cmake
index db5736192..327bf7bf3 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,58 +77,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32f7/family.cmake b/hw/bsp/stm32f7/family.cmake
index 1a3365332..2b9ca8cbb 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,58 +79,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32g0/family.cmake b/hw/bsp/stm32g0/family.cmake
index 4da26f27e..065ec3a0e 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,61 +49,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32g4/family.cmake b/hw/bsp/stm32g4/family.cmake
index 5ec9926fe..f0c0e5549 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,57 +49,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32h5/family.cmake b/hw/bsp/stm32h5/family.cmake
index 1df6bcb90..7ad59dbd4 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,57 +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_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)
# Flashing
family_add_bin_hex(${TARGET})
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..cfffc7770 100644
--- a/hw/bsp/stm32h7/boards/stm32h743eval/board.h
+++ b/hw/bsp/stm32h7/boards/stm32h743eval/board.h
@@ -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..4f80b15ff 100644
--- a/hw/bsp/stm32h7/family.c
+++ b/hw/bsp/stm32h7/family.c
@@ -131,7 +131,7 @@ void board_init(void) {
#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..840391e0b 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,58 +86,42 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32h7rs/family.cmake b/hw/bsp/stm32h7rs/family.cmake
index 40230ef12..b1253d7fe 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,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32l0/family.cmake b/hw/bsp/stm32l0/family.cmake
index 954bdb158..4d24a21a6 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,56 +53,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_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)
# Flashing
family_add_bin_hex(${TARGET})
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..e89035e8b 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,63 +49,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_${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)
# Flashing
family_add_bin_hex(${TARGET})
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.cmake b/hw/bsp/stm32n6/family.cmake
index 76763937e..587ebc0fb 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}_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 ${ST_CMSIS}/Source/Templates/gcc/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}_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,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_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)
# 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/family.cmake b/hw/bsp/stm32u0/family.cmake
index fefaea9de..0c9d92fae 100644
--- a/hw/bsp/stm32u0/family.cmake
+++ b/hw/bsp/stm32u0/family.cmake
@@ -18,28 +18,24 @@ set(FAMILY_MCUS STM32U0 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})
- if (NOT DEFINED LD_FILE_IAR)
- set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
- endif ()
+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
@@ -50,7 +46,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}
@@ -59,56 +54,48 @@ 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_STM32U0)
- # 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_STM32U0)
- 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32u5/family.cmake b/hw/bsp/stm32u5/family.cmake
index 7a5935961..6bbeb1017 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,60 +53,51 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32wb/family.cmake b/hw/bsp/stm32wb/family.cmake
index 0ea937257..461ce6ffd 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,60 +52,50 @@ 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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/stm32wba/family.cmake b/hw/bsp/stm32wba/family.cmake
index 3f42879be..fab3d786b 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,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_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)
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/tm4c/family.cmake b/hw/bsp/tm4c/family.cmake
index e1cf94e96..936dcffa1 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,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
- -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_FLAGS "-Wno-cast-qual"
+ )
# Flashing
family_add_bin_hex(${TARGET})
diff --git a/hw/bsp/xmc4000/family.cmake b/hw/bsp/xmc4000/family.cmake
index 6edd72caf..ffce97a8c 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,58 +37,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
- -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)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_jlink(${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)