mirror of
https://gitee.com/dlmu-cone/half-steering-basic-framework
synced 2026-10-23 17:42:20 +08:00
supercap
This commit is contained in:
@@ -1,29 +1,61 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: Chenfu
|
||||
* @Date: 2022-12-02 21:32:47
|
||||
* @LastEditTime: 2022-12-05 15:25:46
|
||||
* @Descripttion: 适配群星战队协议的超级电容模块
|
||||
* @version: V2.0
|
||||
*/
|
||||
#ifndef SUPER_CAP_H
|
||||
#define SUPER_CAP_H
|
||||
|
||||
#include "bsp_can.h"
|
||||
|
||||
// 超级电容状态枚举(从群星战队协议移植)
|
||||
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;
|
||||
|
||||
#pragma pack(1)
|
||||
/* 接收到的超级电容信息结构体 */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vol; // 电压
|
||||
uint16_t current; // 电流
|
||||
uint16_t power; // 功率
|
||||
SuperCapReadyEnum ready; // 可用标志:1为可用,0为不可用
|
||||
SuperCapStateEnum state; // 状态标志
|
||||
uint8_t energy; // 超级电容可用能量:0-100%
|
||||
uint16_t chassis_power; // 底盘功率
|
||||
uint8_t bat_voltage; // 电池电压*10
|
||||
uint8_t bat_power; // 电池功率
|
||||
} SuperCap_Msg_s;
|
||||
|
||||
/* 需要发送给超级电容的控制信息结构体 */
|
||||
typedef struct {
|
||||
uint8_t Enable; // 超级电容使能。1使能,0失能
|
||||
uint8_t Charge; // 超级电容充电。1充电,0放电
|
||||
uint8_t Powerlimit; // 裁判系统功率限制
|
||||
uint8_t ChargePower; // 超级电容充电功率
|
||||
} SuperCap_TxMsg_s;
|
||||
#pragma pack()
|
||||
|
||||
/* 超级电容实例 */
|
||||
typedef struct
|
||||
{
|
||||
CANInstance *can_ins; // CAN实例
|
||||
SuperCap_Msg_s cap_msg; // 超级电容信息
|
||||
CANInstance *can_ins; // CAN实例
|
||||
SuperCap_Msg_s cap_msg; // 超级电容接收信息
|
||||
uint8_t power_offset; // 功率补偿值
|
||||
} SuperCapInstance;
|
||||
|
||||
/* 超级电容初始化配置 */
|
||||
@@ -34,18 +66,22 @@ typedef struct
|
||||
|
||||
/**
|
||||
* @brief 初始化超级电容
|
||||
*
|
||||
* @param supercap_config 超级电容初始化配置
|
||||
* @return SuperCapInstance* 超级电容实例指针
|
||||
*/
|
||||
SuperCapInstance *SuperCapInit(SuperCap_Init_Config_s *supercap_config);
|
||||
|
||||
/**
|
||||
* @brief 发送超级电容控制信息
|
||||
*
|
||||
* @param instance 超级电容实例
|
||||
* @param data 超级电容控制信息
|
||||
*/
|
||||
void SuperCapSend(SuperCapInstance *instance, uint8_t *data);
|
||||
void SuperCapSend(SuperCapInstance *instance, SuperCap_TxMsg_s *tx_data);
|
||||
|
||||
#endif // !SUPER_CAP_Hd
|
||||
/**
|
||||
* @brief 设置超级电容功率补偿
|
||||
*/
|
||||
void SuperCapSetPowerOffset(SuperCapInstance *instance, uint8_t offset);
|
||||
|
||||
/**
|
||||
* @brief 获取超级电容数据
|
||||
*/
|
||||
SuperCap_Msg_s SuperCapGet(SuperCapInstance *instance);
|
||||
|
||||
#endif // !SUPER_CAP_H
|
||||
Reference in New Issue
Block a user