diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index e18d3137065f3..584976563ce3f 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -438,22 +438,24 @@ def configure_env(self, cfg, env): '-Wl,--gc-sections', ] - if self.with_can and not cfg.env.AP_PERIPH: - env.AP_LIBRARIES += [ - 'AP_DroneCAN', - 'modules/DroneCAN/libcanard/*.c', - ] - if cfg.options.enable_dronecan_tests: + if self.with_can: + # for both AP_Perip and main fw enable deadlines + env.DEFINES.update(CANARD_ENABLE_DEADLINE = 1) + + if not cfg.env.AP_PERIPH: + env.AP_LIBRARIES += [ + 'AP_DroneCAN', + 'modules/DroneCAN/libcanard/*.c', + ] + if cfg.options.enable_dronecan_tests: + env.DEFINES.update(AP_TEST_DRONECAN_DRIVERS = 1) + env.DEFINES.update( - AP_TEST_DRONECAN_DRIVERS = 1 + DRONECAN_CXX_WRAPPERS = 1, + USE_USER_HELPERS = 1, + CANARD_ALLOCATE_SEM=1 ) - env.DEFINES.update( - DRONECAN_CXX_WRAPPERS = 1, - USE_USER_HELPERS = 1, - CANARD_ENABLE_DEADLINE = 1, - CANARD_ALLOCATE_SEM=1 - ) if cfg.options.build_dates: diff --git a/Tools/ardupilotwaf/chibios.py b/Tools/ardupilotwaf/chibios.py index 819b3474c540f..1ead8ed05298f 100644 --- a/Tools/ardupilotwaf/chibios.py +++ b/Tools/ardupilotwaf/chibios.py @@ -468,6 +468,20 @@ def setup_canmgr_build(cfg): cfg.get_board().with_can = True +def setup_canperiph_build(cfg): + '''enable CAN build for peripherals''' + env = cfg.env + env.DEFINES += [ + 'CANARD_ENABLE_DEADLINE=1', + ] + + if cfg.env.HAL_CANFD_SUPPORTED: + env.DEFINES += ['UAVCAN_SUPPORT_CANFD=1'] + else: + env.DEFINES += ['UAVCAN_SUPPORT_CANFD=0'] + + cfg.get_board().with_can = True + def load_env_vars(env): '''optionally load extra environment variables from env.py in the build directory''' print("Checking for env.py") @@ -578,6 +592,8 @@ def bldpath(path): load_env_vars(cfg.env) if env.HAL_NUM_CAN_IFACES and not env.AP_PERIPH: setup_canmgr_build(cfg) + if env.HAL_NUM_CAN_IFACES and env.AP_PERIPH and not env.BOOTLOADER: + setup_canperiph_build(cfg) if env.HAL_NUM_CAN_IFACES and env.AP_PERIPH and int(env.HAL_NUM_CAN_IFACES)>1 and not env.BOOTLOADER: env.DEFINES += [ 'CANARD_MULTI_IFACE=1' ] setup_optimization(cfg.env)