changeset 326:919b44c991fc

FCHG: reading of battery table from FFS implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 05 Dec 2017 05:04:09 +0000
parents ab47ade99fa9
children d7b25dca1266
files src/cs/drivers/drv_app/fchg/fchg_default_batt.c src/cs/drivers/drv_app/fchg/fchg_ffs_init.c src/cs/drivers/drv_app/fchg/fchg_func_i.h
diffstat 3 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/fchg/fchg_default_batt.c	Tue Dec 05 02:16:32 2017 +0000
+++ b/src/cs/drivers/drv_app/fchg/fchg_default_batt.c	Tue Dec 05 05:04:09 2017 +0000
@@ -6,6 +6,7 @@
  */
 
 #include "fchg/fchg_env.h"
+#include "fchg/fchg_func_i.h"
 #include "rv/rv_general.h"
 #include <string.h>
 
--- a/src/cs/drivers/drv_app/fchg/fchg_ffs_init.c	Tue Dec 05 02:16:32 2017 +0000
+++ b/src/cs/drivers/drv_app/fchg/fchg_ffs_init.c	Tue Dec 05 05:04:09 2017 +0000
@@ -4,6 +4,7 @@
  */
 
 #include "fchg/fchg_env.h"
+#include "fchg/fchg_func_i.h"
 #include "rv/rv_general.h"
 #include "rvf/rvf_api.h"
 #include "ffs/ffs_api.h"
@@ -28,3 +29,22 @@
 				FCHG_USE_ID);
 	}
 }
+
+void pwr_load_ffs_batt_table(void)
+{
+	int rc;
+
+	rc = ffs_file_read("/etc/batterytab", pwr_ctrl->batt_thresholds,
+			   sizeof(pwr_ctrl->batt_thresholds));
+	if (rc >= sizeof(T_PWR_THRESHOLDS)) {
+		pwr_ctrl->nb_thresholds = rc / sizeof(T_PWR_THRESHOLDS);
+		rvf_send_trace("FCHG: battery table loaded from FFS", 35,
+				NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
+				FCHG_USE_ID);
+	} else {
+		pwr_set_default_batt_table();
+		rvf_send_trace("FCHG: using compiled-in default battery table",
+				45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
+				FCHG_USE_ID);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cs/drivers/drv_app/fchg/fchg_func_i.h	Tue Dec 05 05:04:09 2017 +0000
@@ -0,0 +1,12 @@
+/*
+ * Declarations of internal functions live here.
+ */
+
+#ifndef __FCHG_FUNC_I
+#define __FCHG_FUNC_I
+
+void pwr_load_ffs_batt_table(void);
+void pwr_load_ffs_charging_config(void);
+void pwr_set_default_batt_table(void);
+
+#endif	/* include guard */