Files
half-steering-basic-framework/modules/super_cap/super_cap.h

87 lines
2.3 KiB
C
Raw Permalink Normal View History

2026-01-17 14:06:59 +08:00
/*
2026-03-10 03:05:49 +08:00
* @Descripttion: 适配群星战队协议的超级电容模块
* @version: V2.0
2026-01-17 14:06:59 +08:00
*/
#ifndef SUPER_CAP_H
#define SUPER_CAP_H
#include "bsp_can.h"
2026-03-10 03:05:49 +08:00
// 超级电容状态枚举(从群星战队协议移植)
typedef enum
{
DISCHARGE = 0, // 放电状态
CHARGE = 1, // 充电状态
WAIT = 2, // 待机状态
SOFTSTART_PROTECTION = 3, // 处于软起动状态
OVER_LOAD_PROTECTION = 4, // 超电过载保护状态
BAT_OVER_VOLTAGE_PROTECTION = 5, // 过压保护状态
BAT_UNDER_VOLTAGE_PROTECTION = 6, // 电池欠压保护
CAP_UNDER_VOLTAGE_PROTECTION = 7, // 超级电容欠压保护
OVER_TEMPERATURE_PROTECTION = 8, // 过温保护
BOOM = 9, // 超电爆炸了
} SuperCapStateEnum;
// 超级电容准备状态
typedef enum
{
UNREADY = 0,
READY = 1,
} SuperCapReadyEnum;
2026-01-17 14:06:59 +08:00
#pragma pack(1)
2026-03-10 03:05:49 +08:00
/* 接收到的超级电容信息结构体 */
2026-01-17 14:06:59 +08:00
typedef struct
{
2026-03-10 03:05:49 +08:00
SuperCapReadyEnum ready; // 可用标志:1为可用,0为不可用
SuperCapStateEnum state; // 状态标志
uint8_t energy; // 超级电容可用能量:0-100%
uint16_t chassis_power; // 底盘功率
uint8_t bat_voltage; // 电池电压*10
uint8_t bat_power; // 电池功率
2026-01-17 14:06:59 +08:00
} SuperCap_Msg_s;
2026-03-10 03:05:49 +08:00
/* 需要发送给超级电容的控制信息结构体 */
typedef struct {
uint8_t Enable; // 超级电容使能。1使能,0失能
uint8_t Charge; // 超级电容充电。1充电,0放电
uint8_t Powerlimit; // 裁判系统功率限制
uint8_t ChargePower; // 超级电容充电功率
} SuperCap_TxMsg_s;
2026-01-17 14:06:59 +08:00
#pragma pack()
/* 超级电容实例 */
typedef struct
{
2026-03-10 03:05:49 +08:00
CANInstance *can_ins; // CAN实例
SuperCap_Msg_s cap_msg; // 超级电容接收信息
uint8_t power_offset; // 功率补偿值
2026-01-17 14:06:59 +08:00
} SuperCapInstance;
/* 超级电容初始化配置 */
typedef struct
{
CAN_Init_Config_s can_config;
} SuperCap_Init_Config_s;
/**
* @brief 初始化超级电容
*/
SuperCapInstance *SuperCapInit(SuperCap_Init_Config_s *supercap_config);
/**
* @brief 发送超级电容控制信息
*/
2026-03-10 03:05:49 +08:00
void SuperCapSend(SuperCapInstance *instance, SuperCap_TxMsg_s *tx_data);
/**
* @brief 设置超级电容功率补偿
*/
void SuperCapSetPowerOffset(SuperCapInstance *instance, uint8_t offset);
/**
* @brief 获取超级电容数据
*/
SuperCap_Msg_s SuperCapGet(SuperCapInstance *instance);
2026-01-17 14:06:59 +08:00
2026-03-10 03:05:49 +08:00
#endif // !SUPER_CAP_H