From 64cd58c21a69c14d964d45627671df4b8c01a741 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 22 Apr 2023 14:18:40 +1000 Subject: [PATCH] ChibiOS: disable DMA on I2C on F7 and H7 by default this was already done on many (most?) boards, and greatly reduces DMA sharing which improves performance of UARTs. This changes the default to no DMA on I2C --- libraries/AP_HAL_ChibiOS/hwdef/common/stm32f47_mcuconf.h | 7 +++++++ libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h | 4 ++++ libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32f47_mcuconf.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32f47_mcuconf.h index 5bdcb72faa..384e48c331 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32f47_mcuconf.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32f47_mcuconf.h @@ -580,3 +580,10 @@ // limit ISR count per byte #define STM32_I2C_ISR_LIMIT 6 + +#if defined(STM32F7xx_MCUCONF) +// disable DMA on I2C by default on F7 +#ifndef STM32_I2C_USE_DMA +#define STM32_I2C_USE_DMA FALSE +#endif +#endif diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h index 9ab42b1260..f7884066f0 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h @@ -635,3 +635,7 @@ #define STM32_SPI_SPI6_TX_BDMA_STREAM 5 #define STM32_ADC_ADC3_BDMA_STREAM 7 +// disable DMA on I2C by default on H7 +#ifndef STM32_I2C_USE_DMA +#define STM32_I2C_USE_DMA FALSE +#endif diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 1edd3a6810..af75433bd4 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -151,7 +151,7 @@ def get_mcu_lib(mcu): def setup_mcu_type_defaults(): '''setup defaults for given mcu type''' - global pincount, ports, portmap, vtypes, mcu_type + global pincount, ports, portmap, vtypes, mcu_type, dma_exclude_pattern lib = get_mcu_lib(mcu_type) if hasattr(lib, 'pincount'): pincount = lib.pincount @@ -166,6 +166,9 @@ def setup_mcu_type_defaults(): for pin in range(pincount[port]): portmap[port].append(generic_pin(port, pin, None, default_gpio[0], default_gpio[1:])) + if mcu_series.startswith("STM32H7") or mcu_series.startswith("STM32F7"): + # default DMA off on I2C for H7, we're much better off reducing DMA sharing + dma_exclude_pattern = ['I2C*'] def get_alt_function(mcu, pin, function): '''return alternative function number for a pin'''