#ifndef FM_UART_DEV_H_ #define FM_UART_DEV_H_ #include "main.h" #include "HD_COMM.h" #include "comm_types.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 enum{ DEBUG_UART_INDEX = 4, BAT485_UART_INDEX = 3, GW485_UART_INDEX = 2, }uartIndex_e; /* UART 驱动数据结构,对应一个uart设备 */ typedef struct _uart_device_info{ uint8_t init; uartIndex_e uart_index; uint32_t uart_baudrate; RingQueue uart_ring_queue; }uart_device_info; typedef uint32_t device_handle; extern device_handle g_gw485_uart2_handle; extern device_handle g_bat485_uart3_handle; extern device_handle g_debug_uart4_handle; extern uint8_t rx_gw485_buf[1]; extern uint8_t rx_bat485_buf[1]; void uart_close(uartIndex_e uart_index); void uart_sendstr(device_handle device, char *str); void debug_printf(char *format, ...); void Init_debug_uart(void); void Init_BAT485_uart(uint32_t baud); void Init_GW485_uart(uint32_t baud); uint8_t uart_dev_in_char(device_handle device); int uart_dev_char_present(device_handle device); void uart_dev_write(device_handle device, void *data, int len); void start_gw485Rx_It(void); void start_bat485Rx_It(void); extern void gw485_RxIt(void); extern void bat485_RxIt(void); extern void gw485_TxIt(void); extern void bat485_TxIt(void); #endif