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