FreeCalypso > hg > fc-magnetite
annotate src/g23m-aci/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 | adae731ae50d |
children |
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 |
562
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
96 /* AT%VBAT - retrieve VBAT measurement, independent of FCHG */ |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
97 GLOBAL T_ATI_RSLT atPercentVBAT ( char *cl, UBYTE srcId ) |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
98 { |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
99 extern USHORT *csf_return_adc(void); |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
100 USHORT *adc_conversion; |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
101 |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
102 TRACE_FUNCTION("atPercentVBAT()"); |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
103 adc_conversion = csf_return_adc(); |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
104 sprintf(g_sa, "%%VBAT: %u", adc_conversion[0]); |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
105 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
106 return ATI_CMPL; |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
107 } |
adae731ae50d
aci3: implemented AT%VBAT command independent of FCHG
Mychaela Falconia <falcon@freecalypso.org>
parents:
371
diff
changeset
|
108 |
371
9a237d51c226
aci3: ati_fchg.c module brought over from aci2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 #endif /* ATI_FCHG_C */ |