diff options
author | Vic Yang <victoryang@chromium.org> | 2013-04-30 20:02:58 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-04-30 10:38:43 -0700 |
commit | c08e0ade765bf69fb9ab3f62305a84a4d3d34c1d (patch) | |
tree | 7392ff1c7148233efc85dd86dc90092d7d53f72f | |
parent | 115ab924fc16e8d8403433b243b1fabb53e42dac (diff) | |
download | chrome-ec-c08e0ade765bf69fb9ab3f62305a84a4d3d34c1d.tar.gz |
Fix ADC test for LM4
LM4 doesn't have implementation of adc_read_all_channels(). Let's use
adc_read_channel() in this case.
BUG=chrome-os-partner:18598
TEST=Build stress test for link. See no error about
adc_read_all_channels() undefined.
BRANCH=None
Change-Id: I5b13384468667cbd17b83faab9f9d3fdc48de91d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49589
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | chip/lm4/lm4_adc.h | 3 | ||||
-rw-r--r-- | chip/stm32/stm32_adc.h | 3 | ||||
-rw-r--r-- | include/adc.h | 2 | ||||
-rw-r--r-- | test/stress.c | 14 |
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]; |