FreeCalypso > hg > fc-tourmaline
changeset 239:305d3bb691a5
FCHG startup: replace fchg_is_running with fchg_first_vbat
and also report the first Vbat reading in a trace
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 02 May 2021 05:30:59 +0000 |
parents | 8f16e0663737 |
children | 184a031e38e6 |
files | src/cs/drivers/drv_app/fchg/fchg_process.c src/cs/drivers/drv_app/power/board/power.c |
diffstat | 2 files changed, 19 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/fchg/fchg_process.c Sun May 02 04:36:25 2021 +0000 +++ b/src/cs/drivers/drv_app/fchg/fchg_process.c Sun May 02 05:30:59 2021 +0000 @@ -23,12 +23,11 @@ #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. + * The following global variable captures the initial battery voltage + * at the time of system boot - it is intended to be used for various + * system start-up decisions. */ -int fchg_is_running; +UINT16 fchg_first_vbat; void pwr_init_discharge(void) { @@ -62,6 +61,16 @@ pwr_ctrl->event_handler(FCHG_EVENT_DISCHARGE); } +static void capture_first_vbat(void) +{ + char trace[64]; + + fchg_first_vbat = pwr_ctrl->batt_mv; + sprintf(trace, "System boot: Vbat=%u", pwr_ctrl->batt_mv); + rvf_send_trace(trace, strlen(trace), NULL_PARAM, + RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); +} + static void start_i2v_cal(void) { UINT16 bciconf; @@ -271,6 +280,8 @@ void pwr_process_adc(struct pwr_adc_ind_s *msg) { pwr_ctrl->batt_mv = madc_vbat_2_physical(msg->data[0]); + if (!fchg_first_vbat) + capture_first_vbat(); switch (pwr_ctrl->state) { case FCHG_STATE_NO_EXT_PWR: @@ -365,7 +376,6 @@ 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/power/board/power.c Sun May 02 04:36:25 2021 +0000 +++ b/src/cs/drivers/drv_app/power/board/power.c Sun May 02 05:30:59 2021 +0000 @@ -53,9 +53,10 @@ { #if (MMI != 0) extern void fchs_pwon_button_boot(void); - extern int fchg_is_running, r2d_is_running, mmi_task_init_done; + extern int r2d_is_running, mmi_task_init_done; + extern UINT16 fchg_first_vbat; - while (!fchg_is_running || !r2d_is_running || !mmi_task_init_done) + while (!fchg_first_vbat || !r2d_is_running || !mmi_task_init_done) rvf_delay(8); fchs_pwon_button_boot();