annotate src/cs/services/fcbm/fcbm_env.c @ 264:00107c0b8570

FCBM display: new charger plug debounce state
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 May 2021 06:01:34 +0000
parents baa738eeb842
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
230
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module provides the glue to the RiViera environment
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * for our FCBM SWE.
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "fcbm/fcbm_env.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "rv/rv_general.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rvf/rvf_api.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvm/rvm_priorities.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "rvm/rvm_api.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "rvm/rvm_use_id_list.h"
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <string.h>
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /* Global variables for FCBM addr_id and prim_id */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 T_RVF_ADDR_ID fcbm_addr_id;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 T_RVF_MB_ID fcbm_prim_id;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 T_RVM_RETURN fcbm_get_info (T_RVM_INFO_SWE *infoSWE)
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 /* SWE info */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 infoSWE->swe_type = RVM_SWE_TYPE_4;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 infoSWE->type_info.type4.swe_use_id = FCBM_USE_ID;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 memcpy( infoSWE->type_info.type4.swe_name, "FCBM", 5 );
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 infoSWE->type_info.type4.stack_size = FCBM_STACK_SIZE;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 infoSWE->type_info.type4.priority = RVM_FCBM_TASK_PRIORITY;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* memory bank info */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 infoSWE->type_info.type4.nb_mem_bank = 1;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 memcpy ((UINT8 *) infoSWE->type_info.type4.mem_bank[0].bank_name, "FCBM_PRIM", 10);
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 infoSWE->type_info.type4.mem_bank[0].initial_params.size = FCBM_MB_PRIM_SIZE;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 infoSWE->type_info.type4.mem_bank[0].initial_params.watermark = FCBM_MB_PRIM_WATERMARK;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 /* linked SWE info: we depend on FCHG, R2D, KPD */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 infoSWE->type_info.type4.nb_linked_swe = 3;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 infoSWE->type_info.type4.linked_swe_id[0] = FCHG_USE_ID;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 infoSWE->type_info.type4.linked_swe_id[1] = R2D_USE_ID;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 infoSWE->type_info.type4.linked_swe_id[2] = KPD_USE_ID;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /* generic functions */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 infoSWE->type_info.type4.set_info = fcbm_set_info;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 infoSWE->type_info.type4.init = fcbm_init;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 infoSWE->type_info.type4.core = fcbm_core;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 infoSWE->type_info.type4.stop = fcbm_stop;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 infoSWE->type_info.type4.kill = fcbm_kill;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /* Set the return path */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 infoSWE->type_info.type4.return_path.callback_func = NULL;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 infoSWE->type_info.type4.return_path.addr_id = 0;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return RV_OK;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 T_RVM_RETURN fcbm_set_info(T_RVF_ADDR_ID addr_id,
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 T_RV_RETURN return_path[],
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 T_RVF_MB_ID mbId[],
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 T_RVM_RETURN (*callBackFct) (T_RVM_NAME SWEntName,
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 T_RVM_RETURN errorCause,
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 T_RVM_ERROR_TYPE errorType,
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 T_RVM_STRING errorMsg))
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /* Store the addr id */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 fcbm_addr_id = addr_id;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 /* Store the memory bank id */
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 fcbm_prim_id = mbId[0];
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return RV_OK;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 T_RVM_RETURN fcbm_init(void)
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 {
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 return RV_OK;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 T_RVM_RETURN fcbm_stop(void)
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 {
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return RV_OK;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 T_RVM_RETURN fcbm_kill(void)
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 {
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 return RV_OK;
baa738eeb842 FCBM code implemented in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 }