From b079188b22698e70b5ebc83decd1455f24dc29bc Mon Sep 17 00:00:00 2001 From: RB Date: Sun, 27 Apr 2025 12:57:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User/task/user_task.c.template | 12 ++++++++ User/task/user_task.h.template | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 User/task/user_task.c.template create mode 100644 User/task/user_task.h.template diff --git a/User/task/user_task.c.template b/User/task/user_task.c.template new file mode 100644 index 0000000..28a4f84 --- /dev/null +++ b/User/task/user_task.c.template @@ -0,0 +1,12 @@ +#include "task/user_task.h" + +Task_Runtime_t task_runtime; + +const osThreadAttr_t attr_init = { + .name = "Task_Init", + .priority = osPriorityRealtime, + .stack_size = 256 * 4, +}; + +// 用户自定义任务 +{task_attr_definitions} \ No newline at end of file diff --git a/User/task/user_task.h.template b/User/task/user_task.h.template new file mode 100644 index 0000000..2892584 --- /dev/null +++ b/User/task/user_task.h.template @@ -0,0 +1,53 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "FreeRTOS.h" +#include "task.h" + +// 定义任务运行时结构体 +typedef struct { + /* 各任务,也可以叫做线程 */ + struct { +{thread_definitions} + } thread; + + struct { +{heap_water_mark_definitions} + } heap_water_mark; /* heap使用 */ + + struct { +{freq_definitions} + } freq; /* 任务运行频率 */ + + struct { +{last_up_time_definitions} + } last_up_time; /* 任务最近运行时间 */ +} Task_Runtime_t; + +// 任务频率和初始化延时 +{task_frequency_definitions} +{task_init_delay_definitions} + +// 任务句柄 +typedef struct { +{task_handle_definitions} +} Task_Handles_t; + +// 任务运行时结构体 +extern Task_Runtime_t task_runtime; + +// 初始化任务句柄 +extern const osThreadAttr_t attr_init; +{task_attr_declarations} + +// 任务函数声明 +void Task_Init(void *argument); +{task_function_declarations} + +#ifdef __cplusplus +} +#endif \ No newline at end of file