waf: enable CAN deadlines in AP_Periph

This commit is contained in:
Andrew Tridgell 2023-12-16 08:43:37 +11:00 committed by Peter Barker
parent 0ec994c46b
commit 23e67f7b53
2 changed files with 31 additions and 13 deletions

View File

@ -438,22 +438,24 @@ class Board:
'-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:

View File

@ -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 configure(cfg):
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)