FreeCalypso > hg > fc-tourmaline
changeset 236:3c790d29748e
fchg_is_running startup sync flag change:
set the flag when the first ADC message has been processed,
and not merely when the task is running - this way the flag indicates
that meaningful info about the state of the battery is available.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 02 May 2021 04:25:48 +0000 |
parents | ee04ca45053d |
children | 8d5373b24f5f |
files | src/cs/drivers/drv_app/fchg/fchg_process.c src/cs/drivers/drv_app/fchg/fchg_task.c |
diffstat | 2 files changed, 28 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/fchg/fchg_process.c Sat May 01 10:36:52 2021 +0000 +++ b/src/cs/drivers/drv_app/fchg/fchg_process.c Sun May 02 04:25:48 2021 +0000 @@ -22,6 +22,14 @@ #define LEDC 0 #endif +/* + * The following global variable is a system startup synchronization flag: + * it indicates that FCHG is running and has processed at least one + * ADC message, signifying that meaningful information about the state + * of the battery is available. + */ +int fchg_is_running; + void pwr_init_discharge(void) { pwr_ctrl->curr_disch_thresh = 0; @@ -269,29 +277,29 @@ case FCHG_STATE_PWR_PLUG_TIMER: case FCHG_STATE_NO_CHARGING: handle_discharge(); - return; + break; case FCHG_STATE_READY_TO_CHARGE: handle_discharge(); if (!(msg->data[9] & CHGPRES)) { pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; - return; + break; } if (pwr_ctrl->batt_mv < pwr_ctrl->config.start_thresh) start_charge_condition_met(); - return; + break; case FCHG_STATE_READY_TO_RECHARGE: handle_discharge(); if (!(msg->data[9] & CHGPRES)) { pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; - return; + break; } if (pwr_ctrl->batt_mv < pwr_ctrl->config.restart_thresh) start_charge_condition_met(); - return; + break; case FCHG_STATE_I2V_CAL_1: if (!(msg->data[9] & CHGPRES)) { pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; - return; + break; } if (pwr_ctrl->config.bciconf) start_i2v_cal(); @@ -299,7 +307,7 @@ pwr_ctrl->i2v_offset = 0; start_ci_charging(); } - return; + break; case FCHG_STATE_I2V_CAL_2: pwr_ctrl->i2v_offset = msg->data[2]; ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); @@ -309,54 +317,55 @@ if (!(msg->data[9] & CHGPRES)) { pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; pwr_init_discharge(); - return; + break; } start_ci_charging(); - return; + break; case FCHG_STATE_CI_CHARGING: ci_progress_trace(msg->data[2]); if (!(msg->data[9] & CHGPRES)) { ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; pwr_init_discharge(); - return; + break; } if (charging_time_limit_check()) - return; + break; if (pwr_ctrl->batt_mv >= pwr_ctrl->config.ci2cv_thresh) start_cv_charging(); - return; + break; case FCHG_STATE_CV_CHARGING: if (!(msg->data[9] & CHGPRES)) { ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; pwr_init_discharge(); - return; + break; } if (cv_ichg_process(msg->data[2])) - return; + break; if (overvoltage_end_charge_check()) - return; + break; if (charging_time_limit_check()) - return; + break; cv_ctrl_loop_high_check(); cv_ctrl_loop_low_check(); - return; + break; case FCHG_STATE_RECHARGE_TIMER: handle_discharge(); if ((rvf_get_tick_count() - pwr_ctrl->start_time) < RVF_SECS_TO_TICKS(pwr_ctrl->config.recharge_delay)) - return; + break; rvf_send_trace("Restart time met, allowing new charging", 39, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); pwr_ctrl->state = FCHG_STATE_READY_TO_RECHARGE; - return; + break; default: rvf_send_trace("Invalid state in pwr_process_adc()", 32, pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, FCHG_USE_ID); } + fchg_is_running = 1; } void pwr_handle_timer(void)
--- a/src/cs/drivers/drv_app/fchg/fchg_task.c Sat May 01 10:36:52 2021 +0000 +++ b/src/cs/drivers/drv_app/fchg/fchg_task.c Sun May 02 04:25:48 2021 +0000 @@ -9,9 +9,6 @@ #include "rvm/rvm_use_id_list.h" #include "abb/abb.h" -/* startup synchronization with MMI task in GPF land */ -int fchg_is_running; - static void set_initial_state(void) { SYS_UWORD16 abb_status; @@ -39,7 +36,6 @@ /* just for safety, clear any previous BCI hardware state */ ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); pwr_init_discharge(); - fchg_is_running = 1; /* loop to process messages */ while (error_occured == FALSE)