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

cpu/sam0_common: adc: Automatically configure external reference pin #18042

Merged
merged 1 commit into from May 18, 2022

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented May 2, 2022

Contribution description

The ADC can be configured to use an input pin for the external reference voltage.
Automatically configure this pin when ADC_REF_DEFAULT is set accordingly.

On all members of the family PA03 and P04 can be used as reference A and B respectively. SAM D5x/E5x also allows to use PA06 as reference C.

Testing procedure

Set ADC_REFSEL_AREFB_PIN to e.g. ADC_REFCTRL_REFSEL_AREFA and connect a reference voltage to PA03, then run tests/periph_adc.

Issues/PRs references

@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms labels May 2, 2022
@dylad dylad self-assigned this May 10, 2022
@dylad dylad added this to the Release 2022.07 milestone May 10, 2022
Comment on lines +226 to +235
#ifdef ADC_REFCTRL_REFSEL_AREFA
if (ADC_REF_DEFAULT == ADC_REFCTRL_REFSEL_AREFA) {
gpio_init_mux(ADC_REFSEL_AREFA_PIN, GPIO_MUX_B);
}
#endif
#ifdef ADC_REFCTRL_REFSEL_AREFB
if (ADC_REF_DEFAULT == ADC_REFCTRL_REFSEL_AREFB) {
gpio_init_mux(ADC_REFSEL_AREFB_PIN, GPIO_MUX_B);
}
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Jut wondering: Why did you use #ifdef for these two ? Looks like they are always present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for consistency

Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@dylad dylad added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 17, 2022
@dylad dylad enabled auto-merge May 17, 2022 20:18
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 17, 2022
@dylad dylad merged commit 5681cc0 into RIOT-OS:master May 18, 2022
@benpicco benpicco deleted the cpu/sam0-adc-extref branch May 18, 2022 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants