FreeCalypso > hg > fc-tourmaline
comparison src/g23m-aci/aci/ati_fcmisc.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 | a927f030a4e0 |
comparison
equal
deleted
inserted
replaced
0:4e78acac3d88 | 1:fa8dc04885d8 |
---|---|
1 /* | |
2 * This module implements miscellaneous FreeCalypso-added AT commands. | |
3 */ | |
4 | |
5 #ifndef ATI_FCMISC_C | |
6 #define ATI_FCMISC_C | |
7 | |
8 #include "aci_all.h" | |
9 | |
10 #include <ctype.h> | |
11 #include <string.h> | |
12 | |
13 #include "aci_cmh.h" | |
14 #include "ati_cmd.h" | |
15 #include "aci_cmd.h" | |
16 #include "aci_io.h" | |
17 #include "aci_cmd.h" | |
18 #include "l4_tim.h" | |
19 #include "line_edit.h" | |
20 #include "aci_lst.h" | |
21 | |
22 #include "pcm.h" | |
23 #include "audio.h" | |
24 #include "aci.h" | |
25 #include "rx.h" | |
26 #include "pwr.h" | |
27 #include "l4_tim.h" | |
28 | |
29 #ifdef GPRS | |
30 #ifdef DTI | |
31 #include "dti.h" | |
32 #include "dti_conn_mng.h" | |
33 #include "dti_cntrl_mng.h" | |
34 #endif /* DTI */ | |
35 #include "gaci.h" | |
36 #include "gaci_cmh.h" | |
37 #include "gaci_cmd.h" | |
38 #endif /* GPRS */ | |
39 | |
40 #include "aci_mem.h" | |
41 #include "aci_prs.h" | |
42 | |
43 #include "ati_int.h" | |
44 | |
45 #ifndef _SIMULATION_ | |
46 #include "ffs/ffs.h" | |
47 #endif | |
48 | |
49 #ifdef FF_ATI_BAT | |
50 | |
51 #include "typedefs.h" | |
52 #include "gdd.h" | |
53 #include "bat.h" | |
54 | |
55 #include "ati_bat.h" | |
56 | |
57 #endif /*FF_ATI_BAT*/ | |
58 | |
59 #include "main/sys_types.h" | |
60 #include "fc-target.h" | |
61 #include "armio.h" | |
62 | |
63 extern SYS_UWORD8 SIM_allow_speed_enhancement; | |
64 | |
65 /* AT@SPENH - enable or disable SIM speed enhancement */ | |
66 GLOBAL T_ATI_RSLT atAtSPENH ( char *cl, UBYTE srcId ) | |
67 { | |
68 int state, nonvol = 0; | |
69 | |
70 TRACE_FUNCTION("atAtSPENH()"); | |
71 | |
72 cl = parse(cl, "Dd", &state, &nonvol); | |
73 if (!cl) | |
74 return (ATI_FAIL); | |
75 if (state != 0 && state != 1) | |
76 return (ATI_FAIL); | |
77 SIM_allow_speed_enhancement = state; | |
78 if (!nonvol) | |
79 return (ATI_CMPL); | |
80 ffs_mkdir("/etc"); | |
81 if (ffs_file_write("/etc/SIM_spenh", &SIM_allow_speed_enhancement, 1, | |
82 FFS_O_CREATE | FFS_O_TRUNC) == EFFS_OK) | |
83 return (ATI_CMPL); | |
84 else | |
85 return (ATI_FAIL); | |
86 } | |
87 | |
88 GLOBAL T_ATI_RSLT queatAtSPENH (char *cl, UBYTE srcId) | |
89 { | |
90 char *me="@SPENH: "; | |
91 | |
92 TRACE_FUNCTION("queatAtSPENH()"); | |
93 | |
94 sprintf(g_sa, "%s%u", me, SIM_allow_speed_enhancement); | |
95 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
96 return (ATI_CMPL); | |
97 } | |
98 | |
99 #ifdef TARGET_HAS_LPG | |
100 /* AT@LPG - program LPG output */ | |
101 GLOBAL T_ATI_RSLT atAtLPG ( char *cl, UBYTE srcId ) | |
102 { | |
103 unsigned glob, period = 0, ontime = 0; | |
104 | |
105 TRACE_FUNCTION("atAtLPG()"); | |
106 | |
107 cl = parse(cl, "Ddd", &glob, &period, &ontime); | |
108 if (!cl) | |
109 return (ATI_FAIL); | |
110 if (glob > 3 || period > 7 || ontime > 7) | |
111 return (ATI_FAIL); | |
112 *(volatile SYS_UWORD8 *)0xFFFE7801 = 0x01; | |
113 *(volatile SYS_UWORD8 *)0xFFFE7800 = | |
114 (glob << 6) | (ontime << 3) | period; | |
115 return (ATI_CMPL); | |
116 } | |
117 | |
118 GLOBAL T_ATI_RSLT queatAtLPG (char *cl, UBYTE srcId) | |
119 { | |
120 char *me="@LPG: "; | |
121 SYS_UWORD8 regval; | |
122 unsigned glob, period, ontime; | |
123 | |
124 TRACE_FUNCTION("queatAtLPG()"); | |
125 | |
126 regval = *(volatile SYS_UWORD8 *)0xFFFE7800; | |
127 glob = (regval >> 6) & 3; | |
128 ontime = (regval >> 3) & 7; | |
129 period = regval & 7; | |
130 sprintf(g_sa, "%s%u,%u,%u", me, glob, period, ontime); | |
131 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
132 return (ATI_CMPL); | |
133 } | |
134 #endif /* TARGET_HAS_LPG */ | |
135 | |
136 #ifdef TARGET_HAS_PWL | |
137 /* AT@PWL - program PWL output */ | |
138 GLOBAL T_ATI_RSLT atAtPWL ( char *cl, UBYTE srcId ) | |
139 { | |
140 unsigned level; | |
141 | |
142 TRACE_FUNCTION("atAtPWL()"); | |
143 | |
144 cl = parse(cl, "D", &level); | |
145 if (!cl) | |
146 return (ATI_FAIL); | |
147 if (level > 255) | |
148 return (ATI_FAIL); | |
149 *(volatile SYS_UWORD8 *)0xFFFE8000 = level; | |
150 *(volatile SYS_UWORD8 *)0xFFFE8001 = 0x01; | |
151 return (ATI_CMPL); | |
152 } | |
153 | |
154 GLOBAL T_ATI_RSLT queatAtPWL (char *cl, UBYTE srcId) | |
155 { | |
156 char *me="@PWL: "; | |
157 SYS_UWORD8 regval; | |
158 | |
159 TRACE_FUNCTION("queatAtPWL()"); | |
160 | |
161 regval = *(volatile SYS_UWORD8 *)0xFFFE8000; | |
162 sprintf(g_sa, "%s%u", me, regval); | |
163 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
164 return (ATI_CMPL); | |
165 } | |
166 #endif /* TARGET_HAS_PWL */ | |
167 | |
168 /* AT+IOR - read GPIO pin */ | |
169 GLOBAL T_ATI_RSLT atPlusIOR (char *cl, UBYTE srcId) | |
170 { | |
171 char *me="+IOR: "; | |
172 unsigned ionum; | |
173 int state; | |
174 | |
175 TRACE_FUNCTION("atPlusIOR()"); | |
176 | |
177 cl = parse(cl, "D", &ionum); | |
178 if (!cl) | |
179 return (ATI_FAIL); | |
180 if (ionum > 13) | |
181 return (ATI_FAIL); | |
182 state = AI_ReadBit(ionum); | |
183 sprintf(g_sa, "%s%u,%d", me, ionum, state); | |
184 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); | |
185 return (ATI_CMPL); | |
186 } | |
187 | |
188 /* AT+IOW - set GPIO pin */ | |
189 GLOBAL T_ATI_RSLT atPlusIOW (char *cl, UBYTE srcId) | |
190 { | |
191 unsigned ionum; | |
192 int state; | |
193 | |
194 TRACE_FUNCTION("atPlusIOW()"); | |
195 | |
196 cl = parse(cl, "DD", &ionum, &state); | |
197 if (!cl) | |
198 return (ATI_FAIL); | |
199 if (ionum > 13) | |
200 return (ATI_FAIL); | |
201 if (state) | |
202 AI_SetBit(ionum); | |
203 else | |
204 AI_ResetBit(ionum); | |
205 return (ATI_CMPL); | |
206 } | |
207 | |
208 #endif /* ATI_FCMISC_C */ |