Skip to content

Commit

Permalink
waf: enable CAN deadlines in AP_Periph
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Dec 15, 2023
1 parent 11a5b78 commit 97b6c85
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Tools/ardupilotwaf/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions Tools/ardupilotwaf/chibios.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 97b6c85

Please sign in to comment.