Skip to content

Commit

Permalink
ChibiOS: disable DMA on I2C on F7 and H7 by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tridge committed Jul 31, 2023
1 parent a121f66 commit eac2146
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/common/stm32f47_mcuconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,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
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,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
5 changes: 4 additions & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'''
Expand Down

0 comments on commit eac2146

Please sign in to comment.