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