2024-07-13 05:59:56 +00:00
|
|
|
|
/*
|
|
|
|
|
* uart_dev.h
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>22<EFBFBD><EFBFBD>
|
|
|
|
|
* Author: psx
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef APP_INC_UART_DEV_H_
|
|
|
|
|
#define APP_INC_UART_DEV_H_
|
|
|
|
|
|
|
|
|
|
#include "ch32v30x.h"
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
#include <rthw.h>
|
2024-07-15 03:33:54 +00:00
|
|
|
|
#include "RingQueue/ring_queue.h"
|
2024-07-13 05:59:56 +00:00
|
|
|
|
|
|
|
|
|
#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' */
|
|
|
|
|
|
2024-07-15 03:33:54 +00:00
|
|
|
|
//#define RS485_MAX_PACK_DATA_LEN 30
|
2024-07-13 05:59:56 +00:00
|
|
|
|
|
|
|
|
|
typedef uint32_t device_handle;
|
2024-07-15 03:33:54 +00:00
|
|
|
|
extern device_handle g_J1RS485_UART6_handle;
|
|
|
|
|
extern device_handle g_J2RS485_UART7_handle;
|
|
|
|
|
extern device_handle g_J3RS485_USART2_handle;
|
|
|
|
|
extern device_handle g_J4RS485_UART8_handle;
|
|
|
|
|
extern device_handle g_J50RS485_USART3_handle;
|
2024-08-07 06:53:50 +00:00
|
|
|
|
extern device_handle g_LORA_UART4_handle;
|
|
|
|
|
extern device_handle g_Upward_UART5_handle;
|
2024-07-13 05:59:56 +00:00
|
|
|
|
|
2024-08-07 06:53:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>豸
|
|
|
|
|
* ONLYONE<EFBFBD><EFBFBD>ʾΨһ
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µķ<EFBFBD>ʽȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˭ͨ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2024-07-15 03:33:54 +00:00
|
|
|
|
typedef enum{
|
|
|
|
|
ONLYONE = 1,
|
|
|
|
|
J0RS485 = 0,
|
|
|
|
|
J5RS485 = 5,
|
|
|
|
|
J6RS485 = 6,
|
|
|
|
|
J7RS485 = 7,
|
|
|
|
|
J8RS485 = 8,
|
|
|
|
|
J9RS485 = 9,
|
|
|
|
|
}uartNum_e;
|
|
|
|
|
|
2024-07-13 05:59:56 +00:00
|
|
|
|
/* UART <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD>Ӧһ<D3A6><D2BB>uart<72>豸 */
|
|
|
|
|
typedef struct _uart_device_info{
|
2024-08-07 06:53:50 +00:00
|
|
|
|
uint8_t init; /* <20>豸<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ<EFBFBD><CABC> */
|
|
|
|
|
USART_TypeDef *uart_index; /* <20><>Ӧ<EFBFBD><D3A6>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint32_t uart_baudrate; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
RingQueue uart_ring_queue; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uartNum_e uart_num; /* <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸 */
|
2024-07-13 05:59:56 +00:00
|
|
|
|
}uart_device_info;
|
|
|
|
|
|
|
|
|
|
//device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size);
|
2024-07-15 03:33:54 +00:00
|
|
|
|
//device_handle uart_dev_init(uart_device_info *uart_device, uint8_t *buff, int buff_size);
|
2024-08-07 06:53:50 +00:00
|
|
|
|
//device_handle uart_dev_init(void);
|
|
|
|
|
uint8_t uart_all_dev_init(void);
|
2024-07-13 05:59:56 +00:00
|
|
|
|
void uart_sendstr(device_handle device,char *str);
|
|
|
|
|
void uart_dev_write(device_handle device, void *data, int len);
|
|
|
|
|
int uart_dev_char_present(device_handle device);
|
|
|
|
|
char uart_dev_in_char(device_handle device);
|
|
|
|
|
int ring_queue_dev_char_present(RingQueue *ring_queue);
|
|
|
|
|
char ring_queue_dev_in_char(RingQueue *ring_queue);
|
|
|
|
|
int ring_queue_length(device_handle device);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* APP_INC_UART_DEV_H_ */
|