Skip to content

Commit

Permalink
fixup! fixup! cpu/sam0_common: implement 16 bit mode by oversampling
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 21, 2023
1 parent 0e6d45e commit 4b12799
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpu/sam0_common/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,17 @@ int32_t adc_sample(adc_t line, adc_res_t res)
/* Wait for the result */
while (!(dev->INTFLAG.reg & ADC_INTFLAG_RESRDY)) {}

int16_t result = dev->RESULT.reg;
uint16_t sample = dev->RESULT.reg;
int result;

_adc_poweroff(dev);
_done();

/* in differential mode we lose one bit for the sign */
if (diffmode) {
result *= 2;
result = 2 * (int16_t)sample;
} else {
result = sample;
}

/* 16 bit mode is implemented as oversampling */
Expand Down

0 comments on commit 4b12799

Please sign in to comment.