sick_dt35/User/task/init.c
2025-04-02 16:20:48 +08:00

43 lines
1.5 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.

/*
初始化任务
根据机器人的FLASH配置决定生成哪些任务。
*/
/* Includes ----------------------------------------------------------------- */
#include "task\user_task.h"
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
osMessageQueueId_t adcQueueHandle;
osMessageQueueId_t pcQueueHandle;
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
/**
* \brief 初始化
*
* \param argument 未使用
*/
void Task_Init(void *argument) {
(void)argument; /* 未使用argument消除警告 */
osKernelLock(); // 锁定内核,防止任务切换
// 创建任务,确保任务创建成功
osThreadId_t monitorTaskHandle = osThreadNew(Task_Monitor, NULL, &attr_monitor);
osThreadId_t adcReadTaskHandle = osThreadNew(Task_Adc, NULL, &attr_adc);
osThreadId_t canTaskHandle = osThreadNew(Task_Can, NULL, &attr_can);
osThreadId_t pcTaskHandle = osThreadNew(Task_PC, NULL, &attr_pc);
//创建消息队列
adcQueueHandle = osMessageQueueNew(2u, sizeof(uint16_t), NULL);
pcQueueHandle = osMessageQueueNew(2u, sizeof(uint16_t), NULL);
osKernelUnlock(); // 解锁内核
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
}