Skip to content

ADC hardware timing framework considerations #88770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zbas opened this issue Apr 17, 2025 · 2 comments
Open

ADC hardware timing framework considerations #88770

zbas opened this issue Apr 17, 2025 · 2 comments
Assignees
Labels
area: ADC Analog-to-Digital Converter (ADC) Enhancement Changes/Updates/Additions to existing features

Comments

@zbas
Copy link
Contributor

zbas commented Apr 17, 2025

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.

@zbas zbas added the Enhancement Changes/Updates/Additions to existing features label Apr 17, 2025
Copy link

Hi @zbas! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

@JarmouniA JarmouniA added the area: ADC Analog-to-Digital Converter (ADC) label Apr 17, 2025
@zbas
Copy link
Contributor Author

zbas commented Apr 23, 2025

I have seen that the first issue (no reference to hardware) is solved by the CONTAINER_OF macro. I would still appreciate advice/input on implementation of hardware and kernel timers together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

3 participants