comparison src/gpf3/frame/esf_func.c @ 2:c41a534f33c6

src/gpf3: preened GPF goo from TCS3.2
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 23:52:50 +0000
parents
children
comparison
equal deleted inserted replaced
1:864b8cc0cf63 2:c41a534f33c6
1 /*
2 +------------------------------------------------------------------------------
3 | File: esf_func.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : This Modul defines the ESF interface functions.
17 +-----------------------------------------------------------------------------
18 */
19
20
21
22 #ifndef __ESF_FUNC_C__
23 #define __ESF_FUNC_C__
24 #endif
25
26 #undef TEST_ESF_REGISTER
27
28 /*==== INCLUDES ===================================================*/
29
30 #ifdef _NUCLEUS_
31 /* the include of nucleus.h in this file is a dirty hack to mask the
32 issue of different type definitions in typedefs.h nad nucleus.h.
33 typedefs.h contains #if defined (NUCLEUS) to protect against
34 double definition and must be included after nucleus.h
35 */
36 #include "nucleus.h"
37 #endif
38 #include "typedefs.h"
39 #include "glob_defs.h"
40 #include "vsi.h"
41 #include "os.h"
42 #include "os_types.h"
43 #include "header.h"
44 #include "esf_func.h"
45 #include "string.h"
46 #include "stdio.h"
47
48 /*==== TYPES ======================================================*/
49
50
51 /*==== CONSTANTS ==================================================*/
52
53
54 /*==== EXTERNALS ==================================================*/
55
56 #ifdef FF_OS_ONLY
57 extern char esf_pool[];
58 extern int esf_pool_size;
59 #endif
60
61 /*==== VARIABLES ==================================================*/
62
63 #ifndef RUN_INT_RAM
64 T_ESF_FUNC esf_func;
65 #ifdef FF_OS_ONLY
66 OS_HANDLE esf_pool_handle;
67 #endif
68 #else
69 extern T_ESF_FUNC esf_func;
70 extern void esf_register ( T_ESF_FUNC * func );
71 #endif
72
73 /*==== LINT =======================================================*/
74
75
76 /*==== FUNCTIONS ==================================================*/
77
78 #ifdef TEST_ESF_REGISTER
79
80 #ifndef RUN_INT_RAM
81 void init_func1 ( void )
82 {
83 #ifndef _TARGET_
84 printf ("%s\n","ESF inif_func1 called");
85 #endif
86 }
87 #endif
88
89 #ifndef RUN_INT_RAM
90 void init_func2 ( void )
91 {
92 #ifndef _TARGET_
93 printf ("%s\n","ESF inif_func2 called");
94 #endif
95 }
96 #endif
97
98 #ifndef RUN_INT_RAM
99 void send_prim ( T_PRIM_HEADER * prim )
100 {
101 #ifndef _TARGET_
102 printf ("%s\n","ESF send_prim called");
103 #endif
104 }
105 #endif
106
107 #ifndef RUN_INT_RAM
108 T_ESF_FUNC esf_functions =
109 {
110 ESF_INITIALIZED,
111 init_func1,
112 init_func2,
113 send_prim
114 };
115 #endif
116
117 #endif
118
119 #ifdef FF_OS_ONLY
120 #ifndef RUN_INT_RAM
121 /*
122 +--------------------------------------------------------------------+
123 | PROJECT : GSM-Frame (8415) MODULE : OS_FRM |
124 | STATE : code ROUTINE : esf_task_entry |
125 +--------------------------------------------------------------------+
126
127 PURPOSE : entry function for the ESF helping task.
128
129 */
130
131 GLOBAL void esf_task_entry (OS_HANDLE TaskHandle, ULONG Value)
132 {
133 /* call second ESF init function */
134 esf_init_func2();
135
136 /* suspend helping task forever */
137 for(;;)
138 {
139 os_SuspendTask(TaskHandle,10000);
140 }
141 }
142 #endif
143
144 #ifndef RUN_INT_RAM
145 /*
146 +--------------------------------------------------------------------+
147 | PROJECT : GSM-Frame (8415) MODULE : OS_FRM |
148 | STATE : code ROUTINE : StartFrame |
149 +--------------------------------------------------------------------+
150
151 PURPOSE : this is called by ESF.
152
153 */
154 SHORT StartFrame ( void )
155 {
156 OS_HANDLE esf_task_handle;
157
158 os_Initialize();
159
160 /* set the OS tick to 10ms */
161 os_set_tick(SYSTEM_TICK_10_MS);
162
163 /* create memory pool for temporary usage during ESF partition pool creation and HISR stacks */
164 os_CreateMemoryPool (OS_NOTASK, "ESF_POOL", &esf_pool, esf_pool_size, &esf_pool_handle);
165
166 /* tell this pool handle to the OS layer */
167 os_SetPoolHandles (esf_pool_handle, esf_pool_handle);
168
169 /* create a helping task that calls esf_init2() from task context */
170 os_CreateTask (OS_NOTASK, "ESF_TASK", esf_task_entry, 1024, 255, &esf_task_handle, esf_pool_handle);
171
172 /* and start it */
173 os_StartTask (OS_NOTASK, esf_task_handle, 0);
174
175 esf_init();
176 /* call fist ESF init function */
177 esf_init_func1();
178
179 return OS_OK;
180
181 }
182 #endif
183 #endif /* FF_OS_ONLY */
184
185 #ifndef RUN_INT_RAM
186 /*
187 +------------------------------------------------------------------------------
188 | Function : esf_init
189 +------------------------------------------------------------------------------
190 | Description : initialize ESF API function pointer table.
191 |
192 | Parameters : void
193 |
194 | Return : void
195 +------------------------------------------------------------------------------
196 */
197 void esf_init ( void )
198 {
199 #ifdef TEST_ESF_REGISTER
200 esf_register ( &esf_functions );
201 #endif
202 if ( esf_func.magic_nr != ESF_INITIALIZED )
203 {
204 esf_func.init_func1 = NULL;
205 esf_func.init_func2 = NULL;
206 esf_func.send_prim = NULL;
207 }
208 }
209 #endif
210
211
212 #ifndef RUN_INT_RAM
213 /*
214 +------------------------------------------------------------------------------
215 | Function : esf_register
216 +------------------------------------------------------------------------------
217 | Description : register the ESF API functions.
218 |
219 | Parameters : func - pointer to API function pointer table
220 |
221 | Return : void
222 +------------------------------------------------------------------------------
223 */
224 void esf_register ( T_ESF_FUNC * func )
225 {
226 esf_func.init_func1 = func->init_func1;
227 esf_func.init_func2 = func->init_func2;
228 esf_func.send_prim = func->send_prim;
229 esf_func.magic_nr = ESF_INITIALIZED;
230 }
231 #endif
232
233 #ifndef RUN_INT_RAM
234 /*
235 +------------------------------------------------------------------------------
236 | Function : esf_init_func1
237 +------------------------------------------------------------------------------
238 | Description : call first ESF init function
239 |
240 | Parameters : void
241 |
242 | Return : void
243 +------------------------------------------------------------------------------
244 */
245 void esf_init_func1 ( void )
246 {
247 if ( esf_func.init_func1 != NULL )
248 {
249 esf_func.init_func1 ();
250 }
251 }
252 #endif
253
254 #ifndef RUN_INT_RAM
255 /*
256 +------------------------------------------------------------------------------
257 | Function : esf_init_func2
258 +------------------------------------------------------------------------------
259 | Description : call second ESF init function
260 |
261 | Parameters : void
262 |
263 | Return : void
264 +------------------------------------------------------------------------------
265 */
266 void esf_init_func2 ( void )
267 {
268 if ( esf_func.init_func2 != NULL )
269 {
270 esf_func.init_func2 ();
271 }
272 }
273 #endif
274
275 #ifndef RUN_FLASH
276 /*
277 +------------------------------------------------------------------------------
278 | Function : esf_send_prim
279 +------------------------------------------------------------------------------
280 | Description : call ESF send primitive function
281 |
282 | Parameters : void
283 |
284 | Return : void
285 +------------------------------------------------------------------------------
286 */
287 void esf_send_prim ( T_PRIM_HEADER * prim )
288 {
289 if ( esf_func.send_prim != NULL )
290 {
291 esf_func.send_prim ( prim );
292 }
293 }
294 #endif
295