comparison src/gpf/tst/drv/usart.h @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /*
2 +------------------------------------------------------------------------------
3 | File: usart.h
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : This Modul defines functions for actual or simulated
17 | USART comunication between two PS-Frames.
18 | Use US_set_mode() to select actual USART under windows95 or
19 | under windowsNT, or to select simulated USART under win95/NT
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef USART_H
24 #define USART_H
25
26 /*
27 * Device addresses
28 */
29 #define USART_DC (USART_BASE + 0x00) /* Data Channel */
30 #define USART_CC (USART_BASE + 0x04) /* Control Channel */
31 #define USART_CLK (USART_BASE + 0x08) /* Clock */
32
33 #define USART_CTL (USART_BASE + 0x0C) /* FIFO control */
34 #define USART_FSTAT (USART_BASE + 0x10) /* FIFO status */
35 #define USART_FTHR (USART_BASE + 0x14) /* FIFO threshold */
36
37 /*
38 * USART_CLK bit definitions
39 */
40 #define US_CLK_CLK_SEL 0x0001
41 #define US_CLK_TXC_SEL 0x0002
42 #define US_CLK_RXC_SEL 0x0004
43 #define US_CLK_TXC_CTL 0x0100
44 #define US_CLK_RXC_CTL 0x0200
45 #define US_CLK_RESET 0x0400
46
47 /*
48 * USART_MODE bit definitions
49 */
50 /* Sync/Async and Baud rate */
51 #define US_MODE_SYNC 0x00
52 #define US_MODE_ASYNC 0x01
53 #define US_MODE_ASYNC16 0x02
54 #define US_MODE_SYNC64 0x03
55
56 /* Character length */
57 #define US_MODE_CHAR5 (0x00 << 2)
58 #define US_MODE_CHAR6 (0x01 << 2)
59 #define US_MODE_CHAR7 (0x02 << 2)
60 #define US_MODE_CHAR8 (0x03 << 2)
61
62 /* Parity */
63 #define US_MODE_PEN 0x10
64 #define US_MODE_EP 0x20
65
66 /* Stop bits */
67 #define US_MODE_STOP1 (0x01 << 6)
68 #define US_MODE_STOP15 (0x02 << 6)
69 #define US_MODE_STOP2 (0x03 << 6)
70
71 /* Baud rates */
72 #define US_BAUD_115200 0
73 #define US_BAUD_57600 1
74 #define US_BAUD_38400 2
75 #define US_BAUD_33900 3
76 #define US_BAUD_28800 4
77 #define US_BAUD_19200 5
78 #define US_BAUD_14400 6
79 #define US_BAUD_9600 7
80 #define US_BAUD_4800 8
81 #define US_BAUD_2400 9
82 #define US_BAUD_1200 10
83 #define US_BAUD_600 11
84 #define US_BAUD_300 12
85 #define US_BAUD_150 13
86 #define US_BAUD_75 14
87 #define US_BAUD_128000 15
88 #define US_BAUD_256000 16
89
90
91 /*
92 * USART COMMAND bit definitions
93 */
94 #define US_CMD_TXEN 0x01
95 #define US_CMD_DTR 0x02
96 #define US_CMD_RXE 0x04
97 #define US_CMD_SBRK 0x08
98 #define US_CMD_ER 0x10
99 #define US_CMD_RTS 0x20
100 #define US_CMD_IR 0x40
101 #define US_CMD_EH 0x80
102
103
104 /*
105 * USART STATUS bit definitions
106 */
107 #define US_STAT_TXRDY 0x01
108 #define US_STAT_RXRDY 0x02
109 #define US_STAT_TXEMPTY 0x04
110 #define US_STAT_PE 0x08
111 #define US_STAT_OE 0x10
112 #define US_STAT_FE 0x20
113 #define US_STAT_SBDET 0x40
114 #define US_STAT_DSR 0x80
115
116 /*
117 * FIFO control
118 */
119 #define US_CTL_RST_FIFO 0x0001
120 #define US_CTL_FIFOBYPASS 0x0002
121 #define US_CTL_AUTOFC 0x0004
122 #define US_CTL_MS_MSK 0x0008
123 #define US_CTL_RDRY_MSK 0x0100
124 #define US_CTL_TO_MSK 0x0200
125 #define US_CTL_TDRY_MSK 0x1000
126 #define US_CTL_TXE_MSK 0x2000
127
128 #define US_FSTAT_GFE 0x0001
129 #define US_FSTAT_GPE 0x0002
130 #define US_FSTAT_MODSTAT 0x0008
131 #define US_FSTAT_RXOE 0x0020
132 #define US_FSTAT_RXFULL 0x0040
133 #define US_FSTAT_RXEMPTY 0x0080
134 #define US_FSTAT_RDRY 0x0100
135 #define US_FSTAT_TIMEOUT 0x0200
136 #define US_FSTAT_TXFULL 0x0800
137 #define US_FSTAT_TDRY 0x1000
138 #define US_FSTAT_TXE 0x2000
139 #define US_FSTAT_TXEMPTY 0x4000
140
141 /*
142 * mode constants
143 */
144 #define US_MODE_95 1
145 #define US_MODE_NT 2
146 #define US_MODE_SIM 3
147 #define US_MODE_FILE 4
148
149 /*
150 * Prototypes
151 */
152 void US_set_mode(int mode);
153 int US_get_mode(void);
154
155 int US_Init(unsigned int baudRate, int fifoSize, char flow_ctrl, void (func(void)), const char* fname );
156 BOOL US_Close(void);
157 BYTE US_ReadChar(void);
158 void US_Handler(void);
159 void US_WriteChar(int usart_id, char ch);
160 void US_WriteNChars(int usart_id, BYTE *s, unsigned int n);
161 int US_IsChar(void);
162 void US_WriteString(int usart_id, char *s);
163 void US_Handler(void);
164 void US_SetFlowCtrl (char flowCtrl);
165 /*
166 int US_InitBlk(int baudRate, int fifoSize, NU_HISR *hP );
167 */
168 ULONG US_ReadNChars(int usart_id, BYTE *s, ULONG n);
169
170 /*
171 defines for name_change US -> UT
172 */
173 #ifndef _TARGET_
174 #define UT_DEVICE_0 (0)
175
176 #define UT_BAUD_256000 US_BAUD_256000
177 #define UT_BAUD_128000 US_BAUD_128000
178 #define UT_BAUD_115200 US_BAUD_115200
179 #define UT_BAUD_57600 US_BAUD_57600
180 #define UT_BAUD_38400 US_BAUD_38400
181 #define UT_BAUD_33900 US_BAUD_33900
182 #define UT_BAUD_28800 US_BAUD_28800
183 #define UT_BAUD_19200 US_BAUD_19200
184 #define UT_BAUD_14400 US_BAUD_14400
185 #define UT_BAUD_9600 US_BAUD_9600
186 #define UT_BAUD_4800 US_BAUD_4800
187 #define UT_BAUD_2400 US_BAUD_2400
188 #define UT_BAUD_1200 US_BAUD_1200
189 #define UT_BAUD_600 US_BAUD_600
190 #define UT_BAUD_300 US_BAUD_300
191 #define UT_BAUD_150 US_BAUD_150
192 #define UT_BAUD_75 US_BAUD_75
193
194 #define UT_MODE_95 US_MODE_95
195 #define UT_MODE_NT US_MODE_NT
196 #define UT_MODE_SIM US_MODE_SIM
197 #define UT_MODE_FILE US_MODE_FILE
198
199 #define UT_set_mode US_set_mode
200 #define UT_get_mode US_get_mode
201 #define UT_Init US_Init
202 #define UT_Close US_Close
203 #define UT_ReadChar US_ReadChar
204 #define UT_ReadNChars US_ReadNChars
205 #define UT_Handler US_Handler
206 #define UT_WriteChar US_WriteChar
207 #define UT_WriteNChars US_WriteNChars
208 #define UT_IsChar US_IsChar
209 #define UT_WriteString US_WriteString
210 #define UT_SetFlowCtrl US_SetFlowCtrl
211
212 #endif
213
214
215 #endif