diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d7aefa..30c0629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE # User/module sources User/module/balance_chassis.c + User/module/cmd.c User/module/config.c User/module/gimbal.c User/module/shoot.c @@ -91,7 +92,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE User/task/ai.c User/task/atti_esti.c User/task/blink.c - User/task/command.c + User/task/cmd.c User/task/ctrl_chassis.c User/task/ctrl_gimbal.c User/task/ctrl_shoot.c diff --git a/User/module/command.c b/User/module/cmd.c similarity index 100% rename from User/module/command.c rename to User/module/cmd.c diff --git a/User/module/cmd.h b/User/module/cmd.h new file mode 100644 index 0000000..445d39d --- /dev/null +++ b/User/module/cmd.h @@ -0,0 +1,19 @@ +/* + 控制命令 +*/ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + + + +#ifdef __cplusplus +} +#endif diff --git a/User/module/command.h b/User/module/command.h deleted file mode 100644 index e69de29..0000000 diff --git a/User/task/atti_esti.c b/User/task/atti_esti.c index 63bb56a..2a0e8a9 100644 --- a/User/task/atti_esti.c +++ b/User/task/atti_esti.c @@ -160,6 +160,4 @@ void Task_atti_esti(void *argument) { osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */ } -} - - +} \ No newline at end of file diff --git a/User/task/command.c b/User/task/cmd.c similarity index 85% rename from User/task/command.c rename to User/task/cmd.c index 9d11fc7..a0f2d07 100644 --- a/User/task/command.c +++ b/User/task/cmd.c @@ -1,5 +1,5 @@ /* - command Task + cmd Task */ @@ -19,14 +19,14 @@ /* Private function --------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */ -void Task_command(void *argument) { +void Task_cmd(void *argument) { (void)argument; /* 未使用argument,消除警告 */ /* 计算任务运行到指定频率需要等待的tick数 */ - const uint32_t delay_tick = osKernelGetTickFreq() / COMMAND_FREQ; + const uint32_t delay_tick = osKernelGetTickFreq() / CMD_FREQ; - osDelay(COMMAND_INIT_DELAY); /* 延时一段时间再开启任务 */ + osDelay(CMD_INIT_DELAY); /* 延时一段时间再开启任务 */ uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */ /* USER CODE INIT BEGIN */ @@ -36,7 +36,7 @@ void Task_command(void *argument) { while (1) { tick += delay_tick; /* 计算下一个唤醒时刻 */ /* USER CODE BEGIN */ - + /* USER CODE END */ osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */ } diff --git a/User/task/config.yaml b/User/task/config.yaml index d7b2264..0104238 100644 --- a/User/task/config.yaml +++ b/User/task/config.yaml @@ -58,6 +58,6 @@ description: '' freq_control: true frequency: 500.0 - function: Task_command - name: command + function: Task_cmd + name: cmd stack: 256 diff --git a/User/task/init.c b/User/task/init.c index aeaad5d..ad6ec55 100644 --- a/User/task/init.c +++ b/User/task/init.c @@ -41,7 +41,7 @@ void Task_Init(void *argument) { task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot); task_runtime.thread.monitor = osThreadNew(Task_monitor, NULL, &attr_monitor); task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai); - task_runtime.thread.command = osThreadNew(Task_command, NULL, &attr_command); + task_runtime.thread.cmd = osThreadNew(Task_cmd, NULL, &attr_cmd); // 创建消息队列 /* USER MESSAGE BEGIN */ diff --git a/User/task/user_task.c b/User/task/user_task.c index d5928b6..d3ddc0a 100644 --- a/User/task/user_task.c +++ b/User/task/user_task.c @@ -49,8 +49,8 @@ const osThreadAttr_t attr_ai = { .priority = osPriorityNormal, .stack_size = 256 * 4, }; -const osThreadAttr_t attr_command = { - .name = "command", +const osThreadAttr_t attr_cmd = { + .name = "cmd", .priority = osPriorityNormal, .stack_size = 256 * 4, }; \ No newline at end of file diff --git a/User/task/user_task.h b/User/task/user_task.h index 91f3040..b055b3e 100644 --- a/User/task/user_task.h +++ b/User/task/user_task.h @@ -21,7 +21,7 @@ extern "C" { #define CTRL_SHOOT_FREQ (500.0) #define MONITOR_FREQ (500.0) #define AI_FREQ (500.0) -#define COMMAND_FREQ (500.0) +#define CMD_FREQ (500.0) /* 任务初始化延时ms */ #define TASK_INIT_DELAY (100u) @@ -33,7 +33,7 @@ extern "C" { #define CTRL_SHOOT_INIT_DELAY (0) #define MONITOR_INIT_DELAY (0) #define AI_INIT_DELAY (0) -#define COMMAND_INIT_DELAY (0) +#define CMD_INIT_DELAY (0) /* Exported defines --------------------------------------------------------- */ /* Exported macro ----------------------------------------------------------- */ @@ -51,7 +51,7 @@ typedef struct { osThreadId_t ctrl_shoot; osThreadId_t monitor; osThreadId_t ai; - osThreadId_t command; + osThreadId_t cmd; } thread; /* USER MESSAGE BEGIN */ @@ -70,6 +70,11 @@ typedef struct { struct { osMessageQueueId_t shoot_cmd; /* 发射命令队列 */ }shoot; + struct { + osMessageQueueId_t rc; + osMessageQueueId_t ref; + osMessageQueueId_t ai; + }cmd; } msgq; /* USER MESSAGE END */ @@ -94,7 +99,7 @@ typedef struct { UBaseType_t ctrl_shoot; UBaseType_t monitor; UBaseType_t ai; - UBaseType_t command; + UBaseType_t cmd; } stack_water_mark; /* 各任务运行频率 */ @@ -107,7 +112,7 @@ typedef struct { float ctrl_shoot; float monitor; float ai; - float command; + float cmd; } freq; /* 任务最近运行时间 */ @@ -120,7 +125,7 @@ typedef struct { float ctrl_shoot; float monitor; float ai; - float command; + float cmd; } last_up_time; } Task_Runtime_t; @@ -138,7 +143,7 @@ extern const osThreadAttr_t attr_ctrl_gimbal; extern const osThreadAttr_t attr_ctrl_shoot; extern const osThreadAttr_t attr_monitor; extern const osThreadAttr_t attr_ai; -extern const osThreadAttr_t attr_command; +extern const osThreadAttr_t attr_cmd; /* 任务函数声明 */ void Task_Init(void *argument); @@ -150,7 +155,7 @@ void Task_ctrl_gimbal(void *argument); void Task_ctrl_shoot(void *argument); void Task_monitor(void *argument); void Task_ai(void *argument); -void Task_command(void *argument); +void Task_cmd(void *argument); #ifdef __cplusplus }