FreeCalypso > hg > fc-magnetite
annotate src/cs/drivers/drv_app/fchg/fchg_task.c @ 629:3231dd9b38c1
armio.c: make GPIOs 8 & 13 outputs driving 1 on all "classic" targets
Calypso GPIOs 8 & 13 are pinmuxed with MCUEN1 & MCUEN2, respectively,
and on powerup these pins are MCUEN, i.e., outputs driving 1. TI's code
for C-Sample and earlier turns them into GPIOs configured as outputs also
driving 1 - so far, so good - but TI's code for BOARD 41 (which covers
D-Sample, Leonardo and all real world Calypso devices derived from the
latter) switches them from MCUEN to GPIOs, but then leaves them as inputs.
Given that the hardware powerup state of these two pins is outputs driving 1,
every Calypso board design MUST be compatible with such driving; typically
these GPIO signals will be either unused and unconnected or connected as
outputs driving some peripheral. Turning these pins into GPIO inputs will
result in floating inputs on every reasonably-wired board, thus I am
convinced that this configuration is nothing but a bug on the part of
whoever wrote this code at TI.
This floating input bug had already been fixed earlier for GTA modem and
FCDEV3B targets; the present change makes the fix unconditional for all
"classic" targets. The newly affected targets are D-Sample, Leonardo,
Tango and GTM900.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 02 Jan 2020 05:38:26 +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 } |