FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/uart/uart_rxf.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 | procedures and functions as described in the | |
19 | SDL-documentation (RX-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef UART_RXF_C | |
24 #define UART_RXF_C | |
25 #endif /* !UART_RXF_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 #ifdef _SIMULATION_ | |
60 #include <stdio.h> /* to get sprintf */ | |
61 #endif /* _SIMULATION_ */ | |
62 #include <string.h> /* JK, delete warnings: to get memcpy */ | |
63 | |
64 /*==== CONST ================================================================*/ | |
65 | |
66 /*==== LOCAL VARS ===========================================================*/ | |
67 | |
68 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
69 | |
70 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
71 | |
72 | |
73 | |
74 /* | |
75 +------------------------------------------------------------------------------ | |
76 | Function : rx_proc_input | |
77 +------------------------------------------------------------------------------ | |
78 | Description : The function rx_proc_input() is the actual callback function | |
79 | to read data from the receive buffer. | |
80 | | |
81 | Parameters : uart_device - database for the affected UART device | |
82 | | |
83 +------------------------------------------------------------------------------ | |
84 */ | |
85 LOCAL void rx_proc_input (T_UART_DATA* uart_device) | |
86 { | |
87 USHORT i, len; | |
88 T_DLC *dlc; /* used Data Link Connection */ | |
89 UBYTE *source; /* Data source pointer */ | |
90 UBYTE *destination; /* Data destination pointer */ | |
91 UBYTE temp_field; /* multi purpose value */ | |
92 BOOL channels_complete; /* indicator of complete reception */ | |
93 SHORT error_code; /* error code returned from a function */ | |
94 | |
95 TRACE_FUNCTION( "rx_proc_input" ); | |
96 | |
97 /* | |
98 * read data only if we have read permission | |
99 */ | |
100 if(uart_device->rx.read_permission) | |
101 { | |
102 if(uart_device->rx.dlc_instance EQ UART_EMPTY_INSTANCE) | |
103 dlc = &uart_device->dlc_table[UART_CONTROL_INSTANCE]; | |
104 else | |
105 dlc = &uart_device->dlc_table[uart_device->rx.dlc_instance]; | |
106 destination = &dlc->receive_data->buffer[dlc->receive_pos]; | |
107 #ifdef _SIMULATION_ | |
108 { | |
109 char buf[80]; | |
110 sprintf(buf,"uart_device->rx.dlc_instance: %d", uart_device->rx.dlc_instance); | |
111 TRACE_EVENT(buf); | |
112 } | |
113 #endif /* _SIMULATION_ */ | |
114 if(uart_device->rx.dlc_instance EQ UART_EMPTY_INSTANCE) | |
115 { | |
116 /* | |
117 * Raw data | |
118 */ | |
119 /* | |
120 * Is a data descriptor allocated and | |
121 * is the channel ready to receive | |
122 */ | |
123 if((dlc->receive_process EQ UART_RX_PROCESS_READY) && | |
124 (dlc->receive_data)) | |
125 { | |
126 for (i=0; i < uart_device->rx.nsource; i++) | |
127 { | |
128 /* | |
129 * are there still data in the ring buffer segment and | |
130 * are there still space in the data descriptor | |
131 */ | |
132 if ((uart_device->rx.size[i] > 0) && | |
133 (dlc->receive_size > dlc->receive_pos)) | |
134 { | |
135 len = dlc->receive_size - dlc->receive_pos; | |
136 if (len > uart_device->rx.size[i]) | |
137 len = uart_device->rx.size[i]; | |
138 | |
139 memcpy(&dlc->receive_data->buffer[dlc->receive_pos], | |
140 uart_device->rx.source[i], | |
141 len); | |
142 | |
143 uart_device->rx.size[i] -= len; | |
144 dlc->receive_pos += len; | |
145 dlc->receive_data->len = dlc->receive_pos; | |
146 } | |
147 } | |
148 dlc->receive_process = UART_RX_PROCESS_COMPLETE; | |
149 } | |
150 } | |
151 else | |
152 { | |
153 channels_complete = FALSE; | |
154 /* | |
155 * for each fragment | |
156 */ | |
157 for (i=0; i < uart_device->rx.nsource; i++) | |
158 { | |
159 /* | |
160 * while there is still data in buffer and | |
161 * not yet all channels are processed | |
162 */ | |
163 source = uart_device->rx.source[i]; | |
164 while((uart_device->rx.size[i] > 0) && (channels_complete NEQ TRUE)) | |
165 { | |
166 /* | |
167 * detect HDLC flag | |
168 */ | |
169 if(*source EQ UART_HDLC_FLAG) | |
170 { | |
171 switch(uart_device->rx.analyze_state) | |
172 { | |
173 case UART_RX_ERROR: | |
174 /* | |
175 * begin of frame detected | |
176 */ | |
177 uart_device->rx.analyze_state = UART_RX_BEGIN; | |
178 /* fall through */ | |
179 case UART_RX_BEGIN: | |
180 /* | |
181 * initialize new packet | |
182 */ | |
183 uart_device->rx.stored_len = 0; | |
184 uart_device->rx.address_field = 0; | |
185 uart_device->rx.fcs = UART_INITFCS; | |
186 uart_device->rx.escape = FALSE; | |
187 uart_device->rx.analyze_state = UART_RX_ADDRESS; | |
188 break; | |
189 | |
190 default: | |
191 /* | |
192 * detect HDLC flag | |
193 */ | |
194 if(uart_device->rx.stored_len > 0) | |
195 { | |
196 /* | |
197 * determine whether FCS already calculated | |
198 */ | |
199 if(uart_device->rx.analyze_state NEQ UART_RX_FCS) | |
200 { | |
201 /* | |
202 * UART_RX_INFORMATION_... | |
203 */ | |
204 destination--; | |
205 #ifdef _SIMULATION_ | |
206 uart_device->rx.fcs = *destination; | |
207 #else /* _SIMULATION_ */ | |
208 uart_device->rx.fcs = uart_device-> | |
209 fcstab[uart_device->rx.fcs ^ *destination]; | |
210 #endif /* _SIMULATION_ */ | |
211 /* | |
212 * remove FCS from data stream | |
213 */ | |
214 dlc->receive_pos--; | |
215 uart_data->rx.stored_len--; | |
216 } | |
217 if(uart_device->rx.fcs EQ UART_GOODFCS) | |
218 { | |
219 /* | |
220 * no error occured, frame complete | |
221 */ | |
222 dlc->receive_data->len = dlc->receive_pos; | |
223 dlc->receive_process = UART_RX_PROCESS_COMPLETE; | |
224 uart_device->rx.analyze_state = UART_RX_END; | |
225 break; | |
226 } | |
227 } | |
228 /* | |
229 * remove receiced frame because of an error | |
230 */ | |
231 switch(uart_device->rx.analyze_state) | |
232 { | |
233 case UART_RX_INFORMATION: | |
234 case UART_RX_FCS: | |
235 if(uart_data->rx.dlc_instance EQ UART_CONTROL_INSTANCE) | |
236 dlc->receive_pos-= 2; | |
237 dlc->receive_pos -= uart_data->rx.stored_len; | |
238 dlc->receive_process = UART_RX_PROCESS_READY; | |
239 break; | |
240 default: | |
241 /* | |
242 * Other states are not handeled here | |
243 */ | |
244 break; | |
245 } | |
246 uart_device->rx.analyze_state = UART_RX_END; | |
247 break; | |
248 } | |
249 } | |
250 else if((*source EQ UART_HDLC_ESCAPE) && | |
251 (uart_device->rx.escape NEQ TRUE)) | |
252 { | |
253 /* | |
254 * detect Control Escape octet | |
255 */ | |
256 uart_device->rx.escape = TRUE; | |
257 } | |
258 else | |
259 { | |
260 /* | |
261 * bit 5 complement for the octet followed by Control Escape | |
262 */ | |
263 if(uart_device->rx.escape EQ TRUE) | |
264 { | |
265 *source ^= 0x20; | |
266 uart_device->rx.escape = FALSE; | |
267 } | |
268 /* | |
269 * store the packet and determine the protocol | |
270 */ | |
271 switch(uart_device->rx.analyze_state) | |
272 { | |
273 case UART_RX_ERROR: | |
274 /* | |
275 * wait for next HDLC flag | |
276 */ | |
277 break; | |
278 | |
279 case UART_RX_ADDRESS: | |
280 if((*source & UART_EA) EQ UART_EA) | |
281 { | |
282 /* | |
283 * FCS calculation | |
284 */ | |
285 #ifdef _SIMULATION_ | |
286 uart_device->rx.fcs = *source; | |
287 #else /* _SIMULATION_ */ | |
288 uart_device->rx.fcs = uart_device-> | |
289 fcstab[uart_device->rx.fcs ^ *source]; | |
290 #endif /* _SIMULATION_ */ | |
291 /* | |
292 * store Address field | |
293 */ | |
294 uart_device->rx.address_field = *source; | |
295 uart_device->rx.analyze_state = UART_RX_CONTROL; | |
296 } | |
297 else | |
298 { | |
299 /* | |
300 * invalid frame detected | |
301 */ | |
302 uart_device->rx.analyze_state = UART_RX_ERROR; | |
303 } | |
304 break; | |
305 | |
306 case UART_RX_CONTROL: | |
307 switch(*source) | |
308 { | |
309 case UART_UIH_DATA_FRAME: | |
310 /* | |
311 * Data frame detected | |
312 */ | |
313 temp_field = uart_device->rx.address_field >> UART_DLCI_POS; | |
314 /* | |
315 * if it is an existing channel, but not control channel | |
316 */ | |
317 if((temp_field NEQ UART_DLCI_CONTROL) && | |
318 (uart_device->dlc_instance[temp_field] NEQ | |
319 UART_EMPTY_INSTANCE)) | |
320 { | |
321 uart_device->rx.dlc_instance = | |
322 uart_device->dlc_instance[temp_field]; | |
323 dlc = &uart_device->dlc_table[uart_device->rx.dlc_instance]; | |
324 #ifdef _SIMULATION_ | |
325 TRACE_EVENT_P2("Addressfield found DLCI: 0x%02X \ | |
326 (dlc_instance 0x%02X)", | |
327 temp_field, uart_device->rx.dlc_instance); | |
328 #endif /* _SIMULATION_ */ | |
329 if(dlc->receive_process EQ UART_RX_PROCESS_READY) | |
330 { | |
331 /* | |
332 * reception Data channel found | |
333 * FCS calculation | |
334 */ | |
335 #ifdef _SIMULATION_ | |
336 uart_device->rx.fcs = *source; | |
337 #else /* _SIMULATION_ */ | |
338 uart_device->rx.fcs = uart_device-> | |
339 fcstab[uart_device-> | |
340 rx.fcs ^ *source]; | |
341 #endif /* _SIMULATION_ */ | |
342 destination = &dlc->receive_data-> | |
343 buffer[dlc->receive_pos]; | |
344 uart_device->rx.analyze_state = UART_RX_INFORMATION; | |
345 break; | |
346 } | |
347 else if(dlc->receive_process EQ UART_RX_PROCESS_COMPLETE) | |
348 { | |
349 channels_complete = TRUE; | |
350 break; | |
351 } | |
352 } | |
353 /* fall through */ | |
354 case UART_SABM_FRAME: | |
355 case UART_UA_FRAME: | |
356 case UART_DM_DATA_FRAME: | |
357 case UART_DM_CONTROL_FRAME: | |
358 case UART_DISC_FRAME: | |
359 case UART_UIH_CONTROL_FRAME: | |
360 /* | |
361 * Control frame detected | |
362 */ | |
363 dlc = &uart_device->dlc_table[UART_CONTROL_INSTANCE]; | |
364 uart_device->rx.dlc_instance = UART_CONTROL_INSTANCE; | |
365 if(dlc->receive_process EQ UART_RX_PROCESS_READY) | |
366 { | |
367 /* | |
368 * reception Control channel found | |
369 * FCS calculation | |
370 */ | |
371 #ifdef _SIMULATION_ | |
372 uart_device->rx.fcs = *source; | |
373 #else /* _SIMULATION_ */ | |
374 uart_device->rx.fcs = uart_device-> | |
375 fcstab[uart_device-> | |
376 rx.fcs ^ *source]; | |
377 #endif /* _SIMULATION_ */ | |
378 destination = &dlc->receive_data-> | |
379 buffer[dlc->receive_pos]; | |
380 uart_device->rx.analyze_state = UART_RX_INFORMATION; | |
381 /* | |
382 * store Address and Control field | |
383 */ | |
384 *destination = uart_device->rx.address_field; | |
385 destination++; | |
386 dlc->receive_pos++; | |
387 *destination = *source; | |
388 destination++; | |
389 dlc->receive_pos++; | |
390 } | |
391 else if(dlc->receive_process EQ UART_RX_PROCESS_COMPLETE) | |
392 { | |
393 channels_complete = TRUE; | |
394 } | |
395 else | |
396 /* | |
397 * discard frame, because it is unexpected | |
398 */ | |
399 uart_device->rx.analyze_state = UART_RX_ERROR; | |
400 break; | |
401 default: | |
402 /* | |
403 * invalid frame detected | |
404 */ | |
405 uart_device->rx.analyze_state = UART_RX_ERROR; | |
406 break; | |
407 } | |
408 break; | |
409 | |
410 case UART_RX_INFORMATION: | |
411 if(uart_device->rx.stored_len < uart_device->n1) | |
412 { | |
413 *destination = *source; | |
414 /* | |
415 * increase destination pointer | |
416 */ | |
417 destination++; | |
418 uart_device->rx.stored_len++; | |
419 dlc->receive_pos++; | |
420 } | |
421 else | |
422 { | |
423 /* | |
424 * FCS calculation | |
425 */ | |
426 #ifdef _SIMULATION_ | |
427 uart_device->rx.fcs = *source; | |
428 #else /* _SIMULATION_ */ | |
429 uart_device->rx.fcs = uart_device-> | |
430 fcstab[uart_device->rx.fcs ^ *source]; | |
431 #endif /* _SIMULATION_ */ | |
432 uart_device->rx.analyze_state = UART_RX_FCS; | |
433 } | |
434 break; | |
435 | |
436 case UART_RX_FCS: | |
437 /* | |
438 * remove receiced packet because its to long | |
439 */ | |
440 if(uart_data->rx.dlc_instance EQ UART_CONTROL_INSTANCE) | |
441 dlc->receive_pos-= 2; | |
442 dlc->receive_pos -= uart_data->rx.stored_len; | |
443 dlc->receive_process = UART_RX_PROCESS_READY; | |
444 uart_device->rx.analyze_state = UART_RX_ERROR; | |
445 break; | |
446 | |
447 default: | |
448 /* | |
449 * wrong analyze state | |
450 */ | |
451 uart_device->rx.analyze_state = UART_RX_ERROR; | |
452 break; | |
453 } | |
454 } | |
455 if(uart_device->rx.analyze_state EQ UART_RX_END) | |
456 uart_device->rx.analyze_state = UART_RX_BEGIN; | |
457 /* | |
458 * don't move source pointer | |
459 * if each possible channel was processed | |
460 * In this case analyze_state should be UART_RX_CONTROL. | |
461 * The Control field must be analyzed again in next call of | |
462 * this function. | |
463 */ | |
464 else if(channels_complete NEQ TRUE) | |
465 { | |
466 /* | |
467 * increase source pointer | |
468 */ | |
469 source++; | |
470 uart_device->rx.size[i]--; | |
471 } | |
472 } | |
473 } | |
474 } | |
475 } | |
476 | |
477 PSIGNAL(hCommUART, UART_DRIVER_RECEIVED_IND, uart_device); | |
478 | |
479 *uart_device->rx.reInstall = rm_noInstall; | |
480 | |
481 /* | |
482 * update pointer in UART driver | |
483 */ | |
484 if((error_code = UF_InpAvail (uart_device->device)) < 0 ) | |
485 { | |
486 TRACE_ERROR_P2("UF Driver: DataPointerUpdate failed, [%d], uart_rxf.c(%d)", | |
487 error_code, __LINE__); | |
488 } | |
489 } /* rx_proc_input() */ | |
490 | |
491 | |
492 | |
493 /* | |
494 +------------------------------------------------------------------------------ | |
495 | Function : rx_init | |
496 +------------------------------------------------------------------------------ | |
497 | Description : The function rx_init() initializes the RX service | |
498 | | |
499 | Parameters : no parameters | |
500 | | |
501 +------------------------------------------------------------------------------ | |
502 */ | |
503 GLOBAL void rx_init () | |
504 { | |
505 #ifndef _SIMULATION_ | |
506 #ifdef WIN32 | |
507 #ifndef _TARGET_ | |
508 char buf[80]; | |
509 #endif /* !_TARGET_ */ | |
510 STATUS sts; | |
511 #endif /* WIN32 */ | |
512 #endif /* !_SIMULATION_ */ | |
513 | |
514 TRACE_FUNCTION( "rx_init" ); | |
515 | |
516 #ifndef _SIMULATION_ | |
517 #ifdef WIN32 | |
518 sts = NU_Create_HISR (&uart_data->rx.rx_HISR, | |
519 "RX_HISR", | |
520 rx_proc_input, | |
521 2, | |
522 uart_data->HISR_stack, | |
523 HISR_STACK_SIZE); | |
524 #ifndef _TARGET_ | |
525 sprintf (buf, "NU_Create_HISR(RX) = %d", sts); | |
526 TRACE_EVENT (buf); | |
527 #endif /* _TARGET_ */ | |
528 #endif /* WIN32 */ | |
529 #endif /* !_SIMULATION_ */ | |
530 | |
531 uart_data->rx.read_permission = FALSE; | |
532 uart_data->rx.prev_lines = 0; | |
533 uart_data->rx.dlc_instance = UART_EMPTY_INSTANCE; | |
534 uart_data->rx.escape = FALSE; | |
535 uart_data->rx.analyze_state = UART_RX_ERROR; | |
536 uart_data->rx.receive_state = UART_RX_NOT_RECEIVING; | |
537 uart_data->rx.fcs = UART_INITFCS; | |
538 uart_data->rx.address_field = 0; | |
539 uart_data->rx.stored_len = 0; | |
540 | |
541 INIT_STATE( UART_SERVICE_RX , RX_DEAD ); | |
542 } /* rx_init() */ | |
543 | |
544 | |
545 | |
546 /* | |
547 +------------------------------------------------------------------------------ | |
548 | Function : rx_readOutFunc_0 | |
549 +------------------------------------------------------------------------------ | |
550 | Description : The function rx_readOutFunc_0() is the official callback | |
551 | function to read data from the receive buffer of UART device 0. | |
552 | It just copies the parameters and calls then the actual | |
553 | function. | |
554 | | |
555 | Parameters : cldFromIrq - called from interrupt | |
556 | reInstall - reinstallation mode | |
557 | nsource - number of source pointers | |
558 | source - array of source pointers | |
559 | size - array of sizes for every source pointer | |
560 | state - state of V.24 lines | |
561 | | |
562 +------------------------------------------------------------------------------ | |
563 */ | |
564 GLOBAL void rx_readOutFunc_0 (BOOL cldFromIrq, | |
565 T_reInstMode *reInstall, | |
566 UBYTE nsource, | |
567 UBYTE *source[], | |
568 USHORT *size, | |
569 ULONG state) | |
570 { | |
571 #ifndef _SIMULATION_ | |
572 #ifndef _TARGET_ | |
573 char buf[40]; | |
574 #endif /* !_TARGET_ */ | |
575 #endif /* !_SIMULATION_ */ | |
576 T_UART_DATA* uart_device; | |
577 | |
578 TRACE_FUNCTION( "rx_readOutFunc_0" ); | |
579 | |
580 /* | |
581 * select UART device 0 | |
582 */ | |
583 uart_device = &(uart_data_base[0]); | |
584 | |
585 /* | |
586 * store parameters | |
587 */ | |
588 uart_device->rx.cldFromIrq = cldFromIrq; | |
589 uart_device->rx.nsource = nsource; | |
590 uart_device->rx.source[0] = source[0]; | |
591 uart_device->rx.source[1] = source[1]; | |
592 uart_device->rx.size = size; | |
593 uart_device->rx.lines = state; | |
594 uart_device->rx.reInstall = reInstall; | |
595 | |
596 #ifndef _SIMULATION_ | |
597 #ifdef WIN32 | |
598 if (cldFromIrq) | |
599 { | |
600 STATUS sts; | |
601 /* | |
602 * interrupt context of the UART driver -> activate the HISR | |
603 */ | |
604 sts = NU_Activate_HISR (&uart_device->rx.rx_HISR); | |
605 #ifndef _TARGET_ | |
606 sprintf (buf, "NU_Activate_HISR(RX) = %d", sts); | |
607 TRACE_EVENT (buf); | |
608 #endif /* !_TARGET_ */ | |
609 } | |
610 else | |
611 #endif /* WIN32 */ | |
612 #endif /* !_SIMULATION_ */ | |
613 { | |
614 #ifdef _SIMULATION_ | |
615 UBYTE* trace_source[2]; | |
616 USHORT trace_size[2]; | |
617 USHORT i; | |
618 USHORT pos; | |
619 char buf[90]; | |
620 | |
621 trace_source[0] = source[0]; | |
622 trace_source[1] = source[1]; | |
623 | |
624 trace_size[0] = size[0]; | |
625 trace_size[1] = size[1]; | |
626 | |
627 /* | |
628 * trace input | |
629 */ | |
630 if((nsource) && | |
631 (uart_device->rx.read_permission)) | |
632 { | |
633 | |
634 TRACE_EVENT("==== INRAW"); | |
635 i = 0; | |
636 pos = 0; | |
637 while(pos < trace_size[0]) | |
638 { | |
639 i+= sprintf(&buf[i], "0x%02x, ", trace_source[0][pos]); | |
640 pos++; | |
641 if(i > 80) | |
642 { | |
643 TRACE_EVENT( buf ); | |
644 i = 0; | |
645 } | |
646 else if(pos >= trace_size[0]) | |
647 { | |
648 TRACE_EVENT( buf ); | |
649 } | |
650 } | |
651 if(nsource > 1) | |
652 { | |
653 i = 0; | |
654 pos = 0; | |
655 while(pos < trace_size[1]) | |
656 { | |
657 i+= sprintf(&buf[i], "0x%02x, ", trace_source[1][pos]); | |
658 pos++; | |
659 if(i > 80) | |
660 { | |
661 TRACE_EVENT( buf ); | |
662 i = 0; | |
663 } | |
664 else if(pos >= trace_size[1]) | |
665 { | |
666 TRACE_EVENT( buf ); | |
667 } | |
668 } | |
669 } | |
670 } | |
671 #endif /* _SIMULATION_ */ | |
672 | |
673 /* | |
674 * normal callback from UF_ReadData | |
675 */ | |
676 rx_proc_input(uart_device); | |
677 } | |
678 | |
679 } /* rx_readOutFunc_0() */ | |
680 | |
681 | |
682 | |
683 #ifdef FF_TWO_UART_PORTS | |
684 /* | |
685 +------------------------------------------------------------------------------ | |
686 | Function : rx_readOutFunc_1 | |
687 +------------------------------------------------------------------------------ | |
688 | Description : The function rx_readOutFunc_1() is the official callback | |
689 | function to read data from the receive buffer of UART device 1. | |
690 | It just copies the parameters and calls then the actual | |
691 | function. | |
692 | | |
693 | Parameters : cldFromIrq - called from interrupt | |
694 | reInstall - reinstallation mode | |
695 | nsource - number of source pointers | |
696 | source - array of source pointers | |
697 | size - array of sizes for every source pointer | |
698 | state - state of V.24 lines | |
699 | | |
700 +------------------------------------------------------------------------------ | |
701 */ | |
702 GLOBAL void rx_readOutFunc_1 (BOOL cldFromIrq, | |
703 T_reInstMode *reInstall, | |
704 UBYTE nsource, | |
705 UBYTE *source[], | |
706 USHORT *size, | |
707 ULONG state) | |
708 { | |
709 #ifndef _SIMULATION_ | |
710 #ifndef _TARGET_ | |
711 char buf[40]; | |
712 #endif /* !_TARGET_ */ | |
713 #endif /* !_SIMULATION_ */ | |
714 T_UART_DATA* uart_device; | |
715 | |
716 TRACE_FUNCTION( "rx_readOutFunc_1" ); | |
717 | |
718 /* | |
719 * select UART device 1 | |
720 */ | |
721 uart_device = &(uart_data_base[1]); | |
722 | |
723 /* | |
724 * store parameters | |
725 */ | |
726 uart_device->rx.cldFromIrq = cldFromIrq; | |
727 uart_device->rx.nsource = nsource; | |
728 uart_device->rx.source[0] = source[0]; | |
729 uart_device->rx.source[1] = source[1]; | |
730 uart_device->rx.size = size; | |
731 uart_device->rx.lines = state; | |
732 uart_device->rx.reInstall = reInstall; | |
733 | |
734 #ifndef _SIMULATION_ | |
735 #ifdef WIN32 | |
736 if (cldFromIrq) | |
737 { | |
738 STATUS sts; | |
739 /* | |
740 * interrupt context of the UART driver -> activate the HISR | |
741 */ | |
742 sts = NU_Activate_HISR (&uart_device->rx.rx_HISR); | |
743 #ifndef _TARGET_ | |
744 sprintf (buf, "NU_Activate_HISR(RX) = %d", sts); | |
745 TRACE_EVENT (buf); | |
746 #endif /* !_TARGET_ */ | |
747 } | |
748 else | |
749 #endif /* WIN32 */ | |
750 #endif /* !_SIMULATION_ */ | |
751 { | |
752 #ifdef _SIMULATION_ | |
753 UBYTE* trace_source[2]; | |
754 USHORT trace_size[2]; | |
755 USHORT i; | |
756 USHORT pos; | |
757 char buf[90]; | |
758 | |
759 trace_source[0] = source[0]; | |
760 trace_source[1] = source[1]; | |
761 | |
762 trace_size[0] = size[0]; | |
763 trace_size[1] = size[1]; | |
764 | |
765 /* | |
766 * trace input | |
767 */ | |
768 if((nsource) && | |
769 (uart_device->rx.read_permission)) | |
770 { | |
771 | |
772 TRACE_EVENT("==== INRAW"); | |
773 i = 0; | |
774 pos = 0; | |
775 while(pos < trace_size[0]) | |
776 { | |
777 i+= sprintf(&buf[i], "0x%02x, ", trace_source[0][pos]); | |
778 pos++; | |
779 if(i > 80) | |
780 { | |
781 TRACE_EVENT( buf ); | |
782 i = 0; | |
783 } | |
784 else if(pos >= trace_size[0]) | |
785 { | |
786 TRACE_EVENT( buf ); | |
787 } | |
788 } | |
789 if(nsource > 1) | |
790 { | |
791 i = 0; | |
792 pos = 0; | |
793 while(pos < trace_size[1]) | |
794 { | |
795 i+= sprintf(&buf[i], "0x%02x, ", trace_source[1][pos]); | |
796 pos++; | |
797 if(i > 80) | |
798 { | |
799 TRACE_EVENT( buf ); | |
800 i = 0; | |
801 } | |
802 else if(pos >= trace_size[1]) | |
803 { | |
804 TRACE_EVENT( buf ); | |
805 } | |
806 } | |
807 } | |
808 } | |
809 #endif /* _SIMULATION_ */ | |
810 | |
811 /* | |
812 * normal callback from UF_ReadData | |
813 */ | |
814 rx_proc_input(uart_device); | |
815 } | |
816 | |
817 } /* rx_readOutFunc_1() */ | |
818 #endif /* FF_TWO_UART_PORTS */ | |
819 #endif /* !FF_MULTI_PORT */ |