annotate src/cs/drivers/drv_app/fchg/fchg_convert_mA.c @ 262:7420959e02ec

FCHG rework for charger plug/unplug debouncing
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 May 2021 05:38:55 +0000
parents 09ea37852fd6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
225
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the fchg_convert_ichg_to_mA() function,
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * converting charging current (Ichg) measurements from ADC units
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * to human-friendly mA numbers. In the phone hardware this current
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * measurement is made with the aid of a current measurement resistor
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * placed in the charging current path (the Iota chip's MADC actually
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 * measures the voltage across this resistor, between VCCS and VBATS
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * terminals), and it just so happens that different phone designers
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 * have chosen different values for this current measurement resistor:
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * Pirelli DP-L10 uses 0.20R, following TI's canon, whereas Mot C1xx
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * phones use 0.15R. Because of these different resistor values,
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * the formula for converting ADC units to mA becomes target-dependent.
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 */
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "fchg/fchg_api.h"
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include "fc-target.h"
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 UINT16 fchg_convert_ichg_to_mA(UINT16 ichg)
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #ifdef CONFIG_TARGET_COMPAL
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 /* formula for 0.15R */
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return (ichg * 875 / 768);
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #else
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /* formula for 0.20R */
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 return (ichg * 875 / 1024);
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 #endif
09ea37852fd6 add function to convert Ichg ADC readings to mA
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }