@@ -186,6 +186,11 @@ static int ti_adc_channel_setup(const struct device *dev, const struct adc_chann
186186 return - EINVAL ;
187187 }
188188
189+ if (chan_cfg -> reference != ADC_REF_VDD_1 ) {
190+ LOG_ERR ("Invalid channel reference" );
191+ return - EINVAL ;
192+ }
193+
189194 if (chan_cfg -> gain != ADC_GAIN_1 ) {
190195 LOG_ERR ("Gain must be 1x" );
191196 return - EINVAL ;
@@ -368,15 +373,17 @@ static void ti_adc_isr(const struct device *dev)
368373
369374#define EXPLICIT_CHAN_PROP (node , prop ) [DT_REG_ADDR(node)] = DT_PROP(node, prop)
370375
371- #define CHAN_PROP_LIST (n , prop ) {DT_INST_FOREACH_CHILD_SEP_VARGS(n, EXPLICIT_CHAN_PROP, (,), prop)}
376+ #define CHAN_PROP_LIST (n , prop ) {DT_INST_FOREACH_CHILD_SEP_VARGS(n, EXPLICIT_CHAN_PROP, (, ), prop)}
377+
378+ static DEVICE_API (adc , ti_adc_driver_api ) = {
379+ .channel_setup = ti_adc_channel_setup ,
380+ .read = ti_adc_read ,
381+ #ifdef CONFIG_ADC_ASYNC
382+ .read_async = ti_adc_read_async ,
383+ #endif /* CONFIG_ADC_ASYNC */
384+ };
372385
373386#define TI_ADC_INIT (n ) \
374- static DEVICE_API(adc, ti_adc_driver_api_##n) = { \
375- .channel_setup = ti_adc_channel_setup, \
376- .read = ti_adc_read, \
377- .ref_internal = DT_INST_PROP(n, ti_vrefp), \
378- IF_ENABLED(CONFIG_ADC_ASYNC, (.read_async = ti_adc_read_async,)) }; \
379- \
380387 static void ti_adc_irq_setup_##n(const struct device *dev) \
381388 { \
382389 IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), ti_adc_isr, \
@@ -400,6 +407,6 @@ static void ti_adc_isr(const struct device *dev)
400407 }; \
401408 \
402409 DEVICE_DT_INST_DEFINE(n, ti_adc_init, NULL, &ti_adc_data_##n, &ti_adc_cfg_##n, \
403- POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, &ti_adc_driver_api_##n );
410+ POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, &ti_adc_driver_api );
404411
405412DT_INST_FOREACH_STATUS_OKAY (TI_ADC_INIT )
0 commit comments