changeset 360:ce6d71349af0

FCHG: data structure changes in preparation for the new version
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 29 Dec 2017 05:42:54 +0000
parents edd20483fa59
children 9e0608dc9170
files src/cs/drivers/drv_app/fchg/fchg_common.h src/cs/drivers/drv_app/fchg/fchg_process.c src/cs/drivers/drv_app/fchg/fchg_struct.h
diffstat 3 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/fchg/fchg_common.h	Fri Dec 29 03:20:34 2017 +0000
+++ b/src/cs/drivers/drv_app/fchg/fchg_common.h	Fri Dec 29 05:42:54 2017 +0000
@@ -15,6 +15,7 @@
 	FCHG_STATE_I2V_CAL_2,
 	FCHG_STATE_CI_CHARGING,
 	FCHG_STATE_CV_CHARGING,
+	FCHG_STATE_RECHARGE_TIMER,
 	FCHG_STATE_NO_CHARGING
 };
 
--- a/src/cs/drivers/drv_app/fchg/fchg_process.c	Fri Dec 29 03:20:34 2017 +0000
+++ b/src/cs/drivers/drv_app/fchg/fchg_process.c	Fri Dec 29 05:42:54 2017 +0000
@@ -97,7 +97,7 @@
 	ABB_Write_Register_on_page(PAGE0, BCICTL2, 0);
 	/* figure out the DAC code */
 	while (code &&
-	       madc_vbat_2_physical(code) >= pwr_ctrl->config.charge_to_mv)
+	       madc_vbat_2_physical(code) >= pwr_ctrl->config.cv_init_set)
 		code--;
 	code++;
 	rvf_send_trace("Voltage (DAC code) ", 19, code,
@@ -193,7 +193,7 @@
 		}
 		if (overvoltage_end_charge_check())
 			return;
-		if (pwr_ctrl->batt_mv >= pwr_ctrl->config.charge_to_mv)
+		if (pwr_ctrl->batt_mv >= pwr_ctrl->config.ci2cv_thresh)
 			start_cv_charging(msg->data[0]);
 		return;
 	case FCHG_STATE_CV_CHARGING:
--- a/src/cs/drivers/drv_app/fchg/fchg_struct.h	Fri Dec 29 03:20:34 2017 +0000
+++ b/src/cs/drivers/drv_app/fchg/fchg_struct.h	Fri Dec 29 05:42:54 2017 +0000
@@ -15,10 +15,18 @@
 	UINT16	start_delay;
 	UINT16	start_thresh;
 	UINT16	restart_thresh;
-	UINT16	charge_to_mv;
+	UINT16	ci2cv_thresh;
+	UINT16	cv_init_set;
+	UINT16	cv_ctrl_loop_high;
+	UINT16	cv_ctrl_loop_low;
+	UINT16	cv_samples_needed;
 	UINT16	overvoltage;
 	UINT16	ci_current;
 	UINT16	end_current;
+	UINT16	ichg_max_spike;
+	UINT16	ichg_samples_needed;
+	UINT16	charge_time_limit;
+	UINT16	recharge_delay;
 	UINT16	bciconf;
 };
 
@@ -30,6 +38,8 @@
 
 #define	MAX_THRESHOLDS	101
 
+#define	ICHG_AVG_WINDOW	6
+
 typedef struct {
 	/* RiViera boilerplate */
 	T_RVF_ADDR_ID		addr_id;
@@ -45,6 +55,16 @@
 	UINT16			curr_disch_thresh;
 	/* valid only during a charging cycle */
 	UINT16			i2v_offset;
+	UINT16			cv_dac_init;
+	UINT16			cv_dac_curr;
+	UINT16			cv_high_vbat_count;
+	UINT16			cv_low_vbat_count;
+	UINT16			ichg_avg_buf[ICHG_AVG_WINDOW];
+	UINT16			ichg_fill_level;
+	UINT16			ichg_ring_ptr;
+	UINT16			ichg_average;
+	UINT16			ichg_low_count;
+	UINT32			start_time;
 } T_PWR_CTRL_BLOCK;
 
 #endif	/* include guard */