FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/alr/alr_tim.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
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 #include "config.h" | |
24 #include "fixedconf.h" | |
25 #include "condat-features.h" | |
26 | |
27 #define ENTITY_PL | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 #include <string.h> | |
31 #include <stdlib.h> | |
32 #include <ctype.h> | |
33 #include "typedefs.h" | |
34 #include "pconst.cdg" | |
35 #include "mconst.cdg" | |
36 #include "message.h" | |
37 #include "ccdapi.h" | |
38 #include "vsi.h" | |
39 #include "custom.h" | |
40 #include "gsm.h" | |
41 #include "prim.h" | |
42 #include "cnf_alr.h" | |
43 #include "mon_alr.h" | |
44 #include "pei.h" | |
45 #include "tok.h" | |
46 #include "pcm.h" | |
47 | |
48 #ifdef GPRS | |
49 #include "alr_gprs.h" | |
50 #endif | |
51 | |
52 #include "alr.h" | |
53 | |
54 /*==== PRIVAT =====================================================*/ | |
55 #if defined(TIMER_TRACE) | |
56 #define TRACE_TIMER(FMT) TRACE_EVENT((FMT)) | |
57 #define TRACE_TIMER_P1(FMT,P1) TRACE_EVENT_P1((FMT),(P1)) | |
58 #define TRACE_TIMER_P2(FMT,P1,P2) TRACE_EVENT_P2((FMT),(P1),(P2)) | |
59 #define TRACE_TIMER_P3(FMT,P1,P2,P3) TRACE_EVENT_P3((FMT),(P1),(P2),(P3)) | |
60 #else | |
61 #define TRACE_TIMER(FMT) | |
62 #define TRACE_TIMER_P1(FMT,P1) | |
63 #define TRACE_TIMER_P2(FMT,P1,P2) | |
64 #define TRACE_TIMER_P3(FMT,P1,P2,P2) | |
65 #endif | |
66 | |
67 /* Implements Measure#32: Row 247, 248, 249, 251, 252, 259 and 260 */ | |
68 static T_S2I_STRING const tim_names[] = | |
69 { | |
70 S2I_STRING("TIM_POWERMEAS"), | |
71 S2I_STRING("TIM_NW_SYNC_GUARD"), | |
72 #if defined(FF_HOMEZONE) | |
73 S2I_STRING("TIM_HOMEZONE"), | |
74 #endif /* FF_HOMEZONE */ | |
75 S2I_STRING("???") | |
76 }; | |
77 | |
78 /*==== EXPORT =====================================================*/ | |
79 | |
80 | |
81 /*==== FUCTIONS ===================================================*/ | |
82 #if defined(TIMER_TRACE) | |
83 void trace_timer (USHORT index, long value) | |
84 { | |
85 GET_INSTANCE_DATA; | |
86 switch(value) | |
87 { | |
88 /* Implements Measure#32: Row 247, 248, 249, 251 and 252 */ | |
89 default:/* >0: start */ | |
90 TRACE_TIMER_P2 ("T-Start:%s=%lu", S2I_STRING(tim_names[index]), value); | |
91 break; | |
92 case 0:/* ==0: stop */ | |
93 TRACE_TIMER_P1 ("T-Stop:%s", S2I_STRING(tim_names[index])); | |
94 break; | |
95 case -1:/* -1: expire */ | |
96 TRACE_TIMER_P1 ("T-Expired:%s ", S2I_STRING(tim_names[index])); | |
97 break; | |
98 case -2:/* -2: check */ | |
99 if(alr_data->tim_data.running[index]) | |
100 { | |
101 TRACE_TIMER_P1 ("T-Check:%s active", S2I_STRING(tim_names[index])); | |
102 } | |
103 else | |
104 { | |
105 TRACE_TIMER_P1 ("T-Check:%s inactive", S2I_STRING(tim_names[index])); | |
106 } | |
107 break; | |
108 case -3:/* -2: set expire function */ | |
109 TRACE_TIMER_P1 ("T-Set:%s expire function", S2I_STRING(tim_names[index])); | |
110 break; | |
111 } | |
112 } | |
113 #else | |
114 #define trace_timer(index,value) | |
115 #endif /* TIMER_TRACE */ | |
116 | |
117 /* | |
118 +--------------------------------------------------------------------+ | |
119 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
120 | STATE : code ROUTINE : tim_exec_timeout | | |
121 +--------------------------------------------------------------------+ | |
122 | |
123 PURPOSE : reset timeout functions and values. | |
124 | |
125 */ | |
126 | |
127 GLOBAL void tim_init (void) | |
128 { | |
129 GET_INSTANCE_DATA; | |
130 TRACE_FUNCTION ("tim_init()"); | |
131 | |
132 memset (&alr_data->tim_data, 0, sizeof (alr_data->tim_data)); | |
133 alr_data->tim_data.expire[TIM_POWERMEAS] = ma_cs_rxlev_req; | |
134 alr_data->tim_data.expire[TIM_NW_SYNC_GUARD] = tim_stop_sync_to_nw; | |
135 #if defined(FF_HOMEZONE) | |
136 alr_data->tim_data.expire[TIM_HOMEZONE] = cb_tim_homezone; | |
137 #endif /* FF_HOMEZONE */ | |
138 } | |
139 | |
140 /* | |
141 +--------------------------------------------------------------------+ | |
142 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
143 | STATE : code ROUTINE : tim_exec_timeout | | |
144 +--------------------------------------------------------------------+ | |
145 | |
146 PURPOSE : execute timeout for the new frame variant. | |
147 | |
148 */ | |
149 | |
150 GLOBAL void tim_exec_timeout (USHORT index) | |
151 { | |
152 GET_INSTANCE_DATA; | |
153 #if !defined(TIMER_TRACE) | |
154 TRACE_FUNCTION ("tim_exec_timeout()"); | |
155 #endif /* !TIMER_TRACE */ | |
156 | |
157 if (index < NUM_OF_ALR_TIMERS) | |
158 { | |
159 trace_timer (index, -1); | |
160 alr_data->tim_data.running[index] = 0; | |
161 | |
162 if (alr_data->tim_data.expire[index]) | |
163 alr_data->tim_data.expire[index] (); | |
164 } | |
165 else | |
166 { | |
167 SYST_TRACE_P ((SYST, "tim_exec_timeout: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
168 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
169 } | |
170 } | |
171 | |
172 /* | |
173 +--------------------------------------------------------------------+ | |
174 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
175 | STATE : code ROUTINE : tim_stop_timer | | |
176 +--------------------------------------------------------------------+ | |
177 | |
178 PURPOSE : stop timer in the new frame variant. | |
179 | |
180 */ | |
181 | |
182 GLOBAL void tim_stop_timer (USHORT index) | |
183 { | |
184 GET_INSTANCE_DATA; | |
185 #if !defined(TIMER_TRACE) | |
186 TRACE_FUNCTION ("tim_stop_timer()"); | |
187 #endif /* !TIMER_TRACE */ | |
188 | |
189 if (index < NUM_OF_ALR_TIMERS) | |
190 { | |
191 trace_timer (index, 0); | |
192 alr_data->tim_data.running[index] = 0; | |
193 | |
194 /* | |
195 * stop physical timer. | |
196 */ | |
197 TIMER_STOP(pl_handle, index); | |
198 } | |
199 else | |
200 { | |
201 SYST_TRACE_P ((SYST,"tim_stop_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
202 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
203 } | |
204 } | |
205 | |
206 /* | |
207 +--------------------------------------------------------------------+ | |
208 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
209 | STATE : code ROUTINE : tim_start_timer | | |
210 +--------------------------------------------------------------------+ | |
211 | |
212 PURPOSE : start timer in the new frame variant. | |
213 | |
214 */ | |
215 | |
216 GLOBAL void tim_start_timer (USHORT index, T_TIME value) | |
217 { | |
218 GET_INSTANCE_DATA; | |
219 #if !defined(TIMER_TRACE) | |
220 TRACE_FUNCTION ("tim_start_timer()"); | |
221 #endif /* !TIMER_TRACE */ | |
222 | |
223 if (index < NUM_OF_ALR_TIMERS) | |
224 { | |
225 trace_timer (index, value); | |
226 alr_data->tim_data.running[index] = 1; | |
227 | |
228 /* | |
229 * start physical timer. | |
230 */ | |
231 TIMER_START(pl_handle, index, value); | |
232 } | |
233 else | |
234 { | |
235 SYST_TRACE_P ((SYST,"tim_start_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
236 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
237 } | |
238 } | |
239 | |
240 /* | |
241 +--------------------------------------------------------------------+ | |
242 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
243 | STATE : code ROUTINE : tim_check_timer | | |
244 +--------------------------------------------------------------------+ | |
245 | |
246 PURPOSE : check timer in the new frame variant. | |
247 | |
248 */ | |
249 GLOBAL BOOL tim_check_timer(USHORT index) | |
250 { | |
251 GET_INSTANCE_DATA; | |
252 T_TIME value = 0; | |
253 | |
254 #if !defined(TIMER_TRACE) | |
255 TRACE_FUNCTION ("tim_check_timer()"); | |
256 #endif /* !TIMER_TRACE */ | |
257 | |
258 if (index < NUM_OF_ALR_TIMERS) | |
259 { | |
260 #if defined(TIMER_TRACE) | |
261 if (alr_data->tim_data.running[index]) | |
262 { | |
263 SHORT vsi_ret; | |
264 vsi_ret = TIMER_STATUS(pl_handle, index, &value); | |
265 if ((vsi_ret EQ VSI_OK) AND (value NEQ 0)) | |
266 { | |
267 /* Implements Measure#32: Row 259 */ | |
268 TRACE_TIMER_P2 ("T-Check:%s active (%u left)", S2I_STRING(tim_names[index]), value); | |
269 } | |
270 else | |
271 { | |
272 /* Implements Measure#32: Row 260 */ | |
273 TRACE_TIMER_P1 ("T-Check:%s inactive", S2I_STRING(tim_names[index])); | |
274 } | |
275 } | |
276 else | |
277 { | |
278 /* Implements Measure#32: Row 260 */ | |
279 TRACE_TIMER_P1 ("T-Check:%s inactive", S2I_STRING(tim_names[index])); | |
280 } | |
281 #endif /* TIMER_TRACE */ | |
282 | |
283 return alr_data->tim_data.running[index]; | |
284 } | |
285 else | |
286 { | |
287 SYST_TRACE_P ((SYST,"tim_check_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
288 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
289 return FALSE; | |
290 } | |
291 } | |
292 | |
293 #endif /* ALR_TIM_C */ |