FreeCalypso > hg > fc-tourmaline
annotate src/cs/drivers/drv_app/fchg/fchg_default_batt.c @ 236:3c790d29748e
fchg_is_running startup sync flag change:
set the flag when the first ADC message has been processed,
and not merely when the task is running - this way the flag indicates
that meaningful info about the state of the battery is available.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 02 May 2021 04:25:48 +0000 |
parents | 75067af48bfd |
children |
rev | line source |
---|---|
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module provides the default table of battery State-of-Charge |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * thresholds in the absence of a customized table in FFS. |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * The present default table has been taken from Pirelli's firmware. |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 */ |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "fchg/fchg_env.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "fchg/fchg_func_i.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "rv/rv_general.h" |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static const T_PWR_THRESHOLDS default_batt_table[] = { |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 {4170, 100}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 {4120, 95}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 {4070, 90}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 {4030, 85}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 {3964, 80}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 {3930, 75}, |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
20 {3900, 70}, /* 4 bars */ |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 {3882, 65}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 {3847, 60}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 {3805, 55}, |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
24 {3786, 50}, /* 3 bars */ |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 {3771, 45}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 {3759, 40}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 {3750, 35}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 {3745, 30}, |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
29 {3737, 25}, /* 2 bars */ |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 {3719, 20}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 {3688, 15}, |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 {3663, 10}, |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
33 {3539, 5}, /* 1 bar */ |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 {3370, 0} |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 }; |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
37 static const UINT8 default_batt_bars_table[NB_BARS_THRESH] = {6, 10, 15, 19}; |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
38 |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 void pwr_set_default_batt_table(void) |
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 { |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
41 memcpy(pwr_ctrl->batt.percent_thresh, default_batt_table, |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 sizeof default_batt_table); |
61
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
43 pwr_ctrl->nb_percent_thresh = sizeof(default_batt_table) / |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
44 sizeof(T_PWR_THRESHOLDS); |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
45 memcpy(pwr_ctrl->batt.bars_thresh, default_batt_bars_table, |
75067af48bfd
FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
46 sizeof default_batt_bars_table); |
0
4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |