1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-31 09:21:19 +01:00

Merge pull request #8624 from gebart/pr/efm32-adc-res-undef

efm32: Use different values for each unsupported ADC res
This commit is contained in:
Bas Stottelaar 2018-02-23 17:03:41 +01:00 committed by GitHub
commit f8070edb05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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 */

View File

@ -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;
}