comparison src/ui/mfw/ti1_tmr.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children 92abb46dc1ba
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: ti1_tmr.c $|
4 | $Author:: Es $ CONDAT GmbH $Revision:: 8 $|
5 | CREATED: 28.01.99 $Modtime:: 18.02.00 17:57 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : TI1_TMR
10
11 PURPOSE : timer driver interface (TI1 VERSION)
12 uses only one system timer (programmed in milliseconds)
13
14 EXPORT :
15
16 TO DO :
17
18 $History:: ti1_tmr.c $
19 *
20 *Sep 19, 2006 DRT OMAPS00091093 x0047075(Archana)
21 * Description: optimizing of the timer related vsi interface
22 * Solution:Replacing the Vsi_t_start ,Vsi_t_stop with TIMER_START and TIMER_STOP
23 ***************** Version 8 *****************
24 * User: Es Date: 18.02.00 Time: 17:58
25 * Updated in $/GSM/Condat/MS/SRC/MFW
26 * tmrStart(): bug in inner 'if'-clause
27 *
28 * ***************** Version 7 *****************
29 * User: Es Date: 6.07.99 Time: 12:41
30 * Updated in $/GSM/DEV/MS/SRC/MFW
31 *
32 * ***************** Version 6 *****************
33 * User: Es Date: 14.06.99 Time: 12:15
34 * Updated in $/GSM/DEV/MS/SRC/MFW
35 *
36 * ***************** Version 5 *****************
37 * User: Es Date: 1.04.99 Time: 17:07
38 * Updated in $/GSM/DEV/MS/SRC/MFW
39 * removed lots of traces
40 *
41 * ***************** Version 4 *****************
42 * User: Es Date: 17.02.99 Time: 19:11
43 * Updated in $/GSM/DEV/MS/SRC/MFW
44 *
45 * ***************** Version 3 *****************
46 * User: Es Date: 14.02.99 Time: 20:57
47 * Updated in $/GSM/DEV/MS/SRC/MFW
48 *
49 * ***************** Version 2 *****************
50 * User: Es Date: 11.02.99 Time: 16:43
51 * Updated in $/GSM/DEV/MS/SRC/MFW
52 *
53 * ***************** Version 1 *****************
54 * User: Es Date: 9.02.99 Time: 14:54
55 * Created in $/GSM/DEV/MS/SRC/MFW
56 * TI display & keyboard interface for MFW
57 */
58 #define ENTITY_MFW
59
60 #if defined (NEW_FRAME)
61
62 #include "typedefs.h"
63 #include "vsi.h"
64 #include "custom.h"
65 #include "gsm.h"
66
67 #else
68
69 #include "STDDEFS.H"
70 #include "custom.h"
71 #include "gsm.h"
72 #include "vsi.h"
73
74 #endif
75
76 #include "mfw_mfw.h"
77 #include "mfw_sys.h"
78 #include "drv_tmr.h"
79 #include "l4_tim.h"
80 #include "ti1_tmr.h"
81
82 #include "cus_aci.h"
83
84 #if !defined (NEW_FRAME)
85 void aci_flush_fifo (T_VSI_THANDLE timer);
86 #endif
87
88 static void (*sig) (void) = 0; /* timer signaling function */
89 #if !defined (NEW_FRAME)
90 static T_VSI_THANDLE timer = 0; /* VSI timer handle */
91 #endif
92
93 /*
94 +--------------------------------------------------------------------+
95 | PROJECT : MMI-Framework (8417) MODULE : ti1_tmr |
96 | STATE : code ROUTINE : tmrTimer |
97 +--------------------------------------------------------------------+
98
99 PURPOSE : forward timer signal
100
101 */
102 #if defined (NEW_FRAME)
103
104 int mfw_timeout (USHORT t)
105 {
106 if (sig AND t EQ MFW_TIMER)
107 {
108 sig();
109 return 1;
110 }
111 return 0;
112 }
113
114 #else
115
116 int mfw_timeout (T_VSI_THANDLE t)
117 {
118 if (sig && t == timer)
119 {
120 sig();
121 return 1;
122 }
123
124 return 0;
125 }
126 #endif
127
128 /*
129 +--------------------------------------------------------------------+
130 | PROJECT : MMI-Framework (8417) MODULE : ti1_tmr |
131 | STATE : code ROUTINE : tmrInit |
132 +--------------------------------------------------------------------+
133
134 PURPOSE : initialize timer driver
135
136 */
137
138 #if defined (NEW_FRAME)
139
140 int tmrInit (void (*s)(void))
141 {
142 sig = s;
143
144 TRACE_FUNCTION("tmrInit()");
145
146 if (!s)
147 return 0;
148
149 return 1;
150 }
151
152 #else
153
154 int tmrInit (void (*s)(void))
155 {
156 sig = s;
157
158 TRACE_FUNCTION("tmrInit()");
159
160 if (!s)
161 return 0;
162
163 timer = vsi_t_open(VSI_CALLER "mfwTimer");
164 if (timer < VSI_OK)
165 {
166 TRACE_ERROR("TI1_TMR_INIT: No Timer");
167 sig = 0;
168 return 0;
169 }
170
171 return 1;
172 }
173 #endif
174
175 /*
176 +--------------------------------------------------------------------+
177 | PROJECT : MMI-Framework (8417) MODULE : ti1_tmr |
178 | STATE : code ROUTINE : tmrExit |
179 +--------------------------------------------------------------------+
180
181 PURPOSE : finalize timer driver
182
183 */
184
185 #if defined (NEW_FRAME)
186
187 int tmrExit (void)
188 {
189 TRACE_FUNCTION("tmrExit()");
190
191 if (sig)
192 {
193 tmrStop();
194 }
195 sig = 0;
196
197 return 1;
198 }
199
200 #else
201
202 int tmrExit (void)
203 {
204 TRACE_FUNCTION("tmrExit()");
205
206 if (sig)
207 {
208 tmrStop();
209 vsi_t_close(VSI_CALLER timer);
210 }
211 timer = 0;
212 sig = 0;
213
214 return 1;
215 }
216
217 #endif
218
219 /*
220 +--------------------------------------------------------------------+
221 | PROJECT : MMI-Framework (8417) MODULE : ti1_tmr |
222 | STATE : code ROUTINE : tmrStart |
223 +--------------------------------------------------------------------+
224
225 PURPOSE : start timer
226
227 */
228 #if defined (NEW_FRAME)
229
230 void tmrStart (ULONG ms)
231 {
232 if (sig)
233 {
234 if (ms < 5) /* at least one tick */
235 ms = 5; /* set to minimum */
236 // Sep 19, 2006 DRT OMAPS00091093 x0047075(Archana)
237 //Replacing Vsi_t_start with TIMER_START
238 TIMER_START(aci_handle, MFW_TIMER, ms);
239 }
240 }
241
242 #else
243
244 void tmrStart (U32 ms)
245 {
246 T_VSI_TVALUE toTime; /* VSI timer value */
247
248 if (sig && timer >= VSI_OK)
249 {
250 toTime = (ms * TMR_PREC) / TMR_TICK;
251 if (ms && !toTime)
252 toTime = 1; /* set to minimum */
253
254 // Sep 19, 2006 DRT OMAPS00091093 x0047075(Archana)
255 //Replacing Vsi_t_start with TIMER_START
256 TIMER_START(VSI_CALLER timer,toTime);
257 }
258 }
259 #endif
260
261 /*
262 +--------------------------------------------------------------------+
263 | PROJECT : MMI-Framework (8417) MODULE : ti1_tmr |
264 | STATE : code ROUTINE : tmrStop |
265 +--------------------------------------------------------------------+
266
267 PURPOSE : stop timer
268
269 */
270
271 #if defined (NEW_FRAME)
272
273 ULONG tmrStop (void)
274 {
275 T_TIME left; /* VSI timer value */
276
277 if (sig)
278 {
279 vsi_t_status(VSI_CALLER MFW_TIMER, &left);
280 // Sep 19, 2006 DRT OMAPS00091093 x0047075(Archana)
281 //Replacing Vsi_t_stop with TIMER_STOP
282 TIMER_STOP(aci_handle, MFW_TIMER);
283 return (left);
284 }
285 return 0;
286 }
287
288 #else
289
290 U32 tmrStop (void)
291 {
292 T_VSI_TVALUE left; /* VSI timer value */
293
294 if (sig && timer >= VSI_OK)
295 {
296 vsi_t_status(VSI_CALLER timer,&left);
297 // Sep 19, 2006 DRT OMAPS00091093 x0047075(Archana)
298 //Replacing Vsi_t_stop with TIMER_STOP
299 TIMER_STOP(VSI_CALLER timer);
300 aci_flush_fifo(timer);
301 return ((left * TMR_TICK) / TMR_PREC);
302 }
303
304 return 0;
305 }
306
307 #endif
308
309 /*
310 +--------------------------------------------------------------------+
311 | PROJECT : MMI-Framework (8417) MODULE : ti1_tmr |
312 | STATE : code ROUTINE : tmrLeft |
313 +--------------------------------------------------------------------+
314
315 PURPOSE : report left time
316
317 */
318
319 #if defined (NEW_FRAME)
320
321 ULONG tmrLeft (void)
322 {
323 T_TIME left; /* VSI timer value */
324
325 if (sig)
326 {
327 vsi_t_status(VSI_CALLER MFW_TIMER, &left);
328 return (left);
329 }
330 return 0;
331 }
332
333 #else
334
335 U32 tmrLeft (void)
336 {
337 T_VSI_TVALUE left; /* VSI timer value */
338
339 if (sig && timer >= VSI_OK)
340 {
341 vsi_t_status(VSI_CALLER timer,&left);
342 return ((left * TMR_TICK) / TMR_PREC);
343 }
344
345 return 0;
346 }
347
348 #endif