feat: KT mBMS 펌웨어 3종(HW1/2/3) 및 통합 빌드 환경 초기 커밋 (V4.0.0.1)
This commit is contained in:
546
APP_R3323/App/Source/device_param.h
Normal file
546
APP_R3323/App/Source/device_param.h
Normal file
@@ -0,0 +1,546 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file device_param.h
|
||||
* @author AMG Energy Solution Team
|
||||
* @version V1.0.0
|
||||
* @date 07-Feb-2022
|
||||
* @brief This file provides all the headers of the device parameter functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2022 AMG</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef _DEVICE_PARAM_H_
|
||||
#define _DEVICE_PARAM_H_
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "hc32_ddl.h"
|
||||
|
||||
#define DEVICE_NAME "LFPS-48100S"
|
||||
#define DEVICE_TYPE 48100
|
||||
#define DEVICE_REV "2.0"
|
||||
#define DEVICE_MAX_CELL 15
|
||||
#define DEVICE_MAX_TEMP 6
|
||||
#define DEVICE_MAX_MODULE 10
|
||||
|
||||
#define BIT(x) (unsigned short)(0x0001 << x)
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t value;
|
||||
struct
|
||||
{
|
||||
uint16_t DSG_S : 1; // LSB 0 // Dischage Fet Control
|
||||
uint16_t CHG_S : 1; // LSB 1 // Charge Fet Control
|
||||
uint16_t ZVC_S : 1; // LSB 2 // Pre-charge Fet Control
|
||||
uint16_t RXM : 1; // LSB 3
|
||||
uint16_t FD : 1; // LSB 4
|
||||
uint16_t FC : 1; // LSB 5
|
||||
uint16_t MD : 1; // LSB 6
|
||||
uint16_t INIT : 1; // LSB 7
|
||||
|
||||
uint16_t DSG_C : 1; // MSB 8 // Dischage Fet Status
|
||||
uint16_t CHG_C : 1; // MSB 9 // Charge Fet Status
|
||||
uint16_t ZVC_C : 1; // MSB 10 // Pre-charge Fet Status
|
||||
uint16_t CB : 1; // MSB 11 // Cell Balancing Flag
|
||||
uint16_t DCP : 1; // MSB 12 // AFE Comm Status
|
||||
uint16_t TDA : 1; // MSB 13
|
||||
uint16_t TCA : 1; // MSB 14
|
||||
uint16_t ACB : 1; // MSB 15
|
||||
} bit;
|
||||
} TBATTERY_STATUS, *pBATTERY_STATUS;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t value;
|
||||
struct
|
||||
{
|
||||
uint16_t afe_fail : 1; // LSB 0 // Dischage Fet Control
|
||||
uint16_t temp_sensor : 1; // LSB 1 // Charge Fet Control
|
||||
uint16_t ZVC_S : 1; // LSB 2 // Pre-charge Fet Control
|
||||
uint16_t RXM : 1; // LSB 3
|
||||
uint16_t FD : 1; // LSB 4
|
||||
uint16_t FC : 1; // LSB 5
|
||||
uint16_t MD : 1; // LSB 6
|
||||
uint16_t INIT : 1; // LSB 7
|
||||
|
||||
uint16_t DSG_C : 1; // MSB 8 // Dischage Fet Status
|
||||
uint16_t CHG_C : 1; // MSB 9 // Charge Fet Status
|
||||
uint16_t ZVC_C : 1; // MSB 10 // Pre-charge Fet Status
|
||||
uint16_t CB : 1; // MSB 11 // Cell Balancing Flag
|
||||
uint16_t AFE : 1; // MSB 12 // AFE PL455 Comm Status
|
||||
uint16_t TDA : 1; // MSB 13
|
||||
uint16_t TCA : 1; // MSB 14
|
||||
uint16_t ACB : 1; // MSB 15
|
||||
} bit;
|
||||
} TBATTERY_ERROR, *pBATTERY_ERROR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t voltage[DEVICE_MAX_CELL + 1]; // 2bytes * (15 + 1) = 32bytes
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16_t value; // 2bytes
|
||||
uint16_t num; // 2bytes
|
||||
} Max, Min; // 4bytes + 4bytes = 8bytes
|
||||
uint16_t avg; // 2bytes
|
||||
uint16_t diff; // 2bytes
|
||||
} avg; // 12bytes
|
||||
} TCELL_STATUS, *PCELL_STATUS; // 44bytes
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t temperature[DEVICE_MAX_TEMP];
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
int16_t value;
|
||||
uint16_t num;
|
||||
} Max, Min;
|
||||
int16_t avg;
|
||||
int16_t diff;
|
||||
} avg;
|
||||
} TTEMP_STATUS, *PTEMP_STATUS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16_t value;
|
||||
uint16_t num;
|
||||
} Max, Min;
|
||||
uint16_t avg;
|
||||
uint16_t diff;
|
||||
} TAVG_VALUE, *PAVG_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t value;
|
||||
uint16_t num;
|
||||
} TMinMax, *PMinMax;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Heartbeat; // Offset 0
|
||||
uint32_t ManufactureDate; // Offset 4
|
||||
uint32_t FwVersion; // Offset 8
|
||||
uint32_t RemainingCapacity; // Offset 12
|
||||
uint32_t CycleCount; // Offset 16
|
||||
uint32_t BatVoltage; // Offset 20
|
||||
uint32_t BatSumVoltage; // Offset 20
|
||||
int32_t Current; // Offset 22
|
||||
int16_t DCurrent; // Offset 24
|
||||
int16_t CCurrent; // Offset 26
|
||||
uint16_t RelativeStateOfCharge; // Offset 28
|
||||
uint16_t StateOfHealth; // Offset 30
|
||||
|
||||
TCELL_STATUS Cell;
|
||||
TTEMP_STATUS Temp;
|
||||
} TDEVICE_VALUE, *PDEVICE_VALUE;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t value;
|
||||
struct
|
||||
{
|
||||
uint16_t over_voltage : 1; // 0x0001
|
||||
uint16_t cell_over_voltage : 1; // 0x0002
|
||||
uint16_t under_voltage : 1; // 0x0004
|
||||
uint16_t cell_under_voltage : 1; // 0x0008
|
||||
|
||||
uint16_t chg_over_current : 1; // 0x0010
|
||||
uint16_t dsg_over_current : 1; // 0x0020
|
||||
uint16_t reserved1 : 2; //
|
||||
|
||||
uint16_t chg_high_temp : 1; // 0x0100
|
||||
uint16_t dsg_high_temp : 1; // 0x0200
|
||||
uint16_t chg_low_temp : 1; // 0x0400
|
||||
uint16_t dsg_low_temp : 1; // 0x0800
|
||||
|
||||
uint16_t low_capacity : 1; // 0x1000
|
||||
uint16_t reserved2 : 1; //
|
||||
uint16_t cell_voltage_diff : 1; //
|
||||
uint16_t reserved3 : 1; //
|
||||
} bit;
|
||||
} TWarning;
|
||||
|
||||
typedef union {
|
||||
uint16_t value;
|
||||
struct {
|
||||
uint16_t over_voltage : 1; // 0x0001
|
||||
uint16_t cell_over_voltage : 1; // 0x0002
|
||||
uint16_t under_voltage : 1; // 0x0004
|
||||
uint16_t cell_under_voltage : 1; // 0x0008
|
||||
|
||||
uint16_t chg_over_current : 1; // 0x0010
|
||||
uint16_t dsg_over_current : 1; // 0x0020
|
||||
uint16_t reserved1 : 1; // 0x4000
|
||||
uint16_t critial_over_current : 1; // 0x8000
|
||||
|
||||
uint16_t chg_high_temp : 1; // 0x0100
|
||||
uint16_t dsg_high_temp : 1; // 0x0200
|
||||
uint16_t chg_low_temp : 1; // 0x0400
|
||||
uint16_t dsg_low_temp : 1; // 0x0800
|
||||
|
||||
uint16_t temp_diff : 1; // 0x1000
|
||||
uint16_t short_circuit : 1; // 0x2000
|
||||
uint16_t cell_voltage_diff : 1; // 0x4000
|
||||
uint16_t afe_fail : 1; // 0x8000
|
||||
} bit;
|
||||
} TProtect;
|
||||
|
||||
typedef union {
|
||||
uint16_t value;
|
||||
struct {
|
||||
uint16_t cell_00 : 1;
|
||||
uint16_t cell_01 : 1;
|
||||
uint16_t cell_02 : 1;
|
||||
uint16_t cell_03 : 1;
|
||||
uint16_t cell_04 : 1;
|
||||
uint16_t cell_05 : 1;
|
||||
uint16_t cell_06 : 1;
|
||||
uint16_t cell_07 : 1;
|
||||
uint16_t cell_08 : 1;
|
||||
uint16_t cell_09 : 1;
|
||||
uint16_t cell_10 : 1;
|
||||
uint16_t cell_11 : 1;
|
||||
uint16_t cell_12 : 1;
|
||||
uint16_t cell_13 : 1;
|
||||
uint16_t cell_14 : 1;
|
||||
uint16_t cell_flag : 1;
|
||||
} bit;
|
||||
} TCellBalanceData, *PCellBalanceData;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t uValue;
|
||||
struct
|
||||
{
|
||||
uint16_t cell0 : 1;
|
||||
uint16_t cell1 : 1;
|
||||
uint16_t cell2 : 1;
|
||||
uint16_t cell3 : 1;
|
||||
uint16_t cell4 : 1;
|
||||
uint16_t cell5 : 1;
|
||||
uint16_t cell6 : 1;
|
||||
uint16_t cell7 : 1;
|
||||
uint16_t cell8 : 1;
|
||||
uint16_t cell9 : 1;
|
||||
uint16_t cell10 : 1;
|
||||
uint16_t cell11 : 1;
|
||||
uint16_t cell12 : 1;
|
||||
uint16_t cell13 : 1;
|
||||
uint16_t cell14 : 1;
|
||||
uint16_t reserved : 1;
|
||||
} Bit;
|
||||
} TCELL_BIT, *PCELL_BIT;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t uValue;
|
||||
struct {
|
||||
uint16_t temp0 : 1;
|
||||
uint16_t temp1 : 1;
|
||||
uint16_t temp2 : 1;
|
||||
uint16_t temp3 : 1;
|
||||
uint16_t temp4 : 1;
|
||||
uint16_t temp5 : 1;
|
||||
uint16_t temp6 : 1;
|
||||
uint16_t temp7 : 1;
|
||||
uint16_t reserved : 8;
|
||||
} Bit;
|
||||
} TTEMP_BIT, *PTEMP_BIT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TBATTERY_STATUS battery_status; // 2 16 bit
|
||||
uint16_t op_status; // 4 16 bit
|
||||
uint16_t alarm_status; // 6 16 bit
|
||||
TWarning warning; // 8 16 bit
|
||||
TProtect protect; // 10 16 bit
|
||||
TCellBalanceData cellbalance; // 12 16 bit
|
||||
uint16_t auto_balancing; // 14 16 bit
|
||||
TBATTERY_ERROR error; // 16 16 bit
|
||||
|
||||
TCELL_BIT cov_warning_cell; // 18 16 bit
|
||||
TCELL_BIT cov_protection_cell; // 20 16 bit
|
||||
TCELL_BIT cuv_warning_cell; // 22 16 bit
|
||||
TCELL_BIT cuv_protection_cell; // 24 16 bit
|
||||
|
||||
TTEMP_BIT otd_warning_temp; // 26 16 bit
|
||||
TTEMP_BIT otd_protection_temp; // 28 16 bit
|
||||
TTEMP_BIT otc_warning_temp; // 30 16 bit
|
||||
TTEMP_BIT otc_protection_temp; // 32 16 bit
|
||||
TTEMP_BIT ltd_warning_temp; // 34 16 bit
|
||||
TTEMP_BIT ltd_protection_temp; // 36 16 bit
|
||||
TTEMP_BIT ltc_warning_temp; // 38 16 bit
|
||||
TTEMP_BIT ltc_protection_temp; // 40 16 bit
|
||||
} TDEVICE_STATUS, *PDEVICE_STATUS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ManufacturerNameSize;
|
||||
uint8_t ManufacturerName[11];
|
||||
uint8_t DeviceNameSize;
|
||||
uint8_t DeviceName[7];
|
||||
uint8_t DeviceChemistrySize;
|
||||
uint8_t DeviceChemistry[5];
|
||||
uint16_t CellQuantity;
|
||||
} TDEVICE_DEVICE_INFO, *PDEVICE_DEVICE_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t COV_Threshold; // ST COV Threshold (Offset 0)
|
||||
uint16_t COV_Warning; // ST COV Warning (Offset 2)
|
||||
uint16_t COV_Recovery; // ST COV Recovery (Offset 4)
|
||||
uint16_t CUV_Threshold; // CUV Threshold (Offset 6)
|
||||
uint16_t CUV_Warning; // CUV Warning (Offset 8)
|
||||
uint16_t CUV_Recovery; // CUV Recovery (Offset 10)
|
||||
uint16_t SOV_Threshold; // ST COV Threshold (Offset 0)
|
||||
uint16_t SOV_Warning; // ST COV Warning (Offset 2)
|
||||
uint16_t SOV_Recovery; // ST COV Recovery (Offset 4)
|
||||
uint16_t SUV_Threshold; // CUV Threshold (Offset 6)
|
||||
uint16_t SUV_Warning; // CUV Warning (Offset 8)
|
||||
uint16_t SUV_Recovery; // CUV Recovery (Offset 10)
|
||||
} TDEVICE_PARAM_VOLTAGE_VALUE, *PDEVICE_PARAM_VOLTAGE_VALUE;
|
||||
|
||||
// C.2.2 Current (Subclass 671)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t OC_Chg_Threshold; // OC Chg Threshold (Offset 0) A
|
||||
int16_t OC_Chg_Warning; // OC Chg Warning (Offset 2) A
|
||||
int16_t OC_Chg_Recovery; // OC Chg Recovery (Offset 4) A
|
||||
int16_t OC_Chg_Rec_Time; // OC Chg Recovery Time (Offset 6) Sec
|
||||
int16_t OC_Dsg_Threshold; // OC Dsg Threshole (Offset 8) A
|
||||
int16_t OC_Dsg_Warning; // OC Dsg Warning (Offset 10) A
|
||||
int16_t OC_Dsg_Recovery; // OC Dsg Recovery (Offset 12) A
|
||||
int16_t OC_Dsg_Rec_Time; // OC Dsg Recovery Time (Offset 14) Sec
|
||||
} TDEVICE_PARAM_CURRENT_VALUE, *PDEVICE_PARAM_CURRENT_VALUE;
|
||||
|
||||
// C.2.3 Temperature (Subclass 690)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t OT_Chg_Threshold; // (Offset 0) 0.1C
|
||||
int16_t OT_Chg_Warning; // (Offset 2) 0.1C
|
||||
int16_t OT_Chg_Recovery; // (Offset 6) 0.1C
|
||||
int16_t OT_Dsg_Threshold; // (Offset 8) 0.1C
|
||||
int16_t OT_Dsg_Warning; // (Offset 10) 0.1C
|
||||
int16_t OT_Dsg_Recovery; // (Offset 14) 0.1C
|
||||
int16_t LT_Chg_Threshold; // (Offset 16) 0.1C
|
||||
int16_t LT_Chg_Warning; // (Offset 18) 0.1C
|
||||
int16_t LT_Chg_Recovery; // (Offset 22) 0.1C
|
||||
int16_t LT_Dsg_Threshold; // (Offset 16) 0.1C
|
||||
int16_t LT_Dsg_Warning; // (Offset 18) 0.1C
|
||||
int16_t LT_Dsg_Recovery; // (Offset 22) 0.1C
|
||||
int16_t Open_Thermistor; // Open Thermistor (Offset 24)
|
||||
int16_t Recovery_Thermistor; // Recovery Thermistor (Offset 26)
|
||||
} TDEVICE_PARAM_TEMPERATURE_VALUE, *PDEVICE_PARAM_TEMPERATURE_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t Low_Soc_Warning; // (Offset 0) 0.1C
|
||||
int16_t Low_Soc_Recovery; // (Offset 6) 0.1C
|
||||
} TDEVICE_PARAM_SOC_VALUE, *PDEVICE_PARAM_SOC_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t Cell_Voltage_Diff_Threshold; // (Offset 0) mV
|
||||
uint16_t Cell_Voltage_Diff_Warning; // (Offset 2) mV
|
||||
uint16_t Cell_Voltage_Diff_Recovery; // (Offset 4) mV
|
||||
uint16_t Cell_Voltage_Diff_Time; // (Offset 6) Sec
|
||||
} TDEVICE_PARAM_CELL_VOLTAGE_DIFF_VALUE, *PDEVICE_PARAM_CELL_VOLTAGE_DIFF_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TDEVICE_PARAM_VOLTAGE_VALUE voltage;
|
||||
TDEVICE_PARAM_CURRENT_VALUE current;
|
||||
TDEVICE_PARAM_TEMPERATURE_VALUE temperature;
|
||||
TDEVICE_PARAM_SOC_VALUE soc;
|
||||
TDEVICE_PARAM_CELL_VOLTAGE_DIFF_VALUE cv_diff;
|
||||
} TDEVICE_PARAM_SAFETY_VALUE, *PDEVICE_PARAM_SAFETY_VALUE;
|
||||
|
||||
// SBS Configuration
|
||||
typedef struct
|
||||
{
|
||||
uint16_t System_ID; // System ID (Offset 0)
|
||||
uint16_t Design_Voltage; // Design Voltage (Offset 2)
|
||||
uint16_t Spec_Info; // Spec Info (Offset 4)
|
||||
uint16_t Manuf_Date; // Manuf Date (Offset 6)
|
||||
uint16_t Ser_Num; // Ser. Num. (Offset 8)
|
||||
uint16_t Cycle_Count; // Cycle Count (Offset 10)
|
||||
uint16_t CC_Threshold; // CC Threshold (Offset 12)
|
||||
uint16_t Design_Capacity; // Design Capacity (Offset 16)
|
||||
uint16_t Design_Energy; // Design Energy (Offset 18)
|
||||
uint16_t Full_Charge_Capacity; // Full Charge Capacity(Offset 20)
|
||||
} TDEVICE_SBS_DATA_VALUE, *PDEVICE_SBS_DATA_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TDEVICE_SBS_DATA_VALUE data;
|
||||
} TDEVICE_SBS_VALUE, *PDEVICE_SBS_VALUE;
|
||||
|
||||
// Charge Control Configuration
|
||||
typedef struct
|
||||
{
|
||||
int16_t ST_Chg_Voltage; // (Offset 0) mV
|
||||
int16_t ST_Chg_Current; // (Offset 2) A
|
||||
} TDEVICE_CHG_CTRL_CFG_CHG_CFG_VALUE, *PDEVICE_CHG_CTRL_CFG_CHG_CFG_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t Taper_Current; // (Offset 0) mA
|
||||
int16_t Taper_Voltage; // (Offset 2) mV
|
||||
int16_t Current_Taper_Window; // (Offset 4) S
|
||||
int16_t FC_Set; // (Offset 6) %
|
||||
int16_t FC_Clear; // (Offset 8) %
|
||||
int16_t FD_Set; // (Offset 10) %
|
||||
int16_t FD_Clear; // (Offset 12) %
|
||||
uint16_t CB_Limit_Voltage; // (Offset 14) mV
|
||||
} TDEVICE_CHG_CTRL_CFG_TERM_CFG_VALUE, *PDEVICE_CHG_CTRL_CFG_TERM_CFG_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t Cell_Balance_Threshold; // (Offset 0) mV
|
||||
int16_t Cell_Balance_Window; // (Offset 2) mV
|
||||
int16_t Cell_Balance_Min; // (Offset 4) mV
|
||||
int16_t Cell_Balance_Interval; // (offset 6) S
|
||||
} TDEVICE_CHG_CTRL_CFG_CELL_BAL_CFG_VALUE, *PDEVICE_CHG_CTRL_CFG_CELL_BAL_CFG_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t Discharge_Detection_Threshold; // Discharge Detection Threshold (Offset 0)
|
||||
int16_t Charge_Detection_Threshold; // Charge Detection Threshold (Offset 2)
|
||||
int16_t Quit_Current; // Quit Current (Offset 4)
|
||||
uint8_t Discharge_Relax_Time; // Discharge Relax Time (Offset 6)
|
||||
uint8_t Charge_Relax_Time; // Charge Relax Time (Offset 8)
|
||||
} TDEVICE_CHG_CTRL_CURRENT_THR_VALUE, *PDEVICE_CHG_CTRL_CURRENT_THR_VALUE;
|
||||
|
||||
typedef struct _TDEVICE_CHG_CTRL_VALUE
|
||||
{
|
||||
TDEVICE_CHG_CTRL_CFG_CHG_CFG_VALUE chg_cfg;
|
||||
TDEVICE_CHG_CTRL_CFG_TERM_CFG_VALUE term_cfg;
|
||||
TDEVICE_CHG_CTRL_CFG_CELL_BAL_CFG_VALUE cell_bal_cfg;
|
||||
TDEVICE_CHG_CTRL_CURRENT_THR_VALUE current_thr;
|
||||
} TDEVICE_CHG_CTRL_VALUE, *PDEVICE_CHG_CTRL_VALUE;
|
||||
|
||||
// Calibration
|
||||
// Voltage (Subclass 0)
|
||||
typedef struct
|
||||
{
|
||||
int16_t Cell_Scale_0; // Cell Scale 0 (Offset 0)
|
||||
int16_t Cell_Scale_1; // Cell Scale 1 (Offset 2)
|
||||
int32_t BatV_Gain; // Pack Offset (Offset 8)
|
||||
int32_t BatV_Offset; // BAT Offset (Offset 10)
|
||||
} TDEVICE_CAL_VOLTAGE_VALUE, *PDEVICE_CAL_VOLTAGE_VALUE;
|
||||
|
||||
// Current (Subclass 12)
|
||||
typedef struct
|
||||
{
|
||||
int32_t CC1_Gain; // CC Gain (Offset 0)
|
||||
int32_t CC1_Offset; // CC Delta (Offset 4)
|
||||
int32_t CCx_Gain; // CC Gain (Offset 0)
|
||||
int32_t CCx_Offset; // CC Delta (Offset 4)
|
||||
int32_t DC_Gain; // DC Gain (Offset 8)
|
||||
int32_t DC_Offset; // DC Delta (Offset 12)
|
||||
} TDEVICE_CAL_CURRENT_VALUE, *PDEVICE_CAL_CURRENT_VALUE;
|
||||
|
||||
// Current Offset (Subclass 20)
|
||||
typedef struct
|
||||
{
|
||||
int16_t Int_Power; // Internal Power Consumption (Offset 0)
|
||||
int16_t LifePowerCons; // Relay Power Consumption (Offset 2)
|
||||
} TDEVICE_CAL_CURRENT_OFFSET_VALUE, *PDEVICE_CAL_CURRENT_OFFSET_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t Charge_Offset; // Charge Offset (Offset 0)
|
||||
int16_t Discharge_Offset; // Discharge Offset (Offset 2)
|
||||
} TDEVICE_CAL_CURRENT_DEADBAND_VALUE, *PDEVICE_CAL_CURRENT_DEADBAND_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TDEVICE_CAL_VOLTAGE_VALUE voltage;
|
||||
TDEVICE_CAL_CURRENT_VALUE current;
|
||||
TDEVICE_CAL_CURRENT_OFFSET_VALUE current_offset;
|
||||
TDEVICE_CAL_CURRENT_DEADBAND_VALUE current_deadband;
|
||||
} TDEVICE_CAL_VALUE, *PDEVICE_CAL_VALUE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t initdata;
|
||||
TDEVICE_CAL_VALUE cal;
|
||||
} TDEVICE_CALIB_DATA, *PDEVICE_CALIB_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t initdata;
|
||||
TDEVICE_DEVICE_INFO info;
|
||||
TDEVICE_PARAM_SAFETY_VALUE safety;
|
||||
TDEVICE_CHG_CTRL_VALUE chg_ctrl;
|
||||
TDEVICE_SBS_VALUE sbs;
|
||||
} TDEVICE_PARAM, *PDEVICE_PARAM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Time of testing and calibration data, NOT the factory out day. Local time in seconds since 2000.
|
||||
Ex:
|
||||
Epoch time offset (1 January 2000 00:00:00) = 946684800
|
||||
Current epoch time (1 October 2019 12:00:00) = 1569931200
|
||||
Timestamp = 1569931200 - 946684800 = 623246400
|
||||
(Used 'https://www.epochconverter.com/' for conversion)
|
||||
*/
|
||||
uint32_t initdata;
|
||||
uint32_t ManufactureDate;
|
||||
uint8_t SerialNo[16]; // BMU18SAYYMMNNNN
|
||||
uint8_t ModuleNo[32]; //
|
||||
} TDEVICE_INV, *PDEVICE_INV;
|
||||
|
||||
// Setting value
|
||||
typedef struct _TDEVICE_SET_VALUE
|
||||
{
|
||||
uint16_t Flag;
|
||||
uint16_t Busy;
|
||||
uint16_t SubClass;
|
||||
uint16_t Offset;
|
||||
uint16_t Size;
|
||||
uint16_t Value;
|
||||
} TDEVICE_SET_VALUE, *PDEVICE_SET_VALUE;
|
||||
|
||||
extern TDEVICE_VALUE device_value, bakdevice_value, dis_device_value;
|
||||
extern TDEVICE_STATUS device_status, dis_device_status;
|
||||
|
||||
extern TDEVICE_CALIB_DATA device_calib_data, dis_device_calib_data;
|
||||
extern TDEVICE_PARAM device_param, dis_device_param;
|
||||
extern TDEVICE_INV device_inv, dis_device_inv;
|
||||
|
||||
void Save_InvData(void);
|
||||
void Load_InvData(void);
|
||||
|
||||
void Save_CalibData(void);
|
||||
|
||||
void Load_Param(void);
|
||||
void Save_Param(void);
|
||||
|
||||
void LoadFwInfo(void);
|
||||
uint32_t SaveFwInfo(void);
|
||||
|
||||
void Param_Init(uint8_t flag, uint8_t factory);
|
||||
|
||||
#endif
|
||||
|
||||
/*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/
|
||||
Reference in New Issue
Block a user