comparison src/g23m-aci/aci/ati_fchg.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children 089c1882788c
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 * The non-standard FreeCalypso-added AT commands implemented in this module
3 * expose the API of FreeCalypso battery charging driver FCHG.
4 */
5
6 #ifndef ATI_FCHG_C
7 #define ATI_FCHG_C
8
9 #include "aci_all.h"
10
11 #include <ctype.h>
12 #include <string.h>
13
14 #include "aci_cmh.h"
15 #include "ati_cmd.h"
16 #include "aci_cmd.h"
17 #include "aci_io.h"
18 #include "aci_cmd.h"
19 #include "l4_tim.h"
20 #include "line_edit.h"
21 #include "aci_lst.h"
22
23 #include "pcm.h"
24 #include "audio.h"
25 #include "aci.h"
26 #include "rx.h"
27 #include "pwr.h"
28 #include "l4_tim.h"
29
30 #ifdef GPRS
31 #ifdef DTI
32 #include "dti.h"
33 #include "dti_conn_mng.h"
34 #include "dti_cntrl_mng.h"
35 #endif /* DTI */
36 #include "gaci.h"
37 #include "gaci_cmh.h"
38 #include "gaci_cmd.h"
39 #endif /* GPRS */
40
41 #include "aci_mem.h"
42 #include "aci_prs.h"
43
44 #include "ati_int.h"
45
46 #ifndef _SIMULATION_
47 #include "ffs/ffs.h"
48 #endif
49
50 #ifdef FF_ATI_BAT
51
52 #include "typedefs.h"
53 #include "gdd.h"
54 #include "bat.h"
55
56 #include "ati_bat.h"
57
58 #endif /*FF_ATI_BAT*/
59
60 #include "rv/rv_defined_swe.h" // for RVM_FCHG_SWE
61
62 #ifdef RVM_FCHG_SWE
63 #include "fchg/fchg_api.h"
64
65 /* AT%CBC - customized alternative to standard AT+CBC */
66 GLOBAL T_ATI_RSLT atPercentCBC ( char *cl, UBYTE srcId )
67 {
68 struct fchg_user_state fchg;
69
70 TRACE_FUNCTION("atPercentCBC()");
71 if (fchg_get_current_state(&fchg) != RV_OK)
72 return ATI_FAIL;
73 sprintf(g_sa, "%%CBC: %d,%d,%d", fchg.chg_state, fchg.batt_mv,
74 fchg.batt_percent);
75 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
76 return ATI_CMPL;
77 }
78
79 /* AT@CHG - manual control of battery charging */
80 GLOBAL T_ATI_RSLT atAtCHG ( char *cl, UBYTE srcId )
81 {
82 enum fchg_user_charge_ctrl ctrl;
83
84 TRACE_FUNCTION("atAtCHG()");
85 cl = parse(cl, "D", &ctrl);
86 if (!cl)
87 return ATI_FAIL;
88 if (fchg_user_charge_control(ctrl) == RV_OK)
89 return ATI_CMPL;
90 else
91 return ATI_FAIL;
92 }
93
94 #endif /* RVM_FCHG_SWE */
95
96 /* AT%VBAT - retrieve VBAT measurement, independent of FCHG */
97 GLOBAL T_ATI_RSLT atPercentVBAT ( char *cl, UBYTE srcId )
98 {
99 extern USHORT *csf_return_adc(void);
100 USHORT *adc_conversion;
101
102 TRACE_FUNCTION("atPercentVBAT()");
103 adc_conversion = csf_return_adc();
104 sprintf(g_sa, "%%VBAT: %u", adc_conversion[0]);
105 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
106 return ATI_CMPL;
107 }
108
109 #endif /* ATI_FCHG_C */