From d69b8c2693eb562a547e14f28b137c0c277bd7e0 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Wed, 26 Apr 2023 15:18:36 +0100 Subject: [PATCH] AP_HAL_ChibiOS: fix usage of ADC2 and ADC3 in STM32H730 --- .../hwdef/common/stm32h7_mcuconf.h | 2 +- .../hwdef/common/stm32h7_type2_mcuconf.h | 9 +++++ .../hwdef/scripts/STM32H730xx.py | 36 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h index be70a5cbca..a71397764f 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_mcuconf.h @@ -390,7 +390,7 @@ #endif #define STM32_ADC_COMPACT_SAMPLES FALSE #define STM32_ADC_USE_ADC12 TRUE -#if !defined(STM32H750xx) && !defined(STM32H730xx) +#if !defined(STM32H750xx) #ifndef STM32_ADC_USE_ADC3 #define STM32_ADC_USE_ADC3 TRUE #endif diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_type2_mcuconf.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_type2_mcuconf.h index 5069dc4138..197b3bcb5b 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_type2_mcuconf.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32h7_type2_mcuconf.h @@ -322,8 +322,12 @@ /* * ADC driver system settings. */ +#ifndef STM32_ADC_DUAL_MODE #define STM32_ADC_DUAL_MODE FALSE +#endif +#ifndef STM32_ADC_SAMPLES_SIZE #define STM32_ADC_SAMPLES_SIZE 16 +#endif #define STM32_ADC_COMPACT_SAMPLES FALSE #define STM32_ADC_USE_ADC12 TRUE #define STM32_ADC_ADC12_DMA_PRIORITY 2 @@ -597,3 +601,8 @@ #define STM32_SPI_SPI6_RX_BDMA_STREAM 4 #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/STM32H730xx.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32H730xx.py index 965e4e3283..9ef0393b84 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32H730xx.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32H730xx.py @@ -1267,3 +1267,39 @@ ADC1_map = { "PA4" : 18, "PA5" : 19, } + +ADC2_map = { + "PF13" : 2, + "PA6" : 3, + "PC4" : 4, + "PB1" : 5, + "PF14" : 6, + "PA7" : 7, + "PC5" : 8, + "PB0" : 9, + "PC0" : 10, + "PC1" : 11, + "PC2" : 12, + "PC3" : 13, + "PA2" : 14, + "PA3" : 15, + "N/A" : 16, + "N/A" : 17, + "PA4" : 18, + "PA5" : 19, +} + +ADC3_map = { + "PF9" : 2, + "PF7" : 3, + "PF5" : 4, + "PF3" : 5, + "PF10" : 6, + "PF8" : 7, + "PF6" : 8, + "PF4" : 9, + "PH2" : 13, + "PH3" : 14, + "PH4" : 15, + "PH5" : 16, +}