feat: KT mBMS 펌웨어 3종(HW1/2/3) 및 통합 빌드 환경 초기 커밋 (V4.0.0.1)
This commit is contained in:
709
APP_R3221/App/Source/dflash_sf1.c
Normal file
709
APP_R3221/App/Source/dflash_sf1.c
Normal file
@@ -0,0 +1,709 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file dflash_sf1.c
|
||||
* @author AMG Energy Solution Team
|
||||
* @version V1.0.0
|
||||
* @date 07-Feb-2022
|
||||
* @brief This file provides all the codes of safety 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>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup mBMS2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <includes.h>
|
||||
#include "dflash_sf1.h"
|
||||
#include "device_param.h"
|
||||
#include "asutil.h"
|
||||
#include "console.h"
|
||||
#include "alarm.h"
|
||||
//#include "temp.h"
|
||||
|
||||
#ifdef CONSOLE_DEBUG
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
uint8_t SetSF1_Param(uint8_t *text, uint8_t aDevice);
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/* Command processing in SETTING STATE */
|
||||
int8_t Process_DataSF1Set(uint8_t *text, uint16_t size)
|
||||
{
|
||||
uint16_t i, ret;
|
||||
|
||||
/* Invalid command if space is in first position */
|
||||
if (size > 1) {if (text[1] != ' ') return(0);}
|
||||
text[size] = 0x00;
|
||||
ret = 1;
|
||||
|
||||
switch (text[0])
|
||||
{
|
||||
case 'o': /* Switch to operating mode */
|
||||
screenmode = OP_MODE;
|
||||
ViewScreen();
|
||||
break;
|
||||
case 's': /* Switch to setting status */
|
||||
screenmode = SET_MODE;
|
||||
ViewScreen();
|
||||
break;
|
||||
case 'd': /* Switch to diagnostic mode */
|
||||
screenmode = DIAG_MODE;
|
||||
ViewScreen();
|
||||
break;
|
||||
case 'z':
|
||||
screenmode = OS_STATUS_MODE;
|
||||
ViewScreen();
|
||||
break;
|
||||
case 'c':
|
||||
screenmode = CHG_CTRL_CFG_MODE;
|
||||
ViewScreen();
|
||||
break;
|
||||
case '1': // Cell Voltage Parameter Setting
|
||||
case '2': // Current Parameter Setting
|
||||
case '3': // Temperature Parameter Setting
|
||||
case '4': // System Voltage Parameter Setting
|
||||
case '5': // SOC Parameter Setting
|
||||
case '6': // Open Thermistor Parameter Setting
|
||||
i = SetSF1_Param(&text[2],text[0]);
|
||||
if (i == 0)
|
||||
UserMessage("COMMAND COMPLETE");
|
||||
else if (i == 1)
|
||||
UserMessage("COMMAND FORMAT ERROR"); /* setting format error */
|
||||
else
|
||||
UserMessage("COMMAND LIMIT ERROR"); /* setting limit error */
|
||||
break;
|
||||
case 'I':
|
||||
SF1_InitData();
|
||||
Save_Param();
|
||||
break;
|
||||
default :
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void SF1DisplayCellVoltage(uint8_t p)
|
||||
{
|
||||
uint8_t text[20];
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 20;
|
||||
// COV Threshold (Offset 0)
|
||||
if (p || (dis_param->safety.voltage.COV_Threshold != param->safety.voltage.COV_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.COV_Threshold);
|
||||
GreenOutXY(x, 4, text);
|
||||
dis_param->safety.voltage.COV_Threshold = param->safety.voltage.COV_Threshold;
|
||||
}
|
||||
// COV Warning (Offset 2)
|
||||
if (p || (dis_param->safety.voltage.COV_Warning != param->safety.voltage.COV_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.COV_Warning);
|
||||
GreenOutXY(x, 5, text);
|
||||
dis_param->safety.voltage.COV_Warning = param->safety.voltage.COV_Warning;
|
||||
}
|
||||
// COV Recovery (Offset 4)
|
||||
if (p || (dis_param->safety.voltage.COV_Recovery != param->safety.voltage.COV_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.COV_Recovery);
|
||||
GreenOutXY(x, 6, text);
|
||||
dis_param->safety.voltage.COV_Recovery = param->safety.voltage.COV_Recovery;
|
||||
}
|
||||
// CUV Threshold (Offset 6)
|
||||
if (p || (dis_param->safety.voltage.CUV_Threshold != param->safety.voltage.CUV_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.CUV_Threshold);
|
||||
GreenOutXY(x, 8, text);
|
||||
dis_param->safety.voltage.CUV_Threshold = param->safety.voltage.CUV_Threshold;
|
||||
}
|
||||
// CUV Warning (Offset 8)
|
||||
if (p || (dis_param->safety.voltage.CUV_Warning != param->safety.voltage.CUV_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.CUV_Warning);
|
||||
GreenOutXY(x, 9, text);
|
||||
dis_param->safety.voltage.CUV_Warning = param->safety.voltage.CUV_Warning;
|
||||
}
|
||||
// CUV Recovery (Offset 10)
|
||||
if (p || (dis_param->safety.voltage.CUV_Recovery != param->safety.voltage.CUV_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.CUV_Recovery);
|
||||
GreenOutXY(x, 10, text);
|
||||
dis_param->safety.voltage.CUV_Recovery = param->safety.voltage.CUV_Recovery;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1DisplayCurrent(uint8_t p)
|
||||
{
|
||||
uint8_t text[20];
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 19;
|
||||
// OC_Chg_Threshold (Offset 0)
|
||||
if (p || (dis_param->safety.current.OC_Chg_Threshold != param->safety.current.OC_Chg_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%5d", param->safety.current.OC_Chg_Threshold);
|
||||
GreenOutXY(x, 12, text);
|
||||
dis_param->safety.current.OC_Chg_Threshold = param->safety.current.OC_Chg_Threshold;
|
||||
}
|
||||
// OC_Chg_Warning (Offset 2)
|
||||
if (p || (dis_param->safety.current.OC_Chg_Warning != param->safety.current.OC_Chg_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%5d", param->safety.current.OC_Chg_Warning);
|
||||
GreenOutXY(x, 13, text);
|
||||
dis_param->safety.current.OC_Chg_Warning = param->safety.current.OC_Chg_Warning;
|
||||
}
|
||||
// OC_Chg_Recovery (Offset 6)
|
||||
if (p || (dis_param->safety.current.OC_Chg_Recovery != param->safety.current.OC_Chg_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%5d", param->safety.current.OC_Chg_Recovery);
|
||||
GreenOutXY(x, 14, text);
|
||||
dis_param->safety.current.OC_Chg_Recovery = param->safety.current.OC_Chg_Recovery;
|
||||
}
|
||||
// OC_Chg_Rec_Time (Offset 8)
|
||||
if (p || (dis_param->safety.current.OC_Chg_Rec_Time != param->safety.current.OC_Chg_Rec_Time))
|
||||
{
|
||||
sprintf((char *)text, "%3d", param->safety.current.OC_Chg_Rec_Time);
|
||||
GreenOutXY(x + 2, 15, text);
|
||||
dis_param->safety.current.OC_Chg_Rec_Time = param->safety.current.OC_Chg_Rec_Time;
|
||||
}
|
||||
|
||||
// OC_Dsg_Threshold (Offset 10)
|
||||
if (p || (dis_param->safety.current.OC_Dsg_Threshold != param->safety.current.OC_Dsg_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%5d", param->safety.current.OC_Dsg_Threshold);
|
||||
GreenOutXY(x, 17, text);
|
||||
dis_param->safety.current.OC_Dsg_Threshold = param->safety.current.OC_Dsg_Threshold;
|
||||
}
|
||||
// OC_Dsg_Warning (Offset 12)
|
||||
if (p || (dis_param->safety.current.OC_Dsg_Warning != param->safety.current.OC_Dsg_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%5d", param->safety.current.OC_Dsg_Warning);
|
||||
GreenOutXY(x, 18, text);
|
||||
dis_param->safety.current.OC_Dsg_Warning = param->safety.current.OC_Dsg_Warning;
|
||||
}
|
||||
// OC_Dsg_Recovery (Offset 14)
|
||||
if (p || (dis_param->safety.current.OC_Dsg_Recovery != param->safety.current.OC_Dsg_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%5d", param->safety.current.OC_Dsg_Recovery);
|
||||
GreenOutXY(x, 19, text);
|
||||
dis_param->safety.current.OC_Dsg_Recovery = param->safety.current.OC_Dsg_Recovery;
|
||||
}
|
||||
// OC_Dsg_Rec_Time (Offset 16)
|
||||
if (p || (dis_param->safety.current.OC_Dsg_Rec_Time != param->safety.current.OC_Dsg_Rec_Time))
|
||||
{
|
||||
sprintf((char *)text, "%3d", param->safety.current.OC_Dsg_Rec_Time);
|
||||
GreenOutXY(x + 2, 20, text);
|
||||
dis_param->safety.current.OC_Dsg_Rec_Time = param->safety.current.OC_Dsg_Rec_Time;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1DisplayTemperature(uint8_t p)
|
||||
{
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 46;
|
||||
// Over Temp Chg Threshold (Offset 0)
|
||||
if (p || (dis_param->safety.temperature.OT_Chg_Threshold != param->safety.temperature.OT_Chg_Threshold))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 4, (float)param->safety.temperature.OT_Chg_Threshold / 10, 5, 1);
|
||||
dis_param->safety.temperature.OT_Chg_Threshold = param->safety.temperature.OT_Chg_Threshold;
|
||||
}
|
||||
// Over Temp Chg Warning (Offset 2)
|
||||
if (p || (dis_param->safety.temperature.OT_Chg_Warning != param->safety.temperature.OT_Chg_Warning))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 5, (float)param->safety.temperature.OT_Chg_Warning / 10, 5, 1);
|
||||
dis_param->safety.temperature.OT_Chg_Warning = param->safety.temperature.OT_Chg_Warning;
|
||||
}
|
||||
|
||||
// OT Chg Recovery (Offset 3)
|
||||
if (p || (dis_param->safety.temperature.OT_Chg_Recovery != param->safety.temperature.OT_Chg_Recovery))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 6, (float)param->safety.temperature.OT_Chg_Recovery / 10, 5, 1);
|
||||
dis_param->safety.temperature.OT_Chg_Recovery = param->safety.temperature.OT_Chg_Recovery;
|
||||
}
|
||||
|
||||
// Over Temp Dsg Threshold (Offset 5)
|
||||
if (p || (dis_param->safety.temperature.OT_Dsg_Threshold != param->safety.temperature.OT_Dsg_Threshold))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 8, (float)param->safety.temperature.OT_Dsg_Threshold / 10, 5, 1);
|
||||
dis_param->safety.temperature.OT_Dsg_Threshold = param->safety.temperature.OT_Dsg_Threshold;
|
||||
}
|
||||
// Over Temp Dsg Warning (Offset 5)
|
||||
if (p || (dis_param->safety.temperature.OT_Dsg_Warning != param->safety.temperature.OT_Dsg_Warning))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 9, (float)param->safety.temperature.OT_Dsg_Warning / 10, 5, 1);
|
||||
dis_param->safety.temperature.OT_Dsg_Warning = param->safety.temperature.OT_Dsg_Warning;
|
||||
}
|
||||
|
||||
// OT Dsg Recovery (Offset 8)
|
||||
if (p || (dis_param->safety.temperature.OT_Dsg_Recovery != param->safety.temperature.OT_Dsg_Recovery))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 10, (float)param->safety.temperature.OT_Dsg_Recovery / 10, 5, 1);
|
||||
dis_param->safety.temperature.OT_Dsg_Recovery = param->safety.temperature.OT_Dsg_Recovery;
|
||||
}
|
||||
|
||||
// Low temperature
|
||||
// LT Chg Threshold (Offset 0)
|
||||
if (p || (dis_param->safety.temperature.LT_Chg_Threshold != param->safety.temperature.LT_Chg_Threshold))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 12, (float)param->safety.temperature.LT_Chg_Threshold / 10, 5, 1);
|
||||
dis_param->safety.temperature.LT_Chg_Threshold = param->safety.temperature.LT_Chg_Threshold;
|
||||
}
|
||||
// LT Chg Warning (Offset 2)
|
||||
if (p || (dis_param->safety.temperature.LT_Chg_Warning != param->safety.temperature.LT_Chg_Warning))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 13, (float)param->safety.temperature.LT_Chg_Warning / 10, 5, 1);
|
||||
dis_param->safety.temperature.LT_Chg_Warning = param->safety.temperature.LT_Chg_Warning;
|
||||
}
|
||||
// LT Chg Recovery (Offset 3)
|
||||
if (p || (dis_param->safety.temperature.LT_Chg_Recovery != param->safety.temperature.LT_Chg_Recovery))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 14, (float)param->safety.temperature.LT_Chg_Recovery / 10, 5, 1);
|
||||
dis_param->safety.temperature.LT_Chg_Recovery = param->safety.temperature.LT_Chg_Recovery;
|
||||
}
|
||||
|
||||
// LT Dsg Threshold (Offset 5)
|
||||
if (p || (dis_param->safety.temperature.LT_Dsg_Threshold != param->safety.temperature.LT_Dsg_Threshold))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 16, (float)param->safety.temperature.LT_Dsg_Threshold / 10, 5, 1);
|
||||
dis_param->safety.temperature.LT_Dsg_Threshold = param->safety.temperature.LT_Dsg_Threshold;
|
||||
}
|
||||
// LT Dsg Warning (Offset 5)
|
||||
if (p || (dis_param->safety.temperature.LT_Dsg_Warning != param->safety.temperature.LT_Dsg_Warning))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 17, (float)param->safety.temperature.LT_Dsg_Warning / 10, 5, 1);
|
||||
dis_param->safety.temperature.LT_Dsg_Warning = param->safety.temperature.LT_Dsg_Warning;
|
||||
}
|
||||
// LT Dsg Recovery (Offset 8)
|
||||
if (p || (dis_param->safety.temperature.LT_Dsg_Recovery != param->safety.temperature.LT_Dsg_Recovery))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 18, (float)param->safety.temperature.LT_Dsg_Recovery / 10, 5, 1);
|
||||
dis_param->safety.temperature.LT_Dsg_Recovery = param->safety.temperature.LT_Dsg_Recovery;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1DisplaySVoltage(uint8_t p)
|
||||
{
|
||||
uint8_t text[20];
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 73;
|
||||
// SOV Threshold (Offset 0)
|
||||
if (p || (dis_param->safety.voltage.SOV_Threshold != param->safety.voltage.SOV_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.SOV_Threshold);
|
||||
GreenOutXY(x, 4, text);
|
||||
dis_param->safety.voltage.SOV_Threshold = param->safety.voltage.SOV_Threshold;
|
||||
}
|
||||
// SOV Warning (Offset 2)
|
||||
if (p || (dis_param->safety.voltage.SOV_Warning != param->safety.voltage.SOV_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.SOV_Warning);
|
||||
GreenOutXY(x, 5, text);
|
||||
dis_param->safety.voltage.SOV_Warning = param->safety.voltage.SOV_Warning;
|
||||
}
|
||||
// SOV Recovery (Offset 4)
|
||||
if (p || (dis_param->safety.voltage.SOV_Recovery != param->safety.voltage.SOV_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.SOV_Recovery);
|
||||
GreenOutXY(x, 6, text);
|
||||
dis_param->safety.voltage.SOV_Recovery = param->safety.voltage.SOV_Recovery;
|
||||
}
|
||||
// SUV Threshold (Offset 6)
|
||||
if (p || (dis_param->safety.voltage.SUV_Threshold != param->safety.voltage.SUV_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.SUV_Threshold);
|
||||
GreenOutXY(x, 8, text);
|
||||
dis_param->safety.voltage.SUV_Threshold = param->safety.voltage.SUV_Threshold;
|
||||
}
|
||||
// SUV Warning (Offset 8)
|
||||
if (p || (dis_param->safety.voltage.SUV_Warning != param->safety.voltage.SUV_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.SUV_Warning);
|
||||
GreenOutXY(x, 9, text);
|
||||
dis_param->safety.voltage.SUV_Warning = param->safety.voltage.SUV_Warning;
|
||||
}
|
||||
// SUV Recovery (Offset 10)
|
||||
if (p || (dis_param->safety.voltage.SUV_Recovery != param->safety.voltage.SUV_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.voltage.SUV_Recovery);
|
||||
GreenOutXY(x, 10, text);
|
||||
dis_param->safety.voltage.SUV_Recovery = param->safety.voltage.SUV_Recovery;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1DisplaySoc(uint8_t p)
|
||||
{
|
||||
uint8_t text[20];
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 74;
|
||||
// Low SOC Warning (Offset 0)
|
||||
if (p || (dis_param->safety.soc.Low_Soc_Warning != param->safety.soc.Low_Soc_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%3d", param->safety.soc.Low_Soc_Warning);
|
||||
GreenOutXY(x, 12, text);
|
||||
dis_param->safety.soc.Low_Soc_Warning = param->safety.soc.Low_Soc_Warning;
|
||||
}
|
||||
// Low SOC Recovery (Offset 2)
|
||||
if (p || (dis_param->safety.soc.Low_Soc_Recovery != param->safety.soc.Low_Soc_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%3d", param->safety.soc.Low_Soc_Recovery);
|
||||
GreenOutXY(x, 13, text);
|
||||
dis_param->safety.soc.Low_Soc_Recovery = param->safety.soc.Low_Soc_Recovery;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1DisplayCellVoltageDiff(uint8_t p)
|
||||
{
|
||||
uint8_t text[20];
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 73;
|
||||
// Cell Voltage Diff Threshold (Offset 0)
|
||||
if (p || (dis_param->safety.cv_diff.Cell_Voltage_Diff_Threshold != param->safety.cv_diff.Cell_Voltage_Diff_Threshold))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.cv_diff.Cell_Voltage_Diff_Threshold);
|
||||
GreenOutXY(x, 15, text);
|
||||
dis_param->safety.cv_diff.Cell_Voltage_Diff_Threshold = param->safety.cv_diff.Cell_Voltage_Diff_Threshold;
|
||||
}
|
||||
// Cell Voltage Diff Warning (Offset 2)
|
||||
if (p || (dis_param->safety.cv_diff.Cell_Voltage_Diff_Warning != param->safety.cv_diff.Cell_Voltage_Diff_Warning))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.cv_diff.Cell_Voltage_Diff_Warning);
|
||||
GreenOutXY(x, 16, text);
|
||||
dis_param->safety.cv_diff.Cell_Voltage_Diff_Warning = param->safety.cv_diff.Cell_Voltage_Diff_Warning;
|
||||
}
|
||||
// Cell Voltage Diff Recovery (Offset 4)
|
||||
if (p || (dis_param->safety.cv_diff.Cell_Voltage_Diff_Recovery != param->safety.cv_diff.Cell_Voltage_Diff_Recovery))
|
||||
{
|
||||
sprintf((char *)text, "%4d", param->safety.cv_diff.Cell_Voltage_Diff_Recovery);
|
||||
GreenOutXY(x, 17, text);
|
||||
dis_param->safety.cv_diff.Cell_Voltage_Diff_Recovery = param->safety.cv_diff.Cell_Voltage_Diff_Recovery;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1DisplayThermistorOpen(uint8_t p)
|
||||
{
|
||||
PDEVICE_PARAM param = &device_param;
|
||||
PDEVICE_PARAM dis_param = &dis_device_param;
|
||||
int x;
|
||||
|
||||
x = 72;
|
||||
// Open Thermistor (Offset 0)
|
||||
if (p || (dis_param->safety.temperature.Open_Thermistor != param->safety.temperature.Open_Thermistor))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 19, (float)param->safety.temperature.Open_Thermistor / 10, 5, 1);
|
||||
dis_param->safety.temperature.Open_Thermistor = param->safety.temperature.Open_Thermistor;
|
||||
}
|
||||
// Recovery Thermistor (Offset 2)
|
||||
if (p || (dis_param->safety.temperature.Recovery_Thermistor != param->safety.temperature.Recovery_Thermistor))
|
||||
{
|
||||
FloatNormalOutIntXY(x, 20, (float)param->safety.temperature.Recovery_Thermistor / 10, 5, 1);
|
||||
dis_param->safety.temperature.Recovery_Thermistor = param->safety.temperature.Recovery_Thermistor;
|
||||
}
|
||||
}
|
||||
|
||||
void SF1Display(uint8_t p)
|
||||
{
|
||||
SF1DisplayCellVoltage(p);
|
||||
SF1DisplayCurrent(p);
|
||||
SF1DisplayTemperature(p);
|
||||
SF1DisplaySVoltage(p);
|
||||
SF1DisplaySoc(p);
|
||||
SF1DisplayCellVoltageDiff(p);
|
||||
SF1DisplayThermistorOpen(p);
|
||||
}
|
||||
|
||||
uint8_t SetSF1_Param(uint8_t *text, uint8_t aDevice)
|
||||
{
|
||||
uint16_t size, i, j;
|
||||
int16_t aParam[4];
|
||||
uint8_t temp[10];
|
||||
uint8_t ret;
|
||||
uint8_t cmd;
|
||||
|
||||
ret = 0;
|
||||
size = 0;
|
||||
|
||||
while (text[size] != 0x00) size++; /* Measure total string length */
|
||||
|
||||
switch (aDevice)
|
||||
{
|
||||
case '1': // SF1_VoltageSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.voltage.COV_Threshold = aParam[0]; break;
|
||||
case '2': device_param.safety.voltage.COV_Warning = aParam[0]; break;
|
||||
case '3': device_param.safety.voltage.COV_Recovery = aParam[0]; break;
|
||||
case '4': device_param.safety.voltage.CUV_Threshold = aParam[0]; break;
|
||||
case '5': device_param.safety.voltage.CUV_Warning = aParam[0]; break;
|
||||
case '6': device_param.safety.voltage.CUV_Recovery = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
case '2': // SF1_CurrentSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.current.OC_Chg_Threshold = aParam[0]; break;
|
||||
case '2': device_param.safety.current.OC_Chg_Warning = aParam[0]; break;
|
||||
case '3': device_param.safety.current.OC_Chg_Recovery = aParam[0]; break;
|
||||
case '4': device_param.safety.current.OC_Chg_Rec_Time = aParam[0]; break;
|
||||
case '5': device_param.safety.current.OC_Dsg_Threshold = aParam[0]; break;
|
||||
case '6': device_param.safety.current.OC_Dsg_Warning = aParam[0]; break;
|
||||
case '7': device_param.safety.current.OC_Dsg_Recovery = aParam[0]; break;
|
||||
case '8': device_param.safety.current.OC_Chg_Rec_Time = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
case '3': // SF1_TemperatureSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.temperature.OT_Chg_Threshold = aParam[0]; break;
|
||||
case '2': device_param.safety.temperature.OT_Chg_Warning = aParam[0]; break;
|
||||
case '3': device_param.safety.temperature.OT_Chg_Recovery = aParam[0]; break;
|
||||
case '4': device_param.safety.temperature.OT_Dsg_Threshold = aParam[0]; break;
|
||||
case '5': device_param.safety.temperature.OT_Dsg_Warning = aParam[0]; break;
|
||||
case '6': device_param.safety.temperature.OT_Dsg_Recovery = aParam[0]; break;
|
||||
|
||||
case '7': device_param.safety.temperature.LT_Chg_Threshold = aParam[0]; break;
|
||||
case '8': device_param.safety.temperature.LT_Chg_Warning = aParam[0]; break;
|
||||
case '9': device_param.safety.temperature.LT_Chg_Recovery = aParam[0]; break;
|
||||
case 'a': device_param.safety.temperature.LT_Dsg_Threshold = aParam[0]; break;
|
||||
case 'b': device_param.safety.temperature.LT_Dsg_Warning = aParam[0]; break;
|
||||
case 'c': device_param.safety.temperature.LT_Dsg_Recovery = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
case '4': // SF1_SVoltageSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.voltage.SOV_Threshold = aParam[0]; break;
|
||||
case '2': device_param.safety.voltage.SOV_Warning = aParam[0]; break;
|
||||
case '3': device_param.safety.voltage.SOV_Recovery = aParam[0]; break;
|
||||
case '4': device_param.safety.voltage.SUV_Threshold = aParam[0]; break;
|
||||
case '5': device_param.safety.voltage.SUV_Warning = aParam[0]; break;
|
||||
case '6': device_param.safety.voltage.SUV_Recovery = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
case '5': // SF1_SocSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.soc.Low_Soc_Warning = aParam[0]; break;
|
||||
case '2': device_param.safety.soc.Low_Soc_Recovery = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
case '6': // SF1_SocSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.cv_diff.Cell_Voltage_Diff_Threshold = aParam[0]; break;
|
||||
case '2': device_param.safety.cv_diff.Cell_Voltage_Diff_Warning = aParam[0]; break;
|
||||
case '3': device_param.safety.cv_diff.Cell_Voltage_Diff_Recovery = aParam[0]; break;
|
||||
case '4': device_param.safety.cv_diff.Cell_Voltage_Diff_Time = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
case '7': // SF1_OpenThermistorSubClass
|
||||
i = 0;
|
||||
if (size < 2 ) return(1);
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
cmd = temp[0];
|
||||
|
||||
j = FIND_CHAR((uint8_t *)&text[i], temp, size - i, ' ');
|
||||
i = i + j + 1;
|
||||
temp[j] = 0x00;
|
||||
aParam[0] = StrToInt(temp, j); /* Value */
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '1': device_param.safety.temperature.Open_Thermistor = aParam[0]; break;
|
||||
case '2': device_param.safety.temperature.Recovery_Thermistor = aParam[0]; break;
|
||||
default : return (1);
|
||||
}
|
||||
Save_Param();
|
||||
break;
|
||||
default:
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
return(ret); /* Setting value OK */
|
||||
}
|
||||
|
||||
#endif //#ifdef CONSOLE_DEBUG
|
||||
|
||||
void SF1_InitData(void)
|
||||
{
|
||||
device_param.safety.voltage.COV_Threshold = 3850; // mV
|
||||
device_param.safety.voltage.COV_Warning = 3750; // mV
|
||||
device_param.safety.voltage.COV_Recovery = 3580; // mV
|
||||
device_param.safety.voltage.CUV_Threshold = 1000; // mV
|
||||
device_param.safety.voltage.CUV_Warning = 2800; // mV
|
||||
device_param.safety.voltage.CUV_Recovery = 3000; // mV
|
||||
|
||||
device_param.safety.voltage.SOV_Threshold = 5700; // 10mV
|
||||
device_param.safety.voltage.SOV_Warning = 5600; // 10mV
|
||||
device_param.safety.voltage.SOV_Recovery = 5400; // 10mV
|
||||
device_param.safety.voltage.SUV_Threshold = 2000; // 10mV
|
||||
device_param.safety.voltage.SUV_Warning = 4200; // 10mV
|
||||
device_param.safety.voltage.SUV_Recovery = 4500; // 10mV
|
||||
|
||||
device_param.safety.current.OC_Chg_Threshold = 110; // A
|
||||
device_param.safety.current.OC_Chg_Warning = 100; // A
|
||||
device_param.safety.current.OC_Chg_Recovery = 10; // A
|
||||
device_param.safety.current.OC_Chg_Rec_Time = 30; // Sec
|
||||
|
||||
device_param.safety.current.OC_Dsg_Threshold = -500; // A
|
||||
device_param.safety.current.OC_Dsg_Warning = -310; // A
|
||||
device_param.safety.current.OC_Dsg_Recovery = -5; // A
|
||||
device_param.safety.current.OC_Dsg_Rec_Time = 30; // A
|
||||
|
||||
device_param.safety.temperature.OT_Chg_Threshold = 550; // 0.1C
|
||||
device_param.safety.temperature.OT_Chg_Warning = 500; // 0.1C
|
||||
device_param.safety.temperature.OT_Chg_Recovery = 450; // 0.1C
|
||||
device_param.safety.temperature.OT_Dsg_Threshold = 900; // 0.1C
|
||||
device_param.safety.temperature.OT_Dsg_Warning = 600; // 0.1C
|
||||
device_param.safety.temperature.OT_Dsg_Recovery = 550; // 0.1C
|
||||
|
||||
device_param.safety.temperature.LT_Chg_Threshold = 0; // 0.1C
|
||||
device_param.safety.temperature.LT_Chg_Warning = 30; // 0.1C
|
||||
device_param.safety.temperature.LT_Chg_Recovery = 50; // 0.1C
|
||||
device_param.safety.temperature.LT_Dsg_Threshold = -500; // 0.1C
|
||||
device_param.safety.temperature.LT_Dsg_Warning = -150; // 0.1C
|
||||
device_param.safety.temperature.LT_Dsg_Recovery = -100; // 0.1C
|
||||
|
||||
device_param.safety.temperature.Open_Thermistor = -420; // 0.1C
|
||||
device_param.safety.temperature.Recovery_Thermistor = -380; // 0.1C
|
||||
|
||||
device_param.safety.soc.Low_Soc_Warning = 3; // %
|
||||
device_param.safety.soc.Low_Soc_Recovery = 5; // %
|
||||
|
||||
device_param.safety.cv_diff.Cell_Voltage_Diff_Threshold = 200; // mV (KT spec: 200mV)
|
||||
device_param.safety.cv_diff.Cell_Voltage_Diff_Warning = 0; // Unused
|
||||
device_param.safety.cv_diff.Cell_Voltage_Diff_Recovery = 0; // Unused
|
||||
Set_CV_Diff_ProtectHoldTime(0);
|
||||
Set_Temp_Diff_Threshold(0);
|
||||
Set_Temp_Diff_ProtectHoldTime(0);
|
||||
// KT Requirement: Configure CV_Diff_ProtectHoldTime for testing (sec -> ms, 0 means 24h default)
|
||||
}
|
||||
|
||||
/*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/
|
||||
Reference in New Issue
Block a user