FreeCalypso > hg > fc-magnetite
annotate src/cs/drivers/drv_app/fchg/fchg_env.c @ 452:4d7c2ccb5814
config mechanism: high-level UI config made separate from target display drivers
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 14 Mar 2018 07:22:05 +0000 |
parents | ab47ade99fa9 |
children |
rev | line source |
---|---|
322
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module provides the glue to the RiViera environment |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * for our FCHG SWE. |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "fchg/fchg_env.h" |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "rv/rv_general.h" |
325
ab47ade99fa9
FCHG: reading of charging config from FFS implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
322
diff
changeset
|
8 #include "rvf/rvf_api.h" |
322
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "rvm/rvm_priorities.h" |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "rvm/rvm_api.h" |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "rvm/rvm_use_id_list.h" |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 /* Define a pointer to the PWR environment control block */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 T_PWR_CTRL_BLOCK *pwr_ctrl = NULL; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 /* Define global pointer to the error function */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static T_RVM_RETURN (*pwr_error_ft) (T_RVM_NAME swe_name, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 T_RVM_RETURN error_cause, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 T_RVM_ERROR_TYPE error_type, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 T_RVM_STRING error_msg); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 T_RVM_RETURN fchg_get_info (T_RVM_INFO_SWE *infoSWE) |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 /* SWE info */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 infoSWE->swe_type = RVM_SWE_TYPE_4; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 infoSWE->type_info.type4.swe_use_id = FCHG_USE_ID; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 memcpy( infoSWE->type_info.type4.swe_name, "FCHG", 5 ); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 infoSWE->type_info.type4.stack_size = FCHG_STACK_SIZE; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 infoSWE->type_info.type4.priority = RVM_LCC_TASK_PRIORITY; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* memory bank info */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 infoSWE->type_info.type4.nb_mem_bank = 1; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "FCHG_PRIM", 10); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 infoSWE->type_info.type4.mem_bank[0].initial_params.size = FCHG_MB_PRIM_SIZE; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = FCHG_MB_PRIM_WATERMARK; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 /* linked SWE info: we use FFS */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 infoSWE->type_info.type4.nb_linked_swe = 1; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 infoSWE->type_info.type4.linked_swe_id[0] = FFS_USE_ID; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* generic functions */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 infoSWE->type_info.type4.set_info = fchg_set_info; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 infoSWE->type_info.type4.init = fchg_init; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 infoSWE->type_info.type4.core = fchg_core; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 infoSWE->type_info.type4.stop = fchg_stop; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 infoSWE->type_info.type4.kill = fchg_kill; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 /* Set the return path */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 infoSWE->type_info.type4.return_path.callback_func = NULL; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 infoSWE->type_info.type4.return_path.addr_id = 0; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 return RV_OK; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 T_RVM_RETURN fchg_set_info(T_RVF_ADDR_ID addr_id, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 T_RV_RETURN return_path[], |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 T_RVF_MB_ID mbId[], |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 T_RVM_RETURN errorCause, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 T_RVM_ERROR_TYPE errorType, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 T_RVM_STRING errorMsg)) |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 { |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 T_RVF_MB_STATUS mb_status; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 mb_status = rvf_get_buf(mbId[0],sizeof(T_PWR_CTRL_BLOCK),(void **) &pwr_ctrl); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 if (mb_status == RVF_RED) |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 { |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 rvf_send_trace("fchg_set_info: rvf_get_buf() failed", 35, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 NULL_PARAM, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 RV_TRACE_LEVEL_ERROR, |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 FCHG_USE_ID); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 return (RVM_MEMORY_ERR); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 memset(pwr_ctrl, 0, sizeof(T_PWR_CTRL_BLOCK)); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /* store the pointer to the error function */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 pwr_error_ft = callBackFct ; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 /* Store the addr id */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 pwr_ctrl->addr_id = addr_id; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 /* Store the memory bank id */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 pwr_ctrl->prim_id = mbId[0]; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 return RV_OK; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 T_RVM_RETURN fchg_init(void) |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 { |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 return RV_OK; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 T_RVM_RETURN fchg_stop(void) |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 return RV_OK; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 T_RVM_RETURN fchg_kill(void) |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 { |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 /* free all memory buffer previously allocated */ |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 rvf_free_buf ((void *) pwr_ctrl); |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 return RV_OK; |
c4077830aeeb
FCHG implementation code started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |