FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/alr/alr_tim.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
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 static const char* const tim_names[] = | |
64 { | |
65 "TIM_POWERMEAS", | |
66 "TIM_NW_SYNC_GUARD", | |
67 #if defined(FF_HOMEZONE) | |
68 "TIM_HOMEZONE", | |
69 #endif /* FF_HOMEZONE */ | |
70 "???" | |
71 }; | |
72 | |
73 /*==== EXPORT =====================================================*/ | |
74 | |
75 | |
76 /*==== FUCTIONS ===================================================*/ | |
77 #if defined(TIMER_TRACE) | |
78 void trace_timer (USHORT index, long value) | |
79 { | |
80 switch(value) | |
81 { | |
82 default:/* >0: start */ | |
83 TRACE_TIMER_P2 ("T-Start:%s=%lu", tim_names[index], value); | |
84 break; | |
85 case 0:/* ==0: stop */ | |
86 TRACE_TIMER_P1 ("T-Stop:%s", tim_names[index]); | |
87 break; | |
88 case -1:/* -1: expire */ | |
89 TRACE_TIMER_P1 ("T-Expired:%s ", tim_names[index]); | |
90 break; | |
91 case -2:/* -2: check */ | |
92 TRACE_TIMER_P2 ("T-Check:%s %sactive", tim_names[index], | |
93 alr_data->tim_data.running[index] ? "" : "in"); | |
94 break; | |
95 case -3:/* -2: set expire function */ | |
96 TRACE_TIMER_P1 ("T-Set:%s expire function", tim_names[index]); | |
97 break; | |
98 } | |
99 } | |
100 #else | |
101 #define trace_timer(index,value) | |
102 #endif /* TIMER_TRACE */ | |
103 | |
104 /* | |
105 +--------------------------------------------------------------------+ | |
106 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
107 | STATE : code ROUTINE : tim_exec_timeout | | |
108 +--------------------------------------------------------------------+ | |
109 | |
110 PURPOSE : reset timeout functions and values. | |
111 | |
112 */ | |
113 | |
114 GLOBAL void tim_init (void) | |
115 { | |
116 TRACE_FUNCTION ("tim_init()"); | |
117 | |
118 memset (&alr_data->tim_data, 0, sizeof (alr_data->tim_data)); | |
119 alr_data->tim_data.expire[TIM_POWERMEAS] = ma_cs_rxlev_req; | |
120 alr_data->tim_data.expire[TIM_NW_SYNC_GUARD] = tim_stop_sync_to_nw; | |
121 #if defined(FF_HOMEZONE) | |
122 alr_data->tim_data.expire[TIM_HOMEZONE] = cb_tim_homezone; | |
123 #endif /* FF_HOMEZONE */ | |
124 } | |
125 | |
126 /* | |
127 +--------------------------------------------------------------------+ | |
128 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
129 | STATE : code ROUTINE : tim_exec_timeout | | |
130 +--------------------------------------------------------------------+ | |
131 | |
132 PURPOSE : execute timeout for the new frame variant. | |
133 | |
134 */ | |
135 | |
136 GLOBAL void tim_exec_timeout (USHORT index) | |
137 { | |
138 #if !defined(TIMER_TRACE) | |
139 TRACE_FUNCTION ("tim_exec_timeout()"); | |
140 #endif /* !TIMER_TRACE */ | |
141 | |
142 if (index < NUM_OF_ALR_TIMERS) | |
143 { | |
144 trace_timer (index, -1); | |
145 alr_data->tim_data.running[index] = 0; | |
146 | |
147 if (alr_data->tim_data.expire[index]) | |
148 alr_data->tim_data.expire[index] (); | |
149 } | |
150 else | |
151 { | |
152 SYST_TRACE_P ((SYST, "tim_exec_timeout: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
153 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
154 } | |
155 } | |
156 | |
157 /* | |
158 +--------------------------------------------------------------------+ | |
159 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
160 | STATE : code ROUTINE : tim_stop_timer | | |
161 +--------------------------------------------------------------------+ | |
162 | |
163 PURPOSE : stop timer in the new frame variant. | |
164 | |
165 */ | |
166 | |
167 GLOBAL void tim_stop_timer (USHORT index) | |
168 { | |
169 #if !defined(TIMER_TRACE) | |
170 TRACE_FUNCTION ("tim_stop_timer()"); | |
171 #endif /* !TIMER_TRACE */ | |
172 | |
173 if (index < NUM_OF_ALR_TIMERS) | |
174 { | |
175 trace_timer (index, 0); | |
176 alr_data->tim_data.running[index] = 0; | |
177 | |
178 /* | |
179 * stop physical timer. | |
180 */ | |
181 vsi_t_stop (VSI_CALLER index); | |
182 } | |
183 else | |
184 { | |
185 SYST_TRACE_P ((SYST,"tim_stop_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
186 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
187 } | |
188 } | |
189 | |
190 /* | |
191 +--------------------------------------------------------------------+ | |
192 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
193 | STATE : code ROUTINE : tim_start_timer | | |
194 +--------------------------------------------------------------------+ | |
195 | |
196 PURPOSE : start timer in the new frame variant. | |
197 | |
198 */ | |
199 | |
200 GLOBAL void tim_start_timer (USHORT index, T_TIME value) | |
201 { | |
202 #if !defined(TIMER_TRACE) | |
203 TRACE_FUNCTION ("tim_start_timer()"); | |
204 #endif /* !TIMER_TRACE */ | |
205 | |
206 if (index < NUM_OF_ALR_TIMERS) | |
207 { | |
208 trace_timer (index, value); | |
209 alr_data->tim_data.running[index] = 1; | |
210 | |
211 /* | |
212 * start physical timer. | |
213 */ | |
214 vsi_t_start (VSI_CALLER index, value); | |
215 } | |
216 else | |
217 { | |
218 SYST_TRACE_P ((SYST,"tim_start_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
219 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
220 } | |
221 } | |
222 | |
223 /* | |
224 +--------------------------------------------------------------------+ | |
225 | PROJECT : GSM-PS (6147) MODULE : RR_TIM | | |
226 | STATE : code ROUTINE : tim_check_timer | | |
227 +--------------------------------------------------------------------+ | |
228 | |
229 PURPOSE : check timer in the new frame variant. | |
230 | |
231 */ | |
232 GLOBAL BOOL tim_check_timer(USHORT index) | |
233 { | |
234 T_TIME value = 0; | |
235 | |
236 #if !defined(TIMER_TRACE) | |
237 TRACE_FUNCTION ("tim_check_timer()"); | |
238 #endif /* !TIMER_TRACE */ | |
239 | |
240 if (index < NUM_OF_ALR_TIMERS) | |
241 { | |
242 #if defined(TIMER_TRACE) | |
243 if (alr_data->tim_data.running[index]) | |
244 { | |
245 SHORT vsi_ret; | |
246 vsi_ret = vsi_t_status(VSI_CALLER index, &value); | |
247 if ((vsi_ret EQ VSI_OK) AND (value NEQ 0)) | |
248 { | |
249 TRACE_TIMER_P2 ("T-Check:%s active (%u left)", tim_names[index], value); | |
250 } | |
251 else | |
252 { | |
253 TRACE_TIMER_P1 ("T-Check:%s inactive", tim_names[index]); | |
254 } | |
255 } | |
256 else | |
257 { | |
258 TRACE_TIMER_P1 ("T-Check:%s inactive", tim_names[index]); | |
259 } | |
260 #endif /* TIMER_TRACE */ | |
261 | |
262 return alr_data->tim_data.running[index]; | |
263 } | |
264 else | |
265 { | |
266 SYST_TRACE_P ((SYST,"tim_check_timer: index=%u (>=%u)", index, NUM_OF_ALR_TIMERS)); | |
267 TRACE_ASSERT (index < NUM_OF_ALR_TIMERS); | |
268 return FALSE; | |
269 } | |
270 } | |
271 | |
272 #endif /* ALR_TIM_C */ | |
273 |