114 lines
2.6 KiB
C
114 lines
2.6 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <cmsis_os2.h>
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
|
|
// 定义任务运行时结构体
|
|
typedef struct {
|
|
/* 各任务,也可以叫做线程 */
|
|
struct {
|
|
osThreadId_t ps2;
|
|
osThreadId_t test1;
|
|
osThreadId_t atti_esti;
|
|
osThreadId_t height_cal;
|
|
osThreadId_t main_control;
|
|
} thread;
|
|
|
|
/* USER MESSAGE BEGIN */
|
|
|
|
struct {
|
|
osMessageQueueId_t user_msg; /* 用户自定义任务消息队列 */
|
|
|
|
|
|
osMessageQueueId_t accl; /* IMU读取 */
|
|
osMessageQueueId_t gyro; /* IMU读取 */
|
|
osMessageQueueId_t eulr_imu; /* 姿态解算得到 */
|
|
|
|
osMessageQueueId_t baro_height;/*气压计海拔高度*/
|
|
|
|
osMessageQueueId_t fixed_height;/*融合高度*/
|
|
osMessageQueueId_t speed_z;/*融合高度*/
|
|
osMessageQueueId_t rc;/*遥控器数据*/
|
|
|
|
} msgq;
|
|
|
|
/* USER MESSAGE END */
|
|
|
|
struct {
|
|
UBaseType_t ps2;
|
|
UBaseType_t test1;
|
|
UBaseType_t atti_esti;
|
|
UBaseType_t height_cal;
|
|
UBaseType_t main_control;
|
|
|
|
} stack_water_mark; /* stack使用 */
|
|
|
|
struct {
|
|
float ps2;
|
|
float test1;
|
|
float atti_esti;
|
|
float height_cal;
|
|
float main_control;
|
|
} freq; /* 任务运行频率 */
|
|
|
|
struct {
|
|
float ps2;
|
|
float test1;
|
|
float atti_esti;
|
|
float height_cal;
|
|
float main_control;
|
|
} last_up_time; /* 任务最近运行时间 */
|
|
|
|
} Task_Runtime_t;
|
|
|
|
// 任务频率
|
|
#define TASK_FREQ_PS2 (20u)
|
|
#define TASK_FREQ_TEST1 (40u)
|
|
#define TASK_FREQ_ATTI_ESTI (400u)
|
|
#define TASK_FREQ_HEIGHT_CAL (200u)
|
|
#define TASK_FREQ_MAIN_CONTROL (500u)
|
|
// 任务初始化延时
|
|
#define TASK_INIT_DELAY (100u)
|
|
#define TASK_INIT_DELAY_PS2 (0u)
|
|
#define TASK_INIT_DELAY_TEST1 (0u)
|
|
#define TASK_INIT_DELAY_ATTI_ESTI (0u)
|
|
#define TASK_INIT_DELAY_HEIGHT_CAL (500u)
|
|
#define TASK_INIT_DELAY_MAIN_CONTROL (500u)
|
|
|
|
|
|
// 任务句柄
|
|
typedef struct {
|
|
osThreadId_t ps2;
|
|
osThreadId_t test1;
|
|
osThreadId_t atti_esti;
|
|
osThreadId_t height_cal;
|
|
osThreadId_t main_control;
|
|
} Task_Handles_t;
|
|
|
|
// 任务运行时结构体
|
|
extern Task_Runtime_t task_runtime;
|
|
extern Task_Handles_t task_handle;
|
|
// 初始化任务句柄
|
|
extern const osThreadAttr_t attr_init;
|
|
extern const osThreadAttr_t attr_ps2;
|
|
extern const osThreadAttr_t attr_test1;
|
|
extern const osThreadAttr_t attr_atti_esti;
|
|
extern const osThreadAttr_t attr_height_cal;
|
|
extern const osThreadAttr_t attr_main_control;
|
|
|
|
// 任务函数声明
|
|
void Task_Init(void *argument);
|
|
void Task_ps2(void *argument);
|
|
void Task_test1(void *argument);
|
|
void Task_atti_esti(void *argument);
|
|
void Task_height_cal(void *argument);
|
|
void Task_main_control(void *argument);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|