1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

Merge pull request #12828 from bergzand/pr/sam0/adc_api

sam0/periph_adc: Fix API to return `-1` on unsupported resolution
This commit is contained in:
Dylan Laduranty 2019-11-28 09:05:39 +01:00 committed by GitHub
commit 53994bdfeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,12 +82,13 @@ static int _adc_configure(adc_res_t res)
/* Individual comparison necessary because ADC Resolution Bits are not
* numerically in order and 16Bit (averaging - not currently supported)
* falls between 12bit and 10bit. See datasheet for details */
assert((res == ADC_RES_8BIT) || (res == ADC_RES_10BIT) ||
(res == ADC_RES_12BIT));
if (!((res == ADC_RES_8BIT) || (res == ADC_RES_10BIT) ||
(res == ADC_RES_12BIT))){
return -1;
}
_adc_poweroff();
if (ADC->CTRLA.reg & ADC_CTRLA_SWRST ||
ADC->CTRLA.reg & ADC_CTRLA_ENABLE ) {
_done();
DEBUG("adc: not ready\n");
return -1;
}