Skip to content

Implementation of ADC for C0 (compiles but untested)#170

Draft
FeldrinH wants to merge 10 commits intoDavid-OConnor:mainfrom
FeldrinH:main
Draft

Implementation of ADC for C0 (compiles but untested)#170
FeldrinH wants to merge 10 commits intoDavid-OConnor:mainfrom
FeldrinH:main

Conversation

@FeldrinH
Copy link
Contributor

@FeldrinH FeldrinH commented Jan 21, 2026

Closes #166. This is my work in progress implementation of ADC for C0. Currently it compiles but I haven't tested it on actual hardware.

Notable API changes (C0 only, no changes on other device families):

  • C0 supports only single-ended input type, so I removed differential input type from InputType enum.
  • C0 does not support injected conversion, so I removed injected conversion interrupts from AdcInterrupt.
  • C0 does not support setting a seprate sample time for each channel (it does support choosing between two sample times, but these two sample times must be the same for all channels). I removed the channel parameter from set_sample_time and it now sets the sample time for all channels.

Breaking API changes (all device families, not just C0):

  • Trigger enum is now just a reexport of EXTSEL from the PAC. Generally EXTSEL and the old Trigger enum are identical except that EXTSEL sometimes uses different names for a few values (e.g. ExtiX -> ExtiLineX).

Open questions:

  • Should start_conversion call set_sequence_len? It seems to me that it should, but currently it does not. Is this an undiscovered bug in all ADC implementations for all families?
  • The single-ended and differential calibration values can be specified in the config, but they are ignored and overwritten during setup. Is this intentional? If yes then it might make more sense to store them directly inside the ADC struct.
  • Is defining Trigger as a re-export of EXTSEL a good idea?

@FeldrinH FeldrinH changed the title Implementation ADC for C0 (compiles but untested) Implementation of ADC for C0 (compiles but untested) Jan 21, 2026
@FeldrinH FeldrinH marked this pull request as draft January 21, 2026 23:27
@FeldrinH FeldrinH mentioned this pull request Jan 21, 2026
@David-OConnor
Copy link
Owner

David-OConnor commented Jan 24, 2026

Hey! I love what you're doing here. I regrettably don't have a C0 to test. And, at the core of this is handling differences in both hardware, and PAC APIs. I would love to merge this after you've validated it works on hardware.

I don't have immediately answers to your questions regarding design decisions; it's been a while since I touched this part of the code. I will get back to you.

@FeldrinH
Copy link
Contributor Author

I hope to test this on actual C0 hardware soonish, I just haven't been to the lab and I don't have the necessary components at home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADC support for C0

2 participants