Release:5.20灰测

This commit is contained in:
2026-05-21 10:01:28 +08:00
parent 8a5a32b139
commit fd65e9c6a2
68 changed files with 4329 additions and 1489 deletions

View File

@@ -23,10 +23,11 @@
*
* @retval none
*/
void Os_Init(void)
void os_init(void)
{
Os_Semaphore_Init();
Os_Task_Init();
Os_Semaphore_Init();/* 初始化信号量 */
Os_Task_Init();/* 初始化任务 */
SwTimer_Init();/* 初始化软件定时器 */
}

View File

@@ -7,7 +7,7 @@
/* Exported functions prototypes ------------------------------------------------------------------------*/
void Os_Init(void);
void os_init(void);
/* Exported constants --------------------------------------------------------*/

View File

@@ -10,7 +10,7 @@
/* Includes -------------------------------------------------------------------*/
#include "os_queue.h"
#include "ChargerTask.h"
#include "task_udp.h"
/*-内核对象句柄-队列-*/
QueueHandle_t Air724_Message_Queue = NULL; /* 4G数据接收队列 */
@@ -21,7 +21,7 @@ QueueHandle_t UDP_Message_Queue = NULL; /* UDP数据接收队列 */
void Air724_Message_Queue_Init(void)
{
Air724_Message_Queue = xQueueCreate(5, UART1_RX_BUFFER_SIZE);
Air724_Message_Queue = xQueueCreate(20, UART1_RX_BUFFER_SIZE);
if (Air724_Message_Queue == NULL)
{
printf("Air724_Message_Queue_Init Failed\r\n");
@@ -43,7 +43,7 @@ void RS485_Message_Queue_Init(void)
void UDP_Message_Queue_Init(void)
{
UDP_Message_Queue = xQueueCreate(5, sizeof(UdpMsg_t));
UDP_Message_Queue = xQueueCreate(20, sizeof(UdpMsg_t));
if (UDP_Message_Queue == NULL)
{
// 创建失败处理

View File

@@ -12,26 +12,26 @@
#include "os_task.h"
/*-任务句柄-*/
osThreadId HeartbeatTaskHandle; /* 心跳任务句柄 */
osThreadId SysTaskHandle; /* 系统任务句柄 */
osThreadId UDPTaskHandle; /* UDP 消息队列接受任务句柄 */
osThreadId UDP_ParseTaskHandle; /* UDP 消息队列解析任务句柄 */
osThreadId DownLinkTaskHandle; /* 4G接收消息任务句柄 */
osThreadId Air724_ParseTaskHandle; /* 4G消息队列解析任务句柄 */
osThreadId YkcTaskHandle; /* 云快充平台交互任务句柄 */
/*-函数声明-*/
void HeartbeatTask_Function(void const *argument); // 心跳任务
void sys_task_function(void const *argument); // 系统任务
void UDPTask_Function(void const *argument); // UDP 接受任务
void udp_recv_task_function(void const *argument); // UDP 接受任务
void UDP_ParseTask_Function(void const *argument); //UDP消息解析任务
void udp_parse_task_function(void const *argument); //UDP消息解析任务
void YkcTask_Function(void const *argument); // 云快充平台交互任务
void ykc_task_function(void const *argument); // 云快充平台交互任务
void DownLinkTask_Function(void const *argument); // 4G接收消息任务
void air724_recv_task_function(void const *argument); // 云快充 TCP 消息解析任务
/* code -----------------------------------------------------------------------*/
@@ -49,20 +49,16 @@ void Os_Task_Init(void) /*任务入口函数、任务名字、任务栈大小、
{
BaseType_t xReturn = pdPASS;
/* 心跳任务 */
xReturn = xTaskCreate((TaskFunction_t)HeartbeatTask_Function, "HeartbeatTask", 128, NULL, (UBaseType_t)osPriorityLow, &HeartbeatTaskHandle);
/* 4G消息解析任务 */
xReturn = xTaskCreate((TaskFunction_t)DownLinkTask_Function, "DownLinkTask", 1024, NULL, osPriorityAboveNormal, &DownLinkTaskHandle);
/* 系统任务 */
xReturn = xTaskCreate((TaskFunction_t)sys_task_function, "SysTask", 128, NULL, (UBaseType_t)osPriorityLow, &SysTaskHandle);
/* 云快充 TCP 消息解析任务 */
xReturn = xTaskCreate((TaskFunction_t)air724_recv_task_function, "Air724RecvTask", 1024, NULL, osPriorityAboveNormal, &Air724_ParseTaskHandle);
/* UDP 消息队列接受任务 */
xReturn = xTaskCreate((TaskFunction_t)UDPTask_Function, "UDPTask", 1536, NULL, osPriorityHigh, &UDPTaskHandle);
xReturn = xTaskCreate((TaskFunction_t)udp_recv_task_function, "UDPRecvTask", 1536, NULL, osPriorityHigh, &UDPTaskHandle);
/* UDP 消息解析任务 */
xReturn = xTaskCreate((TaskFunction_t)UDP_ParseTask_Function, "UDPParseTask", 2048, NULL, osPriorityAboveNormal, &UDP_ParseTaskHandle);
xReturn = xTaskCreate((TaskFunction_t)udp_parse_task_function, "UDPParseTask", 2048, NULL, osPriorityAboveNormal, &UDP_ParseTaskHandle);
/* 云快充平台交互任务 */
xReturn = xTaskCreate((TaskFunction_t)YkcTask_Function, "YKCTask", 1024, NULL, osPriorityAboveNormal, &YkcTaskHandle);
xReturn = xTaskCreate((TaskFunction_t)ykc_task_function, "YKC_Task", 1024, NULL, osPriorityAboveNormal, &YkcTaskHandle);
if (xReturn == pdPASS)
{

View File

@@ -9,13 +9,13 @@
void Os_Task_Init(void);
/* Exported constants --------------------------------------------------------*/
extern osThreadId HeartbeatTaskHandle; /* 心跳任务句柄 */
extern osThreadId SysTaskHandle; /* 系统任务句柄 */
extern osThreadId UDPTaskHandle; /* UDP 消息队列接受任务句柄 */
extern osThreadId UDP_ParseTaskHandle; /* UDP 消息队列解析任务句柄 */
extern osThreadId DownLinkTaskHandle; /* 消息任务句柄 */
extern osThreadId Air724_ParseTaskHandle; /* 4G消息队列解析任务句柄 */
extern osThreadId YkcTaskHandle; /* 云快充平台交互任务句柄 */

147
Core/User/Os/os_timer.c Normal file
View File

@@ -0,0 +1,147 @@
/**
******************************************************************************
* @file user\os\os_timer.c
* @author luhuaishuai
* @version v0.1
* @date 2026-1-12
* @brief 软件定时器管理
******************************************************************************
*/
/* Includes -------------------------------------------------------------------*/
#include "os_timer.h"
#include "task_ykc.h"
/* variables ------------------------------------------------------------------*/
TimerHandle_t YkcTimerHandle = NULL;
/* code -----------------------------------------------------------------------*/
/**
* @brief 软件定时器初始化
* @note 需要在 FreeRTOS 启动前调用
* @param none
* @retval none
*/
void SwTimer_Init(void)
{
SwTimer_YkcTimer_Init();
}
/**
* @brief 创建软件定时器
* @param name 定时器名称
* @param period_ms 定时周期(ms)
* @param auto_reload true:周期模式 false:单次模式
* @param callback 定时器回调函数
* @retval TimerHandle_t 定时器句柄NULL 表示创建失败
*/
TimerHandle_t SwTimer_Create(const char *name,
uint32_t period_ms,
bool auto_reload,
SwTimerCallback_t callback)
{
UBaseType_t reload = auto_reload ? pdTRUE : pdFALSE;
TimerHandle_t xTimer = xTimerCreate(name,
pdMS_TO_TICKS(period_ms),
reload,
NULL,
callback);
if (xTimer == NULL)
{
printf("SwTimer_Create Failed: %s\r\n", name);
}
return xTimer;
}
/**
* @brief 启动软件定时器
* @param xTimer 定时器句柄
* @retval none
*/
void SwTimer_Start(TimerHandle_t xTimer)
{
if (xTimer != NULL)
{
if (xTimerStart(xTimer, 0) != pdPASS)
{
printf("SwTimer_Start Failed\r\n");
}
}
}
/**
* @brief 停止软件定时器
* @param xTimer 定时器句柄
* @retval none
*/
void SwTimer_Stop(TimerHandle_t xTimer)
{
if (xTimer != NULL)
{
if (xTimerStop(xTimer, 0) != pdPASS)
{
printf("SwTimer_Stop Failed\r\n");
}
}
}
/**
* @brief 复位软件定时器
* @param xTimer 定时器句柄
* @retval none
*/
void SwTimer_Reset(TimerHandle_t xTimer)
{
if (xTimer != NULL)
{
if (xTimerReset(xTimer, 0) != pdPASS)
{
printf("SwTimer_Reset Failed\r\n");
}
}
}
/**
* @brief 创建充电桩状态检查定时器
* @note 500ms 周期,自动重载,遍历检查 1-6 号桩状态
* @param none
* @retval none
*/
void SwTimer_YkcTimer_Init(void)
{
YkcTimerHandle = SwTimer_Create("YkcTimer",
2500,
true,
ykc_timer_callback_function);
if (YkcTimerHandle != NULL)
{
SwTimer_Start(YkcTimerHandle);
printf("YkcTimer_Init\r\n");
}
else
{
printf("YkcTimer_Init Failed\r\n");
}
}
/**
* @brief 修改定时器周期
* @param xTimer 定时器句柄
* @param period_ms 新周期(ms)
* @retval none
*/
void SwTimer_ChangePeriod(TimerHandle_t xTimer, uint32_t period_ms)
{
if (xTimer != NULL)
{
if (xTimerChangePeriod(xTimer, pdMS_TO_TICKS(period_ms), 0) != pdPASS)
{
printf("SwTimer_ChangePeriod Failed\r\n");
}
}
}

29
Core/User/Os/os_timer.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef __OSTIMER_H
#define __OSTIMER_H
/* Private includes ----------------------------------------------------------*/
#include "global.h"
/* Exported types ------------------------------------------------------------*/
typedef void (*SwTimerCallback_t)(TimerHandle_t xTimer);
/* Exported functions prototypes ---------------------------------------------*/
void SwTimer_Init(void);
TimerHandle_t SwTimer_Create(const char *name,
uint32_t period_ms,
bool auto_reload,
SwTimerCallback_t callback);
void SwTimer_Start(TimerHandle_t xTimer);
void SwTimer_Stop(TimerHandle_t xTimer);
void SwTimer_Reset(TimerHandle_t xTimer);
void SwTimer_ChangePeriod(TimerHandle_t xTimer, uint32_t period_ms);
void SwTimer_YkcTimer_Init(void);
/* Exported constants --------------------------------------------------------*/
extern TimerHandle_t YkcTimerHandle;
#endif