god-yuan-hero/User/task/supercap.c
2026-03-18 22:21:50 +08:00

65 lines
2.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
supercap Task
*/
/* Includes ----------------------------------------------------------------- */
#include "task/user_task.h"
/* USER INCLUDE BEGIN */
#include "device/supercap.h"
#include "device/referee_proto_types.h"
/* USER INCLUDE END */
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* USER STRUCT BEGIN */
CAN_SuperCapTXDataTypeDef SuperCap_CanTX;
Referee_ForCap_t cap_ref; /* 裁判系统功率数据 */
/* USER STRUCT END */
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
void Task_supercap(void *argument) {
(void)argument; /* 未使用argument消除警告 */
/* 计算任务运行到指定频率需要等待的tick数 */
const uint32_t delay_tick = osKernelGetTickFreq() / SUPERCAP_FREQ;
osDelay(SUPERCAP_INIT_DELAY); /* 延时一段时间再开启任务 */
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
/* USER CODE INIT BEGIN */
// SuperCap_Init();
// SuperCap_CanTX.Enable = 1 ; //超级电容使能。1使能0失能
// SuperCap_CanTX.Charge = 1 ; //V1.1超级电容充电。1充电0放电在PLUS版本中此标志位无效超电的充放电是自动的
// SuperCap_CanTX.Powerlimit = 120 ; //裁判系统功率限制
// SuperCap_CanTX.ChargePower = 1 ; //V1.1超级电容充电功率在PLUS版本中此参数超电的充电功率随着底盘功率变化
/* USER CODE INIT END */
while (1) {
tick += delay_tick; /* 计算下一个唤醒时刻 */
/* USER CODE BEGIN */
/* 动态更新功率上限裁判系统在线时使用下发值否则回退到初始化值120W */
// osMessageQueueGet(task_runtime.msgq.cap.ref, &cap_ref, NULL, 0);
// if (cap_ref.ref_status == REF_STATUS_RUNNING && cap_ref.chassis_power_limit > 0.0f) {
// SuperCap_CanTX.Powerlimit = (uint8_t)cap_ref.chassis_power_limit;
// }
// SuperCap_Update();
// CAN_TX_SuperCapData(&SuperCap_CanTX);
/* USER CODE END */
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
}
}