From 8d2f57898b20bf3af98173379e17c9437e15e8d8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 29 May 2018 19:50:51 +1000 Subject: [PATCH] HAL_ChibiOS: adjust pin counts for STM32F7 --- .../hwdef/scripts/STM32F767xx.py | 15 ++++++++++++++ .../hwdef/scripts/chibios_hwdef.py | 20 ++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32F767xx.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32F767xx.py index b4ad4676e7..d34328f297 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32F767xx.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32F767xx.py @@ -10,6 +10,21 @@ build = { "CHIBIOS_PLATFORM_MK" : "os/hal/ports/STM32/STM32F7xx/platform.mk" } +pincount = { + 'A': 16, + 'B': 16, + 'C': 16, + 'D': 16, + 'E': 16, + 'F': 16, + 'G': 16, + 'H': 16, + 'I': 16, + 'J': 0, + 'K': 0 +} + + DMA_Map = { # format is (DMA_TABLE, StreamNum, Channel) "ADC1" : [(2,0,0),(2,4,0)], diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 2c8ac18691..9ecea37ad4 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -92,6 +92,18 @@ def get_mcu_lib(mcu): except ImportError: error("Unable to find module for MCU %s" % mcu) +def setup_mcu_type_defaults(): + '''setup defaults for given mcu type''' + lib = get_mcu_lib(mcu_type) + if hasattr(lib, 'pincount'): + pincount = lib.pincount + ports = pincount.keys() + # setup default as input pins + for port in ports: + portmap[port] = [] + for pin in range(pincount[port]): + portmap[port].append(generic_pin(port, pin, None, 'INPUT', [])) + def get_alt_function(mcu, pin, function): '''return alternative function number for a pin''' lib = get_mcu_lib(mcu) @@ -282,13 +294,6 @@ class generic_pin(object): str) -# setup default as input pins -for port in ports: - portmap[port] = [] - for pin in range(pincount[port]): - portmap[port].append(generic_pin(port, pin, None, 'INPUT', [])) - - def get_config(name, column=0, required=True, default=None, type=None): '''get a value from config dictionary''' if not name in config: @@ -1040,6 +1045,7 @@ def process_line(line): if a[0] == 'MCU': global mcu_type mcu_type = a[2] + setup_mcu_type_defaults() if a[0].startswith('P') and a[0][1] in ports: # it is a port/pin definition try: