FreeCalypso > hg > fc-magnetite
annotate src/g23m-aci/aci/ati_fchg.c @ 639:026c98f757a6
tpudrv12.h & targets/gtm900.h: our current support is for MGC2GSMT version only
As it turns out, there exist two different Huawei-made hw platforms both
bearing the marketing name GTM900-B: one is MG01GSMT, the other is MGC2GSMT.
The two are NOT fw-compatible: aside from flash chip differences which
should be handled by autodetection, the two hw platforms are already known
to have different RFFEs with different control signals, and there may be
other differences not yet known. Our current gtm900 build target is for
MGC2GSMT only; we do not yet have a specimen of MG01GSMT on hand, hence
no support for that version will be possible until and unless someone
provides one.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 30 Jan 2020 18:19:01 +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 */ |