annotate src/aci2/aci/ati_fchg.c @ 455:beff67c568cf

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