/* * File: uart.h */ #ifndef UART_H #define UART_H #ifdef __cplusplus extern "C" { #endif #define UART_PORT_COUNT 1 //Max active count of uart ports #define UART_FIFO_LENGTH 128 #define UART_SOFT_BUFFER_LENGTH 4096 #define UART_CARET_FIX 1 //Generate '\r' after '\n' //Interrupts IDs #define UART_INT_MODEM_STATUS (0) #define UART_INT_NO_INTERRUPT (1) #define UART_INT_THR_EMPTY (2) #define UART_INT_DATA_RECIEVE (4) #define UART_INT_RECEIVER_LINE_STATUS (6) #define UART_INT_BUSY_DETECT (7) #define UART_INT_CHAR_TIMEOUT (12) typedef enum { BAUD9600 = 156, BAUD14400 = 104, BAUD19200 = 78, BAUD28800 = 52, BAUD38400 = 39, BAUD57600 = 26, BAUD115200 = 13, BAUD128000 = 12 }uart_baudrate_t; typedef enum { UART_5BIT = 0, UART_6BIT = 1, UART_7BIT = 2, UART_8BIT = 3 }uart_data_len_t; typedef enum { UART_STOPBIT1 = 0, UART_STOPBIT2 = 1, }uart_stop_bit; typedef enum { UART_NOPARITY = 0, UART_ODDPARITY = 2, UART_EVENPARITY = 3 }uart_parity_t; void uart_config(unsigned int uartNum, uart_baudrate_t baud, uart_data_len_t bits, uart_stop_bit stopBit, uart_parity_t parity); void uart_disable(unsigned int uartNum); int uart_init_interrupt(unsigned int uartNum, unsigned int rftl); void uart_interrupt_handler(int ulICCIAR, void(*callback)(int, int, int) ); int uart_send_data(unsigned int uartNum, const char* src, int size); int uart_receive_data(unsigned int uartNum, void* dst, int size, int linesplit); int is_tx_empty(unsigned int uartNum); int is_rx_empty(unsigned int uartNum); /***Non concurrent STA methods*************************************************/ void uart_putchar (unsigned int uartNum, short c); void uart_putstr (unsigned int uartNum, const char* str); unsigned int uart_getchar (unsigned int uartNum); #ifdef __cplusplus } #endif #endif /* UART_H */