From 62df67a4b8dc56576f41dbf18083ff629aff3441 Mon Sep 17 00:00:00 2001 From: Siddharth Purohit Date: Thu, 27 Aug 2020 20:30:22 +0530 Subject: [PATCH] HAL_ChibiOS: hwdef: modify to use HAL CAN driver instead of ChibiOS's --- libraries/AP_HAL_ChibiOS/hwdef/CUAV_GPS/hwdef.dat | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef-bl.dat | 7 +++++-- libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef.dat | 7 +++++-- libraries/AP_HAL_ChibiOS/hwdef/f103-GPS/hwdef.dat | 2 ++ libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat | 7 +++++-- libraries/AP_HAL_ChibiOS/hwdef/f303-periph/hwdef.dat | 7 +++++-- libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CUAV_GPS/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/CUAV_GPS/hwdef.dat index be56507159..2ebbad575d 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CUAV_GPS/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/CUAV_GPS/hwdef.dat @@ -125,8 +125,8 @@ define HAL_DISABLE_LOOP_DELAY PB8 CAN1_RX CAN1 PB9 CAN1_TX CAN1 PB5 GPIO_CAN1_SILENT OUTPUT PUSHPULL SPEED_LOW LOW -define HAL_USE_CAN TRUE -define STM32_CAN_USE_CAN1 TRUE + + # use DNA define HAL_CAN_DEFAULT_NODE_ID 0 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef-bl.dat b/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef-bl.dat index 2219182062..bf08e066c7 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef-bl.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef-bl.dat @@ -60,8 +60,8 @@ define HAL_UART_NODMA # enable CAN support PA11 CAN_RX CAN PB9 CAN_TX CAN -define HAL_USE_CAN TRUE -define STM32_CAN_USE_CAN1 TRUE + + # no I2C buses # I2C_ORDER @@ -127,3 +127,6 @@ define HAL_STORAGE_SIZE 800 # Add CS pins to ensure they are high in bootloader PA15 BARO_CS CS PD2 MAG_CS CS + +# reduce the number of CAN RX Buffer +define HAL_CAN_RX_QUEUE_SIZE 32 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef.dat index 45a6d2c51a..f1dbfbd8af 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/ZubaxGNSS/hwdef.dat @@ -78,8 +78,8 @@ define HAL_WATCHDOG_ENABLED_DEFAULT true # enable CAN support PA11 CAN_RX CAN PB9 CAN_TX CAN -define HAL_USE_CAN TRUE -define STM32_CAN_USE_CAN1 TRUE + + # no I2C buses # I2C_ORDER @@ -162,3 +162,6 @@ define HAL_NO_MONITOR_THREAD define HAL_PERIPH_ENABLE_GPS define HAL_PERIPH_ENABLE_MAG define HAL_PERIPH_ENABLE_BARO + +# reduce the number of CAN RX Buffer +define HAL_CAN_RX_QUEUE_SIZE 32 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/f103-GPS/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/f103-GPS/hwdef.dat index 5b8026e6f1..460bafd872 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/f103-GPS/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/f103-GPS/hwdef.dat @@ -11,6 +11,8 @@ COMPASS RM3100 SPI:rm3100 false ROTATION_NONE # and support all external compass types define HAL_PROBE_EXTERNAL_I2C_COMPASSES +define HAL_DISABLE_I2C_MAGS_BY_DEFAULT +define HAL_USE_I2C_MAG_HMC5843 # increase TX size for RTCM undef HAL_UART_MIN_TX_SIZE diff --git a/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat index 28c1a70ff1..6d602025fd 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat @@ -92,8 +92,8 @@ define HAL_DISABLE_LOOP_DELAY # enable CAN support PA11 CAN_RX CAN PA12 CAN_TX CAN -define HAL_USE_CAN TRUE -define STM32_CAN_USE_CAN1 TRUE + + # reduce memory overheads define HAL_CAN_POOL_SIZE 2500 @@ -142,3 +142,6 @@ RAM_RESERVE_START 256 # keep ROMFS uncompressed as we don't have enough RAM # to uncompress the bootloader at runtime env ROMFS_UNCOMPRESSED True + +# reduce the number of CAN RX Buffer +define HAL_CAN_RX_QUEUE_SIZE 32 \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/f303-periph/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/f303-periph/hwdef.dat index d832abba61..e64ddeaa67 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/f303-periph/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/f303-periph/hwdef.dat @@ -87,8 +87,8 @@ define HAL_DISABLE_LOOP_DELAY # enable CAN support PA11 CAN_RX CAN PA12 CAN_TX CAN -define HAL_USE_CAN TRUE -define STM32_CAN_USE_CAN1 TRUE + + # debugger support PA13 JTMS-SWDIO SWD @@ -138,3 +138,6 @@ RAM_RESERVE_START 256 # keep ROMFS uncompressed as we don't have enough RAM # to uncompress the bootloader at runtime env ROMFS_UNCOMPRESSED True + +# reduce the number of CAN RX Buffer +define HAL_CAN_RX_QUEUE_SIZE 32 \ No newline at end of file diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index b139967f5e..f0e64c9293 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -645,7 +645,7 @@ def write_mcu_config(f): f.write('#define HAL_USE_SERIAL_USB TRUE\n') if 'OTG2' in bytype: f.write('#define STM32_USB_USE_OTG2 TRUE\n') - if have_type_prefix('CAN') and 'AP_PERIPH' not in env_vars: + if have_type_prefix('CAN') and not args.bootloader: if 'CAN1' in bytype and 'CAN2' in bytype: enable_can(f, 2) else: