diff src/cs/layer1/cust0/l1_cust.c @ 330:dd3c89e9ca2e

l1_cust.c: added function that exports the calibrated Vbat conversion for use by the new battery charging code
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 14 Dec 2017 04:10:30 +0000
parents 047fb78947d5
children e0b27310e6ba
line wrap: on
line diff
--- a/src/cs/layer1/cust0/l1_cust.c	Thu Dec 14 03:55:02 2017 +0000
+++ b/src/cs/layer1/cust0/l1_cust.c	Thu Dec 14 04:10:30 2017 +0000
@@ -1006,6 +1006,16 @@
   memcpy(adc_phy, &adc.converted[0], sizeof(adc.raw));
 }
 
+/*
+ * FreeCalypso: the following function has been added
+ * to support the new battery charging code.
+ */
+
+UWORD16 madc_vbat_2_physical (UWORD16 adc_val)
+{
+  return (((UWORD32)(adc_cal.a[ADC_VBAT] * adc_val)) >> 10) +
+         adc_cal.b[ADC_VBAT];
+}
 
   /*------------------------------------------------------*/
   /*  get_cal_from_nvmem                                  */