annotate src/aci2/aci/ati_fchg.c @ 673:62a5285e014a

Lorekeeping: allow tpudrv-leonardo.lib on Leonardo/Tango Back in 2015 the Mother's idea was to produce a FreeCalypso development board that would be a clone of TI Leonardo, including the original quadband RFFE; one major additional stipulation was that this board needed to be able to run original unmodified TCS211-20070608 firmware with all blobs intact, with only minimal binary patches to main.lib and tpudrv.lib. The necessary patched libs were produced at that time in the tcs211-patches repository. That plan was changed and we produced FCDEV3B instead, with Openmoko's triband RFFE instead of Leonardo quadband, but when FC Magnetite started in 2016, a TPUDRV_blob= provision was still made, allowing the possibility of patching OM's tpudrv.lib for a restored Leonardo RFFE. Now in 2020 we have FC Tango which is essentially a verbatim clone of Leonardo core, including the original quadband RFFE. We have also deblobbed our firmware so much that we have absolutely no real need for a blob version of tpudrv.lib - but I thought it would be neat to put the ancient TPUDRV_blob= mechanism (classic config) to its originally intended use, just for the heck of it.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 29 May 2020 03:55:36 +0000
parents 96c1d047b3c6
children
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
565
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
96 /* AT%VBAT - retrieve VBAT measurement, independent of FCHG */
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
97 GLOBAL T_ATI_RSLT atPercentVBAT ( char *cl, UBYTE srcId )
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
98 {
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
99 extern USHORT *csf_return_adc(void);
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
100 USHORT *adc_conversion;
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
101
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
102 TRACE_FUNCTION("atPercentVBAT()");
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
103 adc_conversion = csf_return_adc();
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
104 sprintf(g_sa, "%%VBAT: %u", adc_conversion[0]);
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
105 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
106 return ATI_CMPL;
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
107 }
96c1d047b3c6 aci2: AT%VBAT and melody play enhancements matching aci3
Mychaela Falconia <falcon@freecalypso.org>
parents: 349
diff changeset
108
347
78d1df0b8487 aci2: AT%CBC and AT@CHARGE implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 #endif /* ATI_FCHG_C */