FreeCalypso > hg > fc-tourmaline
changeset 254:4533ef63fdb0
FCHG BSIM: init_percent logic implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 May 2021 23:01:28 +0000 |
parents | 769cf6273fe4 |
children | 1a4413c4eb7e |
files | components/fchg src/cs/drivers/drv_app/fchg/bsim_start.c src/cs/drivers/drv_app/fchg/fchg_func_i.h src/cs/drivers/drv_app/fchg/fchg_task.c |
diffstat | 4 files changed, 37 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/components/fchg Wed May 12 11:14:51 2021 +0000 +++ b/components/fchg Wed May 12 23:01:28 2021 +0000 @@ -43,3 +43,7 @@ cfile_plain $SRCDIR/fchg_messages.c cfile_plain $SRCDIR/fchg_process.c cfile_plain $SRCDIR/fchg_task.c + +# Battery simulation mode + +cfile_plain $SRCDIR/bsim_start.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cs/drivers/drv_app/fchg/bsim_start.c Wed May 12 23:01:28 2021 +0000 @@ -0,0 +1,27 @@ +/* + * This module implements a boot-time function for BSIM mode: + * figuring out the initial battery percentage to be reported. + */ + +#include "fchg/fchg_env.h" +#include "fchg/fchg_func_i.h" +#include "rv/rv_general.h" +#include "rvf/rvf_api.h" +#include "rvm/rvm_use_id_list.h" + +void bsim_init_percent(void) +{ + UINT16 i; + + for (i = 0; i < pwr_ctrl->nb_percent_thresh; i++) { + if (pwr_ctrl->batt.percent_thresh[i].remain_capa == + pwr_ctrl->bsim.init_percent) { + pwr_ctrl->curr_disch_thresh = i; + return; + } + } + rvf_send_trace("BSIM boot: invalid init_percent setting", 39, + pwr_ctrl->bsim.init_percent, RV_TRACE_LEVEL_ERROR, + FCHG_USE_ID); + pwr_ctrl->curr_disch_thresh = 0; +}
--- a/src/cs/drivers/drv_app/fchg/fchg_func_i.h Wed May 12 11:14:51 2021 +0000 +++ b/src/cs/drivers/drv_app/fchg/fchg_func_i.h Wed May 12 23:01:28 2021 +0000 @@ -21,4 +21,6 @@ void pwr_charge_start_req(void); void pwr_charge_stop_req(void); +void bsim_init_percent(void); + #endif /* include guard */
--- a/src/cs/drivers/drv_app/fchg/fchg_task.c Wed May 12 11:14:51 2021 +0000 +++ b/src/cs/drivers/drv_app/fchg/fchg_task.c Wed May 12 23:01:28 2021 +0000 @@ -37,7 +37,10 @@ set_initial_state(); /* just for safety, clear any previous BCI hardware state */ ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); - pwr_init_discharge(); + if (pwr_ctrl->bsim_mode) + bsim_init_percent(); + else + pwr_init_discharge(); /* loop to process messages */ while (error_occured == FALSE)