diff --git a/cpu/efm32/include/periph_cpu.h b/cpu/efm32/include/periph_cpu.h index e0c5fbfb9713e22b1f63709abb505f2f03b9610e..f131e67fe7308e41110030b265f9f0f3f0424977 100644 --- a/cpu/efm32/include/periph_cpu.h +++ b/cpu/efm32/include/periph_cpu.h @@ -56,7 +56,7 @@ extern "C" { /** * @brief Internal define to note that resolution is not supported. */ -#define ADC_MODE_UNDEF (0xff) +#define ADC_MODE_UNDEF(x) (ADC_MODE(x, 15)) #ifndef DOXYGEN /** @@ -65,12 +65,12 @@ extern "C" { */ #define HAVE_ADC_RES_T typedef enum { - ADC_RES_6BIT = ADC_MODE(adcRes6Bit, 0), /**< ADC resolution: 6 bit */ - ADC_RES_8BIT = ADC_MODE(adcRes8Bit, 0), /**< ADC resolution: 8 bit */ + ADC_RES_6BIT = ADC_MODE(adcRes6Bit, 0), /**< ADC resolution: 6 bit */ + ADC_RES_8BIT = ADC_MODE(adcRes8Bit, 0), /**< ADC resolution: 8 bit */ ADC_RES_10BIT = ADC_MODE(adcRes12Bit, 2), /**< ADC resolution: 10 bit (shifted from 12 bit) */ ADC_RES_12BIT = ADC_MODE(adcRes12Bit, 0), /**< ADC resolution: 12 bit */ - ADC_RES_14BIT = ADC_MODE_UNDEF, /**< ADC resolution: 14 bit (unsupported) */ - ADC_RES_16BIT = ADC_MODE_UNDEF, /**< ADC resolution: 16 bit (unsupported) */ + ADC_RES_14BIT = ADC_MODE_UNDEF(0), /**< ADC resolution: 14 bit (unsupported) */ + ADC_RES_16BIT = ADC_MODE_UNDEF(1), /**< ADC resolution: 16 bit (unsupported) */ } adc_res_t; /** @} */ #endif /* ndef DOXYGEN */ diff --git a/cpu/efm32/periph/adc.c b/cpu/efm32/periph/adc.c index a015ab08b60c39ef1dea61fc47db775a20f61982..01b2e5242977ed6b0d85ed2060ce0a05ce0d6f0b 100644 --- a/cpu/efm32/periph/adc.c +++ b/cpu/efm32/periph/adc.c @@ -62,7 +62,7 @@ int adc_init(adc_t line) int adc_sample(adc_t line, adc_res_t res) { /* resolutions larger than 12 bits are not supported */ - if (res == ADC_MODE_UNDEF) { + if (res >= ADC_MODE_UNDEF(0)) { return -1; }