diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 9c2ede9cb0..c1e951ec75 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -8199,6 +8199,16 @@ config STM32_ADC1_DMA_CFG ---help--- 0 - ADC1 DMA in One Shot Mode, 1 - ADC1 DMA in Circular Mode +config STM32_ADC1_ANIOC_TRIGGER + int "ADC1 software trigger (ANIOC_TRIGGER) configuration" + depends on STM32_ADC1 + range 1 3 + default 3 + ---help--- + 1 - ANIOC_TRIGGER only starts regular conversion + 2 - ANIOC_TRIGGER only starts injected conversion + 3 - ANIOC_TRIGGER starts both regular and injected conversions + config STM32_ADC2_DMA bool "ADC2 DMA" depends on STM32_ADC2 && STM32_HAVE_ADC2_DMA @@ -8222,6 +8232,16 @@ config STM32_ADC2_DMA_CFG ---help--- 0 - ADC2 DMA in One Shot Mode, 1 - ADC2 DMA in Circular Mode +config STM32_ADC2_ANIOC_TRIGGER + int "ADC2 software trigger (ANIOC_TRIGGER) configuration" + depends on STM32_ADC2 + range 1 3 + default 3 + ---help--- + 1 - ANIOC_TRIGGER only starts regular conversion + 2 - ANIOC_TRIGGER only starts injected conversion + 3 - ANIOC_TRIGGER starts both regular and injected conversions + config STM32_ADC3_DMA bool "ADC3 DMA" depends on STM32_ADC3 && STM32_HAVE_ADC3_DMA @@ -8245,6 +8265,16 @@ config STM32_ADC3_DMA_CFG ---help--- 0 - ADC3 DMA in One Shot Mode, 1 - ADC3 DMA in Circular Mode +config STM32_ADC3_ANIOC_TRIGGER + int "ADC3 software trigger (ANIOC_TRIGGER) configuration" + depends on STM32_ADC3 + range 1 3 + default 3 + ---help--- + 1 - ANIOC_TRIGGER only starts regular conversion + 2 - ANIOC_TRIGGER only starts injected conversion + 3 - ANIOC_TRIGGER starts both regular and injected conversions + config STM32_ADC4_DMA bool "ADC4 DMA" depends on STM32_ADC4 && STM32_HAVE_ADC4_DMA @@ -8262,6 +8292,16 @@ config STM32_ADC4_DMA_CFG ---help--- 0 - ADC4 DMA in One Shot Mode, 1 - ADC4 DMA in Circular Mode +config STM32_ADC4_ANIOC_TRIGGER + int "ADC4 software trigger (ANIOC_TRIGGER) configuration" + depends on STM32_ADC4 + range 1 3 + default 3 + ---help--- + 1 - ANIOC_TRIGGER only starts regular conversion + 2 - ANIOC_TRIGGER only starts injected conversion + 3 - ANIOC_TRIGGER starts both regular and injected conversions + config STM32_ADC5_DMA bool "ADC5 DMA" depends on STM32_ADC5 && STM32_HAVE_ADC5_DMA diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c index 18f25c13b3..1303e03c60 100644 --- a/arch/arm/src/stm32/stm32_adc.c +++ b/arch/arm/src/stm32/stm32_adc.c @@ -377,6 +377,11 @@ # undef ADC_HAVE_CB #endif +/* ADC software trigger configuration */ + +#define ANIOC_TRIGGER_REGULAR (1 << 0) +#define ANIOC_TRIGGER_INJECTED (1 << 1) + /**************************************************************************** * Private Types ****************************************************************************/ @@ -416,6 +421,7 @@ struct stm32_dev_s uint8_t intf; /* ADC interface number */ uint8_t initialized; /* ADC interface initialization counter */ uint8_t current; /* Current ADC channel being converted */ + uint8_t anioc_trg; /* ANIOC_TRIGGER configuration */ #ifdef HAVE_ADC_RESOLUTION uint8_t resolution; /* ADC resolution (0-3) */ #endif @@ -766,6 +772,7 @@ static struct stm32_dev_s g_adcpriv1 = #endif .intf = 1, .initialized = 0, + .anioc_trg = CONFIG_STM32_ADC1_ANIOC_TRIGGER, #ifdef HAVE_ADC_RESOLUTION .resolution = CONFIG_STM32_ADC1_RESOLUTION, #endif @@ -825,6 +832,7 @@ static struct stm32_dev_s g_adcpriv2 = #endif .intf = 2, .initialized = 0, + .anioc_trg = CONFIG_STM32_ADC2_ANIOC_TRIGGER, #ifdef HAVE_ADC_RESOLUTION .resolution = CONFIG_STM32_ADC2_RESOLUTION, #endif @@ -884,6 +892,7 @@ static struct stm32_dev_s g_adcpriv3 = #endif .intf = 3, .initialized = 0, + .anioc_trg = CONFIG_STM32_ADC3_ANIOC_TRIGGER, #ifdef HAVE_ADC_RESOLUTION .resolution = CONFIG_STM32_ADC3_RESOLUTION, #endif @@ -936,6 +945,7 @@ static struct stm32_dev_s g_adcpriv4 = #endif .intf = 4, .initialized = 0, + .anioc_trg = CONFIG_STM32_ADC4_ANIOC_TRIGGER, #ifdef HAVE_ADC_RESOLUTION .resolution = CONFIG_STM32_ADC4_RESOLUTION, #endif @@ -3820,17 +3830,23 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg) { /* Start regular conversion if regular channels configured */ - if (priv->cr_channels > 0) + if (priv->anioc_trg & ANIOC_TRIGGER_REGULAR) { - adc_reg_startconv(priv, true); + if (priv->cr_channels > 0) + { + adc_reg_startconv(priv, true); + } } #ifdef ADC_HAVE_INJECTED /* Start injected conversion if injected channels configured */ - if (priv->cj_channels > 0) + if (priv->anioc_trg & ANIOC_TRIGGER_INJECTED) { - adc_inj_startconv(priv, true); + if (priv->cj_channels > 0) + { + adc_inj_startconv(priv, true); + } } #endif