summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parker <dparker@chromium.org>2013-08-30 14:30:36 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-08-30 23:56:09 +0000
commit7abb4f75ba8a241c727b1e4e60f13b1f0e25ac74 (patch)
treed4b8d34d7d68f16e3f22e05bebac56b3d038bb0a
parente286b8c87412dd41bbf0e3211fe3f4f89cf5a4f3 (diff)
downloadchrome-ec-7abb4f75ba8a241c727b1e4e60f13b1f0e25ac74.tar.gz
Peppy: Correct adc calculation of charger current
BUG=chrome-os-partner:22405 BRANCH=peppy TEST=Run 'adc' command. Measure charger current reported against actual current. Change-Id: I77b4f23cd945be6e0a6251832e95a9423566604d Original-Change-Id: I1772a781d9d0100e69a5fd1e9a9590252ccd88d6 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167732 Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org> Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org> Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
-rw-r--r--board/peppy/board.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/board/peppy/board.c b/board/peppy/board.c
index 51c008a428..8a8aa2c954 100644
--- a/board/peppy/board.c
+++ b/board/peppy/board.c
@@ -146,11 +146,13 @@ const struct adc_t adc_channels[] = {
{"ECTemp", LM4_ADC_SEQ0, -225, ADC_READ_MAX, 420,
LM4_AIN_NONE, 0x0e /* TS0 | IE0 | END0 */, 0, 0},
- /* HEY: need different equation for Peppy*/
- /* Charger current is mapped from 0~4000mA to 0~1.6V.
- * And ADC maps 0~3.3V to ADC_READ_MAX.
+ /* IOUT == ICMNT is on PE3/AIN0 */
+ /* We have 0.01-ohm resistors, and IOUT is 20X the differential
+ * voltage, so 1000mA ==> 200mV.
+ * ADC returns 0x000-0xFFF, which maps to 0.0-3.3V (as configured).
+ * mA = 1000 * ADC_VALUE / ADC_READ_MAX * 3300 / 200
*/
- {"ChargerCurrent", LM4_ADC_SEQ1, 33 * 4000, ADC_READ_MAX * 16, 0,
+ {"ChargerCurrent", LM4_ADC_SEQ1, 33000, ADC_READ_MAX * 2, 0,
LM4_AIN(0), 0x06 /* IE0 | END0 */, LM4_GPIO_E, (1<<3)},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);