changeset 670:def882d1b354

AT+IOR and AT+IOW GPIO commands implemented in aci3
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 May 2020 03:15:43 +0000
parents 227d37a968ec
children 5f00e9afd5d9
files src/g23m-aci/aci/ati_cmd.c src/g23m-aci/aci/ati_fcmisc.c
diffstat 2 files changed, 45 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/g23m-aci/aci/ati_cmd.c	Thu May 28 02:55:26 2020 +0000
+++ b/src/g23m-aci/aci/ati_cmd.c	Thu May 28 03:15:43 2020 +0000
@@ -780,6 +780,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[] =
 {
@@ -1252,6 +1254,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,AT_CMD_NONE,NULL,NULL,NULL,NULL}
 };
--- a/src/g23m-aci/aci/ati_fcmisc.c	Thu May 28 02:55:26 2020 +0000
+++ b/src/g23m-aci/aci/ati_fcmisc.c	Thu May 28 03:15:43 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 */