FreeCalypso > hg > fc-tourmaline
comparison src/cs/services/fcbm/fcbm_charging.c @ 230:baa738eeb842
FCBM code implemented in first pass
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 01 May 2021 10:05:53 +0000 |
parents | |
children | 35474f3a1782 |
comparison
equal
deleted
inserted
replaced
229:7ec0ae23ce76 | 230:baa738eeb842 |
---|---|
1 /* | |
2 * In this module we are going to implement FCBM functions | |
3 * related specifically to charging mode, as opposed to other | |
4 * special boot modes. | |
5 */ | |
6 | |
7 #include "rv/rv_general.h" | |
8 #include "rvf/rvf_api.h" | |
9 #include "rvm/rvm_use_id_list.h" | |
10 #include "fcbm/fcbm_func_i.h" | |
11 #include "fcbm/fcbm_life_cycle.h" | |
12 #include "fcbm/fcbm_timer_i.h" | |
13 #include "fchg/fchg_api.h" | |
14 #include "r2d/r2d_blrr_api.h" | |
15 #include "abb/abb.h" | |
16 | |
17 void fcbm_process_msg_chg_mode(void) | |
18 { | |
19 if (fcbm_life_cycle_state != FCBM_STATE_INACTIVE) { | |
20 rvf_send_trace("FCBM got charging mode request in wrong state", | |
21 45, fcbm_life_cycle_state, | |
22 RV_TRACE_LEVEL_ERROR, FCBM_USE_ID); | |
23 return; | |
24 } | |
25 rvf_send_trace("Entering charging boot mode", 27, NULL_PARAM, | |
26 RV_TRACE_LEVEL_DEBUG_HIGH, FCBM_USE_ID); | |
27 fcbm_subscribe_kpd(); | |
28 fcbm_setup_long_pwon(); | |
29 /* TODO: display charging boot mode info on the LCD */ | |
30 blrr_display_ctrl(BLRR_DISPLAY_CHG_BOOT); | |
31 rvf_start_timer(FCBM_TIMER_DSPL_OFF, | |
32 RVF_SECS_TO_TICKS(FCBM_DISPLAY_SECS), FALSE); | |
33 rvf_start_timer(FCBM_TIMER_CHG_UPD, | |
34 RVF_MS_TO_TICKS(FCBM_CHG_UPD_INTERVAL), TRUE); | |
35 fcbm_life_cycle_state = FCBM_STATE_ACTIVE; | |
36 } | |
37 | |
38 static void charging_info_update(void) | |
39 { | |
40 /* to be filled */ | |
41 } | |
42 | |
43 static void power_off_check(void) | |
44 { | |
45 SYS_UWORD16 abb_status; | |
46 | |
47 abb_status = ABB_Read_Status(); | |
48 if (abb_status & CHGPRES) | |
49 return; | |
50 rvf_send_trace("Charger unplug, powering off", 28, NULL_PARAM, | |
51 RV_TRACE_LEVEL_DEBUG_HIGH, FCBM_USE_ID); | |
52 /* TODO: display appropriate message on the LCD */ | |
53 blrr_display_ctrl(BLRR_DISPLAY_CHG_BOOT); | |
54 rvf_delay(RVF_MS_TO_TICKS(50)); | |
55 ABB_Power_Off(); | |
56 } | |
57 | |
58 void fcbm_chg_periodic_timer(void) | |
59 { | |
60 if (fcbm_life_cycle_state != FCBM_STATE_ACTIVE) { | |
61 rvf_send_trace("Charging mode periodic timer in wrong state", | |
62 43, fcbm_life_cycle_state, | |
63 RV_TRACE_LEVEL_WARNING, FCBM_USE_ID); | |
64 return; | |
65 } | |
66 power_off_check(); | |
67 charging_info_update(); | |
68 } |