comparison src/cs/drivers/drv_app/fchg/fchg_ffs_init.c @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
1 /*
2 * In this module we implement the loading of the charging config
3 * and the battery table from FFS.
4 */
5
6 #include "fchg/fchg_env.h"
7 #include "fchg/fchg_func_i.h"
8 #include "rv/rv_general.h"
9 #include "rvf/rvf_api.h"
10 #include "rvm/rvm_use_id_list.h"
11 #include "ffs/ffs_api.h"
12
13 void pwr_load_ffs_charging_config(void)
14 {
15 int rc;
16
17 rc = ffs_file_read("/etc/charging", &pwr_ctrl->config,
18 sizeof(struct charging_config));
19 if (rc == sizeof(struct charging_config)) {
20 pwr_ctrl->config_present = TRUE;
21 rvf_send_trace(
22 "FCHG: read charging config from FFS, charging enabled", 53,
23 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
24 FCHG_USE_ID);
25 } else {
26 pwr_ctrl->config_present = FALSE;
27 rvf_send_trace(
28 "FCHG: no charging config in FFS, will not charge", 48,
29 NULL_PARAM, RV_TRACE_LEVEL_WARNING,
30 FCHG_USE_ID);
31 }
32 }
33
34 void pwr_load_ffs_batt_table(void)
35 {
36 int rc;
37
38 rc = ffs_file_read("/etc/batterytab", pwr_ctrl->batt_thresholds,
39 sizeof(pwr_ctrl->batt_thresholds));
40 if (rc >= (int)sizeof(T_PWR_THRESHOLDS)) {
41 pwr_ctrl->nb_thresholds = rc / sizeof(T_PWR_THRESHOLDS);
42 rvf_send_trace("FCHG: battery table loaded from FFS", 35,
43 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
44 FCHG_USE_ID);
45 } else {
46 pwr_set_default_batt_table();
47 rvf_send_trace("FCHG: using compiled-in default battery table",
48 45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
49 FCHG_USE_ID);
50 }
51 }