FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/serial/uart.c @ 426:1060bf70d95d
doc/Compal-unlock: added cautionary note about flashing firmwares containing
boot code that checks the word at 0x2060
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 21 Jun 2014 06:55:27 +0000 |
parents | afceeeb2cba1 |
children |
rev | line source |
---|---|
116
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * UART.C |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * This module allows to use the UARTs of chipset 1.5 in interrupt mode for |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 * the Receive side and in polling mode for the Transmit side. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 * The driver calls a user's function when characters are received. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 * (C) Texas Instruments 1999 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "../include/config.h" |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "../include/sys_types.h" |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "serialswitch.h" |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #include "uart.h" |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 #include <string.h> |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 #include "../bsp/mem.h" |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 #if (BOARD != 34) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 * Needed to reset and restart the sleep timer in case of incoming characters. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 extern SYS_BOOL uart_sleep_timer_enabled; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 #define BUFFER_SIZE (512) /* In bytes. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 #define FIFO_SIZE (64) /* In bytes. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 #define STX 0x02 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 #define DLE 0x10 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 * TLR is used to program the RX FIFO trigger levels. FCR[7:4] are not used. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 #define RX_FIFO_TRIGGER_LEVEL (12 << 4) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 * 16750 addresses. Registers accessed when LCR[7] = 0. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 #define RHR (0x00) /* Rx buffer register - Read access */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 #define THR (0x00) /* Tx holding register - Write access */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 #define IER (0x01) /* Interrupt enable register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 * 16750 addresses. Registers accessed when LCR[7] = 1. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 #define DLL (0x00) /* Divisor latch (LSB) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 #define DLM (0x01) /* Divisor latch (MSB) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 * EFR is accessed when LCR[7:0] = 0xBF. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 #define EFR (0x02) /* Enhanced feature register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 * 16750 addresses. Bit 5 of the FCR register is accessed when LCR[7] = 1. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 #define IIR (0x02) /* Interrupt ident. register - Read only */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 #define FCR (0x02) /* FIFO control register - Write only */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 #define LCR (0x03) /* Line control register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 #define MCR (0x04) /* Modem control register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 #define LSR (0x05) /* Line status register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 #define MSR (0x06) /* Modem status register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 #define TCR (0x06) /* Transmission control register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 #define TLR (0x07) /* Trigger level register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 #define MDR1 (0x08) /* Mode definition register 1 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 #define SCR (0x10) /* Supplementary Control register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 #define SSR (0x11) /* Supplementary Status register */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 * Supplementary control register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 #define TX_EMPTY_CTL_IT (0x08) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 #define RX_CTS_WAKE_UP_ENABLE_BIT (4) /* Use RESET_BIT and SET_BIT macros. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 * Enhanced feature register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 #define ENHANCED_FEATURE_BIT (4) /* Use RESET_BIT and SET_BIT macros. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 * Mode definition register 1. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 #define UART_MODE (0x00) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 #define SIR_MODE (0x01) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 #define UART_MODE_AUTOBAUDING (0x02) /* Reserved in UART/IrDA. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 #define RESET_DEFAULT_STATE (0x07) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 #define IR_SLEEP_DISABLED (0x00) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 #define IR_SLEEP_ENABLED (0x08) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 #define SIR_TX_WITHOUT_ACREG2 (0x00) /* Reserved in UART/modem. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 #define SIR_TX_WITH_ACREG2 (0x20) /* Reserved in UART/modem. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 #define FRAME_LENGTH_METHOD (0x00) /* Reserved in UART/modem. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 #define EOT_BIT_METHOD (0x80) /* Reserved in UART/modem. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 * Supplementary Status Register |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 #define TX_FIFO_FULL (0x01) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 * Interrupt enable register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 #define ERBI (0x01) /* Enable received data available interrupt */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 #define ETBEI (0x02) /* Enable transmitter holding register empty interrupt */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 #define ELSI (0x04) /* Enable receiver line status interrupt */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 #define EDSSI (0x08) /* Enable modem status interrupt */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 #define IER_SLEEP (0x10) /* Enable sleep mode */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 * Modem control register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 #define MDTR (0x01) /* Data terminal ready. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 #define MRTS (0x02) /* Request to send. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 #define TCR_TLR_BIT (6) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 * Line status register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 #define DR (0x01) /* Data ready */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 #define OE (0x02) /* Overrun error */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 #define PE (0x04) /* Parity error */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 #define FE (0x08) /* Framing error */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 #define BI (0x10) /* Break interrupt */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 #define THRE (0x20) /* Transmitter holding register (FIFO empty) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 #define TEMT (0x40) /* Transmitter empty (FIFO and TSR both empty) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 * Interrupt identification register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 * Bit 0 is set to 0 if an IT is pending. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 * Bits 1 and 2 are used to identify the IT. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 #define IIR_BITS_USED (0x07) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 #define IT_NOT_PENDING (0x01) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 #define RX_DATA (0x04) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 #define TX_EMPTY (0x02) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 #define MODEM_STATUS (0x00) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 * Line control register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 #define WLS_5 (0x00) /* Word length: 5 bits */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 #define WLS_6 (0x01) /* Word length: 6 bits */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 #define WLS_7 (0x02) /* Word length: 7 bits */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 #define WLS_8 (0x03) /* Word length: 8 bits */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 #define STB (0x04) /* Number of stop bits: 0: 1, 1: 1,5 or 2 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 #define PEN (0x08) /* Parity enable */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 #define EPS (0x10) /* Even parity select */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 #define BREAK_CONTROL (0x40) /* Enable a break condition */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 #define DLAB (0x80) /* Divisor latch access bit */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 #define DIV_EN_BIT (7) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 * FIFO control register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 #define FIFO_ENABLE (0x01) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 #define RX_FIFO_RESET (0x02) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 #define TX_FIFO_RESET (0x04) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 * These macros allow to read and write a UART register. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 #define READ_UART_REGISTER(UART,REG) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 *((volatile SYS_UWORD8 *) ((UART)->base_address + (REG))) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 #define WRITE_UART_REGISTER(UART,REG,VALUE) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 *((volatile SYS_UWORD8 *) ((UART)->base_address + (REG))) = (VALUE) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 #define RESET_BIT(UART,REG,BIT) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 (WRITE_UART_REGISTER ( \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 UART, REG, READ_UART_REGISTER (UART, REG) & ~(1 << (BIT)))) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 #define SET_BIT(UART,REG,BIT) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 (WRITE_UART_REGISTER ( \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 UART, REG, READ_UART_REGISTER (UART, REG) | (1 << (BIT)))) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 * These macros allow to enable or disable the wake-up interrupt. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 #define ENABLE_WAKEUP_INTERRUPT(UART) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 SET_BIT(UART, SCR, RX_CTS_WAKE_UP_ENABLE_BIT); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 #define DISABLE_WAKEUP_INTERRUPT(UART) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 RESET_BIT(UART, SCR, RX_CTS_WAKE_UP_ENABLE_BIT); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 * This macro allows to know if the RX buffer is full. It must be called only |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 * from the RX interrupt handler. If it is called from the application, the |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 * rx_in pointer may be updated if a RX interrupt occurs. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 #define RX_BUFFER_FULL(UART) \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 (((UART)->rx_in == (UART)->rx_out - 1) || \ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 ((UART)->rx_in == (UART)->rx_out + BUFFER_SIZE - 1)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 * This allows monitor the last 32 inbound buffers gotten from the RX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 //#define UART_RX_BUFFER_DUMP |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 #ifdef UART_RX_BUFFER_DUMP |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 struct { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 char rx_buffer[(BUFFER_SIZE + 1) << 5]; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 char *rx_in; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 int errors_count; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 int wrong_interrupt_status; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 } uart_rx_buffer_dump = {0}; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 typedef struct s_uart { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 SYS_UWORD32 base_address; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 * Buffers management. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 char rx_buffer[BUFFER_SIZE + 1]; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 char *rx_in; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 char *rx_out; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 void (*callback_function) (void); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 * Errors counters. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 SYS_UWORD32 framing_error; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 SYS_UWORD32 parity_error; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 SYS_UWORD32 overrun_error; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 * Framing flags. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 SYS_BOOL dle_detected; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 SYS_BOOL inframe; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 SYS_BOOL encapsulation_flag; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 unsigned char frame_length; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
269 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 } t_uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
271 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 static t_uart uart_parameter[NUMBER_OF_TR_UART]; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
273 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 static const SYS_UWORD32 base_address[NUMBER_OF_TR_UART] = |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
275 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
276 MEM_UART_IRDA, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
277 MEM_UART_MODEM |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
278 #if (CHIPSET == 12) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 , MEM_UART_MODEM2 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
280 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
281 }; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 * DLL (LSB) and DLH (MSB) registers values using the 13 MHz clock. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
286 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
288 static const SYS_UWORD8 dll[] = |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
289 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
290 2, /* 406250 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
291 7, /* 115200 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
292 14, /* 57600 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
293 21, /* 38400 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 24, /* 33900 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 28, /* 28800 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 42, /* 19200 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 56, /* 14400 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
298 84, /* 9600 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
299 169, /* 4800 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
300 83, /* 2400 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 165, /* 1200 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 74, /* 600 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
303 148, /* 300 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
304 40, /* 150 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
305 81 /* 75 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
306 }; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
308 static const SYS_UWORD8 dlh[] = |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
310 0, /* 406250 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
311 0, /* 115200 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
312 0, /* 57600 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
313 0, /* 38400 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
314 0, /* 33900 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
315 0, /* 28800 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 0, /* 19200 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
317 0, /* 14400 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
318 0, /* 9600 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
319 0, /* 4800 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
320 1, /* 2400 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
321 2, /* 1200 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 5, /* 600 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 10, /* 300 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 21, /* 150 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 42 /* 75 baud. */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 }; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
327 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
328 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
329 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
330 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 * read_rx_fifo |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 * Purpose : Check the bytes written into the RX FIFO. Characters are not |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 * written in the RX buffer if it is full. The HISR is called if |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 * enough characters are received. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 * Arguments: In : uart: pointer on UART structure. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 * Returns : none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
343 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 static void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 read_rx_fifo (t_uart *uart) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
346 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 volatile SYS_UWORD8 status; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
348 int error_detected; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 SYS_UWORD8 char_received; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 #if (BOARD != 34) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 * Since new characters have been received, the sleep timer is reset then |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 * restarted preventing the system to enter deep-sleep for a new period of |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
355 * time. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
356 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 SER_activate_timer_hisr (); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 uart_sleep_timer_enabled = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
360 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 status = READ_UART_REGISTER (uart, LSR); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 while (status & DR) { /* While RX FIFO is not empty... */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 error_detected = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 char_received = READ_UART_REGISTER (uart, RHR); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
370 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 * Check if an error (overrun, parity, framing or break) is associated with the |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 * received data. If there is an error the byte is not copied into the |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 * RX buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
375 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 if (status & (OE | PE | FE | BI)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
378 if (status & PE) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
379 uart->parity_error++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
380 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 if (status & FE) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 uart->framing_error++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 if (status & OE) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 uart->overrun_error++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
386 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 error_detected = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
388 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
389 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
391 * If there is no error the byte is copied into the RX |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
392 * buffer if it is not full. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
393 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 if (!error_detected && !RX_BUFFER_FULL (uart)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
396 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 *(uart->rx_in++) = char_received; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
398 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 if (uart->rx_in == &(uart->rx_buffer[0]) + BUFFER_SIZE + 1) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
400 uart->rx_in = &(uart->rx_buffer[0]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
402 #ifdef UART_RX_BUFFER_DUMP |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 *(uart_rx_buffer_dump.rx_in)++ = char_received; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
405 if (uart_rx_buffer_dump.rx_in == uart_rx_buffer_dump.rx_buffer + sizeof (uart_rx_buffer_dump.rx_buffer)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 uart_rx_buffer_dump.rx_in = uart_rx_buffer_dump.rx_buffer; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
407 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 else { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
409 uart_rx_buffer_dump.errors_count++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
410 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
411 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
412 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
413 status = READ_UART_REGISTER (uart, LSR); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
414 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
415 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
416 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 * Call the user's function. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
420 if (uart->callback_function != NULL) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 (*(uart->callback_function)) (); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
423 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
424 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
425 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
426 * initialize_uart_sleep |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
427 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
428 * Purpose : Performs basic UART hardware initialization including sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
429 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
430 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
431 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
432 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
433 * Returns: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
434 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
435 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
436 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
437 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
439 void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
440 initialize_uart_sleep (T_tr_UartId uart_id) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
441 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
442 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
443 int index; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
444 SYS_UWORD8 dummy; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
445 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
446 for (index = 0; index < NUMBER_OF_TR_UART; index++) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
447 uart_parameter[index].base_address = base_address[index]; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
448 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
449 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
450 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
451 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
452 * Mask all interrupts causes and disable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
453 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
454 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
455 WRITE_UART_REGISTER (uart, IER, 0x00); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
456 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
457 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
458 * Reset UART mode configuration. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
459 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
460 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
461 WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
462 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
463 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
464 * LCR[7:0] = 0xBF to allow to access EFR |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
465 * EFR[4] = 1 to allow to program IER[4]. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
466 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
468 WRITE_UART_REGISTER (uart, LCR, 0xBF); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
469 SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
470 WRITE_UART_REGISTER (uart, LCR, 0x83); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
471 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
472 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
473 * Enable FIFO and reset them. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
474 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
475 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
476 WRITE_UART_REGISTER (uart, FCR, FIFO_ENABLE | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
477 RX_FIFO_RESET | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
478 TX_FIFO_RESET); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
479 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
480 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
481 * Program the baud generator (dummy 115200). |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
482 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
483 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 WRITE_UART_REGISTER (uart, DLL, 0x07); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
485 WRITE_UART_REGISTER (uart, DLM, 0x00); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
486 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
487 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
488 * LCR[7] = 0 to allow to access IER and RHR - normal mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
489 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
490 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
491 RESET_BIT (uart, LCR, DIV_EN_BIT); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
492 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
493 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
494 * Select UART mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
495 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
496 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
497 WRITE_UART_REGISTER (uart, MDR1, UART_MODE); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
498 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
499 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
500 * Clear Interrupt and check that Rx FIFO is empty. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
501 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
502 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
503 dummy = READ_UART_REGISTER (uart, IIR); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
504 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
505 while (READ_UART_REGISTER (uart, LSR) & DR) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
506 dummy = READ_UART_REGISTER (uart, RHR); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
507 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
508 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
509 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
510 * Enable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
511 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
512 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
513 WRITE_UART_REGISTER (uart, IER, IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
514 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
515 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
516 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
517 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
518 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
519 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
520 * UA_Init |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
521 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
522 * Purpose : Initializes the module and the UART. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
523 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
524 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
525 * baudrate: baud rate selected. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
526 * callback: user's function called characters are received. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
527 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
528 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
529 * Returns: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
530 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
531 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
532 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
533 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
534 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
535 void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
536 UA_Init (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
537 T_tr_Baudrate baudrate, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
538 void (callback_function (void))) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
539 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
540 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
541 int index; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
542 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
543 #ifdef UART_RX_BUFFER_DUMP |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
544 uart_rx_buffer_dump.rx_in = uart_rx_buffer_dump.rx_buffer; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
545 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
546 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
547 for (index = 0; index < NUMBER_OF_TR_UART; index++) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
548 uart_parameter[index].base_address = base_address[index]; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
549 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
550 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
551 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
552 uart->rx_in = &(uart->rx_buffer[0]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
553 uart->rx_out = &(uart->rx_buffer[0]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
554 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
555 uart->callback_function = callback_function; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
556 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
557 uart->framing_error = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
558 uart->parity_error = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
559 uart->overrun_error = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
560 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
561 uart->dle_detected = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
562 uart->inframe = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
563 uart->encapsulation_flag = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
564 uart->frame_length = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
565 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
566 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
567 * Mask all interrupts causes and disable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
568 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
569 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
570 WRITE_UART_REGISTER (uart, IER, 0x00); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
571 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
572 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
573 * Reset UART mode configuration. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
574 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
575 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
576 WRITE_UART_REGISTER (uart, MDR1, RESET_DEFAULT_STATE | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
577 IR_SLEEP_DISABLED | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
578 SIR_TX_WITHOUT_ACREG2 | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
579 FRAME_LENGTH_METHOD); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
580 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
581 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
582 * FIFO configuration. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
583 * EFR[4] = 1 to allow to program FCR[5:4] and MCR[7:5]. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
584 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
585 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
586 WRITE_UART_REGISTER (uart, LCR, 0xBF); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
587 SET_BIT (uart, EFR, ENHANCED_FEATURE_BIT); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
588 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
589 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
590 * Select the word length, the number of stop bits , the parity and set |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
591 * LCR[7] (DLAB) to allow to program FCR, DLL and DLM. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
592 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
593 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
594 WRITE_UART_REGISTER (uart, LCR, WLS_8 | DLAB); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
595 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
596 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
597 * Program the trigger levels. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
598 * MCR[6] must be set to 1. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
599 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
600 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
601 SET_BIT (uart, MCR, TCR_TLR_BIT); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
602 WRITE_UART_REGISTER (uart, TCR, 0x0F); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
603 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
604 uart, TLR, RX_FIFO_TRIGGER_LEVEL); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
605 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
606 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
607 * Program the FIFO control register. Bit 0 must be set when other FCR bits |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
608 * are written to or they are not programmed. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
609 * FCR is a write-only register. It will not be modified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
610 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
611 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
612 WRITE_UART_REGISTER (uart, FCR, FIFO_ENABLE | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
613 RX_FIFO_RESET | /* self cleared */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
614 TX_FIFO_RESET); /* self cleared */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
615 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
616 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
617 * Program the baud generator. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
618 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
619 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
620 WRITE_UART_REGISTER (uart, DLL, dll[baudrate]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
621 WRITE_UART_REGISTER (uart, DLM, dlh[baudrate]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
622 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
623 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
624 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
625 * Reset LCR[7] (DLAB) to have access to the RBR, THR and IER registers. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
626 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
627 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
628 WRITE_UART_REGISTER (uart, LCR, READ_UART_REGISTER (uart, LCR) & ~DLAB); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
629 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
630 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
631 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
632 * Select UART mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
633 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
634 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
635 WRITE_UART_REGISTER (uart, MDR1, UART_MODE | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
636 IR_SLEEP_DISABLED | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
637 SIR_TX_WITHOUT_ACREG2 | |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
638 FRAME_LENGTH_METHOD); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
639 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
640 #if ((CHIPSET == 5) || (CHIPSET == 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
641 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
642 * Unmask RX interrupt |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
643 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
644 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
645 WRITE_UART_REGISTER (uart, IER, ERBI); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
646 #else |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
647 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
648 * Unmask RX interrupt and allow sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
649 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
650 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
651 WRITE_UART_REGISTER (uart, IER, ERBI | IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
652 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
653 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
654 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
655 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
656 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
657 * UA_ReadNChars |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
658 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
659 * Purpose : Reads N characters from the RX buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
660 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
661 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
662 * buffer : buffer address where the characters are |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
663 * copied. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
664 * chars_to_read: number of characters to read. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
665 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
666 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
667 * Returns : The number of characters read. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
668 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
669 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
670 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
671 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
672 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
673 SYS_UWORD32 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
674 UA_ReadNChars (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
675 char *buffer, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
676 SYS_UWORD32 chars_to_read) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
677 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
678 SYS_UWORD32 chars_in_rx_buffer; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
679 SYS_UWORD32 chars_to_copy; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
680 SYS_UWORD32 chars_written; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
681 char *rx_in; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
682 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
683 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
684 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
685 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
686 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
687 * A copy of the rx_in pointer is used because it may be updated by |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
688 * the interrupt handler. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
689 * Get the number of bytes available in the RX buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
690 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
691 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
692 rx_in = uart->rx_in; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
693 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
694 if (uart->rx_out <= rx_in) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
695 chars_in_rx_buffer = (SYS_UWORD32) (rx_in - uart->rx_out); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
696 else |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
697 chars_in_rx_buffer = (SYS_UWORD32) (rx_in - uart->rx_out + BUFFER_SIZE + 1); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
698 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
699 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
700 * No more bytes than those received may be written in the output buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
701 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
702 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
703 if (chars_in_rx_buffer >= chars_to_read) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
704 chars_to_copy = chars_to_read; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
705 else |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
706 chars_to_copy = chars_in_rx_buffer; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
707 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
708 chars_written = chars_to_copy; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
709 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
710 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
711 * Write the received bytes in the output buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
712 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
713 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
714 while (chars_to_copy) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
715 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
716 *(buffer++) = *(uart->rx_out++); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
717 chars_to_copy--; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
718 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
719 if (uart->rx_out == &(uart->rx_buffer[0]) + BUFFER_SIZE + 1) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
720 uart->rx_out = &(uart->rx_buffer[0]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
721 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
722 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
723 return (chars_written); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
724 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
725 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
726 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
727 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
728 * UA_ReadNBytes |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
729 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
730 * Purpose : Reads and destuff N bytes from the RX buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
731 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
732 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
733 * buffer : buffer address where the bytes are copied. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
734 * chars_to_read: number of bytes to read. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
735 * Out: eof_detected : indicates if an EOF has been detected. Possible |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
736 * values are: |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
737 * - 0: EOF not detected, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
738 * - 1: EOF detected and no more bytes left, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
739 * - 2: EOF not detected and more bytes left. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
740 * Users must invoke this function one more |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
741 * time in order to get those remaining |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
742 * bytes, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
743 * - 3: EOF detected and more bytes left. Users |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
744 * must invoke this function one more time |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
745 * in order to get those remaining bytes. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
746 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
747 * Returns : The number of bytes read. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
748 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
749 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
750 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
751 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
752 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
753 SYS_UWORD32 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
754 UA_ReadNBytes (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
755 char *buffer_p, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
756 SYS_UWORD32 bytes_to_read, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
757 SYS_BOOL *eof_detected_p) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
758 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
759 SYS_UWORD32 bytes_written; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
760 SYS_UWORD32 bytes_in_rx_buffer; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
761 SYS_UWORD32 bytes_to_process; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
762 t_uart *uart_p; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
763 char *rx_in_p; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
764 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
765 bytes_written = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
766 uart_p = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
767 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
768 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
769 * A copy of the rx_in pointer is used because it may be updated by |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
770 * the interrupt handler. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
771 * Get the number of bytes available in the RX buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
772 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
773 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
774 rx_in_p = uart_p->rx_in; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
775 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
776 if (uart_p->rx_out <= rx_in_p) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
777 bytes_in_rx_buffer = (SYS_UWORD32) (rx_in_p - uart_p->rx_out); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
778 else |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
779 bytes_in_rx_buffer = (SYS_UWORD32) (rx_in_p - uart_p->rx_out + BUFFER_SIZE + 1); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
780 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
781 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
782 * No more bytes than those received may be processed and then written |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
783 * in the output buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
784 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
785 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
786 if (bytes_in_rx_buffer > bytes_to_read) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
787 bytes_to_process = bytes_to_read; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
788 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
789 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
790 * More bytes left. Users must invoke this function one more time |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
791 * in order to get those remaining bytes. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
792 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
793 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
794 *eof_detected_p = 2; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
795 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
796 else { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
797 bytes_to_process = bytes_in_rx_buffer; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
798 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
799 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
800 * No more bytes left. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
801 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
802 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
803 *eof_detected_p = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
804 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
805 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
806 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
807 * Perform the byte destuffing and then write the "valid" received bytes in |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
808 * the output buffer. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
809 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
810 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
811 while ((bytes_to_process) && !(*eof_detected_p & 0x01)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
812 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
813 switch (*(uart_p->rx_out)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
814 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
815 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
816 * Current byte is DLE. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
817 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
818 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
819 case DLE: |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
820 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
821 if (!uart_p->dle_detected) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
822 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
823 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
824 * No DLE previously detected => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
825 * Skip the current byte and set the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
826 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
827 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
828 uart_p->dle_detected = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
829 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
830 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
831 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
832 else { /* if (uart_p->dle_detected) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
833 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
834 if (uart_p->inframe) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
835 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
836 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
837 * DLE previously detected AND currently inside of a frame => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
838 * Copy the current byte in the output buffer, reset the flag |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
839 * and increase the frame length. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
840 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
841 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
842 uart_p->dle_detected = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
843 uart_p->frame_length++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
844 *(buffer_p++) = *(uart_p->rx_out++); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
845 bytes_written++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
846 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
847 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
848 else { /* if (!uart_p->inframe) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
849 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
850 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
851 * DLE previously detected AND currently outside of a frame => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
852 * Skip the current byte. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
853 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
854 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
855 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
856 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
857 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
858 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
859 break; /* case DLE */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
860 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
861 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
862 * Current byte is STX. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
863 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
864 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
865 case STX: |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
866 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
867 if ((!uart_p->dle_detected) && (uart_p->inframe)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
868 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
869 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
870 * No DLE previously detected AND currently inside of a frame. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
871 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
872 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
873 if (uart_p->frame_length) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
874 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
875 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
876 * Frame length is not zero (End of Frame) => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
877 * Skip the current byte and set the flags (EOF). |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
878 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
879 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
880 uart_p->inframe = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
881 uart_p->frame_length = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
882 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
883 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
884 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
885 * More bytes left. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
886 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
887 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
888 if ((*eof_detected_p == 0) && (bytes_to_process)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
889 *eof_detected_p = 2; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
890 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
891 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
892 * EOF detected. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
893 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
894 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
895 (*eof_detected_p)++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
896 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
897 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
898 else { /* if (!uart_p->frame_length) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
899 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
900 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
901 * Frame length is zero (STX followed by another STX = |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
902 * Synchro lost but start of a new frame) => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
903 * Skip the current byte and keep the flag set. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
904 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
905 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
906 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
907 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
908 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
909 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
910 else if ((!uart_p->dle_detected) && (!uart_p->inframe)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
911 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
912 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
913 * No DLE previously detected AND currently outside of a |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
914 * frame (Start of Frame) => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
915 * Skip the current byte and set the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
916 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
917 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
918 uart_p->inframe = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
919 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
920 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
921 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
922 else if ((uart_p->dle_detected) && (uart_p->inframe)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
923 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
924 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
925 * DLE previously detected AND currently inside of a frame => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
926 * Copy the current byte in the output buffer, reset the flag |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
927 * and increase the frame length. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
928 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
929 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
930 uart_p->dle_detected = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
931 uart_p->frame_length++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
932 *(buffer_p++) = *(uart_p->rx_out++); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
933 bytes_written++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
934 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
935 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
936 else if ((uart_p->dle_detected) && (!uart_p->inframe)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
937 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
938 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
939 * DLE previously detected AND currently outside of a frame => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
940 * Skip the current byte and reset the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
941 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
942 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
943 uart_p->dle_detected = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
944 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
945 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
946 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
947 break; /* case STX */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
948 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
949 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
950 * Current byte is neither DLE nor STX. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
951 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
952 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
953 default: |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
954 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
955 if (uart_p->inframe) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
956 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
957 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
958 * Currently inside of a frame => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
959 * Copy the current byte in the output buffer and increase |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
960 * the frame length. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
961 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
962 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
963 uart_p->frame_length++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
964 *(buffer_p++) = *(uart_p->rx_out++); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
965 bytes_written++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
966 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
967 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
968 else { /* if (!uart_p->inframe) */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
969 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
970 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
971 * Currently outside of a frame => |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
972 * Skip the current byte. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
973 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
974 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
975 uart_p->rx_out++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
976 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
977 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
978 break; /* default */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
979 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
980 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
981 if (uart_p->rx_out == &(uart_p->rx_buffer[0]) + BUFFER_SIZE + 1) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
982 uart_p->rx_out = &(uart_p->rx_buffer[0]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
983 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
984 bytes_to_process--; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
985 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
986 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
987 return (bytes_written); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
988 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
989 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
990 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
991 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
992 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
993 * UA_WriteNChars |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
994 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
995 * Purpose : Writes N characters in the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
996 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
997 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
998 * buffer : buffer address from which characters are |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
999 * written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1000 * bytes_to_write: number of bytes to write. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1001 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1002 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1003 * Returns : Number of bytes written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1004 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1005 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1006 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1007 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1008 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1009 SYS_UWORD32 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1010 UA_WriteNChars (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1011 char *buffer, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1012 SYS_UWORD32 chars_to_write) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1013 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1014 SYS_UWORD32 chars_in_tx_fifo; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1015 SYS_UWORD32 chars_written; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1016 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1017 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1018 chars_written = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1019 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1020 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1021 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1022 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1023 * Disable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1024 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1025 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1026 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1027 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1028 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1029 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1030 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1031 * Copy the input buffer to the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1032 * Ulyssse Bug #44: TX FIFO full status bit (SSR[1]) is corrupted during |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1033 * one period of Bclock => Workaround S/W. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1034 * Write in TX FIFO only if FIFO is empty instead of writing in TX FIFO |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1035 * while FIFO is not full. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1036 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1037 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1038 if (READ_UART_REGISTER (uart, LSR) & THRE) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1039 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1040 chars_in_tx_fifo = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1041 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1042 while ((chars_written < chars_to_write) && |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1043 (chars_in_tx_fifo < FIFO_SIZE)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1044 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1045 WRITE_UART_REGISTER (uart, THR, *(buffer++)); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1046 chars_written++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1047 chars_in_tx_fifo++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1048 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1049 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1050 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1051 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1052 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1053 * Re-enable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1054 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1055 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1056 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1057 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1058 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1059 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1060 return (chars_written); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1061 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1062 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1063 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1064 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1065 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1066 * UA_EncapsulateNChars |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1067 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1068 * Purpose : Writes N characters in the TX FIFO in encapsulating them with 2 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1069 * STX bytes (one at the beginning and one at the end). |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1070 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1071 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1072 * buffer : buffer address from which characters are |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1073 * written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1074 * chars_to_write: number of chars to write. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1075 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1076 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1077 * Returns : Number of chars written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1078 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1079 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1080 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1081 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1082 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1083 SYS_UWORD32 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1084 UA_EncapsulateNChars (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1085 char *buffer, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1086 SYS_UWORD32 chars_to_write) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1087 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1088 SYS_UWORD32 chars_written; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1089 SYS_UWORD32 chars_in_tx_fifo; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1090 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1091 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1092 chars_written = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1093 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1094 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1095 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1096 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1097 * Disable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1098 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1099 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1100 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1101 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1102 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1103 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1104 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1105 * Copy the input buffer to the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1106 * Ulyssse Bug #44: TX FIFO full status bit (SSR[1]) is corrupted during |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1107 * one period of Bclock => Workaround S/W. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1108 * Write in TX FIFO only if FIFO is empty instead of writing in TX FIFO |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1109 * while FIFO is not full. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1110 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1111 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1112 if (READ_UART_REGISTER (uart, LSR) & THRE) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1113 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1114 chars_in_tx_fifo = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1115 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1116 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1117 * Check if the message has been already encapsulated. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1118 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1119 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1120 if (!uart->encapsulation_flag) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1121 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1122 * Write STX in the TX FIFO and set the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1123 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1124 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1125 WRITE_UART_REGISTER (uart, THR, STX); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1126 chars_in_tx_fifo++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1127 uart->encapsulation_flag = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1128 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1129 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1130 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1131 * Keep one char margin in the TX FIFO for the last STX. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1132 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1133 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1134 while ((chars_written < chars_to_write) && |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1135 (chars_in_tx_fifo < (FIFO_SIZE-1))) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1136 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1137 WRITE_UART_REGISTER (uart, THR, *(buffer++)); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1138 chars_written++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1139 chars_in_tx_fifo++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1140 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1141 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1142 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1143 * Append STX byte at the end if the frame is complete. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1144 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1145 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1146 if (chars_written == chars_to_write) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1147 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1148 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1149 * Write STX in the TX FIFO and reset the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1150 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1151 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1152 WRITE_UART_REGISTER (uart, THR, STX); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1153 uart->encapsulation_flag = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1154 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1155 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1156 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1157 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1158 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1159 * Re-enable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1160 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1161 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1162 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1163 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1164 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1165 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1166 return (chars_written); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1167 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1168 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1169 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1170 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1171 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1172 * UA_WriteNBytes |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1173 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1174 * Purpose : Writes N bytes in the TX FIFO in encapsulating with 2 STX bytes |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1175 * at the beginning and the end of the frame, and in making byte |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1176 * stuffing. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1177 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1178 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1179 * buffer : buffer address from which bytes are |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1180 * written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1181 * bytes_to_write: number of bytes to write. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1182 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1183 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1184 * Returns : Number of bytes written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1185 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1186 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1187 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1188 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1189 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1190 SYS_UWORD32 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1191 UA_WriteNBytes (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1192 SYS_UWORD8 *buffer, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1193 SYS_UWORD32 bytes_to_write) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1194 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1195 SYS_UWORD32 bytes_written; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1196 SYS_UWORD32 bytes_in_tx_fifo; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1197 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1198 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1199 bytes_written = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1200 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1201 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1202 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1203 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1204 * Disable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1205 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1206 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1207 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1208 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1209 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1210 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1211 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1212 * Copy the input buffer to the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1213 * Ulyssse Bug #44: TX FIFO full status bit (SSR[1]) is corrupted during |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1214 * one period of Bclock => Workaround S/W. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1215 * Write in TX FIFO only if FIFO is empty instead of writing in TX FIFO |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1216 * while FIFO is not full. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1217 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1218 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1219 if (READ_UART_REGISTER (uart, LSR) & THRE) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1220 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1221 bytes_in_tx_fifo = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1222 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1223 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1224 * Check if the message has been already encapsulated. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1225 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1226 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1227 if (!uart->encapsulation_flag) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1228 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1229 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1230 * Write STX in the TX FIFO and set the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1231 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1232 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1233 WRITE_UART_REGISTER (uart, THR, STX); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1234 bytes_in_tx_fifo++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1235 uart->encapsulation_flag = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1236 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1237 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1238 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1239 * Keep 2 chars margin in the FIFO, one for the stuffing (if necessary) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1240 * and one for the last STX. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1241 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1242 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1243 while ((bytes_written < bytes_to_write) && |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1244 (bytes_in_tx_fifo < (FIFO_SIZE-2))) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1245 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1246 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1247 * Check for STX or DLE in order to perform the stuffing. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1248 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1249 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1250 if ((*(buffer) == STX) || (*(buffer) == DLE)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1251 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1252 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1253 * Write DLE in the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1254 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1255 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1256 WRITE_UART_REGISTER (uart, THR, DLE); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1257 bytes_in_tx_fifo++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1258 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1259 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1260 WRITE_UART_REGISTER (uart, THR, *(buffer++)); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1261 bytes_written++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1262 bytes_in_tx_fifo++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1263 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1264 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1265 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1266 * Append STX byte at the end if the frame is complete. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1267 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1268 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1269 if (bytes_written == bytes_to_write) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1270 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1271 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1272 * Write STX in the TX FIFO and reset the flag. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1273 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1274 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1275 WRITE_UART_REGISTER (uart, THR, STX); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1276 uart->encapsulation_flag = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1277 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1278 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1279 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1280 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1281 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1282 * Re-enable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1283 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1284 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1285 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1286 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1287 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1288 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1289 return (bytes_written); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1290 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1291 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1292 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1293 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1294 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1295 * UA_WriteChar |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1296 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1297 * Purpose : Writes a character in the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1298 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1299 * Arguments: In : uart: UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1300 * character |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1301 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1302 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1303 * Returns : none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1304 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1305 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1306 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1307 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1308 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1309 void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1310 UA_WriteChar (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1311 char character) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1312 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1313 (void) UA_WriteNChars (uart_id, &character, 1); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1314 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1315 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1316 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1317 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1318 * UA_WriteString |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1319 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1320 * Purpose : Writes a null terminated string in the TX FIFO. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1321 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1322 * Arguments: In : uart_id: UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1323 * buffer : buffer address from which characters are written. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1324 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1325 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1326 * Returns : none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1327 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1328 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1329 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1330 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1331 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1332 void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1333 UA_WriteString (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1334 char *buffer) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1335 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1336 (void) UA_WriteNChars (uart_id, buffer, strlen (buffer)); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1337 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1338 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1339 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1340 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1341 * UA_EnterSleep |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1342 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1343 * Purpose : Checks if UART is ready to enter Deep Sleep. If ready, enables |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1344 * wake-up interrupt. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1345 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1346 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1347 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1348 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1349 * Returns: 0 : Deep Sleep is not possible. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1350 * >= 1 : Deep Sleep is possible. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1351 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1352 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1353 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1354 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1355 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1356 SYS_BOOL |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1357 UA_EnterSleep (T_tr_UartId uart_id) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1358 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1359 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1360 SYS_BOOL deep_sleep; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1361 volatile SYS_UWORD8 status; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1362 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1363 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1364 deep_sleep = 0; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1365 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1366 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1367 * Check if RX & TX FIFOs are both empty |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1368 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1369 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1370 status = READ_UART_REGISTER (uart, LSR); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1371 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1372 if (!(status & DR) && |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1373 (status & TEMT)) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1374 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1375 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1376 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1377 * Disable sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1378 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1379 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1380 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1381 uart, IER, READ_UART_REGISTER (uart, IER) & ~IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1382 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1383 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1384 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1385 * Mask RX interrupt. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1386 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1387 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1388 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1389 uart, IER, READ_UART_REGISTER (uart, IER) & ~ERBI); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1390 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1391 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1392 * Enable the wake-up interrupt. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1393 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1394 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1395 ENABLE_WAKEUP_INTERRUPT (uart); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1396 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1397 deep_sleep = 1; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1398 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1399 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1400 return (deep_sleep); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1401 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1402 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1403 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1404 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1405 * UA_WakeUp |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1406 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1407 * Purpose : Wakes up UART after Deep Sleep. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1408 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1409 * Arguments: In : uart_id : UART id. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1410 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1411 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1412 * Returns: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1413 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1414 * Warning: Parameters are not verified. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1415 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1416 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1417 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1418 void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1419 UA_WakeUp (T_tr_UartId uart_id) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1420 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1421 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1422 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1423 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1424 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1425 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1426 * Disable the wake-up interrupt. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1427 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1428 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1429 DISABLE_WAKEUP_INTERRUPT (uart); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1430 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1431 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1432 * Unmask RX interrupts. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1433 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1434 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1435 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1436 uart, IER, READ_UART_REGISTER (uart, IER) | ERBI); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1437 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1438 #if ((CHIPSET != 5) && (CHIPSET != 6)) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1439 /* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1440 * Allow sleep mode. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1441 */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1442 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1443 WRITE_UART_REGISTER ( |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1444 uart, IER, READ_UART_REGISTER (uart, IER) | IER_SLEEP); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1445 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1446 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1447 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1448 /******************************************************************************* |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1449 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1450 * UA_InterruptHandler |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1451 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1452 * Purpose : Interrupt handler. |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1453 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1454 * Arguments: In : uart_id : origin of interrupt |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1455 * interrupt_status: source of interrupt |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1456 * Out: none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1457 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1458 * Returns : none |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1459 * |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1460 ******************************************************************************/ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1461 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1462 void |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1463 UA_InterruptHandler (T_tr_UartId uart_id, |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1464 SYS_UWORD8 interrupt_status) |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1465 { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1466 t_uart *uart; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1467 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1468 uart = &(uart_parameter[uart_id]); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1469 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1470 switch (interrupt_status) { |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1471 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1472 case RX_DATA: |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1473 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1474 read_rx_fifo (uart); |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1475 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1476 break; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1477 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1478 default: |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1479 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1480 #ifdef UART_RX_BUFFER_DUMP |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1481 uart_rx_buffer_dump.wrong_interrupt_status++; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1482 #endif |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1483 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1484 /* No Processing */ |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1485 |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1486 break; |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1487 } |
22c8199e08af
started integrating TI's serial code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1488 } |