summaryrefslogtreecommitdiff
path: root/board/it8380dev
diff options
context:
space:
mode:
authorDino Li <dino.li@ite.com.tw>2014-12-03 17:28:42 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-19 09:17:27 +0000
commit165cf6c8813420e1ce525e103b42f19017228ec6 (patch)
treeae6722100c5f3d6207fcf206645df2b25ed06654 /board/it8380dev
parent7ec2e4158af7d5564038bc4b0336653445ba08c5 (diff)
downloadchrome-ec-165cf6c8813420e1ce525e103b42f19017228ec6.tar.gz
it8380dev: add adc control module
Add adc control module for emulation board. The ADC converts the input voltage signal ranging from 0v to 3v into a 10-bit unsigned integer. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=manual test. 1 - adc channel 1, 3, 5, and 7 to ground. 2 - adc channel 0 and 2 to 1.26v. 3 - adc channel 4 and 6 to 1.72v. 4 - condition, factor_mul = 3000, factor_div = 1024, and shift = 0. 5 - console "adc", result as following. adc_ch0 = 1256 adc_ch1 = 0 adc_ch2 = 1256 adc_ch3 = 0 adc_ch4 = 1722 adc_ch5 = 0 adc_ch6 = 1725 adc_ch7 = 0 Change-Id: I72efd09c9f7dbff25c4f6fd4846c9b1c1e5637ca Reviewed-on: https://chromium-review.googlesource.com/228092 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw>
Diffstat (limited to 'board/it8380dev')
-rw-r--r--board/it8380dev/board.c16
-rw-r--r--board/it8380dev/board.h14
2 files changed, 30 insertions, 0 deletions
diff --git a/board/it8380dev/board.c b/board/it8380dev/board.c
index 588ab4d0d7..201a6c20c0 100644
--- a/board/it8380dev/board.c
+++ b/board/it8380dev/board.c
@@ -13,6 +13,8 @@
#include "util.h"
#include "pwm.h"
#include "pwm_chip.h"
+#include "adc.h"
+#include "adc_chip.h"
/* Test GPIO interrupt function that toggles one LED. */
void test_interrupt(enum gpio_signal signal)
@@ -47,6 +49,20 @@ static void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
+const struct adc_t adc_channels[] = {
+ /* Convert to mV (3000mV/1024). */
+ {"adc_ch0", 3000, 1024, 0, 0},
+ {"adc_ch1", 3000, 1024, 0, 1},
+ {"adc_ch2", 3000, 1024, 0, 2},
+ {"adc_ch3", 3000, 1024, 0, 3},
+ {"adc_ch4", 3000, 1024, 0, 4},
+ {"adc_ch5", 3000, 1024, 0, 5},
+ {"adc_ch6", 3000, 1024, 0, 6},
+ {"adc_ch7", 3000, 1024, 0, 7},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
/*****************************************************************************/
/* Console commands */
diff --git a/board/it8380dev/board.h b/board/it8380dev/board.h
index 1d612d32a2..afadc3c40b 100644
--- a/board/it8380dev/board.h
+++ b/board/it8380dev/board.h
@@ -29,5 +29,19 @@ enum pwm_channel {
PWM_CH_COUNT
};
+enum adc_channel {
+ ADC_CH_0,
+ ADC_CH_1,
+ ADC_CH_2,
+ ADC_CH_3,
+ ADC_CH_4,
+ ADC_CH_5,
+ ADC_CH_6,
+ ADC_CH_7,
+
+ /* Number of ADC channels */
+ ADC_CH_COUNT
+};
+
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */