comparison gsm-fw/g23m-aci/uart/uart_rxs.c @ 775:eedbf248bac0

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