1
2
3
4
5
6
7
8
9
10
11
12
13
14
15struct NS16550 {
16 unsigned char rbrthrdlb;
17 unsigned char ierdmb;
18 unsigned char iirfcrafr;
19 unsigned char lcr;
20 unsigned char mcr;
21 unsigned char lsr;
22 unsigned char msr;
23 unsigned char scr;
24 unsigned char reserved[2];
25 unsigned char dsr;
26 unsigned char dcr;
27};
28
29
30#define rbr rbrthrdlb
31#define thr rbrthrdlb
32#define dll rbrthrdlb
33#define ier ierdmb
34#define dlm ierdmb
35#define iir iirfcrafr
36#define fcr iirfcrafr
37#define afr iirfcrafr
38
39#define FCR_FIFO_EN 0x01
40#define FCR_RXSR 0x02
41#define FCR_TXSR 0x04
42#define FCR_DMS 0x08
43
44#define MCR_RTS 0x02
45#define MCR_LOOP 0x10
46
47
48
49
50#define LCR_WLS_MSK 0x03
51#define LCR_WLS_5 0x00
52#define LCR_WLS_6 0x01
53#define LCR_WLS_7 0x02
54#define LCR_WLS_8 0x03
55#define LCR_STB 0x04
56#define LCR_PEN 0x08
57#define LCR_EPS 0x10
58#define LCR_STKP 0x20
59#define LCR_SBRK 0x40
60#define LCR_BKSE 0x80
61
62#define LSR_DR 0x01
63#define LSR_OE 0x02
64#define LSR_PE 0x04
65#define LSR_FE 0x08
66#define LSR_BI 0x10
67#define LSR_THRE 0x20
68#define LSR_TEMT 0x40
69#define LSR_ERR 0x80
70
71
72#define LCR_8N1 0x03
73
74
75volatile struct NS16550 *NS16550_init (int chan, int baud_divisor);
76void NS16550_putc (volatile struct NS16550 *com_port, unsigned char c);
77unsigned char NS16550_getc (volatile struct NS16550 *com_port);
78int NS16550_tstc (volatile struct NS16550 *com_port);
79void NS16550_reinit (volatile struct NS16550 *com_port, int baud_divisor);
80