comparison src/cs/drivers/drv_app/fchg/fchg_process.c @ 335:6c0659acf93e

FCHG: implemented functions for user-initiated charge start and stop
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 14 Dec 2017 20:41:18 +0000
parents d583a1f5bd6a
children 2f41f7883261
comparison
equal deleted inserted replaced
334:d583a1f5bd6a 335:6c0659acf93e
292 rvf_send_trace("Invalid state in pwr_charger_unplug()", 35, 292 rvf_send_trace("Invalid state in pwr_charger_unplug()", 35,
293 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, 293 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR,
294 FCHG_USE_ID); 294 FCHG_USE_ID);
295 } 295 }
296 } 296 }
297
298 void pwr_charge_start_req(void)
299 {
300 switch (pwr_ctrl->state) {
301 case FCHG_STATE_NO_EXT_PWR:
302 rvf_send_trace("Cannot charge without a power source", 36,
303 NULL_PARAM, RV_TRACE_LEVEL_ERROR, FCHG_USE_ID);
304 return;
305 case FCHG_STATE_NO_CHARGING:
306 if (!pwr_ctrl->config_present) {
307 rvf_send_trace("No config set, cannot charge", 28,
308 NULL_PARAM, RV_TRACE_LEVEL_ERROR,
309 FCHG_USE_ID);
310 return;
311 }
312 /* FALL THRU */
313 case FCHG_STATE_PWR_PLUG_TIMER:
314 case FCHG_STATE_READY_TO_CHARGE:
315 case FCHG_STATE_READY_TO_RECHARGE:
316 rvf_send_trace("Starting charge on user request", 31,
317 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
318 FCHG_USE_ID);
319 pwr_ctrl->state = FCHG_STATE_I2V_CAL_1;
320 return;
321 case FCHG_STATE_I2V_CAL_1:
322 case FCHG_STATE_I2V_CAL_2:
323 case FCHG_STATE_CI_CHARGING:
324 case FCHG_STATE_CV_CHARGING:
325 rvf_send_trace(
326 "Charging already in progress, start request ignored",
327 51, NULL_PARAM, RV_TRACE_LEVEL_WARNING, FCHG_USE_ID);
328 return;
329 default:
330 rvf_send_trace("Invalid state in pwr_charge_start_req()", 37,
331 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR,
332 FCHG_USE_ID);
333 }
334 }
335
336 void pwr_charge_stop_req(void)
337 {
338 switch (pwr_ctrl->state) {
339 case FCHG_STATE_NO_EXT_PWR:
340 case FCHG_STATE_NO_CHARGING:
341 /* nothing to do */
342 return;
343 case FCHG_STATE_PWR_PLUG_TIMER:
344 case FCHG_STATE_READY_TO_CHARGE:
345 case FCHG_STATE_READY_TO_RECHARGE:
346 case FCHG_STATE_I2V_CAL_1:
347 rvf_send_trace("Charging disabled by user request", 33,
348 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
349 FCHG_USE_ID);
350 pwr_ctrl->state = FCHG_STATE_NO_CHARGING;
351 return;
352 case FCHG_STATE_I2V_CAL_2:
353 case FCHG_STATE_CI_CHARGING:
354 case FCHG_STATE_CV_CHARGING:
355 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0);
356 rvf_send_trace("Charging stopped by user request", 32,
357 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
358 FCHG_USE_ID);
359 pwr_ctrl->state = FCHG_STATE_NO_CHARGING;
360 pwr_init_discharge();
361 return;
362 default:
363 rvf_send_trace("Invalid state in pwr_charge_stop_req()", 36,
364 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR,
365 FCHG_USE_ID);
366 }
367 }