优化代码模版

This commit is contained in:
Robofish 2025-06-19 01:10:01 +08:00
parent fc94a3fa33
commit 22bddbcda7
3 changed files with 17 additions and 24 deletions

View File

@ -1,22 +1,24 @@
/* /*
{{task_name}} Task {{task_name}} Task
{{task_description}}
*/ */
/* Includes ----------------------------------------------------------------- */ /* Includes ----------------------------------------------------------------- */
#include "task\user_task.h" #include "task/user_task.h"
/* USER INCLUDE BEGIN*/
/* USER INCLUDE END*/
/* Private typedef ---------------------------------------------------------- */ /* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */ /* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */ /* Private variables -------------------------------------------------------- */
/* USER STRUCT BEGIN*/
/* USER STRUCT END*/
/* Private function --------------------------------------------------------- */ /* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
/**
* \brief {{task_name}} Task
*
* \param argument 未使用
*/
void {{task_function}}(void *argument) { void {{task_function}}(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */
@ -28,11 +30,9 @@ void {{task_function}}(void *argument) {
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */ uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
while (1) { while (1) {
tick += delay_tick; /* 计算下一个唤醒时刻 */ tick += delay_tick; /* 计算下一个唤醒时刻 */
/* USER CODE BEGIN */
/*User code begin*/ /* USER CODE END */
/*User code end*/
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */ osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
} }
} }

View File

@ -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}}

View File

@ -47,16 +47,16 @@ typedef struct {
/* USER CONFIG END */ /* USER CONFIG END */
/* 各任务运行频率 */
struct {
{{freq_definitions}}
} freq;
/* 各任务的stack使用 */ /* 各任务的stack使用 */
struct { struct {
{{stack_definitions}} {{stack_definitions}}
} stack_water_mark; } stack_water_mark;
/* 各任务运行频率 */
struct {
{{freq_definitions}}
} freq;
/* 任务最近运行时间 */ /* 任务最近运行时间 */
struct { struct {
{{last_up_time_definitions}} {{last_up_time_definitions}}
@ -64,12 +64,6 @@ typedef struct {
} Task_Runtime_t; } Task_Runtime_t;
/* 任务句柄 */
typedef struct {
{{task_handle_definitions}}
} Task_Handles_t;
/* 任务运行时结构体 */ /* 任务运行时结构体 */
extern Task_Runtime_t task_runtime; extern Task_Runtime_t task_runtime;
@ -77,7 +71,6 @@ 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}}