comparison gsm-fw/g23m-gsm/alr/alr_tim.c @ 673:2f7df7a314f8

gsm-fw/g23m-gsm subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 28 Sep 2014 23:20:04 +0000
parents
children 4094f0d750c7
comparison
equal deleted inserted replaced
672:0dc6f9e8e980 673:2f7df7a314f8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : J:\g23m-gsm\alr\alr_tim.c
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose :
18 +-----------------------------------------------------------------------------
19 */
20 #ifndef ALR_TIM_C
21 #define ALR_TIM_C
22
23 #define ENTITY_PL
24
25 /*==== INCLUDES ===================================================*/
26 #include <string.h>
27 #include <stdlib.h>
28 #include <ctype.h>
29 #include "typedefs.h"
30 #include "pconst.cdg"
31 #include "mconst.cdg"
32 #include "message.h"
33 #include "ccdapi.h"
34 #include "vsi.h"
35 #include "custom.h"
36 #include "gsm.h"
37 #include "prim.h"
38 #include "cnf_alr.h"
39 #include "mon_alr.h"
40 #include "pei.h"
41 #include "tok.h"
42 #include "pcm.h"
43
44 #ifdef GPRS
45 #include "alr_gprs.h"
46 #endif
47
48 #include "alr.h"
49
50 /*==== PRIVAT =====================================================*/
51 #if defined(TIMER_TRACE)
52 #define TRACE_TIMER(FMT) TRACE_EVENT((FMT))
53 #define TRACE_TIMER_P1(FMT,P1) TRACE_EVENT_P1((FMT),(P1))
54 #define TRACE_TIMER_P2(FMT,P1,P2) TRACE_EVENT_P2((FMT),(P1),(P2))
55 #define TRACE_TIMER_P3(FMT,P1,P2,P3) TRACE_EVENT_P3((FMT),(P1),(P2),(P3))
56 #else
57 #define TRACE_TIMER(FMT)
58 #define TRACE_TIMER_P1(FMT,P1)
59 #define TRACE_TIMER_P2(FMT,P1,P2)
60 #define TRACE_TIMER_P3(FMT,P1,P2,P2)
61 #endif
62
63 /* Implements Measure#32: Row 247, 248, 249, 251, 252, 259 and 260 */
64 static T_S2I_STRING const tim_names[] =
65 {
66 S2I_STRING("TIM_POWERMEAS"),
67 S2I_STRING("TIM_NW_SYNC_GUARD"),
68 #if defined(FF_HOMEZONE)
69 S2I_STRING("TIM_HOMEZONE"),
70 #endif /* FF_HOMEZONE */
71 S2I_STRING("???")
72 };
73
74 /*==== EXPORT =====================================================*/
75
76
77 /*==== FUCTIONS ===================================================*/
78 #if defined(TIMER_TRACE)
79 void trace_timer (USHORT index, long value)
80 {
81 GET_INSTANCE_DATA;
82 switch(value)
83 {
84 /* Implements Measure#32: Row 247, 248, 249, 251 and 252 */
85 default:/* >0: start */
86 TRACE_TIMER_P2 ("T-Start:%s=%lu", S2I_STRING(tim_names[index]), value);
87 break;
88 case 0:/* ==0: stop */
89 TRACE_TIMER_P1 ("T-Stop:%s", S2I_STRING(tim_names[index]));
90 break;
91 case -1:/* -1: expire */
92 TRACE_TIMER_P1 ("T-Expired:%s ", S2I_STRING(tim_names[index]));
93 break;
94 case -2:/* -2: check */
95 if(alr_data->tim_data.running[index])
96 {
97 TRACE_TIMER_P1 ("T-Check:%s active", S2I_STRING(tim_names[index]));
98 }
99 else
100 {
101 TRACE_TIMER_P1 ("T-Check:%s inactive", S2I_STRING(tim_names[index]));
102 }
103 break;
104 case -3:/* -2: set expire function */
105 TRACE_TIMER_P1 ("T-Set:%s expire function", S2I_STRING(tim_names[index]));
106 break;
107 }
108 }
109 #else
110 #define trace_timer(index,value)
111 #endif /* TIMER_TRACE */
112
113 /*
114 +--------------------------------------------------------------------+
115 | PROJECT : GSM-PS (6147) MODULE : RR_TIM |
116 | STATE : code ROUTINE : tim_exec_timeout |
117 +--------------------------------------------------------------------+
118
119 PURPOSE : reset timeout functions and values.
120
121 */
122
123 GLOBAL void tim_init (void)
124 {
125 GET_INSTANCE_DATA;
126 TRACE_FUNCTION ("tim_init()");
127
128 memset (&alr_data->tim_data, 0, sizeof (alr_data->tim_data));
129 alr_data->tim_data.expire[TIM_POWERMEAS] = ma_cs_rxlev_req;
130 alr_data->tim_data.expire[TIM_NW_SYNC_GUARD] = tim_stop_sync_to_nw;
131 #if defined(FF_HOMEZONE)
132 alr_data->tim_data.expire[TIM_HOMEZONE] = cb_tim_homezone;
133 #endif /* FF_HOMEZONE */
134 }
135
136 /*
137 +--------------------------------------------------------------------+
138 | PROJECT : GSM-PS (6147) MODULE : RR_TIM |
139 | STATE : code ROUTINE : tim_exec_timeout |
140 +--------------------------------------------------------------------+
141
142 PURPOSE : execute timeout for the new frame variant.
143
144 */
145
146 GLOBAL void tim_exec_timeout (USHORT index)
147 {
148 GET_INSTANCE_DATA;
149 #if !defined(TIMER_TRACE)
150 TRACE_FUNCTION ("tim_exec_timeout()");
151 #endif /* !TIMER_TRACE */
152
153 if (index < NUM_OF_ALR_TIMERS)
154 {
155 trace_timer (index, -1);
156 alr_data->tim_data.running[index] = 0;
157
158 if (alr_data->tim_data.expire[index])
159 alr_data->tim_data.expire[index] ();
160 }
161 else
162 {
163 SYST_TRACE_P ((SYST, "tim_exec_timeout: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS));
164 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS);
165 }
166 }
167
168 /*
169 +--------------------------------------------------------------------+
170 | PROJECT : GSM-PS (6147) MODULE : RR_TIM |
171 | STATE : code ROUTINE : tim_stop_timer |
172 +--------------------------------------------------------------------+
173
174 PURPOSE : stop timer in the new frame variant.
175
176 */
177
178 GLOBAL void tim_stop_timer (USHORT index)
179 {
180 GET_INSTANCE_DATA;
181 #if !defined(TIMER_TRACE)
182 TRACE_FUNCTION ("tim_stop_timer()");
183 #endif /* !TIMER_TRACE */
184
185 if (index < NUM_OF_ALR_TIMERS)
186 {
187 trace_timer (index, 0);
188 alr_data->tim_data.running[index] = 0;
189
190 /*
191 * stop physical timer.
192 */
193 TIMER_STOP(pl_handle, index);
194 }
195 else
196 {
197 SYST_TRACE_P ((SYST,"tim_stop_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS));
198 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS);
199 }
200 }
201
202 /*
203 +--------------------------------------------------------------------+
204 | PROJECT : GSM-PS (6147) MODULE : RR_TIM |
205 | STATE : code ROUTINE : tim_start_timer |
206 +--------------------------------------------------------------------+
207
208 PURPOSE : start timer in the new frame variant.
209
210 */
211
212 GLOBAL void tim_start_timer (USHORT index, T_TIME value)
213 {
214 GET_INSTANCE_DATA;
215 #if !defined(TIMER_TRACE)
216 TRACE_FUNCTION ("tim_start_timer()");
217 #endif /* !TIMER_TRACE */
218
219 if (index < NUM_OF_ALR_TIMERS)
220 {
221 trace_timer (index, value);
222 alr_data->tim_data.running[index] = 1;
223
224 /*
225 * start physical timer.
226 */
227 TIMER_START(pl_handle, index, value);
228 }
229 else
230 {
231 SYST_TRACE_P ((SYST,"tim_start_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS));
232 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS);
233 }
234 }
235
236 /*
237 +--------------------------------------------------------------------+
238 | PROJECT : GSM-PS (6147) MODULE : RR_TIM |
239 | STATE : code ROUTINE : tim_check_timer |
240 +--------------------------------------------------------------------+
241
242 PURPOSE : check timer in the new frame variant.
243
244 */
245 GLOBAL BOOL tim_check_timer(USHORT index)
246 {
247 GET_INSTANCE_DATA;
248 T_TIME value = 0;
249
250 #if !defined(TIMER_TRACE)
251 TRACE_FUNCTION ("tim_check_timer()");
252 #endif /* !TIMER_TRACE */
253
254 if (index < NUM_OF_ALR_TIMERS)
255 {
256 #if defined(TIMER_TRACE)
257 if (alr_data->tim_data.running[index])
258 {
259 SHORT vsi_ret;
260 vsi_ret = TIMER_STATUS(pl_handle, index, &value);
261 if ((vsi_ret EQ VSI_OK) AND (value NEQ 0))
262 {
263 /* Implements Measure#32: Row 259 */
264 TRACE_TIMER_P2 ("T-Check:%s active (%u left)", S2I_STRING(tim_names[index]), value);
265 }
266 else
267 {
268 /* Implements Measure#32: Row 260 */
269 TRACE_TIMER_P1 ("T-Check:%s inactive", S2I_STRING(tim_names[index]));
270 }
271 }
272 else
273 {
274 /* Implements Measure#32: Row 260 */
275 TRACE_TIMER_P1 ("T-Check:%s inactive", S2I_STRING(tim_names[index]));
276 }
277 #endif /* TIMER_TRACE */
278
279 return alr_data->tim_data.running[index];
280 }
281 else
282 {
283 SYST_TRACE_P ((SYST,"tim_check_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS));
284 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS);
285 return FALSE;
286 }
287 }
288
289 #endif /* ALR_TIM_C */
290