57 lines
1.6 KiB
C
57 lines
1.6 KiB
C
#ifndef UART_DEV_H
|
||
#define UART_DEV_H
|
||
|
||
#include "ring_queue.h"
|
||
#include "comm_types.h"
|
||
#include "string.h"
|
||
#include "usart.h"
|
||
#include "assertions.h"
|
||
|
||
#define ASCII_CHAR_BACKSPACE 0x08 /* '\b' */
|
||
#define ASCII_CHAR_CHARACTER_TABULATION 0x09 /* '\t' */
|
||
#define ASCII_CHAR_LINE_FEED 0x0A /* '\n' */
|
||
#define ASCII_CHAR_LINE_TABULATION 0x0B /* '\v' */
|
||
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
|
||
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
|
||
|
||
|
||
typedef u_int32_t device_handle;
|
||
extern device_handle g_term_uart_handle;
|
||
extern device_handle g_rs485_uart_handle;
|
||
extern device_handle g_ec801_uart_handle;
|
||
|
||
#define RS485_MAX_PACK_DATA_LEN 30
|
||
|
||
typedef enum{
|
||
RAIN_RS485_UART_INDEX = 0,
|
||
TERM_UART_INDEX = 1,
|
||
RS485_UART_INDEX = 3,
|
||
EC801_UART_INDEX = 5,
|
||
}uartIndex_e;
|
||
|
||
/* UART 驱动数据结构,对应一个uart设备 */
|
||
typedef struct _uart_device_info{
|
||
u_int8_t init;
|
||
uartIndex_e uart_index;
|
||
u_int32_t uart_baudrate;
|
||
RingQueue uart_ring_queue;
|
||
}uart_device_info;
|
||
|
||
void uart_sendstr(device_handle device,char *str);
|
||
void uart_dev_write(device_handle device, void *data, int len);
|
||
void init_term_uart();
|
||
void init_rs485_uart();
|
||
void init_ec801_uart();
|
||
void uart_close(uartIndex_e uart_index);
|
||
void term_printf(char *format, ...);
|
||
int term_uart_readln(u_int8_t *buff, int buff_size, u_int32_t timeout_ms);
|
||
int uart_dev_char_present(device_handle device);
|
||
char uart_dev_in_char(device_handle device);
|
||
#endif
|
||
|
||
|
||
|
||
|
||
|
||
|