root / proj / include / uart.h @ 250
History | View | Annotate | Download (1.79 KB)
1 |
#ifndef UART_H_INCLUDED
|
---|---|
2 |
#define UART_H_INCLUDED
|
3 |
|
4 |
#define COM1_ADDR 0x3F8 |
5 |
#define COM2_ADDR 0x2F8 |
6 |
#define COM1_IRQ 4 |
7 |
#define COM2_IRQ 3 |
8 |
#define COM1_VECTOR 0x0C |
9 |
#define COM2_VECTOR 0x0B |
10 |
|
11 |
typedef enum { |
12 |
uart_parity_none = 0x0,
|
13 |
uart_parity_odd = 0x1,
|
14 |
uart_parity_even = 0x3,
|
15 |
uart_parity_par1 = 0x5,
|
16 |
uart_parity_par0 = 0x7
|
17 |
} uart_parity; |
18 |
|
19 |
typedef struct { |
20 |
int base_addr ;
|
21 |
uint8_t lcr ; |
22 |
uint8_t dll ; |
23 |
uint8_t dlm ; |
24 |
uint8_t bits_per_char ; |
25 |
uint8_t stop_bits ; |
26 |
uart_parity parity ; |
27 |
uint8_t break_control :1;
|
28 |
uint8_t dlab :1;
|
29 |
uint16_t divisor_latch ; |
30 |
uint8_t ier ; |
31 |
uint8_t received_data_int :1;
|
32 |
uint8_t transmitter_empty_int :1;
|
33 |
uint8_t receiver_line_stat_int:1;
|
34 |
uint8_t modem_stat_int :1;
|
35 |
} uart_config; |
36 |
|
37 |
int uart_get_config(int base_addr, uart_config *config); |
38 |
void uart_parse_config(uart_config *config);
|
39 |
void uart_print_config(uart_config config);
|
40 |
|
41 |
int uart_enable_divisor_latch (int base_addr); |
42 |
int uart_disable_divisor_latch(int base_addr); |
43 |
|
44 |
int uart_write_config (int base_addr, uint8_t config ); |
45 |
int uart_set_bits_per_character(int base_addr, uint8_t bits_per_char); |
46 |
int uart_set_stop_bits (int base_addr, uint8_t stop ); |
47 |
int uart_set_parity (int base_addr, uart_parity par ); |
48 |
int uart_set_bit_rate (int base_addr, float bit_rate ); |
49 |
|
50 |
int uart_get_char_poll (int base_addr, uint8_t *p); |
51 |
int uart_send_char_poll (int base_addr, uint8_t c); |
52 |
int uart_send_memory_poll(int base_addr, void *str, size_t n); |
53 |
|
54 |
#endif //UART_H_INCLUDED |