FreeCalypso > hg > fc-magnetite
diff src/aci2/aci/ati_fcmisc.c @ 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 | 36df58db1640 |
children |
line wrap: on
line diff
--- 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 */