This commit is contained in:
Robofish 2026-03-17 09:52:57 +08:00
parent 89ac086894
commit 415b6e4c0f
6 changed files with 21 additions and 9 deletions

View File

@ -89,6 +89,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
User/module/config.c User/module/config.c
User/module/gimbal.c User/module/gimbal.c
User/module/shoot.c User/module/shoot.c
User/module/cap.c
User/module/cmd/cmd.c User/module/cmd/cmd.c
User/module/cmd/cmd_adapter.c User/module/cmd/cmd_adapter.c
User/module/cmd/cmd_behavior.c User/module/cmd/cmd_behavior.c
@ -107,6 +108,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
User/task/monitor.c User/task/monitor.c
User/task/rc.c User/task/rc.c
User/task/cli.c User/task/cli.c
User/task/cap.c
User/task/user_task.c User/task/user_task.c
User/task/vofa.c User/task/vofa.c
User/task/cmd.c User/task/cmd.c

View File

@ -8,8 +8,8 @@ extern "C" {
#include "device/device.h" #include "device/device.h"
//#include "referee.h" //#include "referee.h"
#define SUPERCAP_CAN BSP_FDCAN_1 #define SUPERCAP_CAN BSP_FDCAN_2
//#define SUPERCAP_CAN BSP_FDCAN_2 // #define SUPERCAP_CAN BSP_FDCAN_3
//#define SUPERCAP_TX_ID 0x301 //C板发给超级电容的ID //#define SUPERCAP_TX_ID 0x301 //C板发给超级电容的ID
//#define SUPERCAP_RX_ID 0x100 //超级电容发给C板的ID //#define SUPERCAP_RX_ID 0x100 //超级电容发给C板的ID

View File

@ -28,14 +28,14 @@ Cap_RefereeUI_t cap_ui;
/* USER PRIVATE CODE END */ /* USER PRIVATE CODE END */
/* Exported functions ------------------------------------------------------- */ /* Exported functions ------------------------------------------------------- */
void Task_super_cap(void *argument) { void Task_cap(void *argument) {
(void)argument; /* 未使用argument消除警告 */ (void)argument; /* 未使用argument消除警告 */
/* 计算任务运行到指定频率需要等待的tick数 */ /* 计算任务运行到指定频率需要等待的tick数 */
const uint32_t delay_tick = osKernelGetTickFreq() / SUPER_CAP_FREQ; const uint32_t delay_tick = osKernelGetTickFreq() / CAP_FREQ;
osDelay(SUPER_CAP_INIT_DELAY); /* 延时一段时间再开启任务 */ osDelay(CAP_INIT_DELAY); /* 延时一段时间再开启任务 */
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */ uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
/* USER CODE INIT BEGIN */ /* USER CODE INIT BEGIN */

View File

@ -43,6 +43,7 @@ void Task_Init(void *argument) {
task_runtime.thread.blink = osThreadNew(Task_blink, NULL, &attr_blink); task_runtime.thread.blink = osThreadNew(Task_blink, NULL, &attr_blink);
task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot); task_runtime.thread.ctrl_shoot = osThreadNew(Task_ctrl_shoot, NULL, &attr_ctrl_shoot);
task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai); task_runtime.thread.ai = osThreadNew(Task_ai, NULL, &attr_ai);
task_runtime.thread.cap = osThreadNew(Task_cap, NULL, &attr_cap);
// task_runtime.thread.vofa = osThreadNew(Task_vofa, NULL, &attr_vofa); // task_runtime.thread.vofa = osThreadNew(Task_vofa, NULL, &attr_vofa);
task_runtime.thread.cli = osThreadNew(Task_cli, NULL, &attr_cli); task_runtime.thread.cli = osThreadNew(Task_cli, NULL, &attr_cli);
// task_runtime.thread.debug = osThreadNew(Task_debug, NULL, &attr_debug); // task_runtime.thread.debug = osThreadNew(Task_debug, NULL, &attr_debug);

View File

@ -74,3 +74,8 @@ const osThreadAttr_t attr_referee = {
.priority = osPriorityNormal, .priority = osPriorityNormal,
.stack_size = 512 * 4, .stack_size = 512 * 4,
}; };
const osThreadAttr_t attr_cap = {
.name = "cap",
.priority = osPriorityNormal,
.stack_size = 256 * 4,
};

View File

@ -24,7 +24,7 @@ extern "C" {
#define DEBUG_FREQ (10.0) #define DEBUG_FREQ (10.0)
#define CMD_FREQ (500.0) #define CMD_FREQ (500.0)
#define REFEREE_FREQ (500.0) #define REFEREE_FREQ (500.0)
#define SUPER_CAP_FREQ (500.0) #define CAP_FREQ (500.0)
/* 任务初始化延时ms */ /* 任务初始化延时ms */
#define TASK_INIT_DELAY (100u) #define TASK_INIT_DELAY (100u)
@ -41,7 +41,7 @@ extern "C" {
#define DEBUG_INIT_DELAY (0) #define DEBUG_INIT_DELAY (0)
#define CMD_INIT_DELAY (0) #define CMD_INIT_DELAY (0)
#define REFEREE_INIT_DELAY (0) #define REFEREE_INIT_DELAY (0)
#define SUPER_CAP_INIT_DELAY (0) #define CAP_INIT_DELAY (0)
/* Exported defines --------------------------------------------------------- */ /* Exported defines --------------------------------------------------------- */
/* Exported macro ----------------------------------------------------------- */ /* Exported macro ----------------------------------------------------------- */
@ -64,7 +64,7 @@ typedef struct {
osThreadId_t debug; osThreadId_t debug;
osThreadId_t cmd; osThreadId_t cmd;
osThreadId_t referee; osThreadId_t referee;
osThreadId_t cap;
} thread; } thread;
/* USER MESSAGE BEGIN */ /* USER MESSAGE BEGIN */
@ -144,6 +144,7 @@ typedef struct {
UBaseType_t ai; UBaseType_t ai;
UBaseType_t vofa; UBaseType_t vofa;
UBaseType_t cli; UBaseType_t cli;
UBaseType_t cap;
UBaseType_t debug; UBaseType_t debug;
UBaseType_t cmd; UBaseType_t cmd;
UBaseType_t referee; UBaseType_t referee;
@ -163,6 +164,7 @@ typedef struct {
float debug; float debug;
float cmd; float cmd;
float referee; float referee;
float cap;
} freq; } freq;
/* 任务最近运行时间 */ /* 任务最近运行时间 */
@ -178,6 +180,7 @@ typedef struct {
float debug; float debug;
float cmd; float cmd;
float referee; float referee;
float cap;
} last_up_time; } last_up_time;
} Task_Runtime_t; } Task_Runtime_t;
@ -199,6 +202,7 @@ extern const osThreadAttr_t attr_vofa;
extern const osThreadAttr_t attr_cli; extern const osThreadAttr_t attr_cli;
extern const osThreadAttr_t attr_debug; extern const osThreadAttr_t attr_debug;
extern const osThreadAttr_t attr_cmd; extern const osThreadAttr_t attr_cmd;
extern const osThreadAttr_t attr_cap;
extern const osThreadAttr_t attr_referee; extern const osThreadAttr_t attr_referee;
/* 任务函数声明 */ /* 任务函数声明 */
@ -216,7 +220,7 @@ void Task_cli(void *argument);
void Task_debug(void *argument); void Task_debug(void *argument);
void Task_cmd(void *argument); void Task_cmd(void *argument);
void Task_referee(void *argument); void Task_referee(void *argument);
void Task_cap(void *argument);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif