summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/lm4/lm4_adc.h3
-rw-r--r--chip/stm32/stm32_adc.h3
-rw-r--r--include/adc.h2
-rw-r--r--test/stress.c14
4 files changed, 16 insertions, 6 deletions
diff --git a/chip/lm4/lm4_adc.h b/chip/lm4/lm4_adc.h
index 69479ac265..770c984209 100644
--- a/chip/lm4/lm4_adc.h
+++ b/chip/lm4/lm4_adc.h
@@ -36,9 +36,6 @@ extern const struct adc_t adc_channels[ADC_CH_COUNT];
#define ADC_READ_MIN 0
#define ADC_READ_MAX 4095
-/* Value returned if the read failed. */
-#define ADC_READ_ERROR -1
-
/* Just plain id mapping for code readability */
#define LM4_AIN(x) (x)
diff --git a/chip/stm32/stm32_adc.h b/chip/stm32/stm32_adc.h
index d67459972c..13186720ca 100644
--- a/chip/stm32/stm32_adc.h
+++ b/chip/stm32/stm32_adc.h
@@ -23,9 +23,6 @@ extern const struct adc_t adc_channels[ADC_CH_COUNT];
#define ADC_READ_MIN 0
#define ADC_READ_MAX 4095
-/* Value returned if the read failed. */
-#define ADC_READ_ERROR -1
-
/* Just plain id mapping for code readability */
#define STM32_AIN(x) (x)
diff --git a/include/adc.h b/include/adc.h
index 715852cd76..8c5dda02d5 100644
--- a/include/adc.h
+++ b/include/adc.h
@@ -10,6 +10,8 @@
#include "common.h"
+#define ADC_READ_ERROR -1
+
/**
* Read an ADC channel.
*
diff --git a/test/stress.c b/test/stress.c
index ecd975f712..8a69d84b19 100644
--- a/test/stress.c
+++ b/test/stress.c
@@ -126,6 +126,20 @@ static int test_i2c(void)
#endif
#ifdef CONFIG_ADC
+__attribute__((weak)) int adc_read_all_channels(int *data)
+{
+ int i;
+ int rv = EC_SUCCESS;
+
+ for (i = 0 ; i < ADC_CH_COUNT; ++i) {
+ data[i] = adc_read_channel(i);
+ if (data[i] == ADC_READ_ERROR)
+ rv = EC_ERROR_UNKNOWN;
+ }
+
+ return rv;
+}
+
static int test_adc(void)
{
int data[ADC_CH_COUNT];