micro_climate/App/Inc/uart_dev.h

57 lines
1.6 KiB
C
Raw Normal View History

2024-07-05 03:52:43 +00:00
#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;
2024-07-05 03:52:43 +00:00
#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,
2024-07-05 03:52:43 +00:00
}uartIndex_e;
/* UART <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD>Ӧһ<D3A6><D2BB>uart<72>豸 */
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();
2024-07-05 03:52:43 +00:00
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