66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
#ifndef _USART_H
|
||
#define _USART_H
|
||
|
||
#include "gd32f4xx.h"
|
||
#include "ring_queue.h"
|
||
#include "includes.h"
|
||
#include "comm_types.h"
|
||
#include "agent_hyt.h"
|
||
|
||
typedef u_int32_t device_handle;
|
||
|
||
#define TEST USART0
|
||
#define UART_485 USART1
|
||
#define UART_422 USART2
|
||
|
||
|
||
#define PTZ_UART_485_BUFF_SIZE 100
|
||
#define PTZ_UART_422_BUFF_SIZE 100
|
||
|
||
#define PTZ_UART_485_INDEX 1 //485使用串口1
|
||
#define PTZ_UART_422_INDEX 2 //422使用串口2
|
||
|
||
#define PTZ_UART_485_TX gpio_bit_set(GPIOD, GPIO_PIN_7)//485发送
|
||
#define PTZ_UART_485_RX gpio_bit_reset(GPIOD, GPIO_PIN_7)//485接收
|
||
|
||
|
||
|
||
|
||
extern device_handle uart_485_handle ;
|
||
extern device_handle uart_422_handle ;
|
||
|
||
extern BSP_OS_SEM ser_mutex;
|
||
//串口
|
||
//RS422
|
||
extern u_int8_t ptz_uart_422_buff[PTZ_UART_422_BUFF_SIZE];
|
||
extern char uart_422_state ;
|
||
//RS485
|
||
extern u_int8_t ptz_uart_485_buff[PTZ_UART_485_BUFF_SIZE];
|
||
extern char uart_485_state ;
|
||
|
||
|
||
|
||
typedef struct _uart_device_info{
|
||
u_int8_t init; //该设备是否初始化准备接收数据标志
|
||
u_int8_t index; //uart设备索引,0,1,2...
|
||
RingQueue uart_ring_queue; //用于维护设备的接收缓存的循环队列
|
||
BSP_OS_SEM ser_mutex;//用于锁调用发生一个字节函数
|
||
BSP_OS_SEM port_mutex;//用于所发送一个字节
|
||
BSP_OS_SEM read_mutex;//用于读串口buffer
|
||
BSP_OS_SEM sem_recv_data;//用于通知接收到数据
|
||
}uart_device_info;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
void Usart_init_module();
|
||
void IRQHandler_485_process(u_int8_t data);
|
||
void IRQHandler_422_process(u_int8_t data);
|
||
void ptz_uart_dev_send(device_handle device, void *data, int len);
|
||
char ptz_uart_dev_in_char(device_handle device);
|
||
int ptz_uart_dev_char_present(device_handle device);
|
||
void init_term_uart();
|
||
|
||
#endif |