Skip to content
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

Use type-level programming instead of macros for adc #616

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bradleyharden
Copy link
Contributor

The existing adc modules use macros to be generic over the ADC
peripheral. Update the code to use type-level programming techniques
instead, but do so in a backwards-compatible way.

Checklist

  • CHANGELOG.md for the BSP or HAL updated
  • All new or modified code is well documented, especially public items
  • No new warnings or clippy suggestions have been introduced (see CI or check locally)

The existing `adc` modules use macros to be generic over the ADC
peripheral. Update the code to use type-level programming techniques
instead, but do so in a backwards-compatible way.
}

macro_rules! adc_pins {
(
$(
$PinId:ident: ($ADC:ident, $CHAN:literal),
$PinId:ident: [ $( ($ADC:ident, $CHAN:literal) ),+ ],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this a list of tuples rather than a single tuple, because some pins can be an input for both ADC0 and ADC1. We should update the pin table below to match the datasheet. It's missing a bunch of entries right now.

@bradleyharden
Copy link
Contributor Author

If you want to get more aggressive with the refactor, I see a lot of areas where this module could be cleaned up and simplified. But for now, I wanted to keep everything backwards-compatible.

@bradleyharden
Copy link
Contributor Author

@wembly, it sounds like you were able to get something working for thumbv6m. If so, feel free to make a PR to this branch on my repo, and I'll merge it in. Then we can get a review fromsomeone else for the whole package.

@jbeaurivage jbeaurivage added the enhancement New feature or request label May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants