FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/uart/uartfax.c @ 73:aee006f1d275
uartfax.c: remove trailing while space
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 24 Oct 2020 08:33:50 +0000 |
parents | a8c8a5521073 |
children | 03793f41f9bc |
comparison
equal
deleted
inserted
replaced
72:7bf39f5e834d | 73:aee006f1d275 |
---|---|
27 * DB9 Calypso+ DB9 Calypso+ | 27 * DB9 Calypso+ DB9 Calypso+ |
28 * | 28 * |
29 * 1 DCD DCD output 1 1, 6 and 4 are connected together on DB9 | 29 * 1 DCD DCD output 1 1, 6 and 4 are connected together on DB9 |
30 * 2 RX TX output 2 RX TX2 output | 30 * 2 RX TX output 2 RX TX2 output |
31 * 3 TX RX input 3 TX RX2 input | 31 * 3 TX RX input 3 TX RX2 input |
32 * 4 DTR DSR input 4 | 32 * 4 DTR DSR input 4 |
33 * 5 GND 5 GND | 33 * 5 GND 5 GND |
34 * 6 NC 6 | 34 * 6 NC 6 |
35 * 7 RTS CTS input 7 RTS CTS2 input | 35 * 7 RTS CTS input 7 RTS CTS2 input |
36 * 8 CTS RTS output 8 CTS RTS2 output | 36 * 8 CTS RTS output 8 CTS RTS2 output |
37 * 9 NC 9 NC | 37 * 9 NC 9 NC |
38 * | 38 * |
39 */ | 39 */ |
46 * DB9 Calypso DB9 Calypso | 46 * DB9 Calypso DB9 Calypso |
47 * | 47 * |
48 * 1 DCD I/O 2 output 1 1, 6 and 4 are connected together on DB9 | 48 * 1 DCD I/O 2 output 1 1, 6 and 4 are connected together on DB9 |
49 * 2 RX TX output 2 RX TX2 output | 49 * 2 RX TX output 2 RX TX2 output |
50 * 3 TX RX input 3 TX RX2 input | 50 * 3 TX RX input 3 TX RX2 input |
51 * 4 DTR I/O 3 input 4 | 51 * 4 DTR I/O 3 input 4 |
52 * 5 GND 5 GND | 52 * 5 GND 5 GND |
53 * 6 NC 6 | 53 * 6 NC 6 |
54 * 7 RTS CTS input 7 RTS CTS2 input | 54 * 7 RTS CTS input 7 RTS CTS2 input |
55 * 8 CTS RTS output 8 CTS RTS2 output | 55 * 8 CTS RTS output 8 CTS RTS2 output |
56 * 9 NC 9 NC | 56 * 9 NC 9 NC |
57 * | 57 * |
58 */ | 58 */ |
73 * 7 RTS CTS 7 7 and 8 are connected together on DB9 | 73 * 7 RTS CTS 7 7 and 8 are connected together on DB9 |
74 * 8 CTS RTS 8 | 74 * 8 CTS RTS 8 |
75 * 9 NC 9 NC | 75 * 9 NC 9 NC |
76 * | 76 * |
77 */ | 77 */ |
78 | 78 |
79 #include "swconfig.cfg" | 79 #include "swconfig.cfg" |
80 | 80 |
81 #include "l1sw.cfg" | 81 #include "l1sw.cfg" |
82 | 82 |
83 #if (OP_L1_STANDALONE == 0) | 83 #if (OP_L1_STANDALONE == 0) |
120 | 120 |
121 #ifdef CONFIG_TANGO_MODEM | 121 #ifdef CONFIG_TANGO_MODEM |
122 extern SYS_UWORD8 AI_Tango_pinmux[4]; | 122 extern SYS_UWORD8 AI_Tango_pinmux[4]; |
123 #endif | 123 #endif |
124 | 124 |
125 /* | 125 /* |
126 * Maximal value for an unsigned 32 bits. | 126 * Maximal value for an unsigned 32 bits. |
127 */ | 127 */ |
128 | 128 |
129 #define MAX_UNSIGNED_32 (4294967295) | 129 #define MAX_UNSIGNED_32 (4294967295) |
130 | 130 |
133 | 133 |
134 /* | 134 /* |
135 * TLR is used to program the RX FIFO trigger levels. FCR[7:4] are not used. | 135 * TLR is used to program the RX FIFO trigger levels. FCR[7:4] are not used. |
136 * No trigger level used for TX FIFO. THR_IT generated on TX FIFO empty. | 136 * No trigger level used for TX FIFO. THR_IT generated on TX FIFO empty. |
137 */ | 137 */ |
138 | 138 |
139 #define RX_FIFO_TRIGGER_LEVEL (12 << 4) | 139 #define RX_FIFO_TRIGGER_LEVEL (12 << 4) |
140 | 140 |
141 | 141 |
142 /* | 142 /* |
143 * 16750 addresses. Registers accessed when LCR[7] = 0. | 143 * 16750 addresses. Registers accessed when LCR[7] = 0. |
188 #define DSR_IT_BIT (5) /* Use RESET_BIT and SET_BIT macros. */ | 188 #define DSR_IT_BIT (5) /* Use RESET_BIT and SET_BIT macros. */ |
189 | 189 |
190 /* | 190 /* |
191 * Enhanced feature register. | 191 * Enhanced feature register. |
192 */ | 192 */ |
193 | 193 |
194 #define ENHANCED_FEATURE_BIT (4) /* Use RESET_BIT and SET_BIT macros. */ | 194 #define ENHANCED_FEATURE_BIT (4) /* Use RESET_BIT and SET_BIT macros. */ |
195 #define AUTO_CTS_BIT (7) /* Transmission is halted when the CTS pin is high (inactive). */ | 195 #define AUTO_CTS_BIT (7) /* Transmission is halted when the CTS pin is high (inactive). */ |
196 | 196 |
197 /* | 197 /* |
198 * Mode definition register 1. | 198 * Mode definition register 1. |
306 #define DEFAULT_GUARD_PERIOD (1000) /* 1 second. */ | 306 #define DEFAULT_GUARD_PERIOD (1000) /* 1 second. */ |
307 | 307 |
308 /* | 308 /* |
309 * 3 HISR are used to avoid to execute operations from the LISR. | 309 * 3 HISR are used to avoid to execute operations from the LISR. |
310 */ | 310 */ |
311 | 311 |
312 #define RX_HISR_PRIORITY (2) | 312 #define RX_HISR_PRIORITY (2) |
313 | 313 |
314 | 314 |
315 | 315 |
316 | 316 |
317 // NGENGE increase hisr stack otherwise overflows with multiple callbacks | 317 // NGENGE increase hisr stack otherwise overflows with multiple callbacks |
318 //#define RX_HISR_STACK_SIZE (512) /* Bytes. */ | 318 //#define RX_HISR_STACK_SIZE (512) /* Bytes. */ |
319 #define RX_HISR_STACK_SIZE (768) /* Bytes. */ | 319 #define RX_HISR_STACK_SIZE (768) /* Bytes. */ |
320 | 320 |
321 | 321 |
322 | 322 |
323 | 323 |
324 #define TX_HISR_PRIORITY (2) | 324 #define TX_HISR_PRIORITY (2) |
325 | 325 |
326 | 326 |
327 | 327 |
328 // NGENGE increase hisr stack otherwise overflows with multiple callbacks | 328 // NGENGE increase hisr stack otherwise overflows with multiple callbacks |
329 //#define TX_HISR_STACK_SIZE (512) /* Bytes. */ | 329 //#define TX_HISR_STACK_SIZE (512) /* Bytes. */ |
330 #define TX_HISR_STACK_SIZE (768) /* Bytes. */ | 330 #define TX_HISR_STACK_SIZE (768) /* Bytes. */ |
331 | 331 |
332 | 332 |
333 | 333 |
334 | 334 |
335 #define V24_HISR_PRIORITY (2) | 335 #define V24_HISR_PRIORITY (2) |
336 #define V24_HISR_STACK_SIZE (512) /* Bytes. */ | 336 #define V24_HISR_STACK_SIZE (512) /* Bytes. */ |
337 | 337 |
338 /* | 338 /* |
339 * When the break interrupt indicator (BI) is set in the line status register | 339 * When the break interrupt indicator (BI) is set in the line status register |
340 * (LSR), it indicates that the received data input was held in the low state | 340 * (LSR), it indicates that the received data input was held in the low state |
341 * for longer than a full-word transmission time. In the FIFO mode, when a break | 341 * for longer than a full-word transmission time. In the FIFO mode, when a break |
415 | 415 |
416 /* | 416 /* |
417 * Low and high watermarks for the RX buffer. If it is enabled, the flow | 417 * Low and high watermarks for the RX buffer. If it is enabled, the flow |
418 * control is activated or deactivated according to these values. | 418 * control is activated or deactivated according to these values. |
419 * The high watermark value allows to copy an array filled with the RX FIFO | 419 * The high watermark value allows to copy an array filled with the RX FIFO |
420 * into the RX buffer. | 420 * into the RX buffer. |
421 */ | 421 */ |
422 | 422 |
423 #define RX_LOW_WATERMARK(RX_BUFFER_SIZE) (FIFO_SIZE) | 423 #define RX_LOW_WATERMARK(RX_BUFFER_SIZE) (FIFO_SIZE) |
424 #define RX_HIGH_WATERMARK(RX_BUFFER_SIZE) ((RX_BUFFER_SIZE) - 2 * FIFO_SIZE) | 424 #define RX_HIGH_WATERMARK(RX_BUFFER_SIZE) ((RX_BUFFER_SIZE) - 2 * FIFO_SIZE) |
425 | 425 |
426 /* | 426 /* |
427 * This macro allows to know if the RX buffer is full. It must be called only | 427 * This macro allows to know if the RX buffer is full. It must be called only |
428 * from the RX HISR. If it is called from the application, the rx_in and | 428 * from the RX HISR. If it is called from the application, the rx_in and |
429 * rx_fifo_in pointers may be updated if a RX interrupt occurs or if the | 429 * rx_fifo_in pointers may be updated if a RX interrupt occurs or if the |
430 * RX HISR is activated. | 430 * RX HISR is activated. |
431 */ | 431 */ |
432 | 432 |
433 #define RX_BUFFER_FULL(UART) \ | 433 #define RX_BUFFER_FULL(UART) \ |
434 (((UART)->rx_in == (UART)->rx_out - 1) || \ | 434 (((UART)->rx_in == (UART)->rx_out - 1) || \ |
458 SYS_UWORD32 base_address; | 458 SYS_UWORD32 base_address; |
459 | 459 |
460 /* | 460 /* |
461 * HISR executed from the RX/TX interrupt handler. | 461 * HISR executed from the RX/TX interrupt handler. |
462 */ | 462 */ |
463 | 463 |
464 NU_HISR rx_hisr_ctrl_block; | 464 NU_HISR rx_hisr_ctrl_block; |
465 NU_HISR tx_hisr_ctrl_block; | 465 NU_HISR tx_hisr_ctrl_block; |
466 NU_HISR v24_hisr_ctrl_block; | 466 NU_HISR v24_hisr_ctrl_block; |
467 | 467 |
468 char rx_hisr_stack[RX_HISR_STACK_SIZE]; | 468 char rx_hisr_stack[RX_HISR_STACK_SIZE]; |
469 char tx_hisr_stack[TX_HISR_STACK_SIZE]; | 469 char tx_hisr_stack[TX_HISR_STACK_SIZE]; |
470 char v24_hisr_stack[V24_HISR_STACK_SIZE]; | 470 char v24_hisr_stack[V24_HISR_STACK_SIZE]; |
471 | 471 |
472 /* | 472 /* |
473 * 2 arrays are used to store bytes read in RX FIFO. A UART RX interrupt | 473 * 2 arrays are used to store bytes read in RX FIFO. A UART RX interrupt |
474 * may occur while executing RX operations in RX HISR. To avoid overwriting | 474 * may occur while executing RX operations in RX HISR. To avoid overwriting |
475 * the array in which received bytes are stored, a second array is used. | 475 * the array in which received bytes are stored, a second array is used. |
476 */ | 476 */ |
477 | 477 |
478 SYS_UWORD8 *rx_buffer_used_by_rx_lisr; | 478 SYS_UWORD8 *rx_buffer_used_by_rx_lisr; |
479 SYS_UWORD8 *rx_buffer_used_by_rx_hisr; | 479 SYS_UWORD8 *rx_buffer_used_by_rx_hisr; |
480 SYS_UWORD8 rx_fifo_byte_1[FIFO_SIZE]; | 480 SYS_UWORD8 rx_fifo_byte_1[FIFO_SIZE]; |
481 SYS_UWORD8 rx_fifo_byte_2[FIFO_SIZE]; | 481 SYS_UWORD8 rx_fifo_byte_2[FIFO_SIZE]; |
482 SYS_UWORD16 bytes_in_rx_buffer_1; | 482 SYS_UWORD16 bytes_in_rx_buffer_1; |
483 SYS_UWORD16 bytes_in_rx_buffer_2; | 483 SYS_UWORD16 bytes_in_rx_buffer_2; |
484 | 484 |
485 /* | 485 /* |
486 * RX and TX buffers. | 486 * RX and TX buffers. |
487 * One character is not used in each buffer to allow to know if the buffer | 487 * One character is not used in each buffer to allow to know if the buffer |
488 * is empty or not (See macro RX_BUFFER_FULL). If buffers are empty, | 488 * is empty or not (See macro RX_BUFFER_FULL). If buffers are empty, |
489 * rx_in = rx_out and tx_in = tx_out. It is impossible to use fields to | 489 * rx_in = rx_out and tx_in = tx_out. It is impossible to use fields to |
543 SYS_BOOL break_in_progress; | 543 SYS_BOOL break_in_progress; |
544 NU_HISR break_hisr_ctrl_block; | 544 NU_HISR break_hisr_ctrl_block; |
545 char break_hisr_stack[BREAK_HISR_STACK_SIZE]; | 545 char break_hisr_stack[BREAK_HISR_STACK_SIZE]; |
546 NU_TIMER break_timer_ctrl_block; | 546 NU_TIMER break_timer_ctrl_block; |
547 UNSIGNED baudrate; | 547 UNSIGNED baudrate; |
548 UNSIGNED autobauding; | 548 UNSIGNED autobauding; |
549 UNSIGNED bits_per_char; /* Including start, stop and parity bits. */ | 549 UNSIGNED bits_per_char; /* Including start, stop and parity bits. */ |
550 UNSIGNED break_length; /* In bytes. */ | 550 UNSIGNED break_length; /* In bytes. */ |
551 UNSIGNED time_without_character; | 551 UNSIGNED time_without_character; |
552 | 552 |
553 /* | 553 /* |
582 * the user's Rx callback function is called if the source of interrupt was | 582 * the user's Rx callback function is called if the source of interrupt was |
583 * the DTR interrupt regardless of the other conditions. | 583 * the DTR interrupt regardless of the other conditions. |
584 * The level of DTR is saved to provide the level detected on Rx interrupt | 584 * The level of DTR is saved to provide the level detected on Rx interrupt |
585 * or DTR interrupt in the 'state' parameter of the user's Rx callback | 585 * or DTR interrupt in the 'state' parameter of the user's Rx callback |
586 * function. | 586 * function. |
587 */ | 587 */ |
588 | 588 |
589 SYS_BOOL dtr_change_detected[2]; | 589 SYS_BOOL dtr_change_detected[2]; |
590 SYS_UWORD8 dtr_level_saved[2]; | 590 SYS_UWORD8 dtr_level_saved[2]; |
591 SYS_UWORD8 index_it; | 591 SYS_UWORD8 index_it; |
592 SYS_UWORD8 index_hisr; | 592 SYS_UWORD8 index_hisr; |
593 #endif /* BOARD 8 or 9 or 40 or 41 or CHIPSET 12 */ | 593 #endif /* BOARD 8 or 9 or 40 or 41 or CHIPSET 12 */ |
594 | 594 |
595 SYS_BOOL reading_suspended; | 595 SYS_BOOL reading_suspended; |
596 SYS_BOOL writing_suspended; | 596 SYS_BOOL writing_suspended; |
597 SYS_BOOL rd_call_from_hisr_in_progress; | 597 SYS_BOOL rd_call_from_hisr_in_progress; |
598 SYS_BOOL wr_call_from_hisr_in_progress; | 598 SYS_BOOL wr_call_from_hisr_in_progress; |
599 T_reInstMode rd_call_setup; | 599 T_reInstMode rd_call_setup; |
683 0, /* 203125 baud: not supported. */ | 683 0, /* 203125 baud: not supported. */ |
684 0, /* 406250 baud: not supported. */ | 684 0, /* 406250 baud: not supported. */ |
685 0 /* 812500 baud: not supported. */ | 685 0 /* 812500 baud: not supported. */ |
686 }; | 686 }; |
687 | 687 |
688 static const SYS_UWORD8 dlh[] = | 688 static const SYS_UWORD8 dlh[] = |
689 { | 689 { |
690 0, /* Auto baud: */ | 690 0, /* Auto baud: */ |
691 42, /* 75 baud. */ | 691 42, /* 75 baud. */ |
692 21, /* 150 baud. */ | 692 21, /* 150 baud. */ |
693 10, /* 300 baud. */ | 693 10, /* 300 baud. */ |
732 0, /* Not supported. */ | 732 0, /* Not supported. */ |
733 0 /* Not supported. */ | 733 0 /* Not supported. */ |
734 }; | 734 }; |
735 | 735 |
736 | 736 |
737 | 737 |
738 | 738 |
739 /******************************************************************************* | 739 /******************************************************************************* |
740 * | 740 * |
741 * get_bytes_in_rx_buffer | 741 * get_bytes_in_rx_buffer |
742 * | 742 * |
743 * Purpose : Gets the number of bytes in the RX buffer. | 743 * Purpose : Gets the number of bytes in the RX buffer. |
744 * | 744 * |
745 * Arguments: In : uart: Pointer on the UART structure. | 745 * Arguments: In : uart: Pointer on the UART structure. |
746 * Out: none | 746 * Out: none |
747 * | 747 * |
767 } | 767 } |
768 | 768 |
769 /******************************************************************************* | 769 /******************************************************************************* |
770 * | 770 * |
771 * get_bytes_in_tx_buffer | 771 * get_bytes_in_tx_buffer |
772 * | 772 * |
773 * Purpose : Gets the number of bytes in the TX buffer. | 773 * Purpose : Gets the number of bytes in the TX buffer. |
774 * | 774 * |
775 * Arguments: In : uart: Pointer on the UART structure. | 775 * Arguments: In : uart: Pointer on the UART structure. |
776 * Out: none | 776 * Out: none |
777 * | 777 * |
797 } | 797 } |
798 | 798 |
799 /******************************************************************************* | 799 /******************************************************************************* |
800 * | 800 * |
801 * compute_break_time | 801 * compute_break_time |
802 * | 802 * |
803 * Purpose : Computes a number of TDMA from 3 parameters: | 803 * Purpose : Computes a number of TDMA from 3 parameters: |
804 * - baudrate, | 804 * - baudrate, |
805 * - bits per character including start bit, stop bits and parity, | 805 * - bits per character including start bit, stop bits and parity, |
806 * - number of characters. | 806 * - number of characters. |
807 * Due to the TDMA value (4.6 ms), a minimal value is sent: 2 TDMA. | 807 * Due to the TDMA value (4.6 ms), a minimal value is sent: 2 TDMA. |
834 } | 834 } |
835 | 835 |
836 /******************************************************************************* | 836 /******************************************************************************* |
837 * | 837 * |
838 * update_reading_callback | 838 * update_reading_callback |
839 * | 839 * |
840 * Purpose : Updates the sizes array and the addresses array and get and builds | 840 * Purpose : Updates the sizes array and the addresses array and get and builds |
841 * the state parameter defined in UAF_GetLineState to call the | 841 * the state parameter defined in UAF_GetLineState to call the |
842 * readOutFunc function. | 842 * readOutFunc function. |
843 * | 843 * |
844 * Arguments: In : uart : Pointer on the UART structure. | 844 * Arguments: In : uart : Pointer on the UART structure. |
864 * A copy of rx_in is used because it may be updated by the interrupt | 864 * A copy of rx_in is used because it may be updated by the interrupt |
865 * handler if this function is called from the application. | 865 * handler if this function is called from the application. |
866 */ | 866 */ |
867 | 867 |
868 rx_in = uart->rx_in; | 868 rx_in = uart->rx_in; |
869 | 869 |
870 if (uart->rx_out < rx_in) { | 870 if (uart->rx_out < rx_in) { |
871 | 871 |
872 fragments_number = 1; | 872 fragments_number = 1; |
873 | 873 |
874 uart->rd_address[0] = uart->rx_out; | 874 uart->rd_address[0] = uart->rx_out; |
879 uart->rd_size_after_call[1] = 0; | 879 uart->rd_size_after_call[1] = 0; |
880 | 880 |
881 bytes_in_rx_buffer = uart->rd_size_before_call[0]; | 881 bytes_in_rx_buffer = uart->rd_size_before_call[0]; |
882 | 882 |
883 } else if (rx_in == uart->rx_out) { /* RX buffer empty. */ | 883 } else if (rx_in == uart->rx_out) { /* RX buffer empty. */ |
884 | 884 |
885 fragments_number = 1; | 885 fragments_number = 1; |
886 | 886 |
887 uart->rd_address[0] = uart->rx_out; | 887 uart->rd_address[0] = uart->rx_out; |
888 uart->rd_size_before_call[0] = 0; | 888 uart->rd_size_before_call[0] = 0; |
889 uart->rd_size_after_call[0] = 0; | 889 uart->rd_size_after_call[0] = 0; |
890 | 890 |
891 uart->rd_size_before_call[1] = 0; | 891 uart->rd_size_before_call[1] = 0; |
892 uart->rd_size_after_call[1] = 0; | 892 uart->rd_size_after_call[1] = 0; |
893 | 893 |
894 bytes_in_rx_buffer = 0; | 894 bytes_in_rx_buffer = 0; |
895 | 895 |
896 } else { | 896 } else { |
897 | 897 |
898 fragments_number = 2; | 898 fragments_number = 2; |
899 | 899 |
900 uart->rd_address[0] = uart->rx_out; | 900 uart->rd_address[0] = uart->rx_out; |
901 uart->rd_size_before_call[0] = | 901 uart->rd_size_before_call[0] = |
902 uart->buffer_size + 1 - (SYS_UWORD16) (uart->rx_out - | 902 uart->buffer_size + 1 - (SYS_UWORD16) (uart->rx_out - |
968 if (uart->flow_control_mode != fc_rts) | 968 if (uart->flow_control_mode != fc_rts) |
969 state |= (((SYS_UWORD32) uart->rts_level) << SB); | 969 state |= (((SYS_UWORD32) uart->rts_level) << SB); |
970 | 970 |
971 if (uart->flow_control_mode == fc_rts) | 971 if (uart->flow_control_mode == fc_rts) |
972 state |= (((SYS_UWORD32) uart->rts_level) << X); | 972 state |= (((SYS_UWORD32) uart->rts_level) << X); |
973 | 973 |
974 else if ((uart->flow_control_mode == fc_xoff) && | 974 else if ((uart->flow_control_mode == fc_xoff) && |
975 (uart->tx_stopped_by_application || | 975 (uart->tx_stopped_by_application || |
976 uart->tx_stopped_by_driver)) | 976 uart->tx_stopped_by_driver)) |
977 state |= (1 << X); | 977 state |= (1 << X); |
978 | 978 |
991 } | 991 } |
992 | 992 |
993 /******************************************************************************* | 993 /******************************************************************************* |
994 * | 994 * |
995 * update_writing_callback | 995 * update_writing_callback |
996 * | 996 * |
997 * Purpose : Updates the sizes array and the addresses array to call the | 997 * Purpose : Updates the sizes array and the addresses array to call the |
998 * writeInFunc function. | 998 * writeInFunc function. |
999 * | 999 * |
1000 * Arguments: In : uart : Pointer on the UART structure. | 1000 * Arguments: In : uart : Pointer on the UART structure. |
1001 * call_source: 0: application, 1: HISR | 1001 * call_source: 0: application, 1: HISR |
1017 * A copy of tx_out is used because it may be updated by the interrupt | 1017 * A copy of tx_out is used because it may be updated by the interrupt |
1018 * handler if this function is called from the application. | 1018 * handler if this function is called from the application. |
1019 */ | 1019 */ |
1020 | 1020 |
1021 tx_out = uart->tx_out; | 1021 tx_out = uart->tx_out; |
1022 | 1022 |
1023 if (uart->tx_in < tx_out) { | 1023 if (uart->tx_in < tx_out) { |
1024 | 1024 |
1025 fragments_number = 1; | 1025 fragments_number = 1; |
1026 | 1026 |
1027 uart->wr_address[0] = uart->tx_in; | 1027 uart->wr_address[0] = uart->tx_in; |
1029 (SYS_UWORD16) (tx_out - uart->tx_in - 1); | 1029 (SYS_UWORD16) (tx_out - uart->tx_in - 1); |
1030 uart->wr_size_after_call[0] = uart->wr_size_before_call[0]; | 1030 uart->wr_size_after_call[0] = uart->wr_size_before_call[0]; |
1031 | 1031 |
1032 uart->wr_size_before_call[1] = 0; | 1032 uart->wr_size_before_call[1] = 0; |
1033 uart->wr_size_after_call[1] = 0; | 1033 uart->wr_size_after_call[1] = 0; |
1034 | 1034 |
1035 } else if (tx_out == &(uart->tx_buffer[0])) { | 1035 } else if (tx_out == &(uart->tx_buffer[0])) { |
1036 | 1036 |
1037 fragments_number = 1; | 1037 fragments_number = 1; |
1038 | 1038 |
1039 uart->wr_address[0] = uart->tx_in; | 1039 uart->wr_address[0] = uart->tx_in; |
1040 uart->wr_size_before_call[0] = | 1040 uart->wr_size_before_call[0] = |
1041 uart->buffer_size - | 1041 uart->buffer_size - |
1042 (SYS_UWORD16) (uart->tx_in - &(uart->tx_buffer[0])); | 1042 (SYS_UWORD16) (uart->tx_in - &(uart->tx_buffer[0])); |
1043 uart->wr_size_after_call[0] = uart->wr_size_before_call[0]; | 1043 uart->wr_size_after_call[0] = uart->wr_size_before_call[0]; |
1044 | 1044 |
1045 uart->wr_size_before_call[1] = 0; | 1045 uart->wr_size_before_call[1] = 0; |
1046 uart->wr_size_after_call[1] = 0; | 1046 uart->wr_size_after_call[1] = 0; |
1047 | 1047 |
1048 } else { | 1048 } else { |
1049 | 1049 |
1050 fragments_number = 2; | 1050 fragments_number = 2; |
1051 | 1051 |
1052 uart->wr_address[0] = uart->tx_in; | 1052 uart->wr_address[0] = uart->tx_in; |
1053 uart->wr_size_before_call[0] = | 1053 uart->wr_size_before_call[0] = |
1054 uart->buffer_size + 1 - | 1054 uart->buffer_size + 1 - |
1055 (SYS_UWORD16) (uart->tx_in - &(uart->tx_buffer[0])); | 1055 (SYS_UWORD16) (uart->tx_in - &(uart->tx_buffer[0])); |
1056 uart->wr_size_after_call[0] = uart->wr_size_before_call[0]; | 1056 uart->wr_size_after_call[0] = uart->wr_size_before_call[0]; |
1057 | 1057 |
1058 uart->wr_address[1] = &(uart->tx_buffer[0]); | 1058 uart->wr_address[1] = &(uart->tx_buffer[0]); |
1059 uart->wr_size_before_call[1] = | 1059 uart->wr_size_before_call[1] = |
1078 } | 1078 } |
1079 | 1079 |
1080 /******************************************************************************* | 1080 /******************************************************************************* |
1081 * | 1081 * |
1082 * stop_break | 1082 * stop_break |
1083 * | 1083 * |
1084 * Purpose : The timer is activated to expire when a time corresponding to the | 1084 * Purpose : The timer is activated to expire when a time corresponding to the |
1085 * sending time of 2 characters at least has elapsed. After a break, | 1085 * sending time of 2 characters at least has elapsed. After a break, |
1086 * no character may be sent during this period. | 1086 * no character may be sent during this period. |
1087 * | 1087 * |
1088 * Arguments: In : id: parameter not used. | 1088 * Arguments: In : id: parameter not used. |
1104 | 1104 |
1105 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 1105 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
1106 /* | 1106 /* |
1107 * Disable sleep mode. | 1107 * Disable sleep mode. |
1108 */ | 1108 */ |
1109 | 1109 |
1110 WRITE_UART_REGISTER ( | 1110 WRITE_UART_REGISTER ( |
1111 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 1111 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
1112 #endif | 1112 #endif |
1113 | 1113 |
1114 /* | 1114 /* |
1120 } | 1120 } |
1121 | 1121 |
1122 /******************************************************************************* | 1122 /******************************************************************************* |
1123 * | 1123 * |
1124 * hisr_start_break | 1124 * hisr_start_break |
1125 * | 1125 * |
1126 * Purpose : Enables the timer used to control the time without character. | 1126 * Purpose : Enables the timer used to control the time without character. |
1127 * | 1127 * |
1128 * Arguments: In : none | 1128 * Arguments: In : none |
1129 * Out: none | 1129 * Out: none |
1130 * | 1130 * |
1153 } | 1153 } |
1154 | 1154 |
1155 /******************************************************************************* | 1155 /******************************************************************************* |
1156 * | 1156 * |
1157 * stop_receiver | 1157 * stop_receiver |
1158 * | 1158 * |
1159 * Purpose : Activates DTR or RTS or sends XOFF. | 1159 * Purpose : Activates DTR or RTS or sends XOFF. |
1160 * | 1160 * |
1161 * Arguments: In : uart: Pointer on the UART structure. | 1161 * Arguments: In : uart: Pointer on the UART structure. |
1162 * Out: none | 1162 * Out: none |
1163 * | 1163 * |
1164 * Returns : none | 1164 * Returns : none |
1170 { | 1170 { |
1171 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 1171 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
1172 /* | 1172 /* |
1173 * Disable sleep mode. | 1173 * Disable sleep mode. |
1174 */ | 1174 */ |
1175 | 1175 |
1176 WRITE_UART_REGISTER ( | 1176 WRITE_UART_REGISTER ( |
1177 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 1177 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
1178 #endif | 1178 #endif |
1179 | 1179 |
1180 switch (uart->flow_control_mode) { | 1180 switch (uart->flow_control_mode) { |
1195 uart->send_xon_xoff = 1; | 1195 uart->send_xon_xoff = 1; |
1196 | 1196 |
1197 /* | 1197 /* |
1198 * Unmask Tx interrupt. | 1198 * Unmask Tx interrupt. |
1199 */ | 1199 */ |
1200 | 1200 |
1201 WRITE_UART_REGISTER ( | 1201 WRITE_UART_REGISTER ( |
1202 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); | 1202 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); |
1203 break; | 1203 break; |
1204 } | 1204 } |
1205 } | 1205 } |
1206 | 1206 |
1207 /******************************************************************************* | 1207 /******************************************************************************* |
1208 * | 1208 * |
1209 * start_receiver | 1209 * start_receiver |
1210 * | 1210 * |
1211 * Purpose : Deactivates DTR or RTS or sends XON. | 1211 * Purpose : Deactivates DTR or RTS or sends XON. |
1212 * | 1212 * |
1213 * Arguments: In : uart: Pointer on the UART structure. | 1213 * Arguments: In : uart: Pointer on the UART structure. |
1214 * Out: none | 1214 * Out: none |
1215 * | 1215 * |
1222 { | 1222 { |
1223 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 1223 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
1224 /* | 1224 /* |
1225 * Disable sleep mode. | 1225 * Disable sleep mode. |
1226 */ | 1226 */ |
1227 | 1227 |
1228 WRITE_UART_REGISTER ( | 1228 WRITE_UART_REGISTER ( |
1229 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 1229 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
1230 #endif | 1230 #endif |
1231 | 1231 |
1232 switch (uart->flow_control_mode) { | 1232 switch (uart->flow_control_mode) { |
1247 uart->send_xon_xoff = 1; | 1247 uart->send_xon_xoff = 1; |
1248 | 1248 |
1249 /* | 1249 /* |
1250 * Unmask Tx interrupt. | 1250 * Unmask Tx interrupt. |
1251 */ | 1251 */ |
1252 | 1252 |
1253 WRITE_UART_REGISTER ( | 1253 WRITE_UART_REGISTER ( |
1254 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); | 1254 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); |
1255 break; | 1255 break; |
1256 } | 1256 } |
1257 } | 1257 } |
1258 | 1258 |
1259 /******************************************************************************* | 1259 /******************************************************************************* |
1260 * | 1260 * |
1261 * add_esc_seq_char_in_rx_buffer | 1261 * add_esc_seq_char_in_rx_buffer |
1262 * | 1262 * |
1263 * Purpose : Writes one escape sequence character in the RX buffer. | 1263 * Purpose : Writes one escape sequence character in the RX buffer. |
1264 * | 1264 * |
1265 * Arguments: In : uart: Pointer on the UART structure. | 1265 * Arguments: In : uart: Pointer on the UART structure. |
1266 * Out: none | 1266 * Out: none |
1267 * | 1267 * |
1287 } | 1287 } |
1288 | 1288 |
1289 /******************************************************************************* | 1289 /******************************************************************************* |
1290 * | 1290 * |
1291 * analyze_guard_period_timer_expiration | 1291 * analyze_guard_period_timer_expiration |
1292 * | 1292 * |
1293 * Purpose : According to the state of the escape sequence detection, 1 or 2 | 1293 * Purpose : According to the state of the escape sequence detection, 1 or 2 |
1294 * escape sequence characters may be written into the TX buffer or | 1294 * escape sequence characters may be written into the TX buffer or |
1295 * the escape sequence is declared as detected. | 1295 * the escape sequence is declared as detected. |
1296 * If 1 or 2 escape sequence characters have been detected the | 1296 * If 1 or 2 escape sequence characters have been detected the |
1297 * guard period must not expire. | 1297 * guard period must not expire. |
1299 * expire. | 1299 * expire. |
1300 * | 1300 * |
1301 * Arguments: In : id: parameter not used. | 1301 * Arguments: In : id: parameter not used. |
1302 * Out: none | 1302 * Out: none |
1303 * | 1303 * |
1304 * Returns : none | 1304 * Returns : none |
1305 * | 1305 * |
1306 ******************************************************************************/ | 1306 ******************************************************************************/ |
1307 | 1307 |
1308 static VOID | 1308 static VOID |
1309 analyze_guard_period_timer_expiration (UNSIGNED id) | 1309 analyze_guard_period_timer_expiration (UNSIGNED id) |
1312 SYS_UWORD16 bytes_in_rx_buffer; | 1312 SYS_UWORD16 bytes_in_rx_buffer; |
1313 | 1313 |
1314 uart = &uart_parameters; | 1314 uart = &uart_parameters; |
1315 | 1315 |
1316 switch (uart->esc_seq_detection_state) { | 1316 switch (uart->esc_seq_detection_state) { |
1317 | 1317 |
1318 case ONE_CHAR_DETECTED: | 1318 case ONE_CHAR_DETECTED: |
1319 | 1319 |
1320 /* | 1320 /* |
1321 * 1 escape sequence character has been detected. The guard period has | 1321 * 1 escape sequence character has been detected. The guard period has |
1322 * ellapsed. This character is written into the TX buffer. | 1322 * ellapsed. This character is written into the TX buffer. |
1323 */ | 1323 */ |
1324 | 1324 |
1325 add_esc_seq_char_in_rx_buffer (uart); | 1325 add_esc_seq_char_in_rx_buffer (uart); |
1326 break; | 1326 break; |
1327 | 1327 |
1328 case TWO_CHARS_DETECTED: | 1328 case TWO_CHARS_DETECTED: |
1329 | 1329 |
1330 /* | 1330 /* |
1331 * 2 escape sequence characters have been detected. The guard period has | 1331 * 2 escape sequence characters have been detected. The guard period has |
1332 * ellapsed. These characters are written into the TX buffer. | 1332 * ellapsed. These characters are written into the TX buffer. |
1333 */ | 1333 */ |
1334 | 1334 |
1335 add_esc_seq_char_in_rx_buffer (uart); | 1335 add_esc_seq_char_in_rx_buffer (uart); |
1336 add_esc_seq_char_in_rx_buffer (uart); | 1336 add_esc_seq_char_in_rx_buffer (uart); |
1337 | 1337 |
1338 break; | 1338 break; |
1339 | 1339 |
1340 case THREE_CHARS_DETECTED: | 1340 case THREE_CHARS_DETECTED: |
1341 | 1341 |
1342 /* | 1342 /* |
1343 * 3 escape sequence characters have been detected and the guard period | 1343 * 3 escape sequence characters have been detected and the guard period |
1344 * has ellapsed. The escape sequence is detected. | 1344 * has ellapsed. The escape sequence is detected. |
1345 */ | 1345 */ |
1346 | 1346 |
1347 uart->esc_seq_received = 1; | 1347 uart->esc_seq_received = 1; |
1348 *(uart->state) |= (1 << ESC); | 1348 *(uart->state) |= (1 << ESC); |
1349 | 1349 |
1350 break; | 1350 break; |
1351 } | 1351 } |
1352 | 1352 |
1353 uart->esc_seq_detection_state = NO_ESCAPE_SEQUENCE; | 1353 uart->esc_seq_detection_state = NO_ESCAPE_SEQUENCE; |
1354 | 1354 |
1355 /* | 1355 /* |
1356 * If the high watermark is reached, RTS is activated or XOFF is sent | 1356 * If the high watermark is reached, RTS is activated or XOFF is sent |
1357 * according to the flow control mode. | 1357 * according to the flow control mode. |
1358 */ | 1358 */ |
1359 | 1359 |
1401 } | 1401 } |
1402 | 1402 |
1403 /******************************************************************************* | 1403 /******************************************************************************* |
1404 * | 1404 * |
1405 * stop_guard_period_timer | 1405 * stop_guard_period_timer |
1406 * | 1406 * |
1407 * Purpose : Stops the timer used to detect the guard period expiration. | 1407 * Purpose : Stops the timer used to detect the guard period expiration. |
1408 * | 1408 * |
1409 * Arguments: In : uart: Pointer on the UART structure. | 1409 * Arguments: In : uart: Pointer on the UART structure. |
1410 * Out: none | 1410 * Out: none |
1411 * | 1411 * |
1412 * Returns : none | 1412 * Returns : none |
1413 * | 1413 * |
1414 ******************************************************************************/ | 1414 ******************************************************************************/ |
1415 | 1415 |
1416 static void | 1416 static void |
1417 stop_guard_period_timer (t_uart *uart) | 1417 stop_guard_period_timer (t_uart *uart) |
1421 } | 1421 } |
1422 | 1422 |
1423 /******************************************************************************* | 1423 /******************************************************************************* |
1424 * | 1424 * |
1425 * start_guard_period_timer | 1425 * start_guard_period_timer |
1426 * | 1426 * |
1427 * Purpose : Starts a timer which expires if the guard period has ellapsed. | 1427 * Purpose : Starts a timer which expires if the guard period has ellapsed. |
1428 * | 1428 * |
1429 * Arguments: In : uart: Pointer on the UART structure. | 1429 * Arguments: In : uart: Pointer on the UART structure. |
1430 * Out: none | 1430 * Out: none |
1431 * | 1431 * |
1432 * Returns : none | 1432 * Returns : none |
1433 * | 1433 * |
1434 ******************************************************************************/ | 1434 ******************************************************************************/ |
1435 | 1435 |
1436 static void | 1436 static void |
1437 start_guard_period_timer (t_uart *uart) | 1437 start_guard_period_timer (t_uart *uart) |
1450 } | 1450 } |
1451 | 1451 |
1452 /******************************************************************************* | 1452 /******************************************************************************* |
1453 * | 1453 * |
1454 * detect_escape_sequence | 1454 * detect_escape_sequence |
1455 * | 1455 * |
1456 * Purpose : The state machine used to detect an escape sequence is updated | 1456 * Purpose : The state machine used to detect an escape sequence is updated |
1457 * according to the array of bytes to analyse. If the state machine | 1457 * according to the array of bytes to analyse. If the state machine |
1458 * goes to the initial state due to a break in the sequence | 1458 * goes to the initial state due to a break in the sequence |
1459 * detection, the previous characters are put into the RX buffer. | 1459 * detection, the previous characters are put into the RX buffer. |
1460 * | 1460 * |
1461 * Arguments: In : uart: Pointer on the UART structure. | 1461 * Arguments: In : uart: Pointer on the UART structure. |
1462 * Out: none | 1462 * Out: none |
1463 * | 1463 * |
1464 * Returns : 0: Break in detection or a sequence has been detected. | 1464 * Returns : 0: Break in detection or a sequence has been detected. |
1465 * 1: A sequence may be detected. | 1465 * 1: A sequence may be detected. |
1466 * | 1466 * |
1467 ******************************************************************************/ | 1467 ******************************************************************************/ |
1468 | 1468 |
1469 static int | 1469 static int |
1521 switch (bytes_in_rx_buffer) { | 1521 switch (bytes_in_rx_buffer) { |
1522 | 1522 |
1523 case 1: | 1523 case 1: |
1524 | 1524 |
1525 if (*rx_fifo_byte++ == uart->esc_seq_character) { | 1525 if (*rx_fifo_byte++ == uart->esc_seq_character) { |
1526 | 1526 |
1527 uart->esc_seq_detection_state = ONE_CHAR_DETECTED; | 1527 uart->esc_seq_detection_state = ONE_CHAR_DETECTED; |
1528 start_guard_period_timer (uart); | 1528 start_guard_period_timer (uart); |
1529 detection_result = 1; | 1529 detection_result = 1; |
1530 } | 1530 } |
1531 | 1531 |
1533 | 1533 |
1534 case 2: | 1534 case 2: |
1535 | 1535 |
1536 if ((*rx_fifo_byte++ == uart->esc_seq_character) && | 1536 if ((*rx_fifo_byte++ == uart->esc_seq_character) && |
1537 (*rx_fifo_byte++ == uart->esc_seq_character)) { | 1537 (*rx_fifo_byte++ == uart->esc_seq_character)) { |
1538 | 1538 |
1539 uart->esc_seq_detection_state = TWO_CHARS_DETECTED; | 1539 uart->esc_seq_detection_state = TWO_CHARS_DETECTED; |
1540 start_guard_period_timer (uart); | 1540 start_guard_period_timer (uart); |
1541 detection_result = 1; | 1541 detection_result = 1; |
1542 } | 1542 } |
1543 | 1543 |
1544 break; | 1544 break; |
1545 | 1545 |
1546 case 3: | 1546 case 3: |
1547 | 1547 |
1548 if ((*rx_fifo_byte++ == uart->esc_seq_character) && | 1548 if ((*rx_fifo_byte++ == uart->esc_seq_character) && |
1549 (*rx_fifo_byte++ == uart->esc_seq_character) && | 1549 (*rx_fifo_byte++ == uart->esc_seq_character) && |
1550 (*rx_fifo_byte++ == uart->esc_seq_character)) { | 1550 (*rx_fifo_byte++ == uart->esc_seq_character)) { |
1551 | 1551 |
1552 uart->esc_seq_detection_state = THREE_CHARS_DETECTED; | 1552 uart->esc_seq_detection_state = THREE_CHARS_DETECTED; |
1553 start_guard_period_timer (uart); | 1553 start_guard_period_timer (uart); |
1554 detection_result = 1; | 1554 detection_result = 1; |
1555 } | 1555 } |
1556 | 1556 |
1557 break; | 1557 break; |
1558 | 1558 |
1559 default: | 1559 default: |
1560 | 1560 |
1561 /* | 1561 /* |
1562 * No action. | 1562 * No action. |
1563 */ | 1563 */ |
1564 | 1564 |
1565 break; | 1565 break; |
1585 switch (bytes_in_rx_buffer) { | 1585 switch (bytes_in_rx_buffer) { |
1586 | 1586 |
1587 case 1: | 1587 case 1: |
1588 | 1588 |
1589 if (*rx_fifo_byte++ == uart->esc_seq_character) { | 1589 if (*rx_fifo_byte++ == uart->esc_seq_character) { |
1590 | 1590 |
1591 uart->esc_seq_detection_state = TWO_CHARS_DETECTED; | 1591 uart->esc_seq_detection_state = TWO_CHARS_DETECTED; |
1592 detection_result = 1; | 1592 detection_result = 1; |
1593 } | 1593 } |
1594 | 1594 |
1595 break; | 1595 break; |
1596 | 1596 |
1597 case 2: | 1597 case 2: |
1598 | 1598 |
1599 if ((*rx_fifo_byte++ == uart->esc_seq_character) && | 1599 if ((*rx_fifo_byte++ == uart->esc_seq_character) && |
1600 (*rx_fifo_byte++ == uart->esc_seq_character)) { | 1600 (*rx_fifo_byte++ == uart->esc_seq_character)) { |
1601 | 1601 |
1602 start_guard_period_timer (uart); /* Reset the timer. */ | 1602 start_guard_period_timer (uart); /* Reset the timer. */ |
1603 | 1603 |
1604 uart->esc_seq_detection_state = THREE_CHARS_DETECTED; | 1604 uart->esc_seq_detection_state = THREE_CHARS_DETECTED; |
1605 detection_result = 1; | 1605 detection_result = 1; |
1606 } | 1606 } |
1607 | 1607 |
1608 break; | 1608 break; |
1609 | 1609 |
1610 default: | 1610 default: |
1611 | 1611 |
1612 /* | 1612 /* |
1644 case 1: | 1644 case 1: |
1645 | 1645 |
1646 if (*rx_fifo_byte++ == uart->esc_seq_character) { | 1646 if (*rx_fifo_byte++ == uart->esc_seq_character) { |
1647 | 1647 |
1648 start_guard_period_timer (uart); /* Reset the timer. */ | 1648 start_guard_period_timer (uart); /* Reset the timer. */ |
1649 | 1649 |
1650 uart->esc_seq_detection_state = THREE_CHARS_DETECTED; | 1650 uart->esc_seq_detection_state = THREE_CHARS_DETECTED; |
1651 detection_result = 1; | 1651 detection_result = 1; |
1652 } | 1652 } |
1653 | 1653 |
1654 break; | 1654 break; |
1655 | 1655 |
1656 default: | 1656 default: |
1657 | 1657 |
1658 /* | 1658 /* |
1698 } | 1698 } |
1699 | 1699 |
1700 /******************************************************************************* | 1700 /******************************************************************************* |
1701 * | 1701 * |
1702 * send_break | 1702 * send_break |
1703 * | 1703 * |
1704 * Purpose : This function may only called if the TX FIFO is empty. | 1704 * Purpose : This function may only called if the TX FIFO is empty. |
1705 * Null characters are written in the TX FIFO. The number of bytes to | 1705 * Null characters are written in the TX FIFO. The number of bytes to |
1706 * write has been defined with UAF_SetLineState. Enables the break | 1706 * write has been defined with UAF_SetLineState. Enables the break |
1707 * condition. | 1707 * condition. |
1708 * | 1708 * |
1730 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 1730 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
1731 #endif | 1731 #endif |
1732 | 1732 |
1733 WRITE_UART_REGISTER ( | 1733 WRITE_UART_REGISTER ( |
1734 uart, LCR, READ_UART_REGISTER (uart, LCR) | BREAK_CONTROL); | 1734 uart, LCR, READ_UART_REGISTER (uart, LCR) | BREAK_CONTROL); |
1735 | 1735 |
1736 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 1736 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
1737 /* | 1737 /* |
1738 * Re-enable sleep mode. | 1738 * Re-enable sleep mode. |
1739 */ | 1739 */ |
1740 | 1740 |
1757 } | 1757 } |
1758 | 1758 |
1759 /******************************************************************************* | 1759 /******************************************************************************* |
1760 * | 1760 * |
1761 * build_rx_fifo_array | 1761 * build_rx_fifo_array |
1762 * | 1762 * |
1763 * Purpose : Reads the RX FIFO to build an array with bytes read. | 1763 * Purpose : Reads the RX FIFO to build an array with bytes read. |
1764 * A byte is written in this array if no error is detected. | 1764 * A byte is written in this array if no error is detected. |
1765 * | 1765 * |
1766 * Arguments: In : uart: Pointer on the UART structure. | 1766 * Arguments: In : uart: Pointer on the UART structure. |
1767 * Out: none | 1767 * Out: none |
1768 * | 1768 * |
1769 * Returns : The number of bytes in RX FIFO. | 1769 * Returns : The number of bytes in RX FIFO. |
1783 volatile int x; | 1783 volatile int x; |
1784 | 1784 |
1785 x = 1; | 1785 x = 1; |
1786 | 1786 |
1787 bytes_received = 0; | 1787 bytes_received = 0; |
1788 | 1788 |
1789 | 1789 |
1790 /* | 1790 /* |
1791 * Switch to the other buffer. | 1791 * Switch to the other buffer. |
1792 */ | 1792 */ |
1793 | 1793 |
1794 first_byte = uart->rx_buffer_used_by_rx_lisr; | 1794 first_byte = uart->rx_buffer_used_by_rx_lisr; |
1795 if (first_byte == &(uart->rx_fifo_byte_1[0])) { | 1795 if (first_byte == &(uart->rx_fifo_byte_1[0])) { |
1796 | 1796 |
1797 first_byte = &(uart->rx_fifo_byte_2[0]); | 1797 first_byte = &(uart->rx_fifo_byte_2[0]); |
1798 bytes_in_rx_buffer = &(uart->bytes_in_rx_buffer_2); | 1798 bytes_in_rx_buffer = &(uart->bytes_in_rx_buffer_2); |
1799 | 1799 |
1800 } else { | 1800 } else { |
1801 | 1801 |
1802 first_byte = &(uart->rx_fifo_byte_1[0]); | 1802 first_byte = &(uart->rx_fifo_byte_1[0]); |
1803 bytes_in_rx_buffer = &(uart->bytes_in_rx_buffer_1); | 1803 bytes_in_rx_buffer = &(uart->bytes_in_rx_buffer_1); |
1804 } | 1804 } |
1805 | 1805 |
1806 current_byte = first_byte; | 1806 current_byte = first_byte; |
1807 | 1807 |
1808 if (*bytes_in_rx_buffer) { | 1808 if (*bytes_in_rx_buffer) { |
1809 | 1809 |
1810 | 1810 |
1811 /* The Rx buffer is not empty and is being used by HISR ! */ | 1811 /* The Rx buffer is not empty and is being used by HISR ! */ |
1812 /* Hence stop the flow control */ | 1812 /* Hence stop the flow control */ |
1813 stop_receiver (uart); | 1813 stop_receiver (uart); |
1814 | 1814 |
1815 /* | 1815 /* |
1816 * Reset LCR[7] (DLAB) to have access to the RBR, THR and IER registers. | 1816 * Reset LCR[7] (DLAB) to have access to the RBR, THR and IER registers. |
1817 */ | 1817 */ |
1818 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); | 1818 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
1819 | 1819 |
1820 /* Mask The Rx and interrupt */ | 1820 /* Mask The Rx and interrupt */ |
1821 | 1821 |
1822 WRITE_UART_REGISTER ( | 1822 WRITE_UART_REGISTER ( |
1823 uart, IER, READ_UART_REGISTER (uart, IER) & | 1823 uart, IER, READ_UART_REGISTER (uart, IER) & |
1824 ~(ERBI | EDSSI)); | 1824 ~(ERBI | EDSSI)); |
1825 | 1825 |
1826 uart->rx_stopped_by_lisr = 1; | 1826 uart->rx_stopped_by_lisr = 1; |
1827 return (bytes_received); | 1827 return (bytes_received); |
1828 | 1828 |
1829 } | 1829 } |
1830 | 1830 |
1831 uart->rx_buffer_used_by_rx_lisr = first_byte; | 1831 uart->rx_buffer_used_by_rx_lisr = first_byte; |
1832 | 1832 |
1833 status = READ_UART_REGISTER (uart, LSR); | 1833 status = READ_UART_REGISTER (uart, LSR); |
1834 | 1834 |
1835 /* | 1835 /* |
1836 * Build an array with the bytes contained in the RX FIFO. | 1836 * Build an array with the bytes contained in the RX FIFO. |
1837 */ | 1837 */ |
1860 /* | 1860 /* |
1861 * Check break detection. | 1861 * Check break detection. |
1862 */ | 1862 */ |
1863 | 1863 |
1864 if (status & BI) { | 1864 if (status & BI) { |
1865 | 1865 |
1866 uart->break_received = 1; | 1866 uart->break_received = 1; |
1867 *(uart->state) |= | 1867 *(uart->state) |= |
1868 ((1 << BRK) | (MINIMAL_BREAK_LENGTH << BRKLEN)); | 1868 ((1 << BRK) | (MINIMAL_BREAK_LENGTH << BRKLEN)); |
1869 } | 1869 } |
1870 | 1870 |
1871 } else /* No error */ | 1871 } else /* No error */ |
1872 current_byte++; | 1872 current_byte++; |
1873 | 1873 |
1874 status = READ_UART_REGISTER (uart, LSR); | 1874 status = READ_UART_REGISTER (uart, LSR); |
1875 } | 1875 } |
1876 | 1876 |
1880 /* | 1880 /* |
1881 * Re-switch to the other buffer if no valid character has been received. | 1881 * Re-switch to the other buffer if no valid character has been received. |
1882 */ | 1882 */ |
1883 | 1883 |
1884 if (!bytes_received) { | 1884 if (!bytes_received) { |
1885 | 1885 |
1886 if (uart->rx_buffer_used_by_rx_lisr == &(uart->rx_fifo_byte_1[0])) | 1886 if (uart->rx_buffer_used_by_rx_lisr == &(uart->rx_fifo_byte_1[0])) |
1887 uart->rx_buffer_used_by_rx_lisr = &(uart->rx_fifo_byte_2[0]); | 1887 uart->rx_buffer_used_by_rx_lisr = &(uart->rx_fifo_byte_2[0]); |
1888 | 1888 |
1889 else | 1889 else |
1890 uart->rx_buffer_used_by_rx_lisr = &(uart->rx_fifo_byte_1[0]); | 1890 uart->rx_buffer_used_by_rx_lisr = &(uart->rx_fifo_byte_1[0]); |
1891 } | 1891 } |
1892 | 1892 |
1893 if (bytes_received > uart->max_rx_fifo_level) | 1893 if (bytes_received > uart->max_rx_fifo_level) |
1894 uart->max_rx_fifo_level = bytes_received; | 1894 uart->max_rx_fifo_level = bytes_received; |
1895 | 1895 |
1896 return (bytes_received); | 1896 return (bytes_received); |
1897 } | 1897 } |
1898 | 1898 |
1899 /******************************************************************************* | 1899 /******************************************************************************* |
1900 * | 1900 * |
1901 * empty_rx_fifo | 1901 * empty_rx_fifo |
1902 * | 1902 * |
1903 * Purpose : Read the RX FIFO. | 1903 * Purpose : Read the RX FIFO. |
1904 * | 1904 * |
1905 * Arguments: In : uart: Pointer on the UART structure. | 1905 * Arguments: In : uart: Pointer on the UART structure. |
1906 * Out: none | 1906 * Out: none |
1907 * | 1907 * |
1928 } | 1928 } |
1929 | 1929 |
1930 /******************************************************************************* | 1930 /******************************************************************************* |
1931 * | 1931 * |
1932 * hisr_execute_rx_operations | 1932 * hisr_execute_rx_operations |
1933 * | 1933 * |
1934 * Purpose : If an escape sequence is detected or if a break in the detection | 1934 * Purpose : If an escape sequence is detected or if a break in the detection |
1935 * has occured RX FIFO bytes are written in the RX buffer. | 1935 * has occured RX FIFO bytes are written in the RX buffer. |
1936 * If the software flow control is used bytes are analyzed to know | 1936 * If the software flow control is used bytes are analyzed to know |
1937 * if a XON or a XOFF character is received to stop or start the | 1937 * if a XON or a XOFF character is received to stop or start the |
1938 * transmitter. | 1938 * transmitter. |
1939 * If a flow control is used and if the high watermark of the RX | 1939 * If a flow control is used and if the high watermark of the RX |
1940 * buffer is reached the receiver is stopped. | 1940 * buffer is reached the receiver is stopped. |
1941 * If the RX threshold level is reached the callback mechanism is | 1941 * If the RX threshold level is reached the callback mechanism is |
1942 * activated. | 1942 * activated. |
1943 * | 1943 * |
1959 SYS_UWORD8 *current_byte; | 1959 SYS_UWORD8 *current_byte; |
1960 SYS_UWORD8 xon_xoff_detected; | 1960 SYS_UWORD8 xon_xoff_detected; |
1961 t_uart *uart; | 1961 t_uart *uart; |
1962 | 1962 |
1963 uart = &uart_parameters; | 1963 uart = &uart_parameters; |
1964 | 1964 |
1965 /* | 1965 /* |
1966 * Since new characters have been received, the sleep timer is reset then | 1966 * Since new characters have been received, the sleep timer is reset then |
1967 * restarted preventing the system to enter deep-sleep for a new period of | 1967 * restarted preventing the system to enter deep-sleep for a new period of |
1968 * time. | 1968 * time. |
1969 */ | 1969 */ |
1974 #if (UARTFAX_CLASSIC_DTR_DCD || (CHIPSET == 12)) | 1974 #if (UARTFAX_CLASSIC_DTR_DCD || (CHIPSET == 12)) |
1975 uart->index_hisr = (uart->index_hisr + 1) & 0x01; /* 0 or 1 */ | 1975 uart->index_hisr = (uart->index_hisr + 1) & 0x01; /* 0 or 1 */ |
1976 #endif | 1976 #endif |
1977 | 1977 |
1978 xon_xoff_detected = 0; | 1978 xon_xoff_detected = 0; |
1979 | 1979 |
1980 /* | 1980 /* |
1981 * Switch to the other buffer. | 1981 * Switch to the other buffer. |
1982 */ | 1982 */ |
1983 | 1983 |
1984 current_byte = uart->rx_buffer_used_by_rx_hisr; | 1984 current_byte = uart->rx_buffer_used_by_rx_hisr; |
1985 if (current_byte == &(uart->rx_fifo_byte_1[0])) { | 1985 if (current_byte == &(uart->rx_fifo_byte_1[0])) { |
1986 | 1986 |
1987 current_byte = &(uart->rx_fifo_byte_2[0]); | 1987 current_byte = &(uart->rx_fifo_byte_2[0]); |
1988 bytes_read = uart->bytes_in_rx_buffer_2; | 1988 bytes_read = uart->bytes_in_rx_buffer_2; |
1989 | 1989 |
1990 } else { | 1990 } else { |
1991 | 1991 |
1992 current_byte = &(uart->rx_fifo_byte_1[0]); | 1992 current_byte = &(uart->rx_fifo_byte_1[0]); |
1993 bytes_read = uart->bytes_in_rx_buffer_1; | 1993 bytes_read = uart->bytes_in_rx_buffer_1; |
1994 } | 1994 } |
1995 | 1995 |
1996 uart->rx_buffer_used_by_rx_hisr = current_byte; | 1996 uart->rx_buffer_used_by_rx_hisr = current_byte; |
2008 bytes_free_in_rx_buffer = | 2008 bytes_free_in_rx_buffer = |
2009 (SYS_UWORD16) (uart->buffer_size + uart->rx_out - uart->rx_in); | 2009 (SYS_UWORD16) (uart->buffer_size + uart->rx_out - uart->rx_in); |
2010 | 2010 |
2011 wrap_around_counter = uart->buffer_size + 1 - | 2011 wrap_around_counter = uart->buffer_size + 1 - |
2012 (SYS_UWORD16) (uart->rx_in - &(uart->rx_buffer[0])); | 2012 (SYS_UWORD16) (uart->rx_in - &(uart->rx_buffer[0])); |
2013 | 2013 |
2014 if (uart->flow_control_mode == fc_xoff) { | 2014 if (uart->flow_control_mode == fc_xoff) { |
2015 | 2015 |
2016 /* | 2016 /* |
2017 * For SW Flow Control, need to further investigate the processing | 2017 * For SW Flow Control, need to further investigate the processing |
2018 * in order to improve the performance of the driver, and in order | 2018 * in order to improve the performance of the driver, and in order |
2019 * to avoid managing the wrap around of the circular buffer each | 2019 * to avoid managing the wrap around of the circular buffer each |
2020 * time a character is copied. | 2020 * time a character is copied. |
2021 */ | 2021 */ |
2022 | 2022 |
2023 while (bytes_read && bytes_free_in_rx_buffer) { | 2023 while (bytes_read && bytes_free_in_rx_buffer) { |
2024 | 2024 |
2025 /* | 2025 /* |
2026 * If the data received is XON or XOFF, the transmitter is | 2026 * If the data received is XON or XOFF, the transmitter is |
2027 * enabled (XON) or disabled (XOFF). | 2027 * enabled (XON) or disabled (XOFF). |
2039 | 2039 |
2040 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 2040 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
2041 /* | 2041 /* |
2042 * Disable sleep mode. | 2042 * Disable sleep mode. |
2043 */ | 2043 */ |
2044 | 2044 |
2045 WRITE_UART_REGISTER ( | 2045 WRITE_UART_REGISTER ( |
2046 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 2046 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
2047 #endif | 2047 #endif |
2048 | 2048 |
2049 /* | 2049 /* |
2050 * Unmask Tx interrupt. | 2050 * Unmask Tx interrupt. |
2051 */ | 2051 */ |
2052 | 2052 |
2053 WRITE_UART_REGISTER ( | 2053 WRITE_UART_REGISTER ( |
2054 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); | 2054 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); |
2055 | 2055 |
2056 } else { | 2056 } else { |
2057 | 2057 |
2058 *(uart->rx_in++) = *current_byte; | 2058 *(uart->rx_in++) = *current_byte; |
2059 | 2059 |
2060 wrap_around_counter--; | 2060 wrap_around_counter--; |
2061 if (!wrap_around_counter) { | 2061 if (!wrap_around_counter) { |
2062 | 2062 |
2063 uart->rx_in = &(uart->rx_buffer[0]); | 2063 uart->rx_in = &(uart->rx_buffer[0]); |
2064 wrap_around_counter = uart->buffer_size + 1; | 2064 wrap_around_counter = uart->buffer_size + 1; |
2065 } | 2065 } |
2066 | 2066 |
2067 bytes_free_in_rx_buffer--; | 2067 bytes_free_in_rx_buffer--; |
2068 } | 2068 } |
2069 | 2069 |
2070 current_byte++; | 2070 current_byte++; |
2071 bytes_read--; | 2071 bytes_read--; |
2072 } | 2072 } |
2073 } else { /* No Flow Control or HW Flow Control */ | 2073 } else { /* No Flow Control or HW Flow Control */ |
2074 | 2074 |
2075 /* | 2075 /* |
2076 * Figure out the most restricting condition. | 2076 * Figure out the most restricting condition. |
2077 */ | 2077 */ |
2078 | 2078 |
2079 bytes_to_copy = | 2079 bytes_to_copy = |
2080 Min3 (bytes_free_in_rx_buffer, wrap_around_counter, bytes_read); | 2080 Min3 (bytes_free_in_rx_buffer, wrap_around_counter, bytes_read); |
2081 | 2081 |
2082 /* | 2082 /* |
2083 * Copy characters into the circular Rx buffer. | 2083 * Copy characters into the circular Rx buffer. |
2084 */ | 2084 */ |
2085 | 2085 |
2086 memcpy (uart->rx_in, current_byte, bytes_to_copy); | 2086 memcpy (uart->rx_in, current_byte, bytes_to_copy); |
2087 | 2087 |
2088 /* | 2088 /* |
2089 * Update first the variables associated to blocking conditions: | 2089 * Update first the variables associated to blocking conditions: |
2090 * if (bytes_read = 0) OR | 2090 * if (bytes_read = 0) OR |
2091 * (bytes_free_in_rx_buffer = 0) => No more characters to copy. | 2091 * (bytes_free_in_rx_buffer = 0) => No more characters to copy. |
2092 */ | 2092 */ |
2093 | 2093 |
2094 bytes_free_in_rx_buffer -= bytes_to_copy; | 2094 bytes_free_in_rx_buffer -= bytes_to_copy; |
2095 bytes_read -= bytes_to_copy; | 2095 bytes_read -= bytes_to_copy; |
2096 | 2096 |
2097 wrap_around_counter -= bytes_to_copy; | 2097 wrap_around_counter -= bytes_to_copy; |
2098 if (!wrap_around_counter) | 2098 if (!wrap_around_counter) |
2099 uart->rx_in = &(uart->rx_buffer[0]); | 2099 uart->rx_in = &(uart->rx_buffer[0]); |
2100 else | 2100 else |
2101 uart->rx_in += bytes_to_copy; | 2101 uart->rx_in += bytes_to_copy; |
2123 */ | 2123 */ |
2124 | 2124 |
2125 memcpy (uart->rx_in, current_byte, bytes_to_copy); | 2125 memcpy (uart->rx_in, current_byte, bytes_to_copy); |
2126 | 2126 |
2127 uart->rx_in += bytes_to_copy; | 2127 uart->rx_in += bytes_to_copy; |
2128 | 2128 |
2129 /* | 2129 /* |
2130 * bytes_free_in_rx_buffer not updated since not used anymore. | 2130 * bytes_free_in_rx_buffer not updated since not used anymore. |
2131 */ | 2131 */ |
2132 bytes_read -= bytes_to_copy; | 2132 bytes_read -= bytes_to_copy; |
2133 | 2133 |
2134 } | 2134 } |
2135 else { | 2135 else { |
2136 bytes_read = 0; | 2136 bytes_read = 0; |
2137 } | 2137 } |
2138 } /* end if (uart->flow_control_mode == fc_xoff) */ | 2138 } /* end if (uart->flow_control_mode == fc_xoff) */ |
2194 } | 2194 } |
2195 | 2195 |
2196 | 2196 |
2197 | 2197 |
2198 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); | 2198 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
2199 | 2199 |
2200 /* Mask The Rx and Modem status interrupt */ | 2200 /* Mask The Rx and Modem status interrupt */ |
2201 WRITE_UART_REGISTER ( | 2201 WRITE_UART_REGISTER ( |
2202 uart, IER, READ_UART_REGISTER (uart, IER) & | 2202 uart, IER, READ_UART_REGISTER (uart, IER) & |
2203 ~(ERBI | EDSSI)); | 2203 ~(ERBI | EDSSI)); |
2204 | 2204 |
2205 if ((uart->rx_buffer_used_by_rx_hisr) == &(uart->rx_fifo_byte_1[0])) { | 2205 if ((uart->rx_buffer_used_by_rx_hisr) == &(uart->rx_fifo_byte_1[0])) { |
2206 | 2206 |
2207 uart->bytes_in_rx_buffer_1 = 0; | 2207 uart->bytes_in_rx_buffer_1 = 0; |
2208 | 2208 |
2209 } else { | 2209 } else { |
2210 | 2210 |
2211 uart->bytes_in_rx_buffer_2 = 0; | 2211 uart->bytes_in_rx_buffer_2 = 0; |
2212 } | 2212 } |
2213 | 2213 |
2214 | 2214 |
2215 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); | 2215 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
2216 | 2216 |
2217 /* Unmask The Rx and Modem status interrupt*/ | 2217 /* Unmask The Rx and Modem status interrupt*/ |
2218 WRITE_UART_REGISTER ( | 2218 WRITE_UART_REGISTER ( |
2219 uart, IER, READ_UART_REGISTER (uart, IER) | | 2219 uart, IER, READ_UART_REGISTER (uart, IER) | |
2220 (ERBI | EDSSI)); | 2220 (ERBI | EDSSI)); |
2221 | 2221 |
2222 if(uart->rx_stopped_by_lisr ) { | 2222 if(uart->rx_stopped_by_lisr ) { |
2223 if (!uart->rx_stopped_by_driver) { | 2223 if (!uart->rx_stopped_by_driver) { |
2224 | 2224 |
2225 | 2225 |
2226 uart->rx_stopped_by_lisr = 0; | 2226 uart->rx_stopped_by_lisr = 0; |
2227 | 2227 |
2228 /* | 2228 /* |
2229 * Reset LCR[7] (DLAB) to have access to the RBR, THR and IER registers. | 2229 * Reset LCR[7] (DLAB) to have access to the RBR, THR and IER registers. |
2230 */ | 2230 */ |
2231 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); | 2231 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
2232 | 2232 |
2233 | 2233 |
2234 /* UnMask The Rx interrupt */ | 2234 /* UnMask The Rx interrupt */ |
2235 WRITE_UART_REGISTER ( | 2235 WRITE_UART_REGISTER ( |
2236 uart, IER, READ_UART_REGISTER (uart, IER) | | 2236 uart, IER, READ_UART_REGISTER (uart, IER) | |
2237 (ERBI | EDSSI)); | 2237 (ERBI | EDSSI)); |
2238 | 2238 |
2239 start_receiver (uart); | 2239 start_receiver (uart); |
2240 | 2240 |
2241 } | 2241 } |
2242 } | 2242 } |
2243 | 2243 |
2244 } | 2244 } |
2245 | 2245 |
2246 /******************************************************************************* | 2246 /******************************************************************************* |
2247 * | 2247 * |
2248 * hisr_execute_v24_operations | 2248 * hisr_execute_v24_operations |
2249 * | 2249 * |
2250 * Purpose : The user's function is called if all conditions to call it are | 2250 * Purpose : The user's function is called if all conditions to call it are |
2251 * fulfiled. | 2251 * fulfiled. |
2252 * | 2252 * |
2253 * Arguments: In : none | 2253 * Arguments: In : none |
2254 * Out: none | 2254 * Out: none |
2283 } | 2283 } |
2284 | 2284 |
2285 /******************************************************************************* | 2285 /******************************************************************************* |
2286 * | 2286 * |
2287 * hisr_execute_tx_operations | 2287 * hisr_execute_tx_operations |
2288 * | 2288 * |
2289 * Purpose : Writes bytes from the TX buffer to the TX FIFO. | 2289 * Purpose : Writes bytes from the TX buffer to the TX FIFO. |
2290 * The user's function is called if all conditions to call it are | 2290 * The user's function is called if all conditions to call it are |
2291 * fulfiled. | 2291 * fulfiled. |
2292 * | 2292 * |
2293 * Arguments: In : none | 2293 * Arguments: In : none |
2319 */ | 2319 */ |
2320 | 2320 |
2321 if (READ_UART_REGISTER (uart, LSR) & THRE) { | 2321 if (READ_UART_REGISTER (uart, LSR) & THRE) { |
2322 | 2322 |
2323 bytes_in_tx_fifo = 0; | 2323 bytes_in_tx_fifo = 0; |
2324 | 2324 |
2325 /* | 2325 /* |
2326 * A request to send a XON/XOFF character may have been done by the | 2326 * A request to send a XON/XOFF character may have been done by the |
2327 * RX interrupt handler. The byte can be written because we are sure | 2327 * RX interrupt handler. The byte can be written because we are sure |
2328 * that the TX FIFO is not full. | 2328 * that the TX FIFO is not full. |
2329 */ | 2329 */ |
2330 | 2330 |
2331 if (uart->send_xon_xoff) { | 2331 if (uart->send_xon_xoff) { |
2451 if (bytes_in_tx_fifo) | 2451 if (bytes_in_tx_fifo) |
2452 | 2452 |
2453 /* | 2453 /* |
2454 * Unmask Tx interrupt. | 2454 * Unmask Tx interrupt. |
2455 */ | 2455 */ |
2456 | 2456 |
2457 WRITE_UART_REGISTER ( | 2457 WRITE_UART_REGISTER ( |
2458 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); | 2458 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); |
2459 | 2459 |
2460 else { | 2460 else { |
2461 | 2461 |
2479 } | 2479 } |
2480 | 2480 |
2481 /******************************************************************************* | 2481 /******************************************************************************* |
2482 * | 2482 * |
2483 * read_rx_fifo | 2483 * read_rx_fifo |
2484 * | 2484 * |
2485 * Purpose : Reads the RX FIFO. If the driver is enabled bytes are written in | 2485 * Purpose : Reads the RX FIFO. If the driver is enabled bytes are written in |
2486 * an array to be analyzed by the RX HISR. | 2486 * an array to be analyzed by the RX HISR. |
2487 * | 2487 * |
2488 * Arguments: In : uart: Pointer on the UART structure. | 2488 * Arguments: In : uart: Pointer on the UART structure. |
2489 * Out: none | 2489 * Out: none |
2499 /* | 2499 /* |
2500 * If the driver is disabled the RX FIFO is read to acknoledge the | 2500 * If the driver is disabled the RX FIFO is read to acknoledge the |
2501 * interrupt else bytes received are written into an array which will be | 2501 * interrupt else bytes received are written into an array which will be |
2502 * analyzed from the RX HISR. | 2502 * analyzed from the RX HISR. |
2503 */ | 2503 */ |
2504 | 2504 |
2505 if (DRIVER_DISABLED (uart)) | 2505 if (DRIVER_DISABLED (uart)) |
2506 empty_rx_fifo (uart); | 2506 empty_rx_fifo (uart); |
2507 | 2507 |
2508 else if (build_rx_fifo_array (uart)){ | 2508 else if (build_rx_fifo_array (uart)){ |
2509 (void) NU_Activate_HISR (&(uart->rx_hisr_ctrl_block)); | 2509 (void) NU_Activate_HISR (&(uart->rx_hisr_ctrl_block)); |
2510 | 2510 |
2511 } | 2511 } |
2512 | 2512 |
2513 | 2513 |
2514 } | 2514 } |
2515 | 2515 |
2516 /******************************************************************************* | 2516 /******************************************************************************* |
2517 * | 2517 * |
2518 * check_v24_input_lines | 2518 * check_v24_input_lines |
2519 * | 2519 * |
2520 * Purpose : Check the V.24 input lines. According to the states of the input | 2520 * Purpose : Check the V.24 input lines. According to the states of the input |
2521 * lines and to the flow control mode selected, the transmitter is | 2521 * lines and to the flow control mode selected, the transmitter is |
2522 * enabled or disabled. The reading callback function is called if | 2522 * enabled or disabled. The reading callback function is called if |
2523 * it is installed and if all conditions are fulfiled. | 2523 * it is installed and if all conditions are fulfiled. |
2524 * | 2524 * |
2564 /* | 2564 /* |
2565 * The reading callback function has to be called. But bytes received before | 2565 * The reading callback function has to be called. But bytes received before |
2566 * the change of state of DTR must be copied into the RX buffer before to | 2566 * the change of state of DTR must be copied into the RX buffer before to |
2567 * call it. | 2567 * call it. |
2568 */ | 2568 */ |
2569 | 2569 |
2570 if (READ_UART_REGISTER (uart, LSR) & DR) { /* If Rx FIFO is not empty */ | 2570 if (READ_UART_REGISTER (uart, LSR) & DR) { /* If Rx FIFO is not empty */ |
2571 | 2571 |
2572 /* | 2572 /* |
2573 * The Rx FIFO will be read to fill one of the two buffers and the Rx | 2573 * The Rx FIFO will be read to fill one of the two buffers and the Rx |
2574 * HISR will be activated. | 2574 * HISR will be activated. |
2575 */ | 2575 */ |
2576 | 2576 |
2577 uart->index_it = (uart->index_it + 1) & 0x01; /* 0 or 1 */ | 2577 uart->index_it = (uart->index_it + 1) & 0x01; /* 0 or 1 */ |
2578 uart->dtr_change_detected[uart->index_it] = 1; | 2578 uart->dtr_change_detected[uart->index_it] = 1; |
2579 uart->dtr_level_saved[uart->index_it] = uart->dtr_level; | 2579 uart->dtr_level_saved[uart->index_it] = uart->dtr_level; |
2580 read_rx_fifo (uart); | 2580 read_rx_fifo (uart); |
2581 | 2581 |
2582 } else | 2582 } else |
2583 v24_input_line_changed = 1; | 2583 v24_input_line_changed = 1; |
2584 } | 2584 } |
2585 #endif | 2585 #endif |
2586 | 2586 |
2588 * When the hardware flow control is selected, if the RS 232 input signal is | 2588 * When the hardware flow control is selected, if the RS 232 input signal is |
2589 * deactivated (low), the transmitter is stopped. | 2589 * deactivated (low), the transmitter is stopped. |
2590 */ | 2590 */ |
2591 | 2591 |
2592 if (uart->flow_control_mode == fc_rts) { | 2592 if (uart->flow_control_mode == fc_rts) { |
2593 | 2593 |
2594 if (uart->rts_level) { | 2594 if (uart->rts_level) { |
2595 uart->tx_stopped_by_driver = 1; | 2595 uart->tx_stopped_by_driver = 1; |
2596 } | 2596 } |
2597 | 2597 |
2598 else { | 2598 else { |
2599 | 2599 |
2600 uart->tx_stopped_by_driver = 0; | 2600 uart->tx_stopped_by_driver = 0; |
2601 #ifdef CONFIG_TARGET_GTAMODEM | 2601 #ifdef CONFIG_TARGET_GTAMODEM |
2602 AI_ResetBit(1); | 2602 AI_ResetBit(1); |
2603 #elif defined(CONFIG_TANGO_MODEM) | 2603 #elif defined(CONFIG_TANGO_MODEM) |
2604 if (AI_Tango_pinmux[0] == 0x82) | 2604 if (AI_Tango_pinmux[0] == 0x82) |
2607 | 2607 |
2608 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 2608 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
2609 /* | 2609 /* |
2610 * Disable sleep mode. | 2610 * Disable sleep mode. |
2611 */ | 2611 */ |
2612 | 2612 |
2613 WRITE_UART_REGISTER ( | 2613 WRITE_UART_REGISTER ( |
2614 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 2614 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
2615 #endif | 2615 #endif |
2616 | 2616 |
2617 /* | 2617 /* |
2629 } | 2629 } |
2630 | 2630 |
2631 /******************************************************************************* | 2631 /******************************************************************************* |
2632 * | 2632 * |
2633 * fill_tx_fifo | 2633 * fill_tx_fifo |
2634 * | 2634 * |
2635 * Purpose : If the TX buffer is not empty, and if there is no break in | 2635 * Purpose : If the TX buffer is not empty, and if there is no break in |
2636 * progress, bytes are written into the TX FIFO until the TX FIFO is | 2636 * progress, bytes are written into the TX FIFO until the TX FIFO is |
2637 * full or the TX buffer is empty. Else, if there is a break to send | 2637 * full or the TX buffer is empty. Else, if there is a break to send |
2638 * an all 0s character is written into the TX FIFO and a break is | 2638 * an all 0s character is written into the TX FIFO and a break is |
2639 * declared in progress to avoid to fill the TX FIFO on the next | 2639 * declared in progress to avoid to fill the TX FIFO on the next |
2641 * When the TX FIFO is empty and if a break is in progress, the break | 2641 * When the TX FIFO is empty and if a break is in progress, the break |
2642 * length is programmed: all 0s characters are written into the TX | 2642 * length is programmed: all 0s characters are written into the TX |
2643 * FIFO. The number of bytes has been defined previously with the | 2643 * FIFO. The number of bytes has been defined previously with the |
2644 * UAF_SetLineState function. The break condition is enabled. | 2644 * UAF_SetLineState function. The break condition is enabled. |
2645 * When the TX FIFO and the transmitter shift register (TSR) are both | 2645 * When the TX FIFO and the transmitter shift register (TSR) are both |
2646 * empty and if a break is in progress, the break condition is | 2646 * empty and if a break is in progress, the break condition is |
2647 * disabled. | 2647 * disabled. |
2648 * When bytes are written from the TX buffer to the TX FIFO, the | 2648 * When bytes are written from the TX buffer to the TX FIFO, the |
2649 * writing callback function is called if it is installed and if all | 2649 * writing callback function is called if it is installed and if all |
2650 * conditions are fulfiled. | 2650 * conditions are fulfiled. |
2651 * | 2651 * |
2679 * If a break is in progress, bytes of the TX buffer are not written into | 2679 * If a break is in progress, bytes of the TX buffer are not written into |
2680 * the TX FIFO. | 2680 * the TX FIFO. |
2681 */ | 2681 */ |
2682 | 2682 |
2683 if (!uart->break_in_progress) | 2683 if (!uart->break_in_progress) |
2684 (void) NU_Activate_HISR (&(uart->tx_hisr_ctrl_block)); | 2684 (void) NU_Activate_HISR (&(uart->tx_hisr_ctrl_block)); |
2685 | 2685 |
2686 else { | 2686 else { |
2687 | 2687 |
2688 /* | 2688 /* |
2689 * The break HISR is activated and the break condition is cleared. | 2689 * The break HISR is activated and the break condition is cleared. |
2697 } | 2697 } |
2698 | 2698 |
2699 /******************************************************************************* | 2699 /******************************************************************************* |
2700 * | 2700 * |
2701 * UAF_Init | 2701 * UAF_Init |
2702 * | 2702 * |
2703 * Purpose : Initializes the UART hardware and installs interrupt handlers. | 2703 * Purpose : Initializes the UART hardware and installs interrupt handlers. |
2704 * The parameters are set to the default values: | 2704 * The parameters are set to the default values: |
2705 * - 19200 baud, | 2705 * - 19200 baud, |
2706 * - 8 bits / character, | 2706 * - 8 bits / character, |
2707 * - no parity, | 2707 * - no parity, |
2741 /* | 2741 /* |
2742 * Create the 3 HISR actived in the RX/TX and V24 interrupt handlers. | 2742 * Create the 3 HISR actived in the RX/TX and V24 interrupt handlers. |
2743 * A return is used to simplify the code if an error occurs. | 2743 * A return is used to simplify the code if an error occurs. |
2744 * All stacks are entirely filled with the pattern 0xFE. | 2744 * All stacks are entirely filled with the pattern 0xFE. |
2745 */ | 2745 */ |
2746 | 2746 |
2747 memset (&(uart->rx_hisr_stack[0]), 0xFE, RX_HISR_STACK_SIZE); | 2747 memset (&(uart->rx_hisr_stack[0]), 0xFE, RX_HISR_STACK_SIZE); |
2748 | 2748 |
2749 if (NU_Create_HISR (&(uart->rx_hisr_ctrl_block), | 2749 if (NU_Create_HISR (&(uart->rx_hisr_ctrl_block), |
2750 "UAF_Rx", | 2750 "UAF_Rx", |
2751 hisr_execute_rx_operations, | 2751 hisr_execute_rx_operations, |
2828 * These data are used to send a break. | 2828 * These data are used to send a break. |
2829 * A character has: 8 data bits + 1 start bit + 1 stop bit = 10 bits. | 2829 * A character has: 8 data bits + 1 start bit + 1 stop bit = 10 bits. |
2830 */ | 2830 */ |
2831 | 2831 |
2832 uart->baudrate = baudrate_value[FD_BAUD_19200]; | 2832 uart->baudrate = baudrate_value[FD_BAUD_19200]; |
2833 uart->autobauding = 0; | 2833 uart->autobauding = 0; |
2834 uart->bits_per_char = 10; | 2834 uart->bits_per_char = 10; |
2835 | 2835 |
2836 /* | 2836 /* |
2837 * UART base address. | 2837 * UART base address. |
2838 */ | 2838 */ |
2840 uart->base_address = base_address[uartNo]; | 2840 uart->base_address = base_address[uartNo]; |
2841 | 2841 |
2842 /* | 2842 /* |
2843 * Select the current array used to store received bytes. | 2843 * Select the current array used to store received bytes. |
2844 */ | 2844 */ |
2845 | 2845 |
2846 uart->rx_buffer_used_by_rx_lisr = &(uart->rx_fifo_byte_2[0]); | 2846 uart->rx_buffer_used_by_rx_lisr = &(uart->rx_fifo_byte_2[0]); |
2847 uart->rx_buffer_used_by_rx_hisr = &(uart->rx_fifo_byte_2[0]); | 2847 uart->rx_buffer_used_by_rx_hisr = &(uart->rx_fifo_byte_2[0]); |
2848 | 2848 |
2849 /* | 2849 /* |
2850 * RX and TX buffers. | 2850 * RX and TX buffers. |
2851 */ | 2851 */ |
2852 | 2852 |
2853 uart->buffer_size = FD_MAX_BUFFER_SIZE; | 2853 uart->buffer_size = FD_MAX_BUFFER_SIZE; |
2927 WRITE_UART_REGISTER (uart, IER, 0x00); | 2927 WRITE_UART_REGISTER (uart, IER, 0x00); |
2928 | 2928 |
2929 /* | 2929 /* |
2930 * Reset UART mode configuration. | 2930 * Reset UART mode configuration. |
2931 */ | 2931 */ |
2932 | 2932 |
2933 WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE | | 2933 WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE | |
2934 IR_SLEEP_DISABLED | | 2934 IR_SLEEP_DISABLED | |
2935 SIR_TX_WITHOUT_ACREG2 | | 2935 SIR_TX_WITHOUT_ACREG2 | |
2936 FRAME_LENGTH_METHOD); | 2936 FRAME_LENGTH_METHOD); |
2937 | 2937 |
2938 /* | 2938 /* |
2939 * FIFO configuration. | 2939 * FIFO configuration. |
2940 * EFR[4] = 1 to allow to program FCR[5:4] and MCR[7:5]. | 2940 * EFR[4] = 1 to allow to program FCR[5:4] and MCR[7:5]. |
2941 */ | 2941 */ |
2942 | 2942 |
2943 WRITE_UART_REGISTER (uart, LCR, 0xBF); | 2943 WRITE_UART_REGISTER (uart, LCR, 0xBF); |
2944 SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT); | 2944 SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT); |
2945 | 2945 |
2946 /* | 2946 /* |
2947 * Select the word length, the number of stop bits , the parity and set | 2947 * Select the word length, the number of stop bits , the parity and set |
2952 | 2952 |
2953 /* | 2953 /* |
2954 * Program the trigger levels. | 2954 * Program the trigger levels. |
2955 * MCR[6] must be set to 1. | 2955 * MCR[6] must be set to 1. |
2956 */ | 2956 */ |
2957 | 2957 |
2958 SET_BIT (uart, MCR, TCR_TLR_BIT); | 2958 SET_BIT (uart, MCR, TCR_TLR_BIT); |
2959 WRITE_UART_REGISTER (uart, TCR, 0x0F); | 2959 WRITE_UART_REGISTER (uart, TCR, 0x0F); |
2960 WRITE_UART_REGISTER (uart, TLR, RX_FIFO_TRIGGER_LEVEL); | 2960 WRITE_UART_REGISTER (uart, TLR, RX_FIFO_TRIGGER_LEVEL); |
2961 RESET_BIT (uart, MCR, TCR_TLR_BIT); | 2961 RESET_BIT (uart, MCR, TCR_TLR_BIT); |
2962 | 2962 |
2964 * Force the generation of THR_IT on TX FIFO empty: SCR[3] = 1. | 2964 * Force the generation of THR_IT on TX FIFO empty: SCR[3] = 1. |
2965 */ | 2965 */ |
2966 | 2966 |
2967 WRITE_UART_REGISTER ( | 2967 WRITE_UART_REGISTER ( |
2968 uart, SCR, READ_UART_REGISTER (uart, SCR) | TX_EMPTY_CTL_IT); | 2968 uart, SCR, READ_UART_REGISTER (uart, SCR) | TX_EMPTY_CTL_IT); |
2969 | 2969 |
2970 /* | 2970 /* |
2971 * Program the FIFO control register. Bit 0 must be set when other FCR bits | 2971 * Program the FIFO control register. Bit 0 must be set when other FCR bits |
2972 * are written to or they are not programmed. | 2972 * are written to or they are not programmed. |
2973 * FCR is a write-only register. It will not be modified. | 2973 * FCR is a write-only register. It will not be modified. |
2974 */ | 2974 */ |
2991 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); | 2991 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
2992 | 2992 |
2993 /* | 2993 /* |
2994 * Select UART mode. | 2994 * Select UART mode. |
2995 */ | 2995 */ |
2996 | 2996 |
2997 WRITE_UART_REGISTER (uart, MDR1, UART_MODE | | 2997 WRITE_UART_REGISTER (uart, MDR1, UART_MODE | |
2998 IR_SLEEP_DISABLED | | 2998 IR_SLEEP_DISABLED | |
2999 SIR_TX_WITHOUT_ACREG2 | | 2999 SIR_TX_WITHOUT_ACREG2 | |
3000 FRAME_LENGTH_METHOD); | 3000 FRAME_LENGTH_METHOD); |
3001 | 3001 |
3014 /* | 3014 /* |
3015 * On C & D-Sample, 2 I/O are used to control DCD and DTR on UART Modem. | 3015 * On C & D-Sample, 2 I/O are used to control DCD and DTR on UART Modem. |
3016 * DCD: I/O 2 (output) | 3016 * DCD: I/O 2 (output) |
3017 * DTR: I/O 3 (input) | 3017 * DTR: I/O 3 (input) |
3018 */ | 3018 */ |
3019 | 3019 |
3020 #define EXTENDED_MCU_REG (0xFFFEF006) /* Extended MCU register */ | 3020 #define EXTENDED_MCU_REG (0xFFFEF006) /* Extended MCU register */ |
3021 #define ASIC_CONFIG_REG (0xFFFEF008) /* Asic Configuration register */ | 3021 #define ASIC_CONFIG_REG (0xFFFEF008) /* Asic Configuration register */ |
3022 | 3022 |
3023 #define IO_DTR (10) /* I/O 3; bit 10 of Asic Configuration register */ | 3023 #define IO_DTR (10) /* I/O 3; bit 10 of Asic Configuration register */ |
3024 #define IO_DCD ( 6) /* I/O 2; bit 6 of Extended MCU register */ | 3024 #define IO_DCD ( 6) /* I/O 2; bit 6 of Extended MCU register */ |
3041 /* | 3041 /* |
3042 * Select I/O for DTR and configure it as input. | 3042 * Select I/O for DTR and configure it as input. |
3043 * An interrupt is used to detect a change of state of DTR. Falling edge | 3043 * An interrupt is used to detect a change of state of DTR. Falling edge |
3044 * or rising edge is selected according to the state of DTR. | 3044 * or rising edge is selected according to the state of DTR. |
3045 */ | 3045 */ |
3046 | 3046 |
3047 #ifdef CONFIG_TANGO_MODEM | 3047 #ifdef CONFIG_TANGO_MODEM |
3048 if (AI_Tango_pinmux[1] & 0x80) { | 3048 if (AI_Tango_pinmux[1] & 0x80) { |
3049 #endif | 3049 #endif |
3050 *((volatile SYS_UWORD16 *) ASIC_CONFIG_REG) &= ~(1 << IO_DTR); | 3050 *((volatile SYS_UWORD16 *) ASIC_CONFIG_REG) &= ~(1 << IO_DTR); |
3051 AI_ConfigBitAsInput (ARMIO_DTR); | 3051 AI_ConfigBitAsInput (ARMIO_DTR); |
3053 | 3053 |
3054 if (uart->dtr_level) | 3054 if (uart->dtr_level) |
3055 AI_SelectIOForIT (ARMIO_DTR, ARMIO_FALLING_EDGE); | 3055 AI_SelectIOForIT (ARMIO_DTR, ARMIO_FALLING_EDGE); |
3056 else | 3056 else |
3057 AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE); | 3057 AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE); |
3058 | 3058 |
3059 AI_UnmaskIT (ARMIO_MASKIT_GPIO); | 3059 AI_UnmaskIT (ARMIO_MASKIT_GPIO); |
3060 #ifdef CONFIG_TANGO_MODEM | 3060 #ifdef CONFIG_TANGO_MODEM |
3061 } else | 3061 } else |
3062 uart->dtr_level = 0; | 3062 uart->dtr_level = 0; |
3063 #endif | 3063 #endif |
3064 | 3064 |
3065 /* | 3065 /* |
3066 * Reset the 2 indexes of the circular buffer of 2 elements. | 3066 * Reset the 2 indexes of the circular buffer of 2 elements. |
3067 * The circular buffer does not need to be initialized. | 3067 * The circular buffer does not need to be initialized. |
3068 */ | 3068 */ |
3069 | 3069 |
3070 uart->index_it = 0; | 3070 uart->index_it = 0; |
3071 uart->index_hisr = 0; | 3071 uart->index_hisr = 0; |
3072 #elif (CHIPSET == 12) | 3072 #elif (CHIPSET == 12) |
3073 /* | 3073 /* |
3074 * DCD and DTR are directly handled by Calypso+. | 3074 * DCD and DTR are directly handled by Calypso+. |
3090 | 3090 |
3091 /* | 3091 /* |
3092 * Reset the 2 indexes of the circular buffer of 2 elements. | 3092 * Reset the 2 indexes of the circular buffer of 2 elements. |
3093 * The circular buffer does not need to be initialized. | 3093 * The circular buffer does not need to be initialized. |
3094 */ | 3094 */ |
3095 | 3095 |
3096 uart->index_it = 0; | 3096 uart->index_it = 0; |
3097 uart->index_hisr = 0; | 3097 uart->index_hisr = 0; |
3098 #endif /* BOARD == 8, 9, 40 or 41, CHIPSET == 12 */ | 3098 #endif /* BOARD == 8, 9, 40 or 41, CHIPSET == 12 */ |
3099 | 3099 |
3100 /* | 3100 /* |
3101 * Unmask RX interrupt and the modem status interrupt. | 3101 * Unmask RX interrupt and the modem status interrupt. |
3102 */ | 3102 */ |
3103 | 3103 |
3104 WRITE_UART_REGISTER (uart, IER, ERBI | EDSSI); | 3104 WRITE_UART_REGISTER (uart, IER, ERBI | EDSSI); |
3115 } | 3115 } |
3116 | 3116 |
3117 /******************************************************************************* | 3117 /******************************************************************************* |
3118 * | 3118 * |
3119 * UAF_Enable | 3119 * UAF_Enable |
3120 * | 3120 * |
3121 * Purpose : The functionalities of the UART driver are disabled or enabled. | 3121 * Purpose : The functionalities of the UART driver are disabled or enabled. |
3122 * In the deactivated state, all information about the communication | 3122 * In the deactivated state, all information about the communication |
3123 * parameters should be stored and recalled if the driver is again | 3123 * parameters should be stored and recalled if the driver is again |
3124 * enabled. When the driver is enabled the RX and TX buffers are | 3124 * enabled. When the driver is enabled the RX and TX buffers are |
3125 * cleared. | 3125 * cleared. |
3154 return (FD_NOT_SUPPORTED); | 3154 return (FD_NOT_SUPPORTED); |
3155 | 3155 |
3156 /* | 3156 /* |
3157 * There is no case where FD_INTERNAL_ERR may be returned. | 3157 * There is no case where FD_INTERNAL_ERR may be returned. |
3158 */ | 3158 */ |
3159 | 3159 |
3160 uart = &uart_parameters; | 3160 uart = &uart_parameters; |
3161 | 3161 |
3162 if (enable) { | 3162 if (enable) { |
3163 | 3163 |
3164 uart->rx_stopped_by_driver = 0; | 3164 uart->rx_stopped_by_driver = 0; |
3165 | 3165 |
3166 ENABLE_DRIVER (uart); | 3166 ENABLE_DRIVER (uart); |
3167 start_receiver (uart); | 3167 start_receiver (uart); |
3168 | 3168 |
3169 } else { | 3169 } else { |
3170 | 3170 |
3181 } | 3181 } |
3182 | 3182 |
3183 /******************************************************************************* | 3183 /******************************************************************************* |
3184 * | 3184 * |
3185 * UAF_SetComPar | 3185 * UAF_SetComPar |
3186 * | 3186 * |
3187 * Purpose : Sets up the communication parameters: baud rate, bits per | 3187 * Purpose : Sets up the communication parameters: baud rate, bits per |
3188 * character, number of stop bits, parity. | 3188 * character, number of stop bits, parity. |
3189 * | 3189 * |
3190 * Arguments: In : uartNo : Used UART. | 3190 * Arguments: In : uartNo : Used UART. |
3191 * baudrate: Used baud rate. | 3191 * baudrate: Used baud rate. |
3253 #endif | 3253 #endif |
3254 | 3254 |
3255 /* | 3255 /* |
3256 * Reset UART mode configuration. | 3256 * Reset UART mode configuration. |
3257 */ | 3257 */ |
3258 | 3258 |
3259 WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE | | 3259 WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE | |
3260 IR_SLEEP_DISABLED | | 3260 IR_SLEEP_DISABLED | |
3261 SIR_TX_WITHOUT_ACREG2 | | 3261 SIR_TX_WITHOUT_ACREG2 | |
3262 FRAME_LENGTH_METHOD); | 3262 FRAME_LENGTH_METHOD); |
3263 | 3263 |
3264 /* | 3264 /* |
3265 * FIFO configuration. | 3265 * FIFO configuration. |
3266 * EFR[4] = 1 to allow to program FCR[5:4] and MCR[7:5]. | 3266 * EFR[4] = 1 to allow to program FCR[5:4] and MCR[7:5]. |
3267 */ | 3267 */ |
3268 | 3268 |
3269 WRITE_UART_REGISTER (uart, LCR, 0xBF); | 3269 WRITE_UART_REGISTER (uart, LCR, 0xBF); |
3270 SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT); | 3270 SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT); |
3271 | 3271 |
3272 /* | 3272 /* |
3273 * Select the word length, the number of stop bits , the parity and set | 3273 * Select the word length, the number of stop bits , the parity and set |
3278 uart->autobauding = (baudrate == FD_BAUD_AUTO); /* if autobauding enable trigger */ | 3278 uart->autobauding = (baudrate == FD_BAUD_AUTO); /* if autobauding enable trigger */ |
3279 uart->bits_per_char = 1; /* Start bit. */ | 3279 uart->bits_per_char = 1; /* Start bit. */ |
3280 mcr_value = DLAB; | 3280 mcr_value = DLAB; |
3281 | 3281 |
3282 if (bpc == bpc_7) { | 3282 if (bpc == bpc_7) { |
3283 | 3283 |
3284 mcr_value |= WLS_7; | 3284 mcr_value |= WLS_7; |
3285 uart->bits_per_char += 7; | 3285 uart->bits_per_char += 7; |
3286 | 3286 |
3287 } else { | 3287 } else { |
3288 | 3288 |
3327 | 3327 |
3328 /* | 3328 /* |
3329 * Program the trigger levels. | 3329 * Program the trigger levels. |
3330 * MCR[6] must be set to 1. | 3330 * MCR[6] must be set to 1. |
3331 */ | 3331 */ |
3332 | 3332 |
3333 SET_BIT (uart, MCR, TCR_TLR_BIT); | 3333 SET_BIT (uart, MCR, TCR_TLR_BIT); |
3334 WRITE_UART_REGISTER (uart, TCR, 0x0F); | 3334 WRITE_UART_REGISTER (uart, TCR, 0x0F); |
3335 WRITE_UART_REGISTER (uart, TLR, RX_FIFO_TRIGGER_LEVEL); | 3335 WRITE_UART_REGISTER (uart, TLR, RX_FIFO_TRIGGER_LEVEL); |
3336 RESET_BIT (uart, MCR, TCR_TLR_BIT); | 3336 RESET_BIT (uart, MCR, TCR_TLR_BIT); |
3337 | 3337 |
3339 * Force the generation of THR_IT on TX FIFO empty: SCR[3] = 1. | 3339 * Force the generation of THR_IT on TX FIFO empty: SCR[3] = 1. |
3340 */ | 3340 */ |
3341 | 3341 |
3342 WRITE_UART_REGISTER ( | 3342 WRITE_UART_REGISTER ( |
3343 uart, SCR, READ_UART_REGISTER (uart, SCR) | TX_EMPTY_CTL_IT); | 3343 uart, SCR, READ_UART_REGISTER (uart, SCR) | TX_EMPTY_CTL_IT); |
3344 | 3344 |
3345 /* | 3345 /* |
3346 * Program the FIFO control register. Bit 0 must be set when other FCR bits | 3346 * Program the FIFO control register. Bit 0 must be set when other FCR bits |
3347 * are written to or they are not programmed. | 3347 * are written to or they are not programmed. |
3348 * FCR is a write-only register. It will not be modified. | 3348 * FCR is a write-only register. It will not be modified. |
3349 */ | 3349 */ |
3366 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); | 3366 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
3367 | 3367 |
3368 /* | 3368 /* |
3369 * Select UART mode. | 3369 * Select UART mode. |
3370 */ | 3370 */ |
3371 | 3371 |
3372 WRITE_UART_REGISTER (uart, MDR1, ((baudrate==FD_BAUD_AUTO)? | 3372 WRITE_UART_REGISTER (uart, MDR1, ((baudrate==FD_BAUD_AUTO)? |
3373 UART_MODE_AUTOBAUDING: | 3373 UART_MODE_AUTOBAUDING: |
3374 UART_MODE) | | 3374 UART_MODE) | |
3375 IR_SLEEP_DISABLED | | 3375 IR_SLEEP_DISABLED | |
3376 SIR_TX_WITHOUT_ACREG2 | | 3376 SIR_TX_WITHOUT_ACREG2 | |
3389 | 3389 |
3390 #if UARTFAX_CLASSIC_DTR_DCD | 3390 #if UARTFAX_CLASSIC_DTR_DCD |
3391 /* | 3391 /* |
3392 * Read the state of DTR and select the edge. | 3392 * Read the state of DTR and select the edge. |
3393 */ | 3393 */ |
3394 | 3394 |
3395 #ifdef CONFIG_TANGO_MODEM | 3395 #ifdef CONFIG_TANGO_MODEM |
3396 if (AI_Tango_pinmux[1] & 0x80) { | 3396 if (AI_Tango_pinmux[1] & 0x80) { |
3397 #endif | 3397 #endif |
3398 uart->dtr_level = AI_ReadBit (ARMIO_DTR); | 3398 uart->dtr_level = AI_ReadBit (ARMIO_DTR); |
3399 | 3399 |
3400 if (uart->dtr_level) | 3400 if (uart->dtr_level) |
3401 AI_SelectIOForIT (ARMIO_DTR, ARMIO_FALLING_EDGE); | 3401 AI_SelectIOForIT (ARMIO_DTR, ARMIO_FALLING_EDGE); |
3402 else | 3402 else |
3403 AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE); | 3403 AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE); |
3404 | 3404 |
3405 AI_UnmaskIT (ARMIO_MASKIT_GPIO); | 3405 AI_UnmaskIT (ARMIO_MASKIT_GPIO); |
3406 #ifdef CONFIG_TANGO_MODEM | 3406 #ifdef CONFIG_TANGO_MODEM |
3407 } else | 3407 } else |
3408 uart->dtr_level = 0; | 3408 uart->dtr_level = 0; |
3409 #endif | 3409 #endif |
3420 uart->dtr_level = 1; | 3420 uart->dtr_level = 1; |
3421 #endif | 3421 #endif |
3422 | 3422 |
3423 #if ((CHIPSET == 5) || (CHIPSET == 6)) | 3423 #if ((CHIPSET == 5) || (CHIPSET == 6)) |
3424 /* | 3424 /* |
3425 * Unmask RX and TX interrupts and the modem status interrupt. | 3425 * Unmask RX and TX interrupts and the modem status interrupt. |
3426 */ | 3426 */ |
3427 | 3427 |
3428 WRITE_UART_REGISTER (uart, IER, ERBI | ETBEI | EDSSI); | 3428 WRITE_UART_REGISTER (uart, IER, ERBI | ETBEI | EDSSI); |
3429 #elif (CHIPSET == 12) | 3429 #elif (CHIPSET == 12) |
3430 /* | 3430 /* |
3431 * Unmask RX and TX interrupts and the modem status interrupt... | 3431 * Unmask RX and TX interrupts and the modem status interrupt... |
3432 */ | 3432 */ |
3433 | 3433 |
3434 WRITE_UART_REGISTER (uart, IER, ERBI | ETBEI | EDSSI); | 3434 WRITE_UART_REGISTER (uart, IER, ERBI | ETBEI | EDSSI); |
3435 | 3435 |
3436 /* | 3436 /* |
3437 * ... Then, unmask DSR interrupt... | 3437 * ... Then, unmask DSR interrupt... |
3438 */ | 3438 */ |
3439 | 3439 |
3440 ENABLE_DSR_INTERRUPT (uart); | 3440 ENABLE_DSR_INTERRUPT (uart); |
3441 | 3441 |
3442 /* | 3442 /* |
3443 * ... And finally allow sleep mode. | 3443 * ... And finally allow sleep mode. |
3444 */ | 3444 */ |
3445 | 3445 |
3447 /* | 3447 /* |
3448 WRITE_UART_REGISTER (uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); | 3448 WRITE_UART_REGISTER (uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
3449 */ | 3449 */ |
3450 #else | 3450 #else |
3451 /* | 3451 /* |
3452 * Unmask RX and TX interrupts and the modem status interrupt | 3452 * Unmask RX and TX interrupts and the modem status interrupt |
3453 * and allow sleep mode. | 3453 * and allow sleep mode. |
3454 */ | 3454 */ |
3455 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ | 3455 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ |
3456 | 3456 |
3457 /* WRITE_UART_REGISTER (uart, IER, ERBI | ETBEI | EDSSI | IER_SLEEP);*/ | 3457 /* WRITE_UART_REGISTER (uart, IER, ERBI | ETBEI | EDSSI | IER_SLEEP);*/ |
3464 } | 3464 } |
3465 | 3465 |
3466 /******************************************************************************* | 3466 /******************************************************************************* |
3467 * | 3467 * |
3468 * UAF_SetBuffer | 3468 * UAF_SetBuffer |
3469 * | 3469 * |
3470 * Purpose : Sets up the size of the circular buffers to be used in the UART | 3470 * Purpose : Sets up the size of the circular buffers to be used in the UART |
3471 * driver. This function may be called only if the UART is disabled | 3471 * driver. This function may be called only if the UART is disabled |
3472 * with UAF_Enable. | 3472 * with UAF_Enable. |
3473 * | 3473 * |
3474 * Arguments: In : uartNo : Used UART. | 3474 * Arguments: In : uartNo : Used UART. |
3518 (txThreshold > FD_MAX_BUFFER_SIZE)) | 3518 (txThreshold > FD_MAX_BUFFER_SIZE)) |
3519 | 3519 |
3520 result = FD_NOT_SUPPORTED; | 3520 result = FD_NOT_SUPPORTED; |
3521 | 3521 |
3522 else { | 3522 else { |
3523 | 3523 |
3524 uart = &uart_parameters; | 3524 uart = &uart_parameters; |
3525 | 3525 |
3526 if (!DRIVER_DISABLED (uart)) | 3526 if (!DRIVER_DISABLED (uart)) |
3527 result = FD_INTERNAL_ERR; | 3527 result = FD_INTERNAL_ERR; |
3528 | 3528 |
3529 else if (RX_HIGH_WATERMARK (bufSize) < RX_LOW_WATERMARK (bufSize)) | 3529 else if (RX_HIGH_WATERMARK (bufSize) < RX_LOW_WATERMARK (bufSize)) |
3530 result = FD_NOT_SUPPORTED; | 3530 result = FD_NOT_SUPPORTED; |
3531 | 3531 |
3532 else { | 3532 else { |
3533 | 3533 |
3534 uart->buffer_size = bufSize; | 3534 uart->buffer_size = bufSize; |
3535 uart->rx_threshold_level = rxThreshold; | 3535 uart->rx_threshold_level = rxThreshold; |
3536 uart->tx_threshold_level = txThreshold; | 3536 uart->tx_threshold_level = txThreshold; |
3537 | 3537 |
3538 result = FD_OK; | 3538 result = FD_OK; |
3543 } | 3543 } |
3544 | 3544 |
3545 /******************************************************************************* | 3545 /******************************************************************************* |
3546 * | 3546 * |
3547 * UAF_SetFlowCtrl | 3547 * UAF_SetFlowCtrl |
3548 * | 3548 * |
3549 * Purpose : Changes the flow control mode of the UART driver. | 3549 * Purpose : Changes the flow control mode of the UART driver. |
3550 * If a flow control is activated, DTR is activated or XOFF is sent | 3550 * If a flow control is activated, DTR is activated or XOFF is sent |
3551 * if the RX buffer is not able to store the received characters else | 3551 * if the RX buffer is not able to store the received characters else |
3552 * DTR is deactivated or XON is sent. | 3552 * DTR is deactivated or XON is sent. |
3553 * | 3553 * |
3592 | 3592 |
3593 if (fcMode == fc_dtr) | 3593 if (fcMode == fc_dtr) |
3594 result = FD_NOT_SUPPORTED; | 3594 result = FD_NOT_SUPPORTED; |
3595 | 3595 |
3596 else { | 3596 else { |
3597 | 3597 |
3598 uart = &uart_parameters; | 3598 uart = &uart_parameters; |
3599 | 3599 |
3600 uart->tx_stopped_by_driver = 0; | 3600 uart->tx_stopped_by_driver = 0; |
3601 | 3601 |
3602 | 3602 |
3603 uart->xon_character = XON; | 3603 uart->xon_character = XON; |
3604 uart->xoff_character = XOFF; | 3604 uart->xoff_character = XOFF; |
3605 uart->flow_control_mode = fcMode; | 3605 uart->flow_control_mode = fcMode; |
3606 | 3606 |
3607 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 3607 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
3613 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 3613 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
3614 #endif | 3614 #endif |
3615 | 3615 |
3616 WRITE_UART_REGISTER ( | 3616 WRITE_UART_REGISTER ( |
3617 uart, MCR, READ_UART_REGISTER (uart, MCR) | MRTS); | 3617 uart, MCR, READ_UART_REGISTER (uart, MCR) | MRTS); |
3618 | 3618 |
3619 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 3619 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
3620 /* | 3620 /* |
3621 * Re-enable sleep mode. | 3621 * Re-enable sleep mode. |
3622 */ | 3622 */ |
3623 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ | 3623 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ |
3688 } else if (!DRIVER_DISABLED (uart)) { | 3688 } else if (!DRIVER_DISABLED (uart)) { |
3689 | 3689 |
3690 uart->rx_stopped_by_driver = 0; | 3690 uart->rx_stopped_by_driver = 0; |
3691 start_receiver (uart); | 3691 start_receiver (uart); |
3692 } | 3692 } |
3693 | 3693 |
3694 } else { | 3694 } else { |
3695 | 3695 |
3696 uart->rx_stopped_by_driver = 0; | 3696 uart->rx_stopped_by_driver = 0; |
3697 uart->tx_stopped_by_driver = 0; | 3697 uart->tx_stopped_by_driver = 0; |
3698 } | 3698 } |
3699 | 3699 |
3700 result = FD_OK; | 3700 result = FD_OK; |
3704 } | 3704 } |
3705 | 3705 |
3706 /******************************************************************************* | 3706 /******************************************************************************* |
3707 * | 3707 * |
3708 * UAF_SetEscape | 3708 * UAF_SetEscape |
3709 * | 3709 * |
3710 * Purpose : To return to the command mode at the ACI while a data connection | 3710 * Purpose : To return to the command mode at the ACI while a data connection |
3711 * is established, an escape sequence has to be detected. | 3711 * is established, an escape sequence has to be detected. |
3712 * To distinguish between user data and the escape sequence a | 3712 * To distinguish between user data and the escape sequence a |
3713 * defined guard period is necessary before and after this sequence. | 3713 * defined guard period is necessary before and after this sequence. |
3714 * | 3714 * |
3762 } | 3762 } |
3763 | 3763 |
3764 /******************************************************************************* | 3764 /******************************************************************************* |
3765 * | 3765 * |
3766 * UAF_InpAvail | 3766 * UAF_InpAvail |
3767 * | 3767 * |
3768 * Purpose : Returns the number of characters available in the RX buffer of the | 3768 * Purpose : Returns the number of characters available in the RX buffer of the |
3769 * driver. If the driver is disabled the function returns 0. | 3769 * driver. If the driver is disabled the function returns 0. |
3770 * | 3770 * |
3771 * Arguments: In : uartNo: Used UART. | 3771 * Arguments: In : uartNo: Used UART. |
3772 * Out: none | 3772 * Out: none |
3860 } | 3860 } |
3861 | 3861 |
3862 /******************************************************************************* | 3862 /******************************************************************************* |
3863 * | 3863 * |
3864 * UAF_OutpAvail | 3864 * UAF_OutpAvail |
3865 * | 3865 * |
3866 * Purpose : Returns the number of free characters in TX buffer of the driver. | 3866 * Purpose : Returns the number of free characters in TX buffer of the driver. |
3867 * If the driver is disabled the function returns 0. | 3867 * If the driver is disabled the function returns 0. |
3868 * | 3868 * |
3869 * Arguments: In : uartNo: Used UART. | 3869 * Arguments: In : uartNo: Used UART. |
3870 * Out: none | 3870 * Out: none |
3940 { | 3940 { |
3941 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 3941 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
3942 /* | 3942 /* |
3943 * Disable sleep mode. | 3943 * Disable sleep mode. |
3944 */ | 3944 */ |
3945 | 3945 |
3946 WRITE_UART_REGISTER ( | 3946 WRITE_UART_REGISTER ( |
3947 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 3947 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
3948 #endif | 3948 #endif |
3949 | 3949 |
3950 /* | 3950 /* |
3951 * Unmask Tx interrupt. | 3951 * Unmask Tx interrupt. |
3952 */ | 3952 */ |
3953 | 3953 |
3954 WRITE_UART_REGISTER ( | 3954 WRITE_UART_REGISTER ( |
3955 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); | 3955 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); |
3956 } | 3956 } |
3957 } | 3957 } |
3958 | 3958 |
3963 } | 3963 } |
3964 | 3964 |
3965 /******************************************************************************* | 3965 /******************************************************************************* |
3966 * | 3966 * |
3967 * UAF_EnterSleep | 3967 * UAF_EnterSleep |
3968 * | 3968 * |
3969 * Purpose : Checks if UART is ready to enter Deep Sleep. If ready, enables | 3969 * Purpose : Checks if UART is ready to enter Deep Sleep. If ready, enables |
3970 * wake-up interrupt. | 3970 * wake-up interrupt. |
3971 * | 3971 * |
3972 * Arguments: In : uartNo: Used UART. | 3972 * Arguments: In : uartNo: Used UART. |
3973 * Out: none | 3973 * Out: none |
3984 UAF_EnterSleep (T_fd_UartId uartNo) | 3984 UAF_EnterSleep (T_fd_UartId uartNo) |
3985 { | 3985 { |
3986 t_uart *uart; | 3986 t_uart *uart; |
3987 SYS_BOOL deep_sleep; | 3987 SYS_BOOL deep_sleep; |
3988 volatile SYS_UWORD8 status; | 3988 volatile SYS_UWORD8 status; |
3989 | 3989 |
3990 /* | 3990 /* |
3991 * Check UART number. | 3991 * Check UART number. |
3992 * A return is used to simplify the code. | 3992 * A return is used to simplify the code. |
3993 * UART IrDA (UAF_UART_0) can't be used for F&D on Ulysse because hardware | 3993 * UART IrDA (UAF_UART_0) can't be used for F&D on Ulysse because hardware |
3994 * flow control is not supported. | 3994 * flow control is not supported. |
4013 | 4013 |
4014 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 4014 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
4015 /* | 4015 /* |
4016 * Disable sleep mode. | 4016 * Disable sleep mode. |
4017 */ | 4017 */ |
4018 | 4018 |
4019 WRITE_UART_REGISTER ( | 4019 WRITE_UART_REGISTER ( |
4020 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 4020 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
4021 #endif | 4021 #endif |
4022 | 4022 |
4023 #if (CHIPSET == 12) | 4023 #if (CHIPSET == 12) |
4049 } | 4049 } |
4050 | 4050 |
4051 /******************************************************************************* | 4051 /******************************************************************************* |
4052 * | 4052 * |
4053 * UAF_WakeUp | 4053 * UAF_WakeUp |
4054 * | 4054 * |
4055 * Purpose : Wakes up UART after Deep Sleep. | 4055 * Purpose : Wakes up UART after Deep Sleep. |
4056 * | 4056 * |
4057 * Arguments: In : uartNo: Used UART. | 4057 * Arguments: In : uartNo: Used UART. |
4058 * Out: none | 4058 * Out: none |
4059 * | 4059 * |
4066 | 4066 |
4067 T_FDRET | 4067 T_FDRET |
4068 UAF_WakeUp (T_fd_UartId uartNo) | 4068 UAF_WakeUp (T_fd_UartId uartNo) |
4069 { | 4069 { |
4070 t_uart *uart; | 4070 t_uart *uart; |
4071 | 4071 |
4072 /* | 4072 /* |
4073 * Check UART number. | 4073 * Check UART number. |
4074 * A return is used to simplify the code. | 4074 * A return is used to simplify the code. |
4075 * UART IrDA (UAF_UART_0) can't be used for F&D on Ulysse because hardware | 4075 * UART IrDA (UAF_UART_0) can't be used for F&D on Ulysse because hardware |
4076 * flow control is not supported. | 4076 * flow control is not supported. |
4106 | 4106 |
4107 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 4107 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
4108 /* | 4108 /* |
4109 * Allow sleep mode. | 4109 * Allow sleep mode. |
4110 */ | 4110 */ |
4111 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ | 4111 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ |
4112 /* | 4112 /* |
4113 WRITE_UART_REGISTER ( | 4113 WRITE_UART_REGISTER ( |
4114 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); | 4114 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
4115 */ | 4115 */ |
4116 #endif | 4116 #endif |
4117 | 4117 |
4118 return (FD_OK); | 4118 return (FD_OK); |
4119 } | 4119 } |
4120 | 4120 |
4121 /******************************************************************************* | 4121 /******************************************************************************* |
4122 * | 4122 * |
4123 * UAF_ReadData | 4123 * UAF_ReadData |
4124 * | 4124 * |
4125 * Purpose : To read the received characters out of the RX buffer the address | 4125 * Purpose : To read the received characters out of the RX buffer the address |
4126 * of a function is passed. If characters are available, the driver | 4126 * of a function is passed. If characters are available, the driver |
4127 * calls this function and pass the address and the amount of | 4127 * calls this function and pass the address and the amount of |
4128 * readable characters. Because the RX buffer is circular, the | 4128 * readable characters. Because the RX buffer is circular, the |
4129 * callback function may be called with more than one address of | 4129 * callback function may be called with more than one address of |
4166 * source : Array which contains the addresses | 4166 * source : Array which contains the addresses |
4167 * of the fragments. | 4167 * of the fragments. |
4168 * size : Array which contains the sizes of | 4168 * size : Array which contains the sizes of |
4169 * each fragments. | 4169 * each fragments. |
4170 * state : The state parameter is the status | 4170 * state : The state parameter is the status |
4171 * of the V.24 lines and the break / | 4171 * of the V.24 lines and the break / |
4172 * escape detection. The state | 4172 * escape detection. The state |
4173 * parameter is described in the | 4173 * parameter is described in the |
4174 * specification of UAF_GetLineState. | 4174 * specification of UAF_GetLineState. |
4175 * Out: none | 4175 * Out: none |
4176 * | 4176 * |
4258 uart->readOutFunc = readOutFunc; | 4258 uart->readOutFunc = readOutFunc; |
4259 uart->reading_suspended = 1; | 4259 uart->reading_suspended = 1; |
4260 result = FD_SUSPENDED; | 4260 result = FD_SUSPENDED; |
4261 | 4261 |
4262 } else { | 4262 } else { |
4263 | 4263 |
4264 /* | 4264 /* |
4265 * The previous callback function is deinstalled. | 4265 * The previous callback function is deinstalled. |
4266 */ | 4266 */ |
4267 | 4267 |
4268 uart->rd_call_setup = rm_noInstall; | 4268 uart->rd_call_setup = rm_noInstall; |
4269 uart->reading_suspended = 0; | 4269 uart->reading_suspended = 0; |
4270 result = 0; /* 0 byte read. */ | 4270 result = 0; /* 0 byte read. */ |
4271 } | 4271 } |
4272 | 4272 |
4274 } | 4274 } |
4275 | 4275 |
4276 /******************************************************************************* | 4276 /******************************************************************************* |
4277 * | 4277 * |
4278 * UAF_WriteData | 4278 * UAF_WriteData |
4279 * | 4279 * |
4280 * Purpose : To write characters into the TX buffer the address of a function | 4280 * Purpose : To write characters into the TX buffer the address of a function |
4281 * is passed. If free space is available in the buffer, the driver | 4281 * is passed. If free space is available in the buffer, the driver |
4282 * calls this function and passes the destination address and the | 4282 * calls this function and passes the destination address and the |
4283 * amount of space. Because the TX buffer is circular, the callback | 4283 * amount of space. Because the TX buffer is circular, the callback |
4284 * function may be called with more than one address of buffer | 4284 * function may be called with more than one address of buffer |
4296 * UAF_SetBuffer). If no suspension is necessary the function returns | 4296 * UAF_SetBuffer). If no suspension is necessary the function returns |
4297 * the number of processed bytes. | 4297 * the number of processed bytes. |
4298 * | 4298 * |
4299 * Arguments: In : uartNo : Used UART. | 4299 * Arguments: In : uartNo : Used UART. |
4300 * suspend : mode of suspension in case of TX buffer empty. | 4300 * suspend : mode of suspension in case of TX buffer empty. |
4301 * writeInFunc: Callback function. | 4301 * writeInFunc: Callback function. |
4302 * cldFromIrq: The driver sets this parameter to 1 | 4302 * cldFromIrq: The driver sets this parameter to 1 |
4303 * if the call-back function is called | 4303 * if the call-back function is called |
4304 * from an interrupt service routine. | 4304 * from an interrupt service routine. |
4305 * reInstall : The callback function sets this | 4305 * reInstall : The callback function sets this |
4306 * parameter to rm_reInstall if the | 4306 * parameter to rm_reInstall if the |
4395 * - the flow control is not activated, | 4395 * - the flow control is not activated, |
4396 * unmask the TX empty interrupt to be able to send characters. | 4396 * unmask the TX empty interrupt to be able to send characters. |
4397 */ | 4397 */ |
4398 if (!uart->break_to_send && | 4398 if (!uart->break_to_send && |
4399 !uart->tx_stopped_by_driver) | 4399 !uart->tx_stopped_by_driver) |
4400 { | 4400 { |
4401 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 4401 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
4402 /* | 4402 /* |
4403 * Disable sleep mode. | 4403 * Disable sleep mode. |
4404 */ | 4404 */ |
4405 | 4405 |
4406 WRITE_UART_REGISTER ( | 4406 WRITE_UART_REGISTER ( |
4407 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); | 4407 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
4408 #endif | 4408 #endif |
4409 | 4409 |
4410 /* | 4410 /* |
4411 * Unmask Tx interrupt. | 4411 * Unmask Tx interrupt. |
4412 */ | 4412 */ |
4413 | 4413 |
4414 WRITE_UART_REGISTER ( | 4414 WRITE_UART_REGISTER ( |
4415 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); | 4415 uart, IER, READ_UART_REGISTER (uart, IER) | ETBEI); |
4416 } | 4416 } |
4417 | 4417 |
4418 result = (T_FDRET) bytes_written; | 4418 result = (T_FDRET) bytes_written; |
4422 uart->writeInFunc = writeInFunc; | 4422 uart->writeInFunc = writeInFunc; |
4423 uart->writing_suspended = 1; | 4423 uart->writing_suspended = 1; |
4424 result = FD_SUSPENDED; | 4424 result = FD_SUSPENDED; |
4425 | 4425 |
4426 } else { | 4426 } else { |
4427 | 4427 |
4428 /* | 4428 /* |
4429 * The previous callback function is deinstalled. | 4429 * The previous callback function is deinstalled. |
4430 */ | 4430 */ |
4431 | 4431 |
4432 uart->wr_call_setup = rm_noInstall; | 4432 uart->wr_call_setup = rm_noInstall; |
4433 uart->writing_suspended = 0; | 4433 uart->writing_suspended = 0; |
4434 result = 0; | 4434 result = 0; |
4435 } | 4435 } |
4436 | 4436 |
4438 } | 4438 } |
4439 | 4439 |
4440 /******************************************************************************* | 4440 /******************************************************************************* |
4441 * | 4441 * |
4442 * UAF_StopRec | 4442 * UAF_StopRec |
4443 * | 4443 * |
4444 * Purpose : If a flow control mode is set, this function tells the terminal | 4444 * Purpose : If a flow control mode is set, this function tells the terminal |
4445 * equipment that no more data can be received. | 4445 * equipment that no more data can be received. |
4446 * XON/XOFF: XOFF is sent. | 4446 * XON/XOFF: XOFF is sent. |
4447 * DTR/DSR : DTR is desactivated. | 4447 * DTR/DSR : DTR is desactivated. |
4448 * RTS/CTS : RTS is deactivated. | 4448 * RTS/CTS : RTS is deactivated. |
4488 } | 4488 } |
4489 | 4489 |
4490 /******************************************************************************* | 4490 /******************************************************************************* |
4491 * | 4491 * |
4492 * UAF_StartRec | 4492 * UAF_StartRec |
4493 * | 4493 * |
4494 * Purpose : If a flow control mode is set, this function tells the terminal | 4494 * Purpose : If a flow control mode is set, this function tells the terminal |
4495 * equipment that the receiver is again able to receive more data. | 4495 * equipment that the receiver is again able to receive more data. |
4496 * If the buffer has already reached the high water mark the driver | 4496 * If the buffer has already reached the high water mark the driver |
4497 * sends the signal only if the buffer drains to a low water mark. | 4497 * sends the signal only if the buffer drains to a low water mark. |
4498 * XON/XOFF: XON is sent. | 4498 * XON/XOFF: XON is sent. |
4506 * FD_NOT_SUPPORTED: Wrong UART number. | 4506 * FD_NOT_SUPPORTED: Wrong UART number. |
4507 * FD_INTERNAL_ERR : Internal problem with the hardware. | 4507 * FD_INTERNAL_ERR : Internal problem with the hardware. |
4508 * | 4508 * |
4509 ******************************************************************************/ | 4509 ******************************************************************************/ |
4510 | 4510 |
4511 T_FDRET | 4511 T_FDRET |
4512 UAF_StartRec (T_fd_UartId uartNo) | 4512 UAF_StartRec (T_fd_UartId uartNo) |
4513 { | 4513 { |
4514 t_uart *uart; | 4514 t_uart *uart; |
4515 | 4515 |
4516 /* | 4516 /* |
4540 } | 4540 } |
4541 | 4541 |
4542 /******************************************************************************* | 4542 /******************************************************************************* |
4543 * | 4543 * |
4544 * UAF_GetLineState | 4544 * UAF_GetLineState |
4545 * | 4545 * |
4546 * Purpose : Returns the state of the V.24 lines, the flow control state and | 4546 * Purpose : Returns the state of the V.24 lines, the flow control state and |
4547 * the result of the break/escape detection process as a bit field. | 4547 * the result of the break/escape detection process as a bit field. |
4548 * | 4548 * |
4549 * Arguments: In : uartNo: Used UART. | 4549 * Arguments: In : uartNo: Used UART. |
4550 * Out: state : State of the V.24 lines, the flow control state and | 4550 * Out: state : State of the V.24 lines, the flow control state and |
4551 * the result of the break/escape sequence detection | 4551 * the result of the break/escape sequence detection |
4552 * process as a bit field. | 4552 * process as a bit field. |
4553 * | 4553 * |
4554 * Returns : FD_OK : Successful operation. | 4554 * Returns : FD_OK : Successful operation. |
4555 * FD_NOT_SUPPORTED: Wrong UART number. | 4555 * FD_NOT_SUPPORTED: Wrong UART number. |
4556 * FD_NOT_READY : The function is called while the callback of | 4556 * FD_NOT_READY : The function is called while the callback of |
4557 * the readOutFunc function is activated and still | 4557 * the readOutFunc function is activated and still |
4558 * not terminated. | 4558 * not terminated. |
4559 * FD_INTERNAL_ERR : Internal problem with the hardware. | 4559 * FD_INTERNAL_ERR : Internal problem with the hardware. |
4560 * | 4560 * |
4561 ******************************************************************************/ | 4561 ******************************************************************************/ |
4593 | 4593 |
4594 /* | 4594 /* |
4595 * The field state_2 is used when state_1 is set to 0 to avoid to | 4595 * The field state_2 is used when state_1 is set to 0 to avoid to |
4596 * lose events detected in the RX interrupt handler. | 4596 * lose events detected in the RX interrupt handler. |
4597 * Fields BRK and BRKLEN are set when a break is detected. | 4597 * Fields BRK and BRKLEN are set when a break is detected. |
4598 * The field ESC is set when an escape sequence is detected. | 4598 * The field ESC is set when an escape sequence is detected. |
4599 */ | 4599 */ |
4600 | 4600 |
4601 *state = uart->state_2; | 4601 *state = uart->state_2; |
4602 uart->state_2 = 0; | 4602 uart->state_2 = 0; |
4603 uart->state = &(uart->state_2); | 4603 uart->state = &(uart->state_2); |
4605 *state |= uart->state_1; | 4605 *state |= uart->state_1; |
4606 uart->state_1 = 0; | 4606 uart->state_1 = 0; |
4607 uart->state = &(uart->state_1); | 4607 uart->state = &(uart->state_1); |
4608 | 4608 |
4609 *state |= ((((SYS_UWORD32) uart->rts_level) << RTS) | | 4609 *state |= ((((SYS_UWORD32) uart->rts_level) << RTS) | |
4610 | 4610 |
4611 #if (UARTFAX_CLASSIC_DTR_DCD || (CHIPSET == 12)) | 4611 #if (UARTFAX_CLASSIC_DTR_DCD || (CHIPSET == 12)) |
4612 (((SYS_UWORD32) uart->dtr_level) << DTR) | | 4612 (((SYS_UWORD32) uart->dtr_level) << DTR) | |
4613 #endif | 4613 #endif |
4614 | 4614 |
4615 (((SYS_UWORD32) (uart->tx_stopped_by_application | | 4615 (((SYS_UWORD32) (uart->tx_stopped_by_application | |
4616 uart->tx_stopped_by_driver)) << TXSTP) | | 4616 uart->tx_stopped_by_driver)) << TXSTP) | |
4617 | 4617 |
4618 (((SYS_UWORD32) (uart->rx_stopped_by_application | | 4618 (((SYS_UWORD32) (uart->rx_stopped_by_application | |
4619 uart->rx_stopped_by_driver)) << RXSTP) | | 4619 uart->rx_stopped_by_driver)) << RXSTP) | |
4620 | 4620 |
4621 (((SYS_UWORD32) (uart->buffer_size - | 4621 (((SYS_UWORD32) (uart->buffer_size - |
4622 get_bytes_in_rx_buffer (uart))) << RXBLEV)); | 4622 get_bytes_in_rx_buffer (uart))) << RXBLEV)); |
4623 | 4623 |
4624 /* | 4624 /* |
4625 * Fields SA, SB and X are set according to the flow control: | 4625 * Fields SA, SB and X are set according to the flow control: |
4626 * | 4626 * |
4627 * None RTS/CTS XON/XOFF | 4627 * None RTS/CTS XON/XOFF |
4628 * SA DTR DTR DTR | 4628 * SA DTR DTR DTR |
4639 if (uart->flow_control_mode != fc_rts) | 4639 if (uart->flow_control_mode != fc_rts) |
4640 *state |= (((SYS_UWORD32) uart->rts_level) << SB); | 4640 *state |= (((SYS_UWORD32) uart->rts_level) << SB); |
4641 | 4641 |
4642 if (uart->flow_control_mode == fc_rts) | 4642 if (uart->flow_control_mode == fc_rts) |
4643 *state |= (((SYS_UWORD32) uart->rts_level) << X); | 4643 *state |= (((SYS_UWORD32) uart->rts_level) << X); |
4644 | 4644 |
4645 else if ((uart->flow_control_mode == fc_xoff) && | 4645 else if ((uart->flow_control_mode == fc_xoff) && |
4646 (uart->tx_stopped_by_application || | 4646 (uart->tx_stopped_by_application || |
4647 uart->tx_stopped_by_driver)) | 4647 uart->tx_stopped_by_driver)) |
4648 *state |= (1 << X); | 4648 *state |= (1 << X); |
4649 | 4649 |
4654 } | 4654 } |
4655 | 4655 |
4656 /******************************************************************************* | 4656 /******************************************************************************* |
4657 * | 4657 * |
4658 * UAF_SetLineState | 4658 * UAF_SetLineState |
4659 * | 4659 * |
4660 * Purpose : Sets the states of the V.24 status lines according to the bit | 4660 * Purpose : Sets the states of the V.24 status lines according to the bit |
4661 * field of the parameter state. | 4661 * field of the parameter state. |
4662 * | 4662 * |
4663 * Arguments: In : uartNo: Used UART. | 4663 * Arguments: In : uartNo: Used UART. |
4664 * state : Bit field. Only the signals which are marked with | 4664 * state : Bit field. Only the signals which are marked with |
4707 if (mask & (1 << SA)) | 4707 if (mask & (1 << SA)) |
4708 #else | 4708 #else |
4709 if ((mask & (1 << SA)) || (mask & (1 << DCD))) | 4709 if ((mask & (1 << SA)) || (mask & (1 << DCD))) |
4710 #endif | 4710 #endif |
4711 return (FD_NOT_SUPPORTED); /* Return used to simplify the code */ | 4711 return (FD_NOT_SUPPORTED); /* Return used to simplify the code */ |
4712 | 4712 |
4713 /* | 4713 /* |
4714 * Check if a break has to be sent. | 4714 * Check if a break has to be sent. |
4715 */ | 4715 */ |
4716 | 4716 |
4717 uart->break_length = (UNSIGNED) ((state >> BRKLEN) & 0xFF); | 4717 uart->break_length = (UNSIGNED) ((state >> BRKLEN) & 0xFF); |
4751 * The CTS field is ignored if the X bit in the mask is set. In this case | 4751 * The CTS field is ignored if the X bit in the mask is set. In this case |
4752 * the X bit controls CTS. | 4752 * the X bit controls CTS. |
4753 */ | 4753 */ |
4754 | 4754 |
4755 if (mask & (1 << CTS)) { | 4755 if (mask & (1 << CTS)) { |
4756 | 4756 |
4757 if (uart->flow_control_mode != fc_rts) { | 4757 if (uart->flow_control_mode != fc_rts) { |
4758 | 4758 |
4759 /* | 4759 /* |
4760 * As the RTS/CTS flow control is not selected, the X bit does not | 4760 * As the RTS/CTS flow control is not selected, the X bit does not |
4761 * control CTS. CTS needs only to be activated or deactivated | 4761 * control CTS. CTS needs only to be activated or deactivated |
4762 * according to the value of the CTS field. | 4762 * according to the value of the CTS field. |
4763 */ | 4763 */ |
4777 * is null. Then the CTS bit controls CTS and the receiver must be | 4777 * is null. Then the CTS bit controls CTS and the receiver must be |
4778 * stopped or started according to the state of the CTS bit. | 4778 * stopped or started according to the state of the CTS bit. |
4779 * The receiver is started only if it was not stopped by the driver | 4779 * The receiver is started only if it was not stopped by the driver |
4780 * and if it was stopped by the application. | 4780 * and if it was stopped by the application. |
4781 */ | 4781 */ |
4782 | 4782 |
4783 if (state & (1 << CTS)) { | 4783 if (state & (1 << CTS)) { |
4784 | 4784 |
4785 if (!uart->rx_stopped_by_application) { | 4785 if (!uart->rx_stopped_by_application) { |
4786 | 4786 |
4787 if (!uart->rx_stopped_by_driver) | 4787 if (!uart->rx_stopped_by_driver) |
4788 stop_receiver (uart); | 4788 stop_receiver (uart); |
4789 | 4789 |
4790 uart->rx_stopped_by_application = 1; | 4790 uart->rx_stopped_by_application = 1; |
4791 } | 4791 } |
4792 | 4792 |
4793 } else { | 4793 } else { |
4794 | 4794 |
4795 if ((!uart->rx_stopped_by_driver) && | 4795 if ((!uart->rx_stopped_by_driver) && |
4796 uart->rx_stopped_by_application) | 4796 uart->rx_stopped_by_application) |
4797 start_receiver (uart); | 4797 start_receiver (uart); |
4798 | 4798 |
4799 uart->rx_stopped_by_application = 0; | 4799 uart->rx_stopped_by_application = 0; |
4893 | 4893 |
4894 if ((mask & (1 << X)) && | 4894 if ((mask & (1 << X)) && |
4895 (uart->flow_control_mode != fc_none)) { | 4895 (uart->flow_control_mode != fc_none)) { |
4896 | 4896 |
4897 if (state & (1 << X)) { | 4897 if (state & (1 << X)) { |
4898 | 4898 |
4899 if (!uart->rx_stopped_by_application) { | 4899 if (!uart->rx_stopped_by_application) { |
4900 | 4900 |
4901 if (!uart->rx_stopped_by_driver) | 4901 if (!uart->rx_stopped_by_driver) |
4902 stop_receiver (uart); | 4902 stop_receiver (uart); |
4903 | 4903 |
4904 uart->rx_stopped_by_application = 1; | 4904 uart->rx_stopped_by_application = 1; |
4905 } | 4905 } |
4906 | 4906 |
4907 } else { | 4907 } else { |
4908 | 4908 |
4909 /* | 4909 /* |
4910 * The receiver is started only if it is not stopped by the driver | 4910 * The receiver is started only if it is not stopped by the driver |
4911 * and if it is stopped by the application. | 4911 * and if it is stopped by the application. |
4912 */ | 4912 */ |
4913 | 4913 |
4921 | 4921 |
4922 #if ((CHIPSET != 5) && (CHIPSET != 6)) | 4922 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
4923 /* | 4923 /* |
4924 * Re-enable sleep mode. | 4924 * Re-enable sleep mode. |
4925 */ | 4925 */ |
4926 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ | 4926 /* BELOW LINES WERE COMMENTED TO DISABLE SLEEP MODE IN DRIVER */ |
4927 /* | 4927 /* |
4928 WRITE_UART_REGISTER ( | 4928 WRITE_UART_REGISTER ( |
4929 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); | 4929 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
4930 */ | 4930 */ |
4931 #endif | 4931 #endif |
4934 } | 4934 } |
4935 | 4935 |
4936 /******************************************************************************* | 4936 /******************************************************************************* |
4937 * | 4937 * |
4938 * UAF_InterruptHandler | 4938 * UAF_InterruptHandler |
4939 * | 4939 * |
4940 * Purpose : Interrupt handler. | 4940 * Purpose : Interrupt handler. |
4941 * | 4941 * |
4942 * Arguments: In : uart_id : origin of interrupt | 4942 * Arguments: In : uart_id : origin of interrupt |
4943 * interrupt_status: source of interrupt | 4943 * interrupt_status: source of interrupt |
4944 * Out: none | 4944 * Out: none |
5049 } | 5049 } |
5050 | 5050 |
5051 /******************************************************************************* | 5051 /******************************************************************************* |
5052 * | 5052 * |
5053 * UAF_CheckXEmpty | 5053 * UAF_CheckXEmpty |
5054 * | 5054 * |
5055 * Purpose : Checks the empty condition of the Transmitter. | 5055 * Purpose : Checks the empty condition of the Transmitter. |
5056 * | 5056 * |
5057 * Arguments: In : uartNo: Used UART. | 5057 * Arguments: In : uartNo: Used UART. |
5058 * Out: none | 5058 * Out: none |
5059 * | 5059 * |
5086 /* | 5086 /* |
5087 * There is no case where FD_INTERNAL_ERR may be returned. | 5087 * There is no case where FD_INTERNAL_ERR may be returned. |
5088 */ | 5088 */ |
5089 | 5089 |
5090 result = FD_OK; | 5090 result = FD_OK; |
5091 | 5091 |
5092 uart = &uart_parameters; | 5092 uart = &uart_parameters; |
5093 status = READ_UART_REGISTER (uart, LSR); | 5093 status = READ_UART_REGISTER (uart, LSR); |
5094 | 5094 |
5095 /* | 5095 /* |
5096 * Checks if: | 5096 * Checks if: |
5127 | 5127 |
5128 void | 5128 void |
5129 UAF_DTRInterruptHandler (void) | 5129 UAF_DTRInterruptHandler (void) |
5130 { | 5130 { |
5131 t_uart *uart; | 5131 t_uart *uart; |
5132 | 5132 |
5133 uart = &uart_parameters; | 5133 uart = &uart_parameters; |
5134 | 5134 |
5135 /* | 5135 /* |
5136 * Read the state of DTR and change the edge to detect the next change | 5136 * Read the state of DTR and change the edge to detect the next change |
5137 * of DTR. | 5137 * of DTR. |
5138 */ | 5138 */ |
5139 | 5139 |
5140 uart->dtr_level = AI_ReadBit (ARMIO_DTR); | 5140 uart->dtr_level = AI_ReadBit (ARMIO_DTR); |
5141 | 5141 |
5142 if (uart->dtr_level) | 5142 if (uart->dtr_level) |
5143 { | 5143 { |
5144 AI_SelectIOForIT (ARMIO_DTR, ARMIO_FALLING_EDGE); | 5144 AI_SelectIOForIT (ARMIO_DTR, ARMIO_FALLING_EDGE); |
5145 if (uart->flow_control_mode != fc_dtr && uart->baudrate == baudrate_value[FD_BAUD_AUTO]) | 5145 if (uart->flow_control_mode != fc_dtr && uart->baudrate == baudrate_value[FD_BAUD_AUTO]) |
5146 UAF_SetComPar (UAF_UART_1, FD_BAUD_AUTO, bpc_8, sb_1, pa_none); | 5146 UAF_SetComPar (UAF_UART_1, FD_BAUD_AUTO, bpc_8, sb_1, pa_none); |
5147 } | 5147 } |
5148 else | 5148 else |
5149 AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE); | 5149 AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE); |
5150 | 5150 |
5151 /* | 5151 /* |
5152 * The reading callback function has to be called. But bytes received before | 5152 * The reading callback function has to be called. But bytes received before |
5153 * the change of state of DTR must be copied into the RX buffer before to | 5153 * the change of state of DTR must be copied into the RX buffer before to |
5154 * call it. | 5154 * call it. |
5155 */ | 5155 */ |
5156 | 5156 |
5157 if (READ_UART_REGISTER (uart, LSR) & DR) { /* If Rx FIFO is not empty */ | 5157 if (READ_UART_REGISTER (uart, LSR) & DR) { /* If Rx FIFO is not empty */ |
5158 | 5158 |
5159 /* | 5159 /* |
5160 * The Rx FIFO will be read to fill one of the two buffers and the Rx | 5160 * The Rx FIFO will be read to fill one of the two buffers and the Rx |
5161 * HISR will be activated. | 5161 * HISR will be activated. |
5162 */ | 5162 */ |
5163 | 5163 |
5164 uart->index_it = (uart->index_it + 1) & 0x01; /* 0 or 1 */ | 5164 uart->index_it = (uart->index_it + 1) & 0x01; /* 0 or 1 */ |
5165 uart->dtr_change_detected[uart->index_it] = 1; | 5165 uart->dtr_change_detected[uart->index_it] = 1; |
5166 uart->dtr_level_saved[uart->index_it] = uart->dtr_level; | 5166 uart->dtr_level_saved[uart->index_it] = uart->dtr_level; |
5167 read_rx_fifo (uart); | 5167 read_rx_fifo (uart); |
5168 | 5168 |
5169 } else | 5169 } else |
5170 (void) NU_Activate_HISR (&(uart->v24_hisr_ctrl_block)); | 5170 (void) NU_Activate_HISR (&(uart->v24_hisr_ctrl_block)); |
5171 | 5171 |
5172 } | 5172 } |
5173 #endif /* BOARD 8 or 9 or 40 or 41 */ | 5173 #endif /* BOARD 8 or 9 or 40 or 41 */ |
5174 | 5174 |
5175 #ifdef SERIAL_DYNAMIC_SWITCH | 5175 #ifdef SERIAL_DYNAMIC_SWITCH |
5176 /******************************************************************************* | 5176 /******************************************************************************* |
5177 * | 5177 * |
5178 * UAF_Exit | 5178 * UAF_Exit |
5179 * | 5179 * |
5180 * Purpose : | 5180 * Purpose : |
5181 * | 5181 * |
5182 * Arguments: In : uartNo: Used UART. | 5182 * Arguments: In : uartNo: Used UART. |
5183 * Out: none | 5183 * Out: none |
5184 * | 5184 * |
5185 * Returns : FD_OK : Successful operation. | 5185 * Returns : FD_OK : Successful operation. |