Skip to content

Commit

Permalink
drivers: adc: adc_mcux_adc12: add API internal reference
Browse files Browse the repository at this point in the history
Extend the adc_mcux_adc12 adc api to set the ref_internal to
a value of vref-mv property.

Signed-off-by: Marcin Wierzbicki <[email protected]>
  • Loading branch information
marcin-wierzbicki authored and nashif committed Aug 30, 2024
1 parent 71810a5 commit 9706383
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/adc/adc_mcux_adc12.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,6 @@ static int mcux_adc12_init(const struct device *dev)
return 0;
}

static const struct adc_driver_api mcux_adc12_driver_api = {
.channel_setup = mcux_adc12_channel_setup,
.read = mcux_adc12_read,
#ifdef CONFIG_ADC_ASYNC
.read_async = mcux_adc12_read_async,
#endif
};

#define ASSERT_WITHIN_RANGE(val, min, max, str) \
BUILD_ASSERT(val >= min && val <= max, str)
#define ASSERT_ADC12_CLK_DIV_VALID(val, str) \
Expand All @@ -276,10 +268,19 @@ static const struct adc_driver_api mcux_adc12_driver_api = {
(kADC12_ReferenceVoltageSourceValt), \
(kADC12_ReferenceVoltageSourceVref))

#define ADC12_MCUX_DRIVER_API(n) \
static const struct adc_driver_api mcux_adc12_driver_api_##n = { \
.channel_setup = mcux_adc12_channel_setup, \
.read = mcux_adc12_read, \
IF_ENABLED(CONFIG_ADC_ASYNC, (.read_async = mcux_adc12_read_async,)) \
.ref_internal = DT_INST_PROP(n, vref_mv), \
};

#define ACD12_MCUX_INIT(n) \
static void mcux_adc12_config_func_##n(const struct device *dev); \
\
PINCTRL_DT_INST_DEFINE(n); \
ADC12_MCUX_DRIVER_API(n); \
\
ASSERT_WITHIN_RANGE(DT_INST_PROP(n, clk_source), 0, 3, \
"Invalid clock source"); \
Expand Down Expand Up @@ -308,7 +309,7 @@ static const struct adc_driver_api mcux_adc12_driver_api = {
NULL, &mcux_adc12_data_##n, \
&mcux_adc12_config_##n, POST_KERNEL, \
CONFIG_ADC_INIT_PRIORITY, \
&mcux_adc12_driver_api); \
&mcux_adc12_driver_api_##n); \
\
static void mcux_adc12_config_func_##n(const struct device *dev) \
{ \
Expand Down

0 comments on commit 9706383

Please sign in to comment.