root / proj / include / uart_macros.h @ 236
History | View | Annotate | Download (1.58 KB)
1 | 235 | up20180642 | #ifndef UART_MACROS_H_INCLUDED
|
---|---|---|---|
2 | #define UART_MACROS_H_INCLUDED
|
||
3 | |||
4 | #define UART_BITRATE 115200 |
||
5 | |||
6 | #define COM1_ADDR 0x3F8 |
||
7 | #define COM2_ADDR 0x2F8 |
||
8 | #define COM1_IRQ 4 |
||
9 | #define COM2_IRQ 3 |
||
10 | #define COM1_VECTOR 0x0C |
||
11 | #define COM2_VECTOR 0x0B |
||
12 | |||
13 | #define UART_RBR 0 |
||
14 | #define UART_THR 0 |
||
15 | #define UART_IER 1 |
||
16 | #define UART_IIR 2 |
||
17 | #define UART_FCR 2 |
||
18 | #define UART_LCR 3 |
||
19 | #define UART_MCR 4 |
||
20 | #define UART_LSR 5 |
||
21 | #define UART_MSR 6 |
||
22 | #define UART_SR 7 |
||
23 | |||
24 | #define UART_DLL 0 |
||
25 | #define UART_DLM 1 |
||
26 | |||
27 | #define UART_BITS_PER_CHAR_POS 0 |
||
28 | #define UART_STOP_BITS_POS 2 |
||
29 | #define UART_PARITY_POS 3 |
||
30 | #define UART_BREAK_CONTROL_POS 6 |
||
31 | #define UART_DLAB_POS 7 |
||
32 | |||
33 | #define UART_BITS_PER_CHAR (BIT(0) | BIT(1)) |
||
34 | #define UART_STOP_BITS (BIT(2)) |
||
35 | #define UART_PARITY (BIT(3) | BIT(4) | BIT(5)) |
||
36 | #define UART_BREAK_CONTROL (BIT(6)) |
||
37 | #define UART_DLAB (BIT(7)) |
||
38 | |||
39 | #define UART_GET_BITS_PER_CHAR(n) ((n)&UART_BITS_PER_CHAR + 5) |
||
40 | #define UART_GET_STOP_BITS(n) ((n)&UART_STOP_BITS? 2 : 1) |
||
41 | #define UART_GET_PARITY(n) (((n)&UART_PARITY )>>UART_PARITY_POS )
|
||
42 | #define UART_GET_BREAK_CONTROL(n) (((n)&UART_BREAK_CONTROL)>>UART_BREAK_CONTROL_POS)
|
||
43 | #define UART_GET_DLAB(n) (((n)&UART_DLAB )>>UART_DLAB_POS )
|
||
44 | |||
45 | |||
46 | typedef enum { |
||
47 | uart_parity_none = 0x0,
|
||
48 | uart_parity_odd = 0x1,
|
||
49 | uart_parity_even = 0x3,
|
||
50 | uart_parity_par1 = 0x5,
|
||
51 | uart_parity_par0 = 0x7
|
||
52 | } uart_parity; |
||
53 | |||
54 | #endif //UART_MACROS_H_INCLUDED |