工程提交

This commit is contained in:
2026-03-31 15:46:04 +08:00
parent 75f512a5b4
commit da4e944bca
2841 changed files with 4822938 additions and 1 deletions

33
Core/User/Hal/_hal_init.c Normal file
View File

@@ -0,0 +1,33 @@
/**
******************************************************************************
* @file user\hal\_hal_init.c
* @author luhuaishuai
* @version v0.1
* @date 2026-1-12
* @brief Briefly describe the function of your function
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "_hal_init.h"
/* code -----------------------------------------------------------------------*/
/**
* @funNm
* @brief
* @param
*/
/**
* @brief _hal_all_Init所有外设接口初始化
*
* @note none
*
* @param none
*
* @retval none
*/
void _hal_all_Init(void)
{
hal_usart_Init();
}

13
Core/User/Hal/_hal_init.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef __HALINIT_H
#define __HALINIT_H
/* includes ----------------------------------------------------------------------------------------------*/
#include "global.h"
/* Exported functions prototypes ------------------------------------------------------------------------*/
void _hal_all_Init(void);
#endif /* __HALINIT_H */

133
Core/User/Hal/_hal_usart.c Normal file
View File

@@ -0,0 +1,133 @@
/**
******************************************************************************
* @file user\hal\_hal_usart.c
* @author luhuaishuai
* @version v0.1
* @date 2026-1-12
* @brief Briefly describe the function of your function
******************************************************************************
*/
/* Includes -------------------------------------------------------------------*/
#include "_hal_usart.h"
/* variables ------------------------------------------------------------------*/
uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE];
uint8_t uart1_tx_buffer[UART1_TX_BUFFER_SIZE];
uint8_t uart3_rx_buffer[UART3_RX_BUFFER_SIZE];
uint8_t uart3_tx_buffer[UART3_TX_BUFFER_SIZE];
/* code -----------------------------------------------------------------------*/
/**
* @brief fputcprintf映射
*
* @note none
*
* @param none
*
* @retval none
*/
int fputc(int ch, FILE *f)
{
HAL_UART_Transmit(&huart6, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}
/**
* @brief Air724_Message_Send4G数据发送
*
* @note none
*
* @param none
*
* @retval none
*/
void Air724_Message_Send(uint8_t *data, uint16_t len)
{
HAL_UART_Transmit(&huart1, data, len, HAL_MAX_DELAY);
}
void Rs485_Message_Send(uint8_t *data, uint16_t len)
{
RS485_EN(1);
HAL_UART_Transmit(&huart3, data, len, HAL_MAX_DELAY);
RS485_EN(0);
}
/**
* @brief _hal_usart_Init所有串口初始化
*
* @note none
*
* @param none
*
* @retval none
*/
void hal_usart_Init(void)
{
/* 初始化串口1 */
Air724_Message_Queue_Init(); // 初始化4G数据接收队列
__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
HAL_UART_Receive_DMA(&huart1, uart1_rx_buffer, UART1_RX_BUFFER_SIZE);
/* 初始化串口3 */
RS485_Message_Queue_Init(); // 初始化RS485数据接收队列
__HAL_UART_ENABLE_IT(&huart3, UART_IT_IDLE);
HAL_UART_Receive_DMA(&huart3, uart3_rx_buffer, UART3_RX_BUFFER_SIZE);
RS485_EN(0);
}
/**
* @brief HAL_UARTEx_RxEventCallback串口接收完成中断处理函数
*
* @note none
*
* @param none
*
* @retval none
*/
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
if (huart->Instance == USART1)
{
SCB_InvalidateDCache_by_Addr((uint32_t *)uart1_rx_buffer, UART1_RX_BUFFER_SIZE);
air724_callback_fun();
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t *)uart1_rx_buffer, UART1_RX_BUFFER_SIZE);
}
else if (huart->Instance == USART3)
{
SCB_InvalidateDCache_by_Addr((uint32_t *)uart3_rx_buffer, UART3_RX_BUFFER_SIZE);
rs485_callback_fun();
HAL_UARTEx_ReceiveToIdle_DMA(&huart3, (uint8_t *)uart3_rx_buffer, UART3_RX_BUFFER_SIZE);
}
}
/**
* @brief air724_callback_fun4G数据接收回调函数
*
* @note none
*
* @param none
*
* @retval none
*/
void air724_callback_fun()
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(Air724_Message_Queue, uart1_rx_buffer, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
memset(uart1_rx_buffer, 0, UART1_RX_BUFFER_SIZE);
}
void rs485_callback_fun()
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(RS485_Message_Queue, uart3_rx_buffer, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
memset(uart3_rx_buffer, 0, UART3_RX_BUFFER_SIZE);
}

View File

@@ -0,0 +1,35 @@
#ifndef __HALUSART_H
#define __HALUSART_H
/* Suppress warning messages */
#if defined(__CC_ARM)
// Suppress warning message: extended constant initialiser used
#pragma diag_suppress 1296
#elif defined(__ICCARM__)
#elif defined(__GNUC__)
#endif
/* includes ----------------------------------------------------------------------------------------------*/
#include "global.h"
/* macro ------------------------------------------------------------------------------------------------*/
#define UART1_TX_BUFFER_SIZE 512
#define UART1_RX_BUFFER_SIZE 512
#define UART3_TX_BUFFER_SIZE 256
#define UART3_RX_BUFFER_SIZE 256
/* global variable ---------------------------------------------------------------------------------------*/
extern uint8_t uart1_rx_buffer[UART1_RX_BUFFER_SIZE];
extern uint8_t uart1_tx_buffer[UART1_TX_BUFFER_SIZE];
extern uint8_t uart3_rx_buffer[UART3_RX_BUFFER_SIZE];
extern uint8_t uart3_tx_buffer[UART3_TX_BUFFER_SIZE];
/* function prototype ------------------------------------------------------------------------------------*/
extern void hal_usart_init(void);
extern void air724_callback_fun(void);
extern void rs485_callback_fun(void);
extern void Air724_Message_Send(uint8_t *data, uint16_t len);
extern void Rs485_Message_Send(uint8_t *data, uint16_t len);
#endif /* __HALUSART_H */