Skip to content

Commit 9566d4e

Browse files
gautierg-stcarlescufi
authored andcommitted
drivers: adc: stm32: add a check for asynchronous clock source
Add a compile-time check to verify that a domain clock is explicitly defined if a STM32 ADC is configured to use an asynchronous clock. Signed-off-by: Guillaume Gautier <[email protected]>
1 parent 111b2bb commit 9566d4e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/adc/adc_stm32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,11 @@ static const struct adc_driver_api api_stm32_driver_api = {
16401640
_CONCAT(ADC_STM32_CLOCK_PREFIX(x), ADC_STM32_DIV(x))
16411641
#endif
16421642

1643+
/* Macro to check if the ADC instance clock setup is correct */
1644+
#define ADC_STM32_CHECK_DT_CLOCK(x) \
1645+
BUILD_ASSERT(IS_EQ(ADC_STM32_CLOCK(x), SYNC) || (DT_INST_NUM_CLOCKS(x) > 1), \
1646+
"ASYNC clock mode defined without ASYNC clock defined in device tree")
1647+
16431648
#if defined(CONFIG_ADC_STM32_DMA)
16441649

16451650
#define ADC_DMA_CHANNEL_INIT(index, src_dev, dest_dev) \
@@ -1782,6 +1787,8 @@ DT_INST_FOREACH_STATUS_OKAY(GENERATE_ISR)
17821787

17831788
#define ADC_STM32_INIT(index) \
17841789
\
1790+
ADC_STM32_CHECK_DT_CLOCK(index); \
1791+
\
17851792
PINCTRL_DT_INST_DEFINE(index); \
17861793
\
17871794
static const struct stm32_pclken pclken_##index[] = \

0 commit comments

Comments
 (0)