From fc4267054cb89397cca85efe83868615f6c9c562 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Thu, 2 May 2013 21:42:36 +0800 Subject: spring: Update PMU ADC constant The current sense resistor has changed. Update constant here to reflect the new values for DVT1. BUG=None TEST=Build Spring BRANCH=Spring Original-Change-Id: Ib27c45cef569fa758db2fbb428150c8c2b6732ef Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/49892 Reviewed-by: Vincent Palatin Change-Id: I176346f13880a63c611fc70dcdb4c462e729b146 Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/51476 Reviewed-by: Vincent Palatin --- board/spring/board.c | 2 +- board/spring/board.h | 4 ++++ board/spring/usb_charging.c | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/board/spring/board.c b/board/spring/board.c index 968986acbd..2abc1d8425 100644 --- a/board/spring/board.c +++ b/board/spring/board.c @@ -526,7 +526,7 @@ static int power_command_info(struct host_cmd_handler_args *args) r->voltage_system = pmu_adc_read(ADC_VAC, ADC_FLAG_KEEP_ON) * 17000 / 1024; r->current_system = pmu_adc_read(ADC_IAC, 0) - * 20 * 33 / 1024; + * (1000 / R_INPUT_MOHM) * 33 / 1024; r->usb_dev_type = board_get_usb_dev_type(); r->usb_current_limit = board_get_usb_current_limit(); args->response_size = sizeof(*r); diff --git a/board/spring/board.h b/board/spring/board.h index 2fd69787f7..662188fb80 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -75,6 +75,10 @@ #define TIM_CLOCK_MSB 2 #define TIM_CLOCK_LSB 4 +/* Current sense resistor values */ +#define R_INPUT_MOHM 20 /* mOhm */ +#define R_BATTERY_MOHM 33 /* mOhm */ + /* ADC signal */ #define CONFIG_ADC enum adc_channel { diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index a0c54517b9..f0c40ea403 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -715,11 +715,11 @@ static int command_batdebug(int argc, char **argv) ccprintf("VAC = %d mV\n", pmu_adc_read(ADC_VAC, ADC_FLAG_KEEP_ON) * 17000 / 1024); ccprintf("IAC = %d mA\n", pmu_adc_read(ADC_IAC, ADC_FLAG_KEEP_ON) - * 20 * 33 / 1024); + * (1000 / R_INPUT_MOHM) * 33 / 1024); ccprintf("VBAT = %d mV\n", pmu_adc_read(ADC_VBAT, ADC_FLAG_KEEP_ON) * 17000 / 1024); ccprintf("IBAT = %d mA\n", pmu_adc_read(ADC_IBAT, 0) - * 50 * 40 / 1024); + * (1000 / R_BATTERY_MOHM) * 40 / 1024); ccprintf("PWM = %d%%\n", STM32_TIM_CCR1(3)); battery_current(&val); ccprintf("Battery Current = %d mA\n", val); -- cgit v1.2.1