mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-04-28 23:39:55 +08:00
清空
This commit is contained in:
parent
51e946c04e
commit
453c64690a
@ -1,33 +0,0 @@
|
||||
/*
|
||||
初始化任务
|
||||
*/
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "task\user_task.h"
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
/* Private variables -------------------------------------------------------- */
|
||||
/* Private function --------------------------------------------------------- */
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* \brief 初始化
|
||||
*
|
||||
* \param argument 未使用
|
||||
*/
|
||||
void Task_Init(void *argument) {
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
|
||||
osKernelLock(); // 锁定内核,防止任务切换
|
||||
|
||||
// 创建线程
|
||||
{{thread_creation_code}}
|
||||
|
||||
// 创建消息队列
|
||||
task_runtime.msgq.user_msg= osMessageQueueNew(2u, 10, NULL);
|
||||
|
||||
osKernelUnlock(); // 解锁内核
|
||||
osThreadTerminate(osThreadGetId()); // 任务完成后结束自身
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "task\\user_task.h"
|
||||
#include "task\user_task.h"
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
{{task_name}} Task
|
||||
*/
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "task\user_task.h"
|
||||
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
/* Private variables -------------------------------------------------------- */
|
||||
/* Private function --------------------------------------------------------- */
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* \brief {{task_name}} Task
|
||||
*
|
||||
* \param argument 未使用
|
||||
*/
|
||||
void {{task_function}}(void *argument) {
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
|
||||
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||
const uint32_t delay_tick = osKernelGetTickFreq() / {{task_frequency}};
|
||||
|
||||
osDelay({{task_delay}}); /* 延时一段时间再开启任务 */
|
||||
|
||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||
while (1) {
|
||||
/* 记录任务所使用的的栈空间 */
|
||||
task_runtime.stack_water_mark.{{task_variable}} = osThreadGetStackSpace(osThreadGetId());
|
||||
|
||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||
|
||||
/*User code begin*/
|
||||
|
||||
/*User code end*/
|
||||
|
||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#include "task/user_task.h"
|
||||
|
||||
Task_Runtime_t task_runtime;
|
||||
|
||||
const osThreadAttr_t attr_init = {
|
||||
.name = "Task_Init",
|
||||
.priority = osPriorityRealtime,
|
||||
.stack_size = 256 * 4,
|
||||
};
|
||||
|
||||
//用户自定义任务
|
||||
|
||||
const osThreadAttr_t attr_user_task = {
|
||||
.name = "Task_User",
|
||||
.priority = osPriorityRealtime,
|
||||
.stack_size = 128 * 4,
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
#include "task/user_task.h"
|
||||
#include "task\user_task.h"
|
||||
|
||||
Task_Runtime_t task_runtime;
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
// 定义任务运行时结构体
|
||||
typedef struct {
|
||||
/* 各任务,也可以叫做线程 */
|
||||
struct {
|
||||
osThreadId_t user_task;
|
||||
} thread;
|
||||
|
||||
struct {
|
||||
osMessageQueueId_t pc;
|
||||
} msgq;
|
||||
|
||||
|
||||
struct {
|
||||
uint32_t user_task;
|
||||
} heap_water_mark; /* heap使用 */
|
||||
|
||||
struct {
|
||||
float user_task; /* 用户自定义任务运行频率 */
|
||||
} freq; /* 任务运行频率 */
|
||||
|
||||
struct {
|
||||
uint32_t user_task;
|
||||
} last_up_time; /* 任务最近运行时间 */
|
||||
} Task_Runtime_t;
|
||||
|
||||
|
||||
|
||||
// 任务频率和初始化延时
|
||||
#define TASK_FREQ_USER_TASK (100u) // 用户自定义任务频率
|
||||
|
||||
|
||||
#define TASK_INIT_DELAY_INFO (100u)
|
||||
|
||||
// 任务句柄
|
||||
typedef struct {
|
||||
osThreadId_t user_task; /* 用户自定义任务 */
|
||||
} Task_Handles_t;
|
||||
|
||||
// 任务运行时结构体
|
||||
extern Task_Runtime_t task_runtime;
|
||||
|
||||
// 初始化任务句柄
|
||||
extern const osThreadAttr_t attr_init;
|
||||
|
||||
// 用户自定义任务句柄
|
||||
extern const osThreadAttr_t attr_user_task
|
||||
|
||||
// 任务函数声明
|
||||
//初始化任务
|
||||
void Task_Init(void *argument);
|
||||
//用户自定义任务
|
||||
void Task_UserTask(void *argument);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user