Skip to content

Commit 97f9411

Browse files
CEV-MINDcarlescufi
authored andcommitted
drivers: adc: esp32: check reference at compile time
Check that the channels are configured with the reference ADC_REF_INTERNAL when compiling the driver. Signed-off-by: Colin Evrard <[email protected]>
1 parent 87177d1 commit 97f9411

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/adc/adc_esp32.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,14 @@ static DEVICE_API(adc, api_esp32_driver_api) = {
751751

752752
#endif /* defined(CONFIG_ADC_ESP32_DMA) */
753753

754+
#define ADC_ESP32_CHECK_CHANNEL_REF(chan) \
755+
BUILD_ASSERT(DT_ENUM_HAS_VALUE(chan, zephyr_reference, adc_ref_internal), \
756+
"adc_esp32 only supports ADC_REF_INTERNAL as a reference");
757+
754758
#define ESP32_ADC_INIT(inst) \
755759
\
760+
DT_INST_FOREACH_CHILD(inst, ADC_ESP32_CHECK_CHANNEL_REF) \
761+
\
756762
static const struct adc_esp32_conf adc_esp32_conf_##inst = { \
757763
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(inst)), \
758764
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(inst, offset), \

0 commit comments

Comments
 (0)