changeset 347:78d1df0b8487

aci2: AT%CBC and AT@CHARGE implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 16 Dec 2017 00:37:43 +0000
parents 550cfa9e1ca7
children d719315db04a
files components/aci-classic src/aci2/aci/aci_cmh.h src/aci2/aci/ati_cmd.c src/aci2/aci/ati_fchg.c
diffstat 4 files changed, 108 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/components/aci-classic	Fri Dec 15 22:45:37 2017 +0000
+++ b/components/aci-classic	Sat Dec 16 00:37:43 2017 +0000
@@ -146,6 +146,7 @@
 cfile_str2ind $SRCDIR/ati_src_rvt.c
 cfile_str2ind $SRCDIR/ati_omcompat.c
 cfile_str2ind $SRCDIR/ati_audio.c
+cfile_str2ind $SRCDIR/ati_fchg.c
 
 # ACI stuff
 cfile_str2ind $SRCDIR/aci_aci.c
--- a/src/aci2/aci/aci_cmh.h	Fri Dec 15 22:45:37 2017 +0000
+++ b/src/aci2/aci/aci_cmh.h	Sat Dec 16 00:37:43 2017 +0000
@@ -491,6 +491,8 @@
   AT_CMD_AT_VMPS,
   AT_CMD_AT_VMR,
   AT_CMD_AT_VMRS,
+  AT_CMD_P_CBC,
+  AT_CMD_AT_CHARGE,
   /* terminator */
   AT_CMD_MAX                  /* maximum command id */
 } T_ACI_AT_CMD;
--- a/src/aci2/aci/ati_cmd.c	Fri Dec 15 22:45:37 2017 +0000
+++ b/src/aci2/aci/ati_cmd.c	Sat Dec 16 00:37:43 2017 +0000
@@ -76,6 +76,7 @@
 #endif
 
 #include "fc-target.cfg"
+#include "rv/rv_defined_swe.h"     // for RVM_FCHG_SWE
 
 #define OLD_NON_STANDARDIZED_ATCMD "&ABDEFHILMOPQSTVWXZ"
 
@@ -690,6 +691,10 @@
 EXTERN T_ATI_RSLT atAtVMPS (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtVMR (char *cl, UBYTE srcId);
 EXTERN T_ATI_RSLT atAtVMRS (char *cl, UBYTE srcId);
+#ifdef RVM_FCHG_SWE
+EXTERN T_ATI_RSLT atPercentCBC (char *cl, UBYTE srcId);
+EXTERN T_ATI_RSLT atAtCHARGE (char *cl, UBYTE srcId);
+#endif
 
 LOCAL const ATCommand_bas cmds_bas[] =
 {
@@ -1092,6 +1097,10 @@
     {"@VMPS",	AT_CMD_AT_VMPS,  atAtVMPS,	0,	0,	0},
     {"@VMR",	AT_CMD_AT_VMR,   atAtVMR,	0,	0,	0},
     {"@VMRS",	AT_CMD_AT_VMRS,  atAtVMRS,	0,	0,	0},
+#ifdef RVM_FCHG_SWE
+    {"%CBC",	AT_CMD_P_CBC,    atPercentCBC,	0,	0,	0},
+    {"@CHARGE",	AT_CMD_AT_CHARGE,atAtCHARGE,	0,	0,	"%s: (0,1)"},
+#endif
     /* terminator */
     {NULL,0,0,0,0,0}
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/aci2/aci/ati_fchg.c	Sat Dec 16 00:37:43 2017 +0000
@@ -0,0 +1,96 @@
+/*
+ * The non-standard FreeCalypso-added AT commands implemented in this module
+ * expose the API of FreeCalypso battery charging driver FCHG.
+ */
+
+#ifndef ATI_FCHG_C
+#define ATI_FCHG_C
+
+#include "aci_all.h"
+
+#include <ctype.h>
+#include <string.h>
+
+#include "aci_cmh.h"
+#include "ati_cmd.h"
+#include "aci_cmd.h"
+#include "aci_io.h"
+#include "aci_cmd.h"
+#include "l4_tim.h"
+#include "line_edit.h"
+#include "aci_lst.h"
+
+#include "pcm.h"
+#include "audio.h"
+#include "aci.h"
+#include "rx.h"
+#include "pwr.h"
+#include "l4_tim.h"
+
+#ifdef GPRS
+#ifdef DTI
+#include "dti.h"
+#include "dti_conn_mng.h"
+#include "dti_cntrl_mng.h"
+#endif /* DTI */
+#include "gaci.h"
+#include "gaci_cmh.h"
+#include "gaci_cmd.h"
+#endif  /* GPRS */
+
+#include "aci_mem.h"
+#include "aci_prs.h"
+
+#include "ati_int.h"
+
+#ifndef _SIMULATION_
+#include "ffs/ffs.h"
+#endif
+
+#ifdef FF_ATI_BAT
+
+#include "typedefs.h"
+#include "gdd.h"
+#include "bat.h"
+
+#include "ati_bat.h"
+
+#endif /*FF_ATI_BAT*/
+
+#include "rv/rv_defined_swe.h"     // for RVM_FCHG_SWE
+
+#ifdef RVM_FCHG_SWE
+#include "fchg/fchg_api.h"
+
+/* AT%CBC - customized alternative to standard AT+CBC */
+GLOBAL T_ATI_RSLT atPercentCBC ( char *cl, UBYTE srcId )
+{
+	struct fchg_user_state fchg;
+
+	TRACE_FUNCTION("atPercentCBC()");
+	if (fchg_get_current_state(&fchg) != RV_OK)
+		return ATI_FAIL;
+	sprintf(g_sa, "%CBC: %d,%d,%d", fchg.chg_state, fchg.batt_mv,
+		fchg.batt_percent);
+	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
+	return ATI_CMPL;
+}
+
+/* AT@CHARGE - manual control of battery charging */
+GLOBAL T_ATI_RSLT atAtCHARGE ( char *cl, UBYTE srcId )
+{
+	enum fchg_user_charge_ctrl ctrl;
+
+	TRACE_FUNCTION("atAtCHARGE()");
+	cl = parse(cl, "D", &ctrl);
+	if (!cl)
+		return ATI_FAIL;
+	if (fchg_user_charge_control(ctrl) == RV_OK)
+		return ATI_CMPL;
+	else
+		return ATI_FAIL;
+}
+
+#endif /* RVM_FCHG_SWE */
+
+#endif /* ATI_FCHG_C */