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
Change-Id: Ib27c45cef569fa758db2fbb428150c8c2b6732ef
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49892
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
diff --git a/common/extpower_usb.c b/common/extpower_usb.c
index 85f11f3..7f1dbcd 100644
--- a/common/extpower_usb.c
+++ b/common/extpower_usb.c
@@ -82,6 +82,10 @@
#define PWM_MAPPING_A 3012
#define PWM_MAPPING_B (-29)
+/* Current sense resistor values */
+#define R_INPUT_MOHM 20 /* mOhm */
+#define R_BATTERY_MOHM 33 /* mOhm */
+
static int current_dev_type = TSU6721_TYPE_NONE;
static int nominal_pwm_duty;
static int current_pwm_duty;
@@ -779,11 +783,11 @@
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);
@@ -844,7 +848,7 @@
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 = current_dev_type;
/* Approximate value by PWM duty cycle */