annotate src/g23m-aci/aci/ati_fcmisc.c @ 204:027b22814ac4

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