Project

General

Profile

Statistics
| Revision:

root / proj / libs / uart / include / uart.h @ 294

History | View | Annotate | Download (1.86 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 (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
38

    
39
int uart_get_config(int base_addr, uart_config *config);
40
void uart_print_config(uart_config config);
41

    
42
int uart_set_bits_per_character(int base_addr, uint8_t     bits_per_char);
43
int uart_set_stop_bits         (int base_addr, uint8_t     stop         );
44
int uart_set_parity            (int base_addr, uart_parity par          );
45
int uart_set_bit_rate          (int base_addr, float       bit_rate     );
46

    
47
int uart_enable_int_rx (int base_addr);
48
int uart_disable_int_rx(int base_addr);
49
int uart_enable_int_tx (int base_addr);
50
int uart_disable_int_tx(int base_addr);
51

    
52
/// NCTP - Non-critical transmission protocol
53
int nctp_init(void (*proc_func)(const uint8_t*, const size_t));
54
int nctp_free(void);
55

    
56
int nctp_send(size_t num, uint8_t* ptr[], size_t sz[]);
57

    
58
int nctp_ih_err;
59
void nctp_ih(void);
60

    
61
#endif //UART_H_INCLUDED