changeset 669:227d37a968ec

AT+IOR and AT+IOW GPIO commands implemented in aci2
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 May 2020 02:55:26 +0000
parents 4011858168a1
children def882d1b354
files src/aci2/aci/ati_cmd.c src/aci2/aci/ati_fcmisc.c
diffstat 2 files changed, 45 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/aci2/aci/ati_cmd.c	Thu May 28 02:13:50 2020 +0000
+++ b/src/aci2/aci/ati_cmd.c	Thu May 28 02:55:26 2020 +0000
@@ -712,6 +712,8 @@
 EXTERN T_ATI_RSLT atAtPWL (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT queatAtPWL (char *cl, UBYTE srcId);
 #endif
+EXTERN T_ATI_RSLT atPlusIOR (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atPlusIOW (char *cl, UBYTE srcId);
 
 LOCAL const ATCommand_bas cmds_bas[] =
 {
@@ -1133,6 +1135,9 @@
 #ifdef TARGET_HAS_PWL
     {"@PWL",	AT_CMD_AT_PWL,   atAtPWL, test_gen, queatAtPWL, "%s: (0-255)"},
 #endif
+    {"+IOR",	AT_CMD_IOR,      atPlusIOR,	test_gen, 0,	"%s: (0-13)"},
+    {"+IOW",	AT_CMD_IOW,      atPlusIOW,	test_gen, 0,
+						"%s: (0-13),(0,1)"},
     /* terminator */
     {NULL,0,0,0,0,0}
 };
--- a/src/aci2/aci/ati_fcmisc.c	Thu May 28 02:13:50 2020 +0000
+++ b/src/aci2/aci/ati_fcmisc.c	Thu May 28 02:55:26 2020 +0000
@@ -165,4 +165,44 @@
 }
 #endif	/* TARGET_HAS_PWL */
 
+/* AT+IOR - read GPIO pin */
+GLOBAL T_ATI_RSLT atPlusIOR (char *cl, UBYTE srcId)
+{
+	char *me="+IOR: ";
+	unsigned ionum;
+	int state;
+
+	TRACE_FUNCTION("atPlusIOR()");
+
+	cl = parse(cl, "D", &ionum);
+	if (!cl)
+		return (ATI_FAIL);
+	if (ionum > 13)
+		return (ATI_FAIL);
+	state = AI_ReadBit(ionum);
+	sprintf(g_sa, "%s%u,%d", me, ionum, state);
+	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
+	return (ATI_CMPL);
+}
+
+/* AT+IOW - set GPIO pin */
+GLOBAL T_ATI_RSLT atPlusIOW (char *cl, UBYTE srcId)
+{
+	unsigned ionum;
+	int state;
+
+	TRACE_FUNCTION("atPlusIOW()");
+
+	cl = parse(cl, "DD", &ionum, &state);
+	if (!cl)
+		return (ATI_FAIL);
+	if (ionum > 13)
+		return (ATI_FAIL);
+	if (state)
+		AI_SetBit(ionum);
+	else
+		AI_ResetBit(ionum);
+	return (ATI_CMPL);
+}
+
 #endif /* ATI_FCMISC_C */