annotate src/cs/drivers/drv_app/fchg/fchg_task.c @ 451:fd1d9063ad40

config mechanism: added ability to build D-Sample B&W UI configuration
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Mar 2018 18:15:14 +0000
parents 1c711302732a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
337
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The FCHG task's core function lives here.
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include "fchg/fchg_env.h"
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "fchg/fchg_func_i.h"
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "rv/rv_general.h"
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rvf/rvf_api.h"
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvm/rvm_use_id_list.h"
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "abb/abb.h"
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static void set_initial_state(void)
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 SYS_UWORD16 abb_status;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 abb_status = ABB_Read_Status();
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (abb_status & CHGPRES) {
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (pwr_ctrl->config_present)
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 pwr_ctrl->state = FCHG_STATE_READY_TO_CHARGE;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 else
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 pwr_ctrl->state = FCHG_STATE_NO_CHARGING;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 } else
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 T_RV_RET fchg_core(void)
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 {
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 BOOLEAN error_occured = FALSE;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 T_RV_HDR *msg_ptr;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 rvf_send_trace("FCHG task: Initialization", 25, NULL_PARAM,
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID);
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 pwr_load_ffs_batt_table();
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 pwr_load_ffs_charging_config();
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 set_initial_state();
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 pwr_init_discharge();
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /* loop to process messages */
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 while (error_occured == FALSE)
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 UINT16 received_event = rvf_wait (0xffff, 0);
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 /* If an event related to mailbox 0 is received, then */
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (received_event & RVF_TASK_MBOX_0_EVT_MASK)
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 {
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /* Read the message in the driver mailbox and delegate action..*/
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 msg_ptr = (T_RV_HDR *) rvf_read_mbox(FCHG_MAILBOX);
338
1c711302732a FCHG: complete enough to attempt linking into fw build
Mychaela Falconia <falcon@freecalypso.org>
parents: 337
diff changeset
49 if (msg_ptr) {
1c711302732a FCHG: complete enough to attempt linking into fw build
Mychaela Falconia <falcon@freecalypso.org>
parents: 337
diff changeset
50 pwr_process_message(msg_ptr);
1c711302732a FCHG: complete enough to attempt linking into fw build
Mychaela Falconia <falcon@freecalypso.org>
parents: 337
diff changeset
51 rvf_free_buf ((void *) msg_ptr);
1c711302732a FCHG: complete enough to attempt linking into fw build
Mychaela Falconia <falcon@freecalypso.org>
parents: 337
diff changeset
52 }
337
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* Timers */
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 if (received_event & RVF_TIMER_0_EVT_MASK)
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 pwr_handle_timer();
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 } // end of while
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 return RV_OK;
0df0668f8bea FCHG: task core function implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 }