annotate src/cs/services/fcbm/fcbm_reset_mode.c @ 263:b5e8dfd114a7

Switch_ON(): go into charging boot mode on either CHGSTS or CHGPRES If someone were to plug and then unplug a charger into a switched-off phone in an extremely brief "glitch" manner, we should do an automatic power-off on boot in this condition. When we were checking only CHGPRES in Switch_ON(), we would go into Misc boot state instead, which is undesirable. Now if we have a CHGSTS but not CHGPRES condition, we will go into charging boot mode, and FCBM will then do the automatic power-off upon detecting absence of the charger in its periodic polling.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 May 2021 05:50:36 +0000
parents a5b00817a60f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we are going to implement FCBM functions
248
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
3 * for the reset or miscellaneous boot mode.
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "rv/rv_general.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "rvf/rvf_api.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rvm/rvm_use_id_list.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "fcbm/fcbm_func_i.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "fcbm/fcbm_life_cycle.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "fcbm/fcbm_timer_i.h"
243
35474f3a1782 FCBM: beginning of display output
Mychaela Falconia <falcon@freecalypso.org>
parents: 230
diff changeset
12 #include "r2d/r2d.h"
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "r2d/r2d_blrr_api.h"
243
35474f3a1782 FCBM: beginning of display output
Mychaela Falconia <falcon@freecalypso.org>
parents: 230
diff changeset
14
248
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
15 extern char fcbm_prod_banner_string[];
245
3eccca3ac219 FCBM: charging state display implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 243
diff changeset
16
248
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
17 void fcbm_process_msg_reset_mode(void)
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (fcbm_life_cycle_state != FCBM_STATE_INACTIVE) {
248
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
20 rvf_send_trace("FCBM got reset mode request in wrong state",
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
21 42, fcbm_life_cycle_state,
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 RV_TRACE_LEVEL_ERROR, FCBM_USE_ID);
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
248
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
25 rvf_send_trace("Entering reset boot mode", 24, NULL_PARAM,
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 RV_TRACE_LEVEL_DEBUG_HIGH, FCBM_USE_ID);
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 fcbm_subscribe_kpd();
243
35474f3a1782 FCBM: beginning of display output
Mychaela Falconia <falcon@freecalypso.org>
parents: 230
diff changeset
28 fcbm_display_init();
35474f3a1782 FCBM: beginning of display output
Mychaela Falconia <falcon@freecalypso.org>
parents: 230
diff changeset
29 fcbm_display_line(0, fcbm_prod_banner_string);
248
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
30 fcbm_display_line(1, "Misc boot state");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
31 #ifdef LSCREEN
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
32 fcbm_display_line(3, "Long-press Power");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
33 fcbm_display_line(4, "button to turn off,");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
34 #else
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
35 fcbm_display_line(3, "Long-press PWR");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
36 fcbm_display_line(4, "button to OFF,");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
37 #endif
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
38 fcbm_display_line(5, "or send fc-tmsh");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
39 fcbm_display_line(6, "phone-on command");
a5b00817a60f FCBM reset mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 245
diff changeset
40 fcbm_display_line(7, "to boot phone.");
243
35474f3a1782 FCBM: beginning of display output
Mychaela Falconia <falcon@freecalypso.org>
parents: 230
diff changeset
41 r2d_flush();
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 blrr_display_ctrl(BLRR_DISPLAY_CHG_BOOT);
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 rvf_start_timer(FCBM_TIMER_DSPL_OFF,
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 RVF_SECS_TO_TICKS(FCBM_DISPLAY_SECS), FALSE);
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 fcbm_life_cycle_state = FCBM_STATE_ACTIVE;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }