FreeCalypso > hg > fc-magnetite
annotate src/cs/drivers/drv_app/fchg/fchg_task.c @ 639:026c98f757a6
tpudrv12.h & targets/gtm900.h: our current support is for MGC2GSMT version only
As it turns out, there exist two different Huawei-made hw platforms both
bearing the marketing name GTM900-B: one is MG01GSMT, the other is MGC2GSMT.
The two are NOT fw-compatible: aside from flash chip differences which
should be handled by autodetection, the two hw platforms are already known
to have different RFFEs with different control signals, and there may be
other differences not yet known. Our current gtm900 build target is for
MGC2GSMT only; we do not yet have a specimen of MG01GSMT on hand, hence
no support for that version will be possible until and unless someone
provides one.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 30 Jan 2020 18:19:01 +0000 |
| parents | 1c711302732a |
| children |
| 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 } |
