summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-12-25 11:02:04 +0800
committerChromeBot <chrome-bot@google.com>2013-01-08 08:58:37 -0800
commit5019591f68b22f8d09a139e30488a8e4525311eb (patch)
tree1851d6cf9607b80f769c67c2c80f8c339dc451ae
parent40c79398a63e8192246ff79900a3974041c9d48d (diff)
downloadchrome-ec-5019591f68b22f8d09a139e30488a8e4525311eb.tar.gz
spring: Configure ADC pins
ADC pins should be configured as analog input pins. Also sets conversion factor to obtain voltage values in mV. BUG=chrome-os-partner:14319 TEST=Manual BRANCH=none Change-Id: I7e084052062c2b669f10da4309e99bf9e2954ded Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/40199 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/spring/board.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/board/spring/board.c b/board/spring/board.c
index db39e26344..1ac1107625 100644
--- a/board/spring/board.c
+++ b/board/spring/board.c
@@ -106,10 +106,10 @@ const struct adc_t adc_channels[ADC_CH_COUNT] = {
* voltage divider, the conversion factor is 6600mV/4096.
*/
[ADC_CH_USB_VBUS_SNS] = {"USB_VBUS_SNS", 6600, 4096, 0, STM32_AIN(5)},
- /* Micro USB D+ sense pin. Raw ADC value. */
- [ADC_CH_USB_DP_SNS] = {"USB_DP_SNS", 1, 1, 0, STM32_AIN(2)},
- /* Micro USB D- sense pin. Raw ADC value. */
- [ADC_CH_USB_DN_SNS] = {"USB_DN_SNS", 1, 1, 0, STM32_AIN(4)},
+ /* Micro USB D+ sense pin. Converted to mV (3300mV/4096). */
+ [ADC_CH_USB_DP_SNS] = {"USB_DP_SNS", 3300, 4096, 0, STM32_AIN(2)},
+ /* Micro USB D- sense pin. Converted to mV (3300mV/4096). */
+ [ADC_CH_USB_DN_SNS] = {"USB_DN_SNS", 3300, 4096, 0, STM32_AIN(4)},
};
void configure_board(void)
@@ -137,6 +137,9 @@ void configure_board(void)
STM32_GPIO_AFIO_MAPR = (STM32_GPIO_AFIO_MAPR & ~(0x3 << 10))
| (2 << 10);
+ /* Analog input for ADC pins (PA2, PA4, PA5) */
+ STM32_GPIO_CRL_OFF(GPIO_A) &= ~0x00ff0f00;
+
/*
* Set alternate function for USART1. For alt. function input
* the port is configured in either floating or pull-up/down