Skip to content

Commit

Permalink
Fix shared ADC IRQs for STM32H7xx (#11)
Browse files Browse the repository at this point in the history
- ADC1/2 share an interrupt vectoron STM32H7xx; this wasn't properly
  implemented before.
  • Loading branch information
tristanseifert authored Dec 14, 2024
1 parent 085c709 commit 4fb8be6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/adc/Kconfig.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config ADC_STM32
help
Enable the driver implementation for the stm32xx ADC

if SOC_SERIES_STM32F2X || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
if SOC_SERIES_STM32F2X || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X || SOC_SERIES_STM32H7X

config ADC_STM32_SHARED_IRQS
bool "STM32 ADC shared interrupts"
Expand Down
21 changes: 21 additions & 0 deletions drivers/adc/adc_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,10 +1162,17 @@ static const struct adc_driver_api api_stm32_driver_api = {

bool adc_stm32_is_irq_active(ADC_TypeDef *adc)
{
#ifdef LL_ADC_IsActiveFlag_EOCS
return LL_ADC_IsActiveFlag_EOCS(adc) ||
LL_ADC_IsActiveFlag_OVR(adc) ||
LL_ADC_IsActiveFlag_JEOS(adc) ||
LL_ADC_IsActiveFlag_AWD1(adc);
#else
return LL_ADC_IsActiveFlag_EOC(adc) ||
LL_ADC_IsActiveFlag_OVR(adc) ||
LL_ADC_IsActiveFlag_JEOS(adc) ||
LL_ADC_IsActiveFlag_AWD1(adc);
#endif
}

#define HANDLE_IRQS(index) \
Expand All @@ -1186,10 +1193,24 @@ static void adc_stm32_irq_init(void)
{
if (init_irq) {
init_irq = false;

// STM32H7: ADC1/2 share IRQ vector, ADC3 has its own vector
#ifdef CONFIG_SOC_SERIES_STM32H7X
IRQ_CONNECT(DT_IRQN(DT_NODELABEL(adc1)),
DT_IRQ(DT_NODELABEL(adc1), priority),
adc_stm32_shared_irq_handler, NULL, 0);
irq_enable(DT_IRQN(DT_NODELABEL(adc1)));

IRQ_CONNECT(DT_IRQN(DT_NODELABEL(adc3)),
DT_IRQ(DT_NODELABEL(adc3), priority),
adc_stm32_shared_irq_handler, NULL, 0);
irq_enable(DT_IRQN(DT_NODELABEL(adc3)));
#else
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority),
adc_stm32_shared_irq_handler, NULL, 0);
irq_enable(DT_INST_IRQN(0));
#endif
}
}

Expand Down

0 comments on commit 4fb8be6

Please sign in to comment.