60 lines
2.6 KiB
C
60 lines
2.6 KiB
C
/*
|
||
Init Task
|
||
任务初始化,创建各个线程任务和消息队列
|
||
*/
|
||
|
||
/* Includes ----------------------------------------------------------------- */
|
||
#include "task/user_task.h"
|
||
|
||
/* USER INCLUDE BEGIN */
|
||
#include "module/gimbal.h"
|
||
#include "module/chassic.h"
|
||
#include "remote_control.h"
|
||
#include "telescoping_gimal.h"
|
||
/* USER INCLUDE END */
|
||
|
||
/* Private typedef ---------------------------------------------------------- */
|
||
/* Private define ----------------------------------------------------------- */
|
||
/* Private macro ------------------------------------------------------------ */
|
||
/* Private variables -------------------------------------------------------- */
|
||
/* Private function --------------------------------------------------------- */
|
||
/* Exported functions ------------------------------------------------------- */
|
||
|
||
/**
|
||
* \brief 初始化
|
||
*
|
||
* \param argument 未使用
|
||
*/
|
||
void Task_Init(void *argument) {
|
||
(void)argument; /* 未使用argument,消除警告 */
|
||
/* USER CODE INIT BEGIN */
|
||
|
||
/* USER CODE INIT END */
|
||
osKernelLock(); /* 锁定内核,防止任务切换 */
|
||
|
||
/* 创建任务线程 */
|
||
task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai);
|
||
task_runtime.thread.gimbal_ctrl = osThreadNew(Task_gimbal_ctrl, NULL, &attr_gimbal_ctrl);
|
||
task_runtime.thread.chassis_ctrl = osThreadNew(Task_chassis_ctrl, NULL, &attr_chassis_ctrl);
|
||
task_runtime.thread.shoot_ctrl = osThreadNew(Task_shoot_ctrl, NULL, &attr_shoot_ctrl);
|
||
task_runtime.thread.telecoping = osThreadNew(Task_telecoping, NULL, &attr_telecoping);
|
||
task_runtime.thread.atti_esti = osThreadNew(Task_atti_esti, NULL, &attr_atti_esti);
|
||
task_runtime.thread.remote_ctrl = osThreadNew(Task_remote_ctrl, NULL, &attr_remote_ctrl);
|
||
|
||
// 创建消息队列
|
||
/* USER MESSAGE BEGIN */
|
||
task_runtime.msgq.user_msg= osMessageQueueNew(2u, 10, NULL);
|
||
task_runtime.msgq.gimbal.imu= osMessageQueueNew(2u, sizeof(Gimbal_IMU_t), NULL);
|
||
task_runtime.msgq.gimbal.cmd= osMessageQueueNew(2u, sizeof(Gimbal_CMD_t), NULL);
|
||
task_runtime.msgq.gimbal.remote= osMessageQueueNew(2u, sizeof(RC_ctrl_t), NULL);
|
||
task_runtime.msgq.shoot.shoot_cmd= osMessageQueueNew(2u, sizeof(COMP_AT9S_CMD_t), NULL);
|
||
|
||
task_runtime.msgq.chassic.cmd= osMessageQueueNew(2u, sizeof(Chassis_CMD_t), NULL);
|
||
// task_runtime.msgq.chassic.remote=osMessageQueueNew(2u, sizeof(Chassis_CMD_t), NULL);
|
||
task_runtime.msgq.chassic.state= osMessageQueueNew(2u, sizeof(Chassis_t), NULL);
|
||
task_runtime.msgq.telescoping.cmd= osMessageQueueNew(2u, sizeof(Telescoping_CMD_t), NULL);
|
||
/* USER MESSAGE END */
|
||
|
||
osKernelUnlock(); // 解锁内核
|
||
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
||
} |