comparison src/aci2/mfw/ti1_tmr.c @ 3:93999a60b835

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