mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-07-05 15:04:15 +08:00
Compare commits
No commits in common. "fc94a3fa33226b6e7f3417b9bb10ac73f3424c60" and "94841a02ddf4813c49b896eec904b1d514bcb7e8" have entirely different histories.
fc94a3fa33
...
94841a02dd
@ -1,10 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
Init Task
|
初始化任务
|
||||||
任务初始化,创建各个线程任务和消息队列
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "task/user_task.h"
|
#include "task\user_task.h"
|
||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
/* USER INCLUDE BEGIN */
|
||||||
|
|
||||||
@ -24,19 +23,16 @@
|
|||||||
*/
|
*/
|
||||||
void Task_Init(void *argument) {
|
void Task_Init(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
/* USER CODE BEGIN Task_Init */
|
|
||||||
|
|
||||||
/* USER CODE END Task_Init */
|
osKernelLock(); // 锁定内核,防止任务切换
|
||||||
osKernelLock(); /* 锁定内核,防止任务切换 */
|
|
||||||
|
// 创建线程
|
||||||
/* 创建任务线程 */
|
|
||||||
{{thread_creation_code}}
|
{{thread_creation_code}}
|
||||||
|
|
||||||
// 创建消息队列
|
// 创建消息队列
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
task_runtime.msgq.user_msg= osMessageQueueNew(2u, 10, NULL);
|
task_runtime.msgq.user_msg= osMessageQueueNew(2u, 10, NULL);
|
||||||
/* USER MESSAGE END */
|
/* USER MESSAGE END */
|
||||||
|
|
||||||
osKernelUnlock(); // 解锁内核
|
osKernelUnlock(); // 解锁内核
|
||||||
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "task/user_task.h"
|
#include "task\user_task.h"
|
||||||
|
|
||||||
Task_Runtime_t task_runtime;
|
Task_Runtime_t task_runtime;
|
||||||
|
|
||||||
@ -8,5 +8,5 @@ const osThreadAttr_t attr_init = {
|
|||||||
.stack_size = 256 * 4,
|
.stack_size = 256 * 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* USER TASK */
|
// USER TASK
|
||||||
{{task_attr_definitions}}
|
{{task_attr_definitions}}
|
||||||
|
@ -3,27 +3,12 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/* Includes ----------------------------------------------------------------- */
|
|
||||||
#include <cmsis_os2.h>
|
#include <cmsis_os2.h>
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
// 定义任务运行时结构体
|
||||||
|
|
||||||
/* USER INCLUDE END */
|
|
||||||
/* Exported constants ------------------------------------------------------- */
|
|
||||||
/* 任务运行频率 */
|
|
||||||
{{task_frequency_definitions}}
|
|
||||||
|
|
||||||
/* 任务初始化延时ms */
|
|
||||||
#define TASK_INIT_DELAY (100u)
|
|
||||||
{{task_init_delay_definitions}}
|
|
||||||
|
|
||||||
/* Exported defines --------------------------------------------------------- */
|
|
||||||
/* Exported macro ----------------------------------------------------------- */
|
|
||||||
/* Exported types ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* 任务运行时结构体 */
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 各任务,也可以叫做线程 */
|
/* 各任务,也可以叫做线程 */
|
||||||
struct {
|
struct {
|
||||||
@ -31,54 +16,41 @@ typedef struct {
|
|||||||
} thread;
|
} thread;
|
||||||
|
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
osMessageQueueId_t user_msg; /* 用户自定义任务消息队列 */
|
osMessageQueueId_t user_msg; /* 用户自定义任务消息队列 */
|
||||||
} msgq;
|
} msgq;
|
||||||
|
|
||||||
/* USER MESSAGE END */
|
/* USER MESSAGE END */
|
||||||
|
|
||||||
/* 机器人状态 */
|
|
||||||
struct {
|
|
||||||
float battery; /* 电池电量百分比 */
|
|
||||||
float vbat; /* 电池电压 */
|
|
||||||
float cpu_temp; /* CPU温度 */
|
|
||||||
} status;
|
|
||||||
|
|
||||||
/* USER CONFIG BEGIN */
|
|
||||||
|
|
||||||
/* USER CONFIG END */
|
|
||||||
|
|
||||||
/* 各任务运行频率 */
|
|
||||||
struct {
|
struct {
|
||||||
{{freq_definitions}}
|
{{freq_definitions}}
|
||||||
} freq;
|
} freq; /* 任务运行频率 */
|
||||||
|
|
||||||
/* 各任务的stack使用 */
|
|
||||||
struct {
|
|
||||||
{{stack_definitions}}
|
|
||||||
} stack_water_mark;
|
|
||||||
|
|
||||||
/* 任务最近运行时间 */
|
|
||||||
struct {
|
struct {
|
||||||
{{last_up_time_definitions}}
|
{{last_up_time_definitions}}
|
||||||
} last_up_time;
|
} last_up_time; /* 任务最近运行时间 */
|
||||||
|
|
||||||
} Task_Runtime_t;
|
} Task_Runtime_t;
|
||||||
|
|
||||||
|
// 任务频率
|
||||||
|
{{task_frequency_definitions}}
|
||||||
|
// 任务初始化延时
|
||||||
|
#define TASK_INIT_DELAY (100u)
|
||||||
|
{{task_init_delay_definitions}}
|
||||||
|
|
||||||
/* 任务句柄 */
|
// 任务句柄
|
||||||
typedef struct {
|
typedef struct {
|
||||||
{{task_handle_definitions}}
|
{{task_handle_definitions}}
|
||||||
} Task_Handles_t;
|
} Task_Handles_t;
|
||||||
|
|
||||||
/* 任务运行时结构体 */
|
// 任务运行时结构体
|
||||||
extern Task_Runtime_t task_runtime;
|
extern Task_Runtime_t task_runtime;
|
||||||
|
|
||||||
/* 初始化任务句柄 */
|
// 初始化任务句柄
|
||||||
extern const osThreadAttr_t attr_init;
|
extern const osThreadAttr_t attr_init;
|
||||||
{{task_attr_declarations}}
|
{{task_attr_declarations}}
|
||||||
|
|
||||||
|
// 任务函数声明
|
||||||
/* 任务函数声明 */
|
|
||||||
void Task_Init(void *argument);
|
void Task_Init(void *argument);
|
||||||
{{task_function_declarations}}
|
{{task_function_declarations}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user