FreeCalypso > hg > fc-magnetite
annotate src/g23m-aci/aci/ati_fchg.c @ 430:68d23de90144
src/ui3/bmi/Icons: file renames to make the case consistent
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 22 Jan 2018 00:19:11 +0000 |
parents | 9a237d51c226 |
children | adae731ae50d |
rev | line source |
---|---|
371
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * The non-standard FreeCalypso-added AT commands implemented in this module |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * expose the API of FreeCalypso battery charging driver FCHG. |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #ifndef ATI_FCHG_C |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #define ATI_FCHG_C |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "aci_all.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <ctype.h> |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "aci_cmh.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "ati_cmd.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "aci_cmd.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "aci_io.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "aci_cmd.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "l4_tim.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "line_edit.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "aci_lst.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "pcm.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "audio.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "aci.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "rx.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include "pwr.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "l4_tim.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #ifdef GPRS |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #ifdef DTI |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "dti.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "dti_conn_mng.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "dti_cntrl_mng.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #endif /* DTI */ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include "gaci.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #include "gaci_cmh.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 #include "gaci_cmd.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 #endif /* GPRS */ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 #include "aci_mem.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 #include "aci_prs.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 #include "ati_int.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #ifndef _SIMULATION_ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 #include "ffs/ffs.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #endif |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 #ifdef FF_ATI_BAT |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 #include "typedefs.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 #include "gdd.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 #include "bat.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 #include "ati_bat.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 #endif /*FF_ATI_BAT*/ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 #include "rv/rv_defined_swe.h" // for RVM_FCHG_SWE |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 #ifdef RVM_FCHG_SWE |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 #include "fchg/fchg_api.h" |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 /* AT%CBC - customized alternative to standard AT+CBC */ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 GLOBAL T_ATI_RSLT atPercentCBC ( char *cl, UBYTE srcId ) |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 { |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 struct fchg_user_state fchg; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 TRACE_FUNCTION("atPercentCBC()"); |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 if (fchg_get_current_state(&fchg) != RV_OK) |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 return ATI_FAIL; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 sprintf(g_sa, "%%CBC: %d,%d,%d", fchg.chg_state, fchg.batt_mv, |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 fchg.batt_percent); |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 return ATI_CMPL; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 /* AT@CHG - manual control of battery charging */ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 GLOBAL T_ATI_RSLT atAtCHG ( char *cl, UBYTE srcId ) |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 { |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 enum fchg_user_charge_ctrl ctrl; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 TRACE_FUNCTION("atAtCHG()"); |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 cl = parse(cl, "D", &ctrl); |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (!cl) |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 return ATI_FAIL; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 if (fchg_user_charge_control(ctrl) == RV_OK) |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 return ATI_CMPL; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 else |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 return ATI_FAIL; |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 #endif /* RVM_FCHG_SWE */ |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 |
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 #endif /* ATI_FCHG_C */ |