Project

General

Profile

Statistics
| Revision:

root / proj / include / uart.h @ 260

History | View | Annotate | Download (1.67 KB)

1 235 up20180642
#ifndef UART_H_INCLUDED
2
#define UART_H_INCLUDED
3
4 249 up20180642
#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 235 up20180642
11 249 up20180642
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 235 up20180642
typedef struct {
20 242 up20180642
    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 249 up20180642
    uart_parity parity              ;
27 242 up20180642
    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 235 up20180642
} uart_config;
36
37
int uart_get_config(int base_addr, uart_config *config);
38
void uart_print_config(uart_config config);
39
40
int uart_set_bits_per_character(int base_addr, uint8_t     bits_per_char);
41
int uart_set_stop_bits         (int base_addr, uint8_t     stop         );
42
int uart_set_parity            (int base_addr, uart_parity par          );
43
int uart_set_bit_rate          (int base_addr, float       bit_rate     );
44
45 252 up20180642
int uart_enable_int_rx (int base_addr);
46
int uart_disable_int_rx(int base_addr);
47
int uart_enable_int_tx (int base_addr);
48
int uart_disable_int_tx(int base_addr);
49
50 249 up20180642
int uart_get_char_poll   (int base_addr, uint8_t *p);
51
int uart_send_char_poll  (int base_addr, uint8_t  c);
52
53 235 up20180642
#endif //UART_H_INCLUDED