ADC hardware timing framework considerations #88770
Labels
area: ADC
Analog-to-Digital Converter (ADC)
Enhancement
Changes/Updates/Additions to existing features
I am part way through implementing a hardware timed adc driver and think there are some issues with the existing framework that need to be addressed.
Adc_context.h says drivers should implement adc_context_enable_timer and adc_context_disable_timer but these functions only pass an adc_context which has no reference to hardware. A driver can ignore these and keep the timer enabled but this is wasteful and defeats the intention.
As a regular C function it can also only be implemented once, either a driver implementation or the existing kernel implementation controlled by ADC_CONTEXT_USES_KERNEL_TIMER. It seems to me that having some adc controlled by a hardware timer and some other controlled by a kernel timer is quite a natural use case. Reimplementing the kernel timer in the driver seems quite clunky and wouldn’t respect the configuration logic.
I don’t know why the framework is the way it is, but could these issues be resolved? Adc_context_on_sampling_done passes a const struct device so perhaps other adc_context functions could, including adc_context_enable_timer and adc_context_disable_timer, or something could be added to adc_context.
The text was updated successfully, but these errors were encountered: