annotate src/cs/drivers/drv_app/fchg/fchg_ffs_init.c @ 337:0df0668f8bea

FCHG: task core function implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 14 Dec 2017 21:47:40 +0000
parents 8166b0afcf8c
children 562fa85c8963
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
325
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement the loading of the charging config
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * and the battery table from FFS.
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "fchg/fchg_env.h"
326
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
7 #include "fchg/fchg_func_i.h"
325
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rv/rv_general.h"
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvf/rvf_api.h"
331
8166b0afcf8c FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 326
diff changeset
10 #include "rvm/rvm_use_id_list.h"
325
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "ffs/ffs_api.h"
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 void pwr_load_ffs_charging_config(void)
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 int rc;
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 rc = ffs_file_read("/etc/charging", &pwr_ctrl->config,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 sizeof(struct charging_config));
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (rc == sizeof(struct charging_config)) {
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 pwr_ctrl->config_present = TRUE;
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 rvf_send_trace(
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 "FCHG: read charging config from FFS, charging enabled", 53,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 FCHG_USE_ID);
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 } else {
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 pwr_ctrl->config_present = FALSE;
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 rvf_send_trace(
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 "FCHG: no charging config in FFS, will not charge", 48,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 NULL_PARAM, RV_TRACE_LEVEL_WARNING,
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 FCHG_USE_ID);
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
ab47ade99fa9 FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
326
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
33
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
34 void pwr_load_ffs_batt_table(void)
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
35 {
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
36 int rc;
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
37
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
38 rc = ffs_file_read("/etc/batterytab", pwr_ctrl->batt_thresholds,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
39 sizeof(pwr_ctrl->batt_thresholds));
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
40 if (rc >= sizeof(T_PWR_THRESHOLDS)) {
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
41 pwr_ctrl->nb_thresholds = rc / sizeof(T_PWR_THRESHOLDS);
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
42 rvf_send_trace("FCHG: battery table loaded from FFS", 35,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
43 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
44 FCHG_USE_ID);
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
45 } else {
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
46 pwr_set_default_batt_table();
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
47 rvf_send_trace("FCHG: using compiled-in default battery table",
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
48 45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
49 FCHG_USE_ID);
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
50 }
919b44c991fc FCHG: reading of battery table from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
51 }