comparison g23m-aci/uart/uart_rxs.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 :
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 modul is part of the entity UART and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (RX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef UART_RXS_C
24 #define UART_RXS_C
25 #endif /* !UART_RXS_C */
26
27 #include "config.h"
28 #include "fixedconf.h"
29 #include "condat-features.h"
30
31 #define ENTITY_UART
32
33 #ifndef FF_MULTI_PORT
34 /*==== INCLUDES =============================================================*/
35
36 #ifdef WIN32
37 #include "nucleus.h"
38 #endif /* WIN32 */
39 #include "typedefs.h" /* to get Condat data types */
40 #include "vsi.h" /* to get a lot of macros */
41 #include "macdef.h" /* to get a lot of macros */
42 #include "custom.h"
43 #include "gsm.h" /* to get a lot of macros */
44 #include "cnf_uart.h" /* to get cnf-definitions */
45 #include "mon_uart.h" /* to get mon-definitions */
46 #include "prim.h" /* to get the definitions of used SAP and directions */
47 #ifdef DTILIB
48 #include "dti.h" /* to get dti lib */
49 #endif /* DTILIB */
50 #include "pei.h" /* to get PEI interface */
51 #ifdef _TARGET_
52 #include "../../serial/serialswitch.h"
53 #include "../../serial/traceswitch.h"
54 #else /* _TARGET_ */
55 #include "serial_dat.h" /* to get definitions of serial driver */
56 #endif /* _TARGET_ */
57 #include "uart.h" /* to get the global entity definitions */
58
59 #include "uart_rxf.h" /* to get rx functions */
60
61 #include "uart_kers.h" /* to get ker signals */
62 #include "uart_dtxs.h" /* to get dtx signals */
63
64 #ifdef _SIMULATION_
65 #include "uart_rxp.h" /* to get rx_readdata */
66 #endif /* _SIMULATION_ */
67 /*==== CONST ================================================================*/
68
69 /*==== LOCAL VARS ===========================================================*/
70
71 /*==== PRIVATE FUNCTIONS ====================================================*/
72
73 /*==== PUBLIC FUNCTIONS =====================================================*/
74
75
76
77 /*
78 +------------------------------------------------------------------------------
79 | Function : sig_ker_rx_dead_mode_req
80 +------------------------------------------------------------------------------
81 | Description : Handles the internal signal SIG_KER_RX_DEAD_MODE_REQ. If this
82 | signal is called the service expectes an disabled UART to work
83 | correctly.
84 |
85 | Parameters : no parameters
86 |
87 +------------------------------------------------------------------------------
88 */
89 GLOBAL void sig_ker_rx_dead_mode_req ()
90 {
91 TRACE_ISIG( "sig_ker_rx_dead_mode_req" );
92
93 uart_data->rx.read_permission = FALSE;
94 uart_data->rx.prev_lines = 0;
95 uart_data->rx.dlc_instance = UART_EMPTY_INSTANCE;
96 uart_data->rx.escape = FALSE;
97 uart_data->rx.receive_state = UART_RX_NOT_RECEIVING;
98 uart_data->rx.analyze_state = UART_RX_ERROR;
99 uart_data->rx.fcs = UART_INITFCS;
100 uart_data->rx.address_field = 0;
101 uart_data->rx.stored_len = 0;
102
103 switch( GET_STATE( UART_SERVICE_RX ) )
104 {
105 case RX_READY:
106 case RX_MUX:
107 SET_STATE( UART_SERVICE_RX, RX_DEAD );
108 break;
109
110 case RX_DEAD:
111 break;
112 default:
113 TRACE_ERROR( "SIG_KER_RX_DEAD_MODE_REQ unexpected" );
114 break;
115 }
116 } /* sig_ker_rx_dead_mode_req() */
117
118
119
120 /*
121 +------------------------------------------------------------------------------
122 | Function : sig_ker_rx_ready_mode_req
123 +------------------------------------------------------------------------------
124 | Description : Handles the internal signal SIG_KER_RX_READY_MODE_REQ.
125 |
126 | Parameters : no parameters
127 |
128 +------------------------------------------------------------------------------
129 */
130 GLOBAL void sig_ker_rx_ready_mode_req ()
131 {
132 TRACE_ISIG( "sig_ker_rx_ready_mode_req" );
133
134 switch( GET_STATE( UART_SERVICE_RX ) )
135 {
136 case RX_DEAD:
137 SET_STATE( UART_SERVICE_RX, RX_READY );
138 uart_data->rx.read_permission = FALSE;
139 uart_data->rx.dlc_instance = UART_EMPTY_INSTANCE;
140 uart_data->rx.receive_state = UART_RX_NOT_RECEIVING;
141 uart_data->rx.analyze_state = UART_RX_ERROR;
142 break;
143
144 case RX_MUX:
145 SET_STATE( UART_SERVICE_RX, RX_READY );
146 if(uart_data->rx.read_permission EQ FALSE)
147 {
148 uart_data->rx.dlc_instance = UART_EMPTY_INSTANCE;
149 uart_data->rx.analyze_state = UART_RX_ERROR;
150 }
151 break;
152
153 case RX_READY:
154 break;
155
156 default:
157 TRACE_ERROR( "SIG_KER_RX_READY_MODE_REQ unexpected" );
158 break;
159 }
160 } /* sig_ker_rx_ready_mode_req() */
161
162
163
164 /*
165 +------------------------------------------------------------------------------
166 | Function : sig_ker_rx_mux_mode_req
167 +------------------------------------------------------------------------------
168 | Description : Handles the internal signal SIG_KER_RX_MUX_MODE_REQ.
169 |
170 | Parameters : no parameters
171 |
172 +------------------------------------------------------------------------------
173 */
174 GLOBAL void sig_ker_rx_mux_mode_req ()
175 {
176 TRACE_ISIG( "sig_ker_rx_mux_mode_req" );
177
178 switch( GET_STATE( UART_SERVICE_RX ) )
179 {
180 case RX_DEAD:
181 SET_STATE( UART_SERVICE_RX, RX_MUX );
182 uart_data->rx.read_permission = FALSE;
183 uart_data->rx.dlc_instance = UART_CONTROL_INSTANCE;
184 uart_data->rx.receive_state = UART_RX_NOT_RECEIVING;
185 uart_data->rx.analyze_state = UART_RX_ERROR;
186 break;
187
188 case RX_READY:
189 SET_STATE( UART_SERVICE_RX, RX_MUX );
190 if(uart_data->rx.read_permission EQ FALSE)
191 {
192 uart_data->rx.dlc_instance = UART_CONTROL_INSTANCE;
193 uart_data->rx.analyze_state = UART_RX_ERROR;
194 }
195 break;
196
197 case RX_MUX:
198 break;
199
200 default:
201 TRACE_ERROR( "SIG_KER_RX_MUX_MODE_REQ unexpected" );
202 break;
203 }
204 } /* sig_ker_rx_mux_mode_req() */
205
206
207
208 /*
209 +------------------------------------------------------------------------------
210 | Function : sig_dtx_rx_ready_to_receive_req
211 +------------------------------------------------------------------------------
212 | Description : Handles the internal signal SIG_DTX_RX_READY_TO_RECEIVE_REQ.
213 |
214 | Parameters : dlc_instance - dlc instance wich belongs to calling DTX
215 | receive_data - descriptor to write
216 | receive_pos - position to start write
217 | receive_size - size of descriptor to write
218 |
219 +------------------------------------------------------------------------------
220 */
221 GLOBAL void sig_dtx_rx_ready_to_receive_req (UBYTE dlc_instance,
222 T_desc2* receive_data,
223 USHORT receive_pos,
224 USHORT receive_size)
225 {
226 T_DLC* dlc;
227
228 TRACE_ISIG( "sig_dtx_rx_ready_to_receive_req" );
229
230 dlc = &uart_data->dlc_table[dlc_instance];
231 dlc->receive_pos = receive_pos;
232 dlc->receive_size = receive_size;
233 dlc->receive_data = receive_data;
234
235 /*
236 * start receiving
237 */
238 if(uart_data->rx.receive_state EQ UART_RX_RECEIVING)
239 {
240 if(uart_data->rx.read_permission EQ FALSE)
241 dlc->receive_process = UART_RX_PROCESS_READY;
242 }
243 else
244 {
245 dlc->receive_process = UART_RX_PROCESS_READY;
246 uart_data->rx.receive_state = UART_RX_RECEIVING;
247 switch( GET_STATE( UART_SERVICE_RX ) )
248 {
249 case RX_READY:
250 uart_data->rx.dlc_instance = UART_EMPTY_INSTANCE;
251 uart_data->rx.analyze_state = UART_RX_ERROR;
252 break;
253
254 case RX_MUX:
255 if(uart_data->rx.dlc_instance EQ UART_EMPTY_INSTANCE)
256 {
257 uart_data->rx.dlc_instance = UART_CONTROL_INSTANCE;
258 uart_data->rx.analyze_state = UART_RX_ERROR;
259 }
260 break;
261
262 default:
263 TRACE_ERROR( "SIG_DTX_RX_READY_TO_RECEIVE_REQ unexpected" );
264 break;
265 }
266 #ifdef _SIMULATION_
267 if(rx_inpavail(uart_data->device) > 0)
268 #else /* _SIMULATION_ */
269 if(UF_InpAvail (uart_data->device) > 0)
270 #endif /* _SIMULATION_ */
271 {
272 /*
273 * inform channel about reading
274 * because previous receive_state was NOT_READING
275 * there is only one channel which must be informed
276 */
277 uart_data->rx.read_permission = TRUE;
278 uart_data->dtx = dlc->dtx;
279 sig_rx_dtx_receiving_ind();
280 }
281 else
282 uart_data->rx.read_permission = FALSE;
283
284 if(uart_data EQ (&(uart_data_base[0])))
285 {
286 TRACE_EVENT("UF_ReadData()");
287 #ifdef _SIMULATION_
288 rx_readdata(0);
289 #else /* _SIMULATION_ */
290 UF_ReadData (uart_data->device, sm_suspend, rx_readOutFunc_0);
291 #endif /* else _SIMULATION_ */
292 }
293 #ifdef FF_TWO_UART_PORTS
294 else if(uart_data EQ (&(uart_data_base[1])))
295 {
296 TRACE_EVENT("UF_ReadData()");
297 #ifdef _SIMULATION_
298 rx_readdata(1);
299 #else /* _SIMULATION_ */
300 UF_ReadData (uart_data->device, sm_suspend, rx_readOutFunc_1);
301 #endif /* else _SIMULATION_ */
302 }
303 #endif /* FF_TWO_UART_PORTS */
304 else
305 {
306 TRACE_ERROR("wrong value of uart_data");
307 }
308 }
309 } /* sig_dtx_rx_ready_to_receive_req() */
310
311
312
313 /*
314 +------------------------------------------------------------------------------
315 | Function : sig_ker_rx_ready_to_receive_req
316 +------------------------------------------------------------------------------
317 | Description : Handles the internal signal SIG_KER_RX_READY_TO_RECEIVE_REQ.
318 |
319 | Parameters : receive_data - descriptor to write
320 | receive_pos - position to start write
321 | receive_size - size of descriptor to write
322 |
323 +------------------------------------------------------------------------------
324 */
325 GLOBAL void sig_ker_rx_ready_to_receive_req (T_desc2* receive_data,
326 USHORT receive_pos,
327 USHORT receive_size)
328 {
329 T_DLC* dlc;
330
331 TRACE_ISIG( "sig_ker_rx_ready_to_receive_req" );
332
333 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
334 switch( GET_STATE( UART_SERVICE_RX ) )
335 {
336 case RX_MUX:
337 /*
338 * store data in control instance
339 */
340 dlc->receive_pos = receive_pos;
341 dlc->receive_size = receive_size;
342 dlc->receive_data = receive_data;
343 /*
344 * start receiving
345 */
346 if(uart_data->rx.receive_state EQ UART_RX_RECEIVING)
347 {
348 if(uart_data->rx.read_permission EQ FALSE)
349 dlc->receive_process = UART_RX_PROCESS_READY;
350 }
351 else
352 {
353 dlc->receive_process = UART_RX_PROCESS_READY;
354 /*
355 * start receiving
356 */
357 uart_data->rx.receive_state = UART_RX_RECEIVING;
358 if(uart_data->rx.dlc_instance EQ UART_EMPTY_INSTANCE)
359 {
360 uart_data->rx.dlc_instance = UART_CONTROL_INSTANCE;
361 uart_data->rx.analyze_state = UART_RX_ERROR;
362 }
363 #ifdef _SIMULATION_
364 if(rx_inpavail(uart_data->device) > 0)
365 #else /* _SIMULATION_ */
366 if(UF_InpAvail (uart_data->device) > 0)
367 #endif /* _SIMULATION_ */
368 {
369 /*
370 * inform channel about reading
371 */
372 uart_data->rx.read_permission = TRUE;
373 sig_rx_ker_receiving_ind();
374 }
375 else
376 uart_data->rx.read_permission = FALSE;
377
378 if(uart_data EQ (&(uart_data_base[0])))
379 {
380 TRACE_EVENT("UF_ReadData()");
381 #ifdef _SIMULATION_
382 rx_readdata(0);
383 #else /* _SIMULATION_ */
384 UF_ReadData (uart_data->device, sm_suspend, rx_readOutFunc_0);
385 #endif /* else _SIMULATION_ */
386 }
387 #ifdef FF_TWO_UART_PORTS
388 else if(uart_data EQ (&(uart_data_base[1])))
389 {
390 TRACE_EVENT("UF_ReadData()");
391 #ifdef _SIMULATION_
392 rx_readdata(1);
393 #else /* _SIMULATION_ */
394 UF_ReadData (uart_data->device, sm_suspend, rx_readOutFunc_1);
395 #endif /* else _SIMULATION_ */
396 }
397 #endif /* FF_TWO_UART_PORTS */
398 else
399 {
400 TRACE_ERROR("wrong value of uart_data");
401 }
402 }
403 break;
404
405 default:
406 TRACE_ERROR( "SIG_KER_RX_READY_TO_RECEIVE_REQ unexpected" );
407 break;
408 }
409 } /* sig_ker_rx_ready_to_receive_req() */
410
411
412
413 /*
414 +------------------------------------------------------------------------------
415 | Function : sig_dtx_rx_not_ready_to_receive_req
416 +------------------------------------------------------------------------------
417 | Description : Handles the internal signal
418 | SIG_DTX_RX_NOT_READY_TO_RECEIVE_REQ.
419 |
420 | Parameters : dlc_instance - dlc instance wich belongs to calling DTX
421 |
422 +------------------------------------------------------------------------------
423 */
424 GLOBAL void sig_dtx_rx_not_ready_to_receive_req (UBYTE dlc_instance)
425 {
426 T_DLC* dlc;
427
428 TRACE_ISIG( "sig_dtx_rx_not_ready_to_receive_req" );
429
430 dlc = &uart_data->dlc_table[dlc_instance];
431 switch( GET_STATE( UART_SERVICE_RX ) )
432 {
433 case RX_READY:
434 case RX_MUX:
435 dlc->receive_data = NULL;
436 dlc->receive_process = UART_RX_PROCESS_STOP;
437 break;
438
439 default:
440 TRACE_ERROR( "SIG_DTX_RX_NOT_READY_TO_RECEIVE_REQ unexpected" );
441 break;
442 }
443 } /* sig_dtx_rx_not_ready_to_receive_req() */
444
445
446
447 /*
448 +------------------------------------------------------------------------------
449 | Function : sig_ker_rx_not_ready_to_receive_req
450 +------------------------------------------------------------------------------
451 | Description : Handles the internal signal
452 | SIG_KER_RX_NOT_READY_TO_RECEIVE_REQ.
453 |
454 | Parameters : no parameters
455 |
456 +------------------------------------------------------------------------------
457 */
458 GLOBAL void sig_ker_rx_not_ready_to_receive_req ()
459 {
460 T_DLC* dlc;
461
462 TRACE_ISIG( "sig_ker_rx_not_ready_to_receive_req" );
463
464 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE];
465 switch( GET_STATE( UART_SERVICE_RX ) )
466 {
467 case RX_MUX:
468 dlc->receive_data = NULL;
469 dlc->receive_process = UART_RX_PROCESS_STOP;
470 break;
471
472 default:
473 TRACE_ERROR( "SIG_KER_RX_NOT_READY_TO_RECEIVE_REQ unexpected" );
474 break;
475 }
476 } /* sig_ker_rx_not_ready_to_receive_req() */
477
478
479
480 /*
481 +------------------------------------------------------------------------------
482 | Function : sig_ker_rx_restart_read_req
483 +------------------------------------------------------------------------------
484 | Description : Handles the internal signal SIG_KER_RX_RESTART_READ_REQ
485 |
486 | Parameters : no parameters
487 |
488 +------------------------------------------------------------------------------
489 */
490 GLOBAL void sig_ker_rx_restart_read_req ()
491 {
492 TRACE_ISIG( "sig_ker_rx_restart_read_req" );
493
494 switch( GET_STATE( UART_SERVICE_RX ) )
495 {
496 case RX_READY:
497 case RX_MUX:
498 if(uart_data->rx.receive_state EQ UART_RX_RECEIVING)
499 {
500 /*
501 * restart readOutFunc
502 */
503 if(uart_data EQ (&(uart_data_base[0])))
504 {
505 TRACE_EVENT("UF_ReadData()");
506 #ifdef _SIMULATION_
507 rx_readdata(0);
508 #else /* _SIMULATION_ */
509 UF_ReadData (uart_data->device, sm_suspend, rx_readOutFunc_0);
510 #endif /* else _SIMULATION_ */
511 }
512 #ifdef FF_TWO_UART_PORTS
513 else if(uart_data EQ (&(uart_data_base[1])))
514 {
515 TRACE_EVENT("UF_ReadData()");
516 #ifdef _SIMULATION_
517 rx_readdata(1);
518 #else /* _SIMULATION_ */
519 UF_ReadData (uart_data->device, sm_suspend, rx_readOutFunc_1);
520 #endif /* else _SIMULATION_ */
521 }
522 #endif /* FF_TWO_UART_PORTS */
523 else
524 {
525 TRACE_ERROR("wrong value of uart_data");
526 }
527 }
528 break;
529
530 default:
531 TRACE_ERROR( "SIG_KER_RX_RESTART_READ_REQ unexpected" );
532 break;
533 }
534 } /* sig_ker_rx_restart_read_req() */
535 #endif /* !FF_MULTI_PORT */