400Vhuganqi/project/400V/user/Src/user.c
2024-12-10 20:11:28 +08:00

30 lines
1.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "user.h"
//串口2为485接口
volatile uint8_t usart2_count = 0; //串口接收数据个数
uint8_t Rx2_Buff[BUFF_LEN] = {0}; //串口接收缓冲区
uint8_t Tx2_Buff[BUFF_LEN] = {0}; //串口发送缓冲区
uint8_t u2_Buff[BUFF_LEN] = {0}; //用户缓冲区
//串口3为lora通讯口
volatile uint8_t usart3_count = 0; //串口接收数据个数
uint8_t Rx3_Buff[BUFF_LEN] = {0}; //串口接收缓冲区
uint8_t Tx3_Buff[BUFF_LEN] = {0}; //串口发送缓冲区
uint8_t u3_Buff[BUFF_LEN] = {0}; //用户缓冲区
void user_init(void)
{
bsp_InitTimer();
__HAL_UART_ENABLE_IT(&huart2,UART_IT_IDLE);
__HAL_UART_CLEAR_FLAG(&huart2, UART_FLAG_TC);
__HAL_UART_CLEAR_IDLEFLAG(&huart2);
HAL_UART_DMAStop(&huart2);//复位DMA //串口DMA接受
HAL_UART_Receive_DMA(&huart2,(uint8_t *)Rx2_Buff,sizeof(Rx2_Buff));
//DE发射器使能高电平有效RE接收器使能低电平有效
HAL_GPIO_WritePin(TXEN_485_GPIO_Port, TXEN_485_Pin, GPIO_PIN_RESET);
// __HAL_UART_CLEAR_IT(&huart2,UART_CLEAR_IDLEF|UART_CLEAR_TCF);
}