FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-glue/gdi/rx.c @ 831:549b7ac60300
gsm-fw/g23m-glue/gdi/*.c: import from Leonardo source
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 23 Apr 2015 06:42:53 +0000 |
parents | |
children | 3efeaab1aea5 |
comparison
equal
deleted
inserted
replaced
830:56e3d8560d69 | 831:549b7ac60300 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS | |
4 | Modul : DRV_RX | |
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 : This Module defines the fieldstrength management | |
18 | device driver for the G23 protocol stack. | |
19 | | |
20 | This driver is used to control all fieldstrength related | |
21 | functions. The driver does support multiple devices and | |
22 | therefore no open and close functionality is supported. | |
23 | The driver can be configured to signal different state | |
24 | transitions. This is done by setting an OS signal or | |
25 | calling a specified call-back function. | |
26 +----------------------------------------------------------------------------- | |
27 */ | |
28 | |
29 #ifndef DRV_RX_C | |
30 #define DRV_RX_C | |
31 #endif | |
32 #define ENTITY_CST | |
33 /*==== INCLUDES ===================================================*/ | |
34 | |
35 #if defined (NEW_FRAME) | |
36 | |
37 #include <string.h> | |
38 #include "typedefs.h" | |
39 #include "vsi.h" | |
40 #include "custom.h" | |
41 #include "gsm.h" | |
42 #include "prim.h" | |
43 #include "gdi.h" | |
44 #include "rx.h" | |
45 | |
46 #else | |
47 | |
48 #include <string.h> | |
49 #include "stddefs.h" | |
50 #include "custom.h" | |
51 #include "gsm.h" | |
52 #include "prim.h" | |
53 #include "vsi.h" | |
54 #include "gdi.h" | |
55 #include "rx.h" | |
56 | |
57 #endif | |
58 /*==== EXPORT =====================================================*/ | |
59 EXTERN USHORT RX_GetValue ( void ); | |
60 EXTERN UBYTE RX_GetRxQual ( void ); | |
61 EXTERN void RX_Enable (T_VOID_FUNC rx_indication); | |
62 | |
63 #if defined (NEW_FRAME) | |
64 EXTERN USHORT cst_handle; | |
65 #endif /* NEW_FRAME */ | |
66 | |
67 /*==== CONSTANTS ==================================================*/ | |
68 #define RX_INDICATION_WITHOUT_TIMER | |
69 #if defined (NEW_FRAME) | |
70 #define CST_RXTIMER 1 | |
71 #endif /* NEW_FRAME */ | |
72 | |
73 /*==== VARIABLES ==================================================*/ | |
74 drv_SignalCB_Type rx_signal_callback = NULL; | |
75 rx_DCB_Type rx_DCB; | |
76 rx_Status_Type rx_Status; | |
77 #if !defined (NEW_FRAME) | |
78 T_VSI_THANDLE rx_handle = VSI_ERROR; | |
79 #endif /* !NEW_FRAME */ | |
80 | |
81 /*==== FUNCTIONS ==================================================*/ | |
82 #if 0 | |
83 #if defined(NEW_FRAME) | |
84 #define SYST_TRACE(a) vsi_o_ttrace(0, 0xFFFF,a) | |
85 #define SYST 0, 0xffff | |
86 #define SYST_TRACE_P(a) vsi_o_ttrace a | |
87 #else /* NEW_FRAME */ | |
88 #define SYST_TRACE(a) vsi_o_trace("", 0xFFFF,a) | |
89 #define SYST "", 0xffff | |
90 #define SYST_TRACE_P(a) vsi_o_trace a | |
91 #endif /* NEW_FRAME */ | |
92 /* | |
93 * use it as showed next line... | |
94 * SYST_TRACE_P((SYST, "e.g. two parameter: %d %d", p1, p2)); | |
95 */ | |
96 #else /* 0|1 */ | |
97 #define SYST_TRACE(a) | |
98 #define SYST_TRACE_P(a) | |
99 #endif /* 0|1 */ | |
100 | |
101 | |
102 LOCAL void RX_Indication (void) | |
103 { | |
104 if (rx_signal_callback) | |
105 { | |
106 USHORT new_rx_value; | |
107 UBYTE calculated_level; | |
108 drv_SignalID_Type signal_params; | |
109 | |
110 new_rx_value = RX_GetValue (); | |
111 rx_Status.gsmLevel = ( UBYTE ) new_rx_value; | |
112 | |
113 calculated_level = (new_rx_value * rx_DCB.Steps) / 64; | |
114 | |
115 SYST_TRACE_P ((SYST, "RX_Indication(): rx=%u new, %u old", | |
116 calculated_level, rx_Status.actLevel)); | |
117 | |
118 if (calculated_level NEQ rx_Status.actLevel) | |
119 { | |
120 signal_params.SignalType = RX_SIGTYPE_RXLEVEL; | |
121 #if defined (NEW_FRAME) | |
122 signal_params.UserData = (void*)&rx_Status; | |
123 #else | |
124 signal_params.SignalValue = 0; | |
125 signal_params.UserData = (ULONG)&rx_Status; | |
126 #endif /* NEW_FRAME */ | |
127 rx_Status.actLevel = calculated_level; | |
128 rx_Status.rxQuality = RX_GetRxQual (); | |
129 | |
130 #if !defined (WIN32) | |
131 /* | |
132 * suppress for windows to avoid disturb of regression tests | |
133 */ | |
134 (*rx_signal_callback)(&signal_params); | |
135 #endif /* !WIN32 */ | |
136 } | |
137 } | |
138 } | |
139 | |
140 /* | |
141 +--------------------------------------------------------------------+ | |
142 | PROJECT : GSM-PS (6103) MODULE : DRV_RX | | |
143 | STATE : code ROUTINE : rx_Init | | |
144 +--------------------------------------------------------------------+ | |
145 | |
146 PURPOSE : The function initializes the driverīs internal data. | |
147 The function returns DRV_OK in case of a successful | |
148 completition. The function returns DRV_INITIALIZED if | |
149 the driver has already been initialized and is ready to | |
150 be used or is already in use. In case of an initialization | |
151 failure, which means the that the driver cannot be used, | |
152 the function returns DRV_INITFAILURE. | |
153 | |
154 */ | |
155 | |
156 GLOBAL UBYTE rx_Init (drv_SignalCB_Type in_SignalCBPtr) | |
157 { | |
158 rx_signal_callback = in_SignalCBPtr; /* store call-back function */ | |
159 rx_DCB.Steps = 4; /* 4 Steps */ | |
160 rx_Status.actLevel = 255; | |
161 rx_Status.gsmLevel = 255; | |
162 | |
163 #if defined (RX_INDICATION_WITHOUT_TIMER) | |
164 if (in_SignalCBPtr) | |
165 { | |
166 SYST_TRACE_P ((SYST, "rx_Init(): enable RX_Indication (%p)", in_SignalCBPtr)); | |
167 RX_Enable (RX_Indication); | |
168 } | |
169 else | |
170 { | |
171 SYST_TRACE ("rx_Init() without in_SignalCBPtr"); | |
172 } | |
173 #else /* RX_INDICATION_WITHOUT_TIMER */ | |
174 #if !defined (NEW_FRAME) | |
175 rx_handle = vsi_t_open (VSI_CALLER "RX"); | |
176 | |
177 if (rx_handle < VSI_OK) | |
178 return DRV_INITFAILURE; | |
179 | |
180 vsi_t_start (VSI_CALLER rx_handle, T_RX_VALUE); | |
181 #else /* !NEW_FRAME */ | |
182 vsi_t_start (VSI_CALLER CST_RXTIMER, T_RX_VALUE); | |
183 #endif /* !NEW_FRAME */ | |
184 #endif /* RX_INDICATION_WITHOUT_TIMER */ | |
185 return DRV_OK; | |
186 } | |
187 | |
188 /* | |
189 +--------------------------------------------------------------------+ | |
190 | PROJECT : GSM-PS (6103) MODULE : DRV_RX | | |
191 | STATE : code ROUTINE : rx_Exit | | |
192 +--------------------------------------------------------------------+ | |
193 | |
194 PURPOSE : The function is used to indicate RX that the driver | |
195 and its functionality isnīt needed anymore. | |
196 | |
197 */ | |
198 | |
199 GLOBAL void rx_Exit (void) | |
200 { | |
201 rx_signal_callback = NULL; | |
202 | |
203 #if !defined (RX_INDICATION_WITHOUT_TIMER) | |
204 #if !defined (NEW_FRAME) | |
205 vsi_t_close (VSI_CALLER rx_handle); | |
206 rx_handle = VSI_ERROR; | |
207 #else /* !NEW_FRAME */ | |
208 vsi_t_stop (VSI_CALLER CST_RXTIME); | |
209 #endif /* !NEW_FRAME */ | |
210 #endif /* RX_INDICATION_WITHOUT_TIMER */ | |
211 } | |
212 | |
213 /* | |
214 +--------------------------------------------------------------------+ | |
215 | PROJECT : GSM-PS (6103) MODULE : DRV_RX | | |
216 | STATE : code ROUTINE : rx_SetConfig | | |
217 +--------------------------------------------------------------------+ | |
218 | |
219 PURPOSE : This function is used to configure the driver. | |
220 If any value of this configuration is out of range or | |
221 invalid in combination with any other value of the | |
222 configuration, the function returns DRV_INVALID_PARAMS. | |
223 Call the rx_GetConfig() function to retrieve the drivers | |
224 configuration. | |
225 | |
226 */ | |
227 | |
228 GLOBAL UBYTE rx_SetConfig (rx_DCB_Type * in_DCBPtr) | |
229 { | |
230 memcpy (&rx_DCB, in_DCBPtr, sizeof (rx_DCB_Type)); | |
231 rx_Status.actLevel = 255; | |
232 rx_Status.gsmLevel = 255; | |
233 | |
234 return DRV_OK; | |
235 } | |
236 | |
237 /* | |
238 +--------------------------------------------------------------------+ | |
239 | PROJECT : GSM-PS (6103) MODULE : DRV_RX | | |
240 | STATE : code ROUTINE : rx_GetConfig | | |
241 +--------------------------------------------------------------------+ | |
242 | |
243 PURPOSE : The function is used to retrieve the configuration of | |
244 the driver. The configuration is returned in the driver | |
245 control block to which the pointer out_DCBPtr points. | |
246 If the driver is not configured, the function returns | |
247 DRV_NOTCONFIGURED. | |
248 Call the rx_SetConfig() function to configure the driver. | |
249 | |
250 */ | |
251 | |
252 GLOBAL UBYTE rx_GetConfig (rx_DCB_Type * out_DCBPtr) | |
253 { | |
254 return DRV_OK; | |
255 } | |
256 | |
257 /* | |
258 +--------------------------------------------------------------------+ | |
259 | PROJECT : GSM-PS (6103) MODULE : DRV_RX | | |
260 | STATE : code ROUTINE : rx_GetStatus | | |
261 +--------------------------------------------------------------------+ | |
262 | |
263 PURPOSE : This function is used to retrieve the status of the driver. | |
264 In case of a successful completion the driver returns | |
265 DRV_OK and the current status of the driver in the buffer | |
266 out_StatusPtr points to. | |
267 In case the driver is not configured yet, it returns | |
268 DRV_NOTCONFIGURED. In this case the contents of the | |
269 buffer out_StatusPtr is invalid. | |
270 In case out_StatusPtr equals NULL the driver returns | |
271 DRV_INVALID_PARAMS. | |
272 | |
273 */ | |
274 | |
275 GLOBAL UBYTE rx_GetStatus (rx_Status_Type * out_StatusPtr) | |
276 { | |
277 USHORT new_rx_value = RX_GetValue (); | |
278 | |
279 rx_Status.gsmLevel = ( UBYTE ) new_rx_value; | |
280 rx_Status.actLevel = (new_rx_value * rx_DCB.Steps) / 64; | |
281 rx_Status.rxQuality = RX_GetRxQual (); | |
282 | |
283 out_StatusPtr->actLevel = rx_Status.actLevel; | |
284 out_StatusPtr->gsmLevel = rx_Status.gsmLevel; | |
285 out_StatusPtr->rxQuality = rx_Status.rxQuality; | |
286 | |
287 return DRV_OK; | |
288 } | |
289 | |
290 /* | |
291 +--------------------------------------------------------------------+ | |
292 | PROJECT : GSM-PS (6103) MODULE : DRV_RX | | |
293 | STATE : code ROUTINE : rx_timeout | | |
294 +--------------------------------------------------------------------+ | |
295 | |
296 PURPOSE : This function calculates a new rxlevel after timeout. | |
297 If a change has occured, the new level is forwarded to | |
298 MMI using the callback function. The timer is started | |
299 again. | |
300 | |
301 */ | |
302 #if defined (NEW_FRAME) | |
303 GLOBAL void rx_timeout (USHORT index) | |
304 #else | |
305 GLOBAL void rx_timeout (T_VSI_THANDLE handle) | |
306 #endif | |
307 { | |
308 #if !defined (RX_INDICATION_WITHOUT_TIMER) | |
309 #if defined (NEW_FRAME) | |
310 if (index EQ CST_RXTIMER) | |
311 #else | |
312 if (handle EQ rx_handle) | |
313 #endif | |
314 { | |
315 /* | |
316 * only if it is the fieldstrength timer | |
317 */ | |
318 SYST_TRACE ("rx_timeout()"); | |
319 | |
320 RX_Indication (); | |
321 | |
322 #if defined (NEW_FRAME) | |
323 vsi_t_start (VSI_CALLER CST_RXTIMER, T_RX_VALUE); | |
324 #else | |
325 vsi_t_start (VSI_CALLER rx_handle, T_RX_VALUE); | |
326 #endif | |
327 } | |
328 #endif /* !RX_INDICATION_WITHOUT_TIMER */ | |
329 } | |
330 |