54 lines
2.0 KiB
C
54 lines
2.0 KiB
C
/*
|
||
初始化任务
|
||
*/
|
||
|
||
/* Includes ----------------------------------------------------------------- */
|
||
#include "task\user_task.h"
|
||
|
||
/* USER INCLUDE BEGIN */
|
||
#include "bsp/dwt.h"
|
||
#include "device/bmi088.h"
|
||
#include "component/ahrs.h"
|
||
#include "device/ps2.h"
|
||
/* USER INCLUDE BEGIN */
|
||
|
||
/* Private typedef ---------------------------------------------------------- */
|
||
/* Private define ----------------------------------------------------------- */
|
||
/* Private macro ------------------------------------------------------------ */
|
||
/* Private variables -------------------------------------------------------- */
|
||
/* Private function --------------------------------------------------------- */
|
||
/* Exported functions ------------------------------------------------------- */
|
||
|
||
/**
|
||
* \brief 初始化
|
||
*
|
||
* \param argument 未使用
|
||
*/
|
||
void Task_Init(void *argument) {
|
||
(void)argument; /* 未使用argument,消除警告 */
|
||
|
||
osKernelLock(); // 锁定内核,防止任务切换
|
||
|
||
// 创建线程
|
||
task_runtime.thread.ps2 = osThreadNew(Task_ps2, NULL, &attr_ps2);
|
||
task_runtime.thread.test1 = osThreadNew(Task_test1, NULL, &attr_test1);
|
||
task_runtime.thread.atti_esti = osThreadNew(Task_atti_esti, NULL, &attr_atti_esti);
|
||
task_runtime.thread.height_cal = osThreadNew(Task_height_cal, NULL, &attr_height_cal);
|
||
task_runtime.thread.main_control = osThreadNew(Task_main_control, NULL, &attr_main_control);
|
||
// 创建消息队列
|
||
/* USER MESSAGE BEGIN */
|
||
task_runtime.msgq.accl= osMessageQueueNew(5, sizeof(AHRS_Accl_t), NULL);
|
||
task_runtime.msgq.gyro= osMessageQueueNew(5, sizeof(AHRS_Gyro_t), NULL);
|
||
task_runtime.msgq.eulr_imu= osMessageQueueNew(5, sizeof(AHRS_Eulr_t), NULL);
|
||
task_runtime.msgq.baro_height= osMessageQueueNew(3, 4, NULL);
|
||
task_runtime.msgq.fixed_height= osMessageQueueNew(3, 4, NULL);
|
||
task_runtime.msgq.speed_z= osMessageQueueNew(3, 4, NULL);
|
||
task_runtime.msgq.rc= osMessageQueueNew(3, sizeof(PS2_TypeDef), NULL);
|
||
/* USER MESSAGE END */
|
||
|
||
DWT_Init(168);
|
||
osKernelUnlock(); // 解锁内核
|
||
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
||
}
|
||
|