FreeCalypso > hg > fc-magnetite
annotate src/cs/drivers/drv_app/fchg/fchg_task.c @ 636:57e67ca2e1cb
pcmdata.c: default +CGMI to "FreeCalypso" and +CGMM to model
The present change has no effect whatsoever on Falconia-made and Openmoko-made
devices on which /pcm/CGMI and /pcm/CGMM files have been programmed in FFS
with sensible ID strings by the respective factories, but what should AT+CGMI
and AT+CGMM queries return when the device is a Huawei GTM900 or Tango modem
that has been converted to FreeCalypso with a firmware change? Before the
present change they would return compiled-in defaults of "<manufacturer>" and
"<model>", respectively; with the present change the firmware will self-identify
as "FreeCalypso GTM900-FC" or "FreeCalypso Tango" on the two respective targets.
This firmware identification will become important if someone incorporates an
FC-converted GTM900 or Tango modem into a ZeroPhone-style smartphone where some
high-level software like ofono will be talking to the modem and will need to
properly identify this modem as FreeCalypso, as opposed to some other AT command
modem flavor with different quirks.
In technical terms, the compiled-in default for the AT+CGMI query (which will
always be overridden by the /pcm/CGMI file in FFS if one is present) is now
"FreeCalypso" in all configs on all targets; the compiled-in default for the
AT+CGMM query (likewise always overridden by /pcm/CGMM if present) is
"GTM900-FC" if CONFIG_TARGET_GTM900 or "Tango" if CONFIG_TARGET_TANGO or the
original default of "<model>" otherwise.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 19 Jan 2020 20:14:58 +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 } |
