Skip to content

fix atmel-samd DAC channel selection logic #3966

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

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions ports/atmel-samd/common-hal/analogio/AnalogOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,22 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
mp_raise_NotImplementedError(translate("No DAC on chip"));
#else

int channel = -1;

#if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02)
if (pin->number != PIN_PA02) {
channel = 0;
}
#endif
#if defined(PIN_PA05) && defined(PIN_PA05) && !defined(IGNORE_PIN_PA05)
if (pin->number != PIN_PA05) {
channel = 1;
}
#endif

if(channel == -1) {
mp_raise_ValueError(translate("AnalogOut not supported on given pin"));
uint8_t channel;
switch (pin->number) {
#if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02)
case PIN_PA02:
channel = 0;
break;
#endif

#if defined(SAM_D5X_E5X) && defined(PIN_PA05) && !defined(IGNORE_PIN_PA05)
case PIN_PA05:
channel = 1;
break;
#endif

default:
mp_raise_ValueError(translate("AnalogOut not supported on given pin"));
return;
}

Expand Down