FreeCalypso > hg > fc-selenite
changeset 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 | 143f3a07e273 |
children | 1a04de9c7974 |
files | src/g23m-aci/aci/aci_cmh.h src/g23m-aci/aci/ati_cmd.c src/g23m-aci/aci/ati_fcmisc.c |
diffstat | 3 files changed, 135 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/g23m-aci/aci/aci_cmh.h Thu May 28 05:38:26 2020 +0000 +++ b/src/g23m-aci/aci/aci_cmh.h Thu May 28 05:42:13 2020 +0000 @@ -544,6 +544,10 @@ AT_CMD_AT_CHG, AT_CMD_P_VBAT, AT_CMD_AT_SPENH, + AT_CMD_AT_LPG, + AT_CMD_AT_PWL, + AT_CMD_IOR, + AT_CMD_IOW, /* terminator */ AT_CMD_MAX, /* maximum command id */ AT_CMD_BIGGEST = 0x0000ffff /* To avoid the lint warning 650 */
--- a/src/g23m-aci/aci/ati_cmd.c Thu May 28 05:38:26 2020 +0000 +++ b/src/g23m-aci/aci/ati_cmd.c Thu May 28 05:42:13 2020 +0000 @@ -772,6 +772,16 @@ EXTERN T_ATI_RSLT atPercentVBAT (char *cl, UBYTE srcId); EXTERN T_ATI_RSLT atAtSPENH (char *cl, UBYTE srcId); EXTERN T_ATI_RSLT queatAtSPENH (char *cl, UBYTE srcId); +#ifdef TARGET_HAS_LPG +EXTERN T_ATI_RSLT atAtLPG (char *cl, UBYTE srcId); +EXTERN T_ATI_RSLT queatAtLPG (char *cl, UBYTE srcId); +#endif +#ifdef TARGET_HAS_PWL +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[] = { @@ -1237,6 +1247,16 @@ {"%VBAT", AT_CMD_P_VBAT, atPercentVBAT, 0, 0, 0}, {"@SPENH", AT_CMD_AT_SPENH, atAtSPENH, test_gen, queatAtSPENH, "%s: (0,1),(0,1)"}, +#ifdef TARGET_HAS_LPG + {"@LPG", AT_CMD_AT_LPG, atAtLPG, test_gen, queatAtLPG, + "%s: (0-3),(0-7),(0-7)"}, +#endif +#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 05:38:26 2020 +0000 +++ b/src/g23m-aci/aci/ati_fcmisc.c Thu May 28 05:42:13 2020 +0000 @@ -57,6 +57,8 @@ #endif /*FF_ATI_BAT*/ #include "main/sys_types.h" +#include "fc-target.h" +#include "armio.h" extern SYS_UWORD8 SIM_allow_speed_enhancement; @@ -94,4 +96,113 @@ return (ATI_CMPL); } +#ifdef TARGET_HAS_LPG +/* AT@LPG - program LPG output */ +GLOBAL T_ATI_RSLT atAtLPG ( char *cl, UBYTE srcId ) +{ + unsigned glob, period = 0, ontime = 0; + + TRACE_FUNCTION("atAtLPG()"); + + cl = parse(cl, "Ddd", &glob, &period, &ontime); + if (!cl) + return (ATI_FAIL); + if (glob > 3 || period > 7 || ontime > 7) + return (ATI_FAIL); + *(volatile SYS_UWORD8 *)0xFFFE7801 = 0x01; + *(volatile SYS_UWORD8 *)0xFFFE7800 = + (glob << 6) | (ontime << 3) | period; + return (ATI_CMPL); +} + +GLOBAL T_ATI_RSLT queatAtLPG (char *cl, UBYTE srcId) +{ + char *me="@LPG: "; + SYS_UWORD8 regval; + unsigned glob, period, ontime; + + TRACE_FUNCTION("queatAtLPG()"); + + regval = *(volatile SYS_UWORD8 *)0xFFFE7800; + glob = (regval >> 6) & 3; + ontime = (regval >> 3) & 7; + period = regval & 7; + sprintf(g_sa, "%s%u,%u,%u", me, glob, period, ontime); + io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); + return (ATI_CMPL); +} +#endif /* TARGET_HAS_LPG */ + +#ifdef TARGET_HAS_PWL +/* AT@PWL - program PWL output */ +GLOBAL T_ATI_RSLT atAtPWL ( char *cl, UBYTE srcId ) +{ + unsigned level; + + TRACE_FUNCTION("atAtPWL()"); + + cl = parse(cl, "D", &level); + if (!cl) + return (ATI_FAIL); + if (level > 255) + return (ATI_FAIL); + *(volatile SYS_UWORD8 *)0xFFFE8000 = level; + *(volatile SYS_UWORD8 *)0xFFFE8001 = 0x01; + return (ATI_CMPL); +} + +GLOBAL T_ATI_RSLT queatAtPWL (char *cl, UBYTE srcId) +{ + char *me="@PWL: "; + SYS_UWORD8 regval; + + TRACE_FUNCTION("queatAtPWL()"); + + regval = *(volatile SYS_UWORD8 *)0xFFFE8000; + sprintf(g_sa, "%s%u", me, regval); + io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT); + return (ATI_CMPL); +} +#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 */