comparison src/g23m-aci/aci/ati_fcmisc.c @ 200:07ece4691685

ACI sync with Magnetite: AT+IOR, AT+IOW, AT@LPG and AT@PWL
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 May 2020 05:42:13 +0000
parents 5f3544fc0308
children
comparison
equal deleted inserted replaced
199:143f3a07e273 200:07ece4691685
55 #include "ati_bat.h" 55 #include "ati_bat.h"
56 56
57 #endif /*FF_ATI_BAT*/ 57 #endif /*FF_ATI_BAT*/
58 58
59 #include "main/sys_types.h" 59 #include "main/sys_types.h"
60 #include "fc-target.h"
61 #include "armio.h"
60 62
61 extern SYS_UWORD8 SIM_allow_speed_enhancement; 63 extern SYS_UWORD8 SIM_allow_speed_enhancement;
62 64
63 /* AT@SPENH - enable or disable SIM speed enhancement */ 65 /* AT@SPENH - enable or disable SIM speed enhancement */
64 GLOBAL T_ATI_RSLT atAtSPENH ( char *cl, UBYTE srcId ) 66 GLOBAL T_ATI_RSLT atAtSPENH ( char *cl, UBYTE srcId )
92 sprintf(g_sa, "%s%u", me, SIM_allow_speed_enhancement); 94 sprintf(g_sa, "%s%u", me, SIM_allow_speed_enhancement);
93 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); 95 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
94 return (ATI_CMPL); 96 return (ATI_CMPL);
95 } 97 }
96 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
97 #endif /* ATI_FCMISC_C */ 208 #endif /* ATI_FCMISC_C */