工程提交
This commit is contained in:
32
Core/User/Os/os_init.c
Normal file
32
Core/User/Os/os_init.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file user\os\os_init.c
|
||||
* @author luhuaishuai
|
||||
* @version v0.1
|
||||
* @date 2026-1-12
|
||||
* @brief Briefly describe the function of your function
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Includes -------------------------------------------------------------------*/
|
||||
#include "os_init.h"
|
||||
|
||||
|
||||
/* code -----------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Os_Init:所有系统相关初始化
|
||||
*
|
||||
* @note none
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void Os_Init(void)
|
||||
{
|
||||
|
||||
Os_Semaphore_Init();
|
||||
Os_Task_Init();
|
||||
}
|
||||
|
||||
16
Core/User/Os/os_init.h
Normal file
16
Core/User/Os/os_init.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef __OSINIT_H
|
||||
#define __OSINIT_H
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
#include "global.h"
|
||||
|
||||
|
||||
|
||||
/* Exported functions prototypes ------------------------------------------------------------------------*/
|
||||
void Os_Init(void);
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
|
||||
53
Core/User/Os/os_queue.c
Normal file
53
Core/User/Os/os_queue.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file user\os\os_queue.c
|
||||
* @author luhuaishuai
|
||||
* @version v0.1
|
||||
* @date 2026-1-12
|
||||
* @brief Briefly describe the function of your function
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes -------------------------------------------------------------------*/
|
||||
#include "os_queue.h"
|
||||
#include "ChargerTask.h"
|
||||
|
||||
/*-内核对象句柄-队列-*/
|
||||
QueueHandle_t Air724_Message_Queue = NULL; /* 4G数据接收队列 */
|
||||
QueueHandle_t RS485_Message_Queue = NULL; /* RS485数据接收队列 */
|
||||
QueueHandle_t UDP_Message_Queue = NULL; /* UDP数据接收队列 */
|
||||
|
||||
/* code --------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void Air724_Message_Queue_Init(void)
|
||||
{
|
||||
Air724_Message_Queue = xQueueCreate(5, UART1_RX_BUFFER_SIZE);
|
||||
if (Air724_Message_Queue == NULL)
|
||||
{
|
||||
printf("Air724_Message_Queue_Init Failed\r\n");
|
||||
// 创建失败处理
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void RS485_Message_Queue_Init(void)
|
||||
{
|
||||
RS485_Message_Queue = xQueueCreate(5, UART3_RX_BUFFER_SIZE);
|
||||
if (RS485_Message_Queue == NULL)
|
||||
{
|
||||
// 创建失败处理
|
||||
printf("RS485_Message_Queue_Init error\r\n");
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void UDP_Message_Queue_Init(void)
|
||||
{
|
||||
UDP_Message_Queue = xQueueCreate(5, sizeof(UdpMsg_t));
|
||||
if (UDP_Message_Queue == NULL)
|
||||
{
|
||||
// 创建失败处理
|
||||
printf("UDP_Message_Queue_Init Failed\r\n");
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
28
Core/User/Os/os_queue.h
Normal file
28
Core/User/Os/os_queue.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef __OSQUEUE_H
|
||||
#define __OSQUEUE_H
|
||||
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Air724_Message_Queue_Init(void);
|
||||
void RS485_Message_Queue_Init(void);
|
||||
void UDP_Message_Queue_Init(void);
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
extern QueueHandle_t Air724_Message_Queue;
|
||||
extern QueueHandle_t RS485_Message_Queue;
|
||||
extern QueueHandle_t UDP_Message_Queue;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
54
Core/User/Os/os_semaphore.c
Normal file
54
Core/User/Os/os_semaphore.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file user\os\os_queue.c
|
||||
* @author luhuaishuai
|
||||
* @version v0.1
|
||||
* @date 2026-1-12
|
||||
* @brief Briefly describe the function of your function
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes -------------------------------------------------------------------*/
|
||||
#include "os_semaphore.h"
|
||||
|
||||
|
||||
/*-内核对象句柄-信号量-*/
|
||||
|
||||
|
||||
|
||||
/*-函数声明-*/
|
||||
void xMutex_Semaphore_Create(void);
|
||||
|
||||
|
||||
/* code -----------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Os_Semaphore_Init:所有信号量相关初始化
|
||||
*
|
||||
* @note none
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void Os_Semaphore_Init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief xMutex_Semaphore_Create:互斥信号量初始化
|
||||
*
|
||||
* @note none
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void xMutex_Semaphore_Create(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
22
Core/User/Os/os_semaphore.h
Normal file
22
Core/User/Os/os_semaphore.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __OSSEMAPHORE_H
|
||||
#define __OSSEMAPHORE_H
|
||||
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
|
||||
|
||||
/* Exported functions prototypes ------------------------------------------------------------------------*/
|
||||
void Os_Semaphore_Init(void);
|
||||
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
extern SemaphoreHandle_t PC_tx_xMutex_Handle;
|
||||
extern SemaphoreHandle_t Usart6_xMutex_Handle;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
97
Core/User/Os/os_task.c
Normal file
97
Core/User/Os/os_task.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file user\os\os_task.c
|
||||
* @author luhuaishuai
|
||||
* @version v0.1
|
||||
* @date 2026-1-12
|
||||
* @brief Briefly describe the function of your function
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes -------------------------------------------------------------------*/
|
||||
#include "os_task.h"
|
||||
|
||||
/*-任务句柄-*/
|
||||
osThreadId HeartbeatTaskHandle; /* 心跳任务句柄 */
|
||||
|
||||
osThreadId UDPTaskHandle; /* UDP 消息队列接受任务句柄 */
|
||||
|
||||
osThreadId UDP_ParseTaskHandle; /* UDP 消息队列解析任务句柄 */
|
||||
|
||||
osThreadId DownLinkTaskHandle; /* 4G接收消息任务句柄 */
|
||||
|
||||
osThreadId YkcTaskHandle; /* 云快充平台交互任务句柄 */
|
||||
|
||||
/*-函数声明-*/
|
||||
void HeartbeatTask_Function(void const *argument); // 心跳任务
|
||||
|
||||
void UDPTask_Function(void const *argument); // UDP 接受任务
|
||||
|
||||
void UDP_ParseTask_Function(void const *argument); //UDP消息解析任务
|
||||
|
||||
void YkcTask_Function(void const *argument); // 云快充平台交互任务
|
||||
|
||||
void DownLinkTask_Function(void const *argument); // 4G接收消息任务
|
||||
|
||||
/* code -----------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Os_Task_Init:所有任务的创建
|
||||
*
|
||||
* @note definition and creation of xxxTask
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
/* UDP 消息队列接受任务 */
|
||||
xReturn = xTaskCreate((TaskFunction_t)UDPTask_Function, "UDPTask", 512, NULL, osPriorityAboveNormal, &UDPTaskHandle);
|
||||
|
||||
/* UDP 消息解析任务 */
|
||||
xReturn = xTaskCreate((TaskFunction_t)UDP_ParseTask_Function, "UDPParseTask", 1024, NULL, osPriorityAboveNormal, &UDP_ParseTaskHandle);
|
||||
|
||||
/* 云快充平台交互任务 */
|
||||
xReturn = xTaskCreate((TaskFunction_t)YkcTask_Function, "YKCTask", 1024, NULL, osPriorityAboveNormal, &YkcTaskHandle);
|
||||
|
||||
if (xReturn == pdPASS)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------Function implementing the xxxTask thread----------------------------------------*/
|
||||
|
||||
__weak void HeartbeatTask_Function(void const *argument)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
__weak void DownLinkTask_Function(void const *argument)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
__weak void UPLinkTask_Function(void const *argument)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
22
Core/User/Os/os_task.h
Normal file
22
Core/User/Os/os_task.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __OSTASK_H
|
||||
#define __OSTASK_H
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
|
||||
#include "global.h"
|
||||
|
||||
/* Exported functions prototypes ------------------------------------------------------------------------*/
|
||||
void Os_Task_Init(void);
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
extern osThreadId HeartbeatTaskHandle; /* 心跳任务句柄 */
|
||||
|
||||
extern osThreadId UDPTaskHandle; /* UDP 消息队列接受任务句柄 */
|
||||
|
||||
extern osThreadId UDP_ParseTaskHandle; /* UDP 消息队列解析任务句柄 */
|
||||
|
||||
extern osThreadId DownLinkTaskHandle; /* 消息任务句柄 */
|
||||
|
||||
extern osThreadId YkcTaskHandle; /* 云快充平台交互任务句柄 */
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user