Browse Source

drivers/adcxx1c: use pseudomodules for device variants

master
smlng 6 years ago committed by Vincent Dupont
parent
commit
f1f80c0098
  1. 3
      drivers/Makefile.dep
  2. 2
      drivers/adcxx1c/include/adcxx1c_params.h
  3. 14
      drivers/include/adcxx1c.h
  4. 5
      makefiles/pseudomodules.inc.mk
  5. 2
      tests/driver_adcxx1c/Makefile

3
drivers/Makefile.dep

@ -240,7 +240,8 @@ ifneq (,$(filter lsm6dsl,$(USEMODULE)))
USEMODULE += xtimer
endif
ifneq (,$(filter adcxx1c,$(USEMODULE)))
ifneq (,$(filter adc%1c,$(USEMODULE)))
FEATURES_REQUIRED += periph_gpio
FEATURES_REQUIRED += periph_i2c
USEMODULE += adcxx1c
endif

2
drivers/adcxx1c/include/adcxx1c_params.h

@ -38,7 +38,7 @@ extern "C" {
#define ADCXX1C_PARAM_ADDR (ADCXX1C_I2C_ADDRESS)
#endif
#ifndef ADCXX1C_PARAM_BITS
#define ADCXX1C_PARAM_BITS (ADCXX1C_RES_8BITS)
#define ADCXX1C_PARAM_BITS (ADCXX1C_RES_DEFAULT)
#endif
#ifndef ADCXX1C_PARAM_CYCLE
#define ADCXX1C_PARAM_CYCLE (ADCXX1C_CYCLE_DISABLED)

14
drivers/include/adcxx1c.h

@ -41,6 +41,20 @@ enum {
ADCXX1C_RES_12BITS = 12, /**< 12 bits resolution (ADC121C family) */
};
/**
* @brief ADC default resolution for device variants
*/
#if defined(MODULE_ADC081C)
#define ADCXX1C_RES_DEFAULT ADCXX1C_RES_8BITS
#elif defined(MODULE_ADC101C)
#define ADCXX1C_RES_DEFAULT ADCXX1C_RES_10BITS
#elif defined(MODULE_ADC121C)
#define ADCXX1C_RES_DEFAULT ADCXX1C_RES_12BITS
#else
#define ADCXX1C_RES_DEFAULT (-1)
#error "ADCXX1C: Failed to select resolution: unknown ADCXX1C device variant!"
#endif
/**
* @brief Conversion interval configuration value
*/

5
makefiles/pseudomodules.inc.mk

@ -64,5 +64,10 @@ PSEUDOMODULES += at86rf21%
PSEUDOMODULES += bmp280
PSEUDOMODULES += bme280
# variants of TI ADCXX1C
PSEUDOMODULES += adc081c
PSEUDOMODULES += adc101c
PSEUDOMODULES += adc121c
# add all pseudo random number generator variants as pseudomodules
PSEUDOMODULES += prng_%

2
tests/driver_adcxx1c/Makefile

@ -3,7 +3,7 @@ include ../Makefile.tests_common
FEATURES_REQUIRED = periph_i2c
USEMODULE += adcxx1c
USEMODULE += adc081c
USEMODULE += xtimer
# set alert parameters in case they are undefined

Loading…
Cancel
Save