Revision 249
implementing uart. done with basic functions, still planning protocol
uart.h | ||
---|---|---|
1 | 1 |
#ifndef UART_H_INCLUDED |
2 | 2 |
#define UART_H_INCLUDED |
3 | 3 |
|
4 |
#include "uart_macros.h" |
|
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 |
|
5 | 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 |
|
|
6 | 19 |
typedef struct { |
7 | 20 |
int base_addr ; |
8 | 21 |
uint8_t lcr ; |
... | ... | |
10 | 23 |
uint8_t dlm ; |
11 | 24 |
uint8_t bits_per_char ; |
12 | 25 |
uint8_t stop_bits ; |
13 |
uint8_t parity ;
|
|
26 |
uart_parity parity ;
|
|
14 | 27 |
uint8_t break_control :1; |
15 | 28 |
uint8_t dlab :1; |
16 | 29 |
uint16_t divisor_latch ; |
... | ... | |
34 | 47 |
int uart_set_parity (int base_addr, uart_parity par ); |
35 | 48 |
int uart_set_bit_rate (int base_addr, float bit_rate ); |
36 | 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 |
|
|
37 | 54 |
#endif //UART_H_INCLUDED |
Also available in: Unified diff