添加异常部分,修改配置文件
This commit is contained in:
parent
031d6b747e
commit
1aedfdd133
File diff suppressed because one or more lines are too long
|
@ -3,13 +3,15 @@
|
|||
#include "TimeSliceOffset.h"
|
||||
#include "Init.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "pDebug.h"
|
||||
|
||||
void start(void)
|
||||
{
|
||||
Init();
|
||||
task_Init();
|
||||
|
||||
debug("start\n");
|
||||
|
||||
TimeSliceOffset_Start();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,29 @@
|
|||
#define BL_ABNORMAL_MANAGE_H_
|
||||
|
||||
#include "FM_TIM.h"
|
||||
#include "comm_types.h"
|
||||
#include "FM_GPIO.h"
|
||||
|
||||
|
||||
|
||||
BOOL getChargOverLoad(void);
|
||||
|
||||
uint8_t getShortCircuit(void);
|
||||
void zeroShortCircuit(void);
|
||||
void setShortCircuitFlag(BOOL state);
|
||||
BOOL getShortCircuitFlag(void);
|
||||
|
||||
void zeroExcessiveLoad(void);
|
||||
uint8_t getExcessiveLoad(void);
|
||||
void setExcessiveLoadFlag(BOOL state);
|
||||
BOOL getExcessiveLoadFlag(void);
|
||||
|
||||
void setPowerOutput(BOOL state);
|
||||
|
||||
void checkAbnormal(void);
|
||||
|
||||
|
||||
void WORK_VOLT_Interrupt(void);
|
||||
void DSG_PROT_Interrupt(void);
|
||||
|
||||
|
||||
#endif
|
|
@ -12,8 +12,8 @@ typedef struct _recv_config_info{
|
|||
uint8_t start_Flag[2]; /* 开始标志 */
|
||||
/* SL */
|
||||
uint8_t address[7]; /* 地址 */
|
||||
uint8_t Access_Node_Type[2]; /* 接入节点类型 */
|
||||
uint8_t Communication_Methods[2]; /* 通信方式 */
|
||||
// uint8_t Access_Node_Type[2]; /* 接入节点类型 */
|
||||
// uint8_t Communication_Methods[2]; /* 通信方式 */
|
||||
uint8_t gw485_Baud[4]; /* 串口波特率 */
|
||||
uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
|
||||
|
||||
|
@ -38,8 +38,8 @@ typedef struct _recv_config_info{
|
|||
uint8_t HighSideMosTemperature_end[2]; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
|
||||
uint8_t HighSideMosTemperature_start[2];/* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||
|
||||
uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */
|
||||
// uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
// uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */
|
||||
uint8_t outputAgainFlagTime[2]; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||
uint8_t excessiveLoadFlagTime[2]; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint8_t eLAgainTime[2]; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
|
@ -51,8 +51,8 @@ typedef struct _recv_config_info{
|
|||
typedef struct _config_info{
|
||||
/* SL */
|
||||
uint8_t address[7]; /* 地址 */
|
||||
uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
uint16_t Communication_Methods; /* 通信方式 */
|
||||
// uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
// uint16_t Communication_Methods; /* 通信方式 */
|
||||
uint32_t gw485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||
uint32_t bat485_Baud; /* 串口波特率 */
|
||||
|
||||
|
@ -76,8 +76,8 @@ typedef struct _config_info{
|
|||
float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
|
||||
float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
|
||||
|
||||
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
||||
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
|
||||
// uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
||||
// uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
|
||||
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 */
|
||||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该段时间中再次出现过载,则关闭输出 */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,该段时间后,再次尝试输出 */
|
||||
|
@ -95,8 +95,9 @@ typedef struct _config_info{
|
|||
#define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20)
|
||||
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
|
||||
|
||||
void save_config_info(config_info *save_config_info);
|
||||
// void save_config_info(config_info *save_config_info);
|
||||
void read_config_info(config_info *output_config_info);
|
||||
void saveConfigInfo(config_info *config_info);
|
||||
void config_info_start(void);
|
||||
|
||||
void saveLoopImpedance(float *loopImpedance);
|
||||
|
|
|
@ -23,11 +23,11 @@ typedef struct _config_parameter{
|
|||
float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||
|
||||
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */
|
||||
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
// uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
|
||||
uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔 */
|
||||
|
||||
/* SL */
|
||||
uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
|
|
|
@ -11,8 +11,10 @@ void task_Init(void);
|
|||
void beginStartControlTask(void);
|
||||
void beginSoftStartTask(void);
|
||||
void beginHYconfigMode(void);
|
||||
void uartTaskInit(void);
|
||||
|
||||
|
||||
|
||||
void startShortCircuitProtection(void);
|
||||
void stopShortCircuitProtection(void);
|
||||
void startExcessiveLoadProtection(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef BL_TEST_H_
|
||||
#define BL_TEST_H_
|
||||
|
||||
|
||||
|
||||
void test(void);
|
||||
|
||||
#endif
|
|
@ -1,14 +1,15 @@
|
|||
|
||||
#include "Init.h"
|
||||
#include "capture.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "inFlash.h"
|
||||
#include "parameter.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "FM_TIM.h"
|
||||
#include "uart_dev.h"
|
||||
#include "parameter.h"
|
||||
#include "abnormalManage.h"
|
||||
|
||||
extern int getMPPT_Mode(void);
|
||||
//extern config_parameter g_cfgParameter;
|
||||
|
||||
/**
|
||||
* @brief 初始化外设,同时通过配置文件初始化系统参数
|
||||
|
@ -26,12 +27,14 @@ void Init(void)
|
|||
tim_Init();
|
||||
|
||||
Init_debug_uart();
|
||||
Init_BAT485_uart();
|
||||
Init_GW485_uart();
|
||||
// Init_BAT485_uart(g_cfgParameter.bat485_Baud);
|
||||
// Init_GW485_uart(g_cfgParameter.gw485_Baud);
|
||||
Init_BAT485_uart(115200);
|
||||
Init_GW485_uart(115200);
|
||||
start_gw485Rx_It();
|
||||
start_bat485Rx_It();
|
||||
|
||||
POW_FF_PCON_Open();
|
||||
POW_OUT_PCON_Open();
|
||||
|
||||
// POW_FF_PCON_Open();
|
||||
// POW_OUT_PCON_Open();
|
||||
setPowerOutput(TRUE);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,202 @@
|
|||
#include "capture.h"
|
||||
#include "checkTime.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "task.h"
|
||||
|
||||
|
||||
|
||||
/* 软件输出过载标志位 */
|
||||
static BOOL disChargOverLoad = FALSE;
|
||||
|
||||
/* 短路标志位 */
|
||||
static uint8_t shortCircuit = 0;
|
||||
static BOOL shortCircuitFlag = FALSE;
|
||||
|
||||
/* 硬件过载状态位 */
|
||||
static uint8_t excessiveLoad = 0;
|
||||
static BOOL excessiveLoadFlag = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设定放电过载状态
|
||||
* @param state TRUE 过载
|
||||
* FALSE 未过载
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setDisChargOverLoad(void)
|
||||
{
|
||||
if (getDischargCurrent() > 30.0f) {
|
||||
disChargOverLoad = TRUE;
|
||||
} else {
|
||||
disChargOverLoad = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到放电过载状态
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
BOOL getChargOverLoad(void)
|
||||
{
|
||||
return disChargOverLoad;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置短路状态位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setShortCircuit(void)
|
||||
{
|
||||
shortCircuit++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清零短路状位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void zeroShortCircuit(void)
|
||||
{
|
||||
shortCircuit = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到短路状位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
uint8_t getShortCircuit(void)
|
||||
{
|
||||
return shortCircuit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设定短路标志位
|
||||
* @param state TRUE 短路
|
||||
* FALSE 未短路
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setShortCircuitFlag(BOOL state)
|
||||
{
|
||||
if (state == TRUE || state == FALSE) {
|
||||
shortCircuitFlag = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到短路标志位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
BOOL getShortCircuitFlag(void)
|
||||
{
|
||||
return shortCircuitFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置硬件过载状态位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setExcessiveLoad(void)
|
||||
{
|
||||
excessiveLoad++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清零硬件过载状态位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void zeroExcessiveLoad(void)
|
||||
{
|
||||
excessiveLoad = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到硬件过载状态位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
uint8_t getExcessiveLoad(void)
|
||||
{
|
||||
return excessiveLoad;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设定硬件过载标志位
|
||||
* @param state TRUE 过载
|
||||
* FALSE 未过载
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setExcessiveLoadFlag(BOOL state)
|
||||
{
|
||||
if (state == TRUE || state == FALSE) {
|
||||
excessiveLoadFlag = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到硬件过载标志位
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
BOOL getExcessiveLoadFlag(void)
|
||||
{
|
||||
return excessiveLoadFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置输出状态
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setPowerOutput(BOOL state)
|
||||
{
|
||||
if (state == TRUE) {
|
||||
POW_FF_PCON_Open();
|
||||
POW_OUT_PCON_Open();
|
||||
} else {
|
||||
POW_FF_PCON_Close();
|
||||
POW_OUT_PCON_Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 判断是否打开充电理想二极管
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void checkFFMOS_CON(void)
|
||||
{
|
||||
if (get_CHG_CURR() > 2.0f) {
|
||||
FFMOS_CON_Open();
|
||||
}
|
||||
else if (get_CHG_CURR() < 1.0f) {
|
||||
FFMOS_CON_Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void checkAbnormal(void)
|
||||
|
@ -19,17 +215,62 @@ void checkAbnormal(void)
|
|||
setSolarInCircuitVoltage();
|
||||
|
||||
/* 判断 */
|
||||
|
||||
/* 是否打开充电理想二极管 */
|
||||
if (get_CHG_CURR() > 2.0f) {
|
||||
FFMOS_CON_Open();
|
||||
}
|
||||
else if (get_CHG_CURR() < 1.0f) {
|
||||
FFMOS_CON_Close();
|
||||
}
|
||||
checkFFMOS_CON();
|
||||
setDisChargOverLoad();
|
||||
|
||||
|
||||
|
||||
// checkAbnormalTime = getCheckTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 工作电压异常中断,过载(输入大于输出)
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void WORK_VOLT_Interrupt(void)
|
||||
{
|
||||
setExcessiveLoad();
|
||||
/* 第一次进入输出过载,启动过载保护任务 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
setExcessiveLoadFlag(TRUE);
|
||||
startExcessiveLoadProtection();
|
||||
}
|
||||
|
||||
/* 多次进入输出过载,关闭输出 */
|
||||
if (getExcessiveLoad() > 2) {
|
||||
zeroExcessiveLoad();
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 短路中断,输出电流大于一定值
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void DSG_PROT_Interrupt(void)
|
||||
{
|
||||
setShortCircuit();
|
||||
/* 第一次进入输出短路,启动短路任务 */
|
||||
if (getShortCircuit() == 1) {
|
||||
setShortCircuitFlag(TRUE);
|
||||
startShortCircuitProtection();
|
||||
}
|
||||
|
||||
/* 一定时间内第二次进入输出短路保护,关闭输出 */
|
||||
else if (getShortCircuit() >= 2) {
|
||||
stopShortCircuitProtection();
|
||||
setPowerOutput(FALSE);
|
||||
zeroShortCircuit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -654,12 +654,13 @@ void setChargControlFlag(BOOL state)
|
|||
*/
|
||||
void bl_chargControl(void)
|
||||
{
|
||||
setBatteryVoltage();
|
||||
|
||||
if (getChargControlFlag() == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// getCVData();
|
||||
setBatteryVoltage();
|
||||
judgeYNBattery();
|
||||
|
||||
chargControlMode();
|
||||
|
|
|
@ -28,11 +28,20 @@ void BAT485_comm(void)
|
|||
*/
|
||||
void gw485_RxIt(void)
|
||||
{
|
||||
// uart_device_info *dev = (uart_device_info *)g_gw485_uart2_handle;
|
||||
// if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
// InRingQueue(&dev->uart_ring_queue, rx_gw485_buf[0]);
|
||||
|
||||
uint8_t c = 0;
|
||||
c = rx_gw485_buf[0];
|
||||
|
||||
uart_device_info *dev = (uart_device_info *)g_gw485_uart2_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
InRingQueue(&dev->uart_ring_queue, rx_gw485_buf[0]);
|
||||
InRingQueue(&dev->uart_ring_queue, c);
|
||||
|
||||
start_gw485Rx_It();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief bat485串口接收中断回调函数
|
||||
* @param
|
||||
|
@ -44,4 +53,6 @@ void bat485_RxIt(void)
|
|||
uart_device_info *dev = (uart_device_info *)g_bat485_uart3_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
InRingQueue(&dev->uart_ring_queue, rx_bat485_buf[0]);
|
||||
|
||||
start_bat485Rx_It();
|
||||
}
|
|
@ -5,10 +5,11 @@
|
|||
#include "parameter.h"
|
||||
#include "string.h"
|
||||
#include "chargControlEnum.h"
|
||||
#include "pDebug.h"
|
||||
|
||||
#define cfgBuffLen 200
|
||||
uint8_t configBuff[cfgBuffLen];
|
||||
uint8_t cfigLen = 0;
|
||||
static uint8_t configBuff[cfgBuffLen];
|
||||
static uint8_t cfigLen = 0;
|
||||
|
||||
/* 配置文件中的部分数据放大倍数 */
|
||||
#define enlargeScale 100
|
||||
|
@ -37,7 +38,8 @@ void outConfigBuff(void)
|
|||
{
|
||||
if (cfigLen > 0) {
|
||||
cfigLen--;
|
||||
memcpy(configBuff, configBuff + 1, cfigLen - 1);
|
||||
memcpy(configBuff, configBuff + 1, cfigLen);
|
||||
// memcpy(configBuff, configBuff + 1, sizeof(configBuff) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,32 +87,33 @@ void zeroConfigBuff(void)
|
|||
*/
|
||||
void read_and_process_config_data(void)
|
||||
{
|
||||
recv_config_info *pack = (recv_config_info *)cfgBuffLen;
|
||||
recv_config_info *pack = (recv_config_info *)configBuff;
|
||||
static config_info save_configInfo;
|
||||
while (cfigLen >= RECV_CONFIG_INFO) {
|
||||
/* 判断起始标志是否正确 */
|
||||
debug_printf(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
|
||||
if (pack->start_Flag[0] != g_cfgParameter.startFlagSL[0]
|
||||
|| pack->start_Flag[1] != g_cfgParameter.startFlagSL[1]) {
|
||||
// debug(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
|
||||
// debug(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
|
||||
goto err;
|
||||
}
|
||||
|
||||
// /* 判断接入节点类型是否正确 */
|
||||
// save_configInfo.Access_Node_Type = (uint16_t)pack->Access_Node_Type[0] << 8
|
||||
// | (uint16_t)pack->Access_Node_Type[1];
|
||||
// if (save_configInfo.Access_Node_Type != POWERBOX) {
|
||||
// // debug(" Access_Node_Type : 0x%x \n", save_configInfo.Access_Node_Type);
|
||||
// goto err;
|
||||
// }
|
||||
|
||||
/* 判断接入节点类型是否正确 */
|
||||
save_configInfo.Access_Node_Type = (uint16_t)pack->Access_Node_Type[0] << 8
|
||||
| (uint16_t)pack->Access_Node_Type[1];
|
||||
// debug(" Access_Node_Type : 0x%x \n", save_configInfo.Access_Node_Type);
|
||||
if (save_configInfo.Access_Node_Type != POWERBOX) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断通信方式是否正确 */
|
||||
save_configInfo.Communication_Methods = (uint16_t)pack->Communication_Methods[0] << 8
|
||||
| (uint16_t)pack->Communication_Methods[1];
|
||||
// debug(" Communication_Methods : 0x%x \n", save_configInfo.Communication_Methods);
|
||||
// if (temp_u16 != RS485 || temp_u16 != RJ45) {
|
||||
if (save_configInfo.Communication_Methods != RS485) {
|
||||
goto err;
|
||||
}
|
||||
// /* 判断通信方式是否正确 */
|
||||
// save_configInfo.Communication_Methods = (uint16_t)pack->Communication_Methods[0] << 8
|
||||
// | (uint16_t)pack->Communication_Methods[1];
|
||||
// // if (temp_u16 != RS485 || temp_u16 != RJ45) {
|
||||
// if (save_configInfo.Communication_Methods != RS485) {
|
||||
// debug(" Communication_Methods : 0x%x \n", save_configInfo.Communication_Methods);
|
||||
// goto err;
|
||||
// }
|
||||
|
||||
/* 判断波特率是否正确 */
|
||||
save_configInfo.gw485_Baud = (uint32_t)pack->gw485_Baud[0] << 24
|
||||
|
@ -118,9 +121,9 @@ void read_and_process_config_data(void)
|
|||
| (uint32_t)pack->gw485_Baud[2] << 8
|
||||
| (uint32_t)pack->gw485_Baud[3];
|
||||
// debug(" gw485_Baud : 0x%x, %d \n", save_configInfo.gw485_Baud, save_configInfo.gw485_Baud);
|
||||
if (save_configInfo.gw485_Baud != 9600 && save_configInfo.gw485_Baud != 115200) {
|
||||
// if (save_configInfo.gw485_Baud != 0x2580 || save_configInfo.gw485_Baud != 115200) {
|
||||
// debug(" error : %d\n", save_configInfo.gw485_Baud);
|
||||
if (save_configInfo.gw485_Baud != 9600
|
||||
&& save_configInfo.gw485_Baud != 115200) {
|
||||
// debug(" gw485_Baud : %d\n", save_configInfo.gw485_Baud);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -128,152 +131,162 @@ void read_and_process_config_data(void)
|
|||
| (uint32_t)pack->bat485_Baud[1] << 16
|
||||
| (uint32_t)pack->bat485_Baud[2] << 8
|
||||
| (uint32_t)pack->bat485_Baud[3];
|
||||
// debug(" bat485_Baud : 0x%x, %d \n", save_configInfo.bat485_Baud, save_configInfo.bat485_Baud);
|
||||
if (save_configInfo.bat485_Baud != 9600 && save_configInfo.bat485_Baud!= 115200 && save_configInfo.bat485_Baud!= 0) {
|
||||
if (save_configInfo.bat485_Baud != 9600
|
||||
&& save_configInfo.bat485_Baud!= 115200
|
||||
&& save_configInfo.bat485_Baud!= 0) {
|
||||
// debug(" bat485_Baud : 0x%x, %d \n", save_configInfo.bat485_Baud, save_configInfo.bat485_Baud);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断协议类型是否正确 */
|
||||
/* 判断汇源协议类型是否正确 */
|
||||
if (pack->protocolType != 0x01 && pack->protocolType != 0x02) {
|
||||
// debug(" protocolType : 0x%x \n", pack->protocolType);
|
||||
goto err;
|
||||
}
|
||||
// debug(" protocolType : 0x%x \n", pack->protocolType);
|
||||
|
||||
/* 判断通信协议类型是否正确 */
|
||||
if (pack->CommunicationProtocolType != 0x00 && pack->CommunicationProtocolType != 0x01) {
|
||||
if (pack->CommunicationProtocolType != 0x00
|
||||
&& pack->CommunicationProtocolType != 0x01) {
|
||||
// debug(" CommunicationProtocolType : 0x%x \n", pack->CommunicationProtocolType);
|
||||
goto err;
|
||||
}
|
||||
// debug(" CommunicationProtocolType : 0x%x \n", pack->CommunicationProtocolType);
|
||||
|
||||
|
||||
/* 判断电源盒类型是否正确 */
|
||||
if (pack->onlyPower != 0x00 && pack->onlyPower != 0x01) {
|
||||
// debug(" onlyPower : 0x%x \n", pack->onlyPower);
|
||||
goto err;
|
||||
}
|
||||
// debug(" onlyPower : 0x%x \n", pack->onlyPower);
|
||||
|
||||
/* 判断恒压充电阈值是否正确 */
|
||||
save_configInfo.constantVoltageV =
|
||||
(float)(pack->ConstantVoltageV[0] << 8 | pack->ConstantVoltageV[1]) / enlargeScale;
|
||||
// debug(" constantVoltageV : %f \n", save_configInfo.constantVoltageV);
|
||||
if (save_configInfo.constantVoltageV > (float)14.4 || save_configInfo.constantVoltageV < (float)13.5) {
|
||||
if (!((save_configInfo.constantVoltageV < 14.4f && save_configInfo.constantVoltageV > 13.5f)
|
||||
|| save_configInfo.constantVoltageV == 0)) {
|
||||
// debug(" constantVoltageV : %f \n", save_configInfo.constantVoltageV);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断浮充充电阈值是否正确 */
|
||||
save_configInfo.floatI = (float)(pack->FloatI[0] << 8 | pack->FloatI[1]) / enlargeScale;
|
||||
// debug(" floatI : %f \n", save_configInfo.floatI);
|
||||
if (save_configInfo.floatI > (float)0.2 || save_configInfo.floatI < (float)0) {
|
||||
if (save_configInfo.floatI > 0.2f || save_configInfo.floatI < 0) {
|
||||
// debug(" floatI : %f \n", save_configInfo.floatI);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断太阳能板开路启动电压是否正确 */
|
||||
save_configInfo.startSolarOpenCircuitV =
|
||||
(float)(pack->startSolarOpenCircuitV[0] << 8 | pack->startSolarOpenCircuitV[1]) / enlargeScale;
|
||||
// debug(" startSolarOpenCircuitV : %f \n", save_configInfo.startSolarOpenCircuitV);
|
||||
if (save_configInfo.startSolarOpenCircuitV > 24 || save_configInfo.startSolarOpenCircuitV < 14) {
|
||||
if (!((save_configInfo.startSolarOpenCircuitV < 24 && save_configInfo.startSolarOpenCircuitV > 14)
|
||||
|| save_configInfo.startSolarOpenCircuitV == 0)) {
|
||||
// debug(" startSolarOpenCircuitV : %f \n", save_configInfo.startSolarOpenCircuitV);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断太阳能板关闭电压是否正确 */
|
||||
save_configInfo.stopSolarOpenCircuitV =
|
||||
(float)(pack->stopSolarOpenCircuitV[0] << 8 | pack->stopSolarOpenCircuitV[1]) / enlargeScale;
|
||||
// debug(" stopSolarOpenCircuitV : %f \n", save_configInfo.stopSolarOpenCircuitV);
|
||||
if (save_configInfo.stopSolarOpenCircuitV > 17 || save_configInfo.stopSolarOpenCircuitV < 13) {
|
||||
if (!((save_configInfo.stopSolarOpenCircuitV > 17 && save_configInfo.stopSolarOpenCircuitV < 13)
|
||||
|| save_configInfo.stopSolarOpenCircuitV == 0)) {
|
||||
// debug(" stopSolarOpenCircuitV : %f \n", save_configInfo.stopSolarOpenCircuitV);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断恒压充电时的输出电压是否正确 */
|
||||
save_configInfo.constantVoltageChargeV =
|
||||
(float)(pack->constantVoltageChargeV[0] << 8 | pack->constantVoltageChargeV[1]) / enlargeScale;
|
||||
// debug(" constantVoltageChargeV : %f \n", save_configInfo.constantVoltageChargeV);
|
||||
if (save_configInfo.constantVoltageChargeV > (float)14.6 || save_configInfo.constantVoltageChargeV < (float)14) {
|
||||
if (!((save_configInfo.constantVoltageChargeV < 14.6f && save_configInfo.constantVoltageChargeV > 14)
|
||||
|| save_configInfo.constantVoltageChargeV == 0)) {
|
||||
// debug(" constantVoltageChargeV : %f \n", save_configInfo.constantVoltageChargeV);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断浮充充电时的输出电压是否正确 */
|
||||
save_configInfo.FloatChargeV =
|
||||
(float)(pack->FloatChargeV[0] << 8 | pack->FloatChargeV[1]) / enlargeScale;
|
||||
// debug(" FloatChargeV : %f \n", save_configInfo.FloatChargeV);
|
||||
if (save_configInfo.FloatChargeV > (float)14.4 || save_configInfo.FloatChargeV < (float)13.8) {
|
||||
if (!((save_configInfo.FloatChargeV < 14.4f && save_configInfo.FloatChargeV > 13.8f)
|
||||
|| save_configInfo.FloatChargeV == 0)) {
|
||||
// debug(" FloatChargeV : %f \n", save_configInfo.FloatChargeV);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断mos管停止工作温度是否正确 */
|
||||
save_configInfo.HighSideMosTemperature_stop =
|
||||
(float)(pack->HighSideMosTemperature_stop[0] << 8 | pack->HighSideMosTemperature_stop[1]) / enlargeScale;
|
||||
// debug(" HighSideMosTemperature_stop : %f \n", save_configInfo.HighSideMosTemperature_stop);
|
||||
if (save_configInfo.HighSideMosTemperature_stop < 60) {
|
||||
if (save_configInfo.HighSideMosTemperature_stop < 50 && save_configInfo.HighSideMosTemperature_stop != 0) {
|
||||
// debug(" HighSideMosTemperature_stop : %f \n", save_configInfo.HighSideMosTemperature_stop);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断mos管降低工作功率工作温度是否正确 */
|
||||
save_configInfo.HighSideMosTemperature_end =
|
||||
(float)(pack->HighSideMosTemperature_end[0] << 8 | pack->HighSideMosTemperature_end[1]) / enlargeScale;
|
||||
// debug(" HighSideMosTemperature_end : %f \n", save_configInfo.HighSideMosTemperature_end));
|
||||
if (save_configInfo.HighSideMosTemperature_end < 50) {
|
||||
if (save_configInfo.HighSideMosTemperature_end < 40 && save_configInfo.HighSideMosTemperature_end != 0) {
|
||||
// debug(" HighSideMosTemperature_end : %f \n", save_configInfo.HighSideMosTemperature_end);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断mos管完全恢复工作温度是否正确 */
|
||||
save_configInfo.HighSideMosTemperature_start =
|
||||
(float)(pack->HighSideMosTemperature_start[0] << 8 | pack->HighSideMosTemperature_start[1]) / enlargeScale;
|
||||
// debug(" HighSideMosTemperature_start : %d \n", save_configInfo.HighSideMosTemperature_start);
|
||||
if (save_configInfo.HighSideMosTemperature_start < 40) {
|
||||
if (save_configInfo.HighSideMosTemperature_start > 70 && save_configInfo.HighSideMosTemperature_start != 0) {
|
||||
debug(" HighSideMosTemperature_start : %d \n", save_configInfo.HighSideMosTemperature_start);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */
|
||||
save_configInfo.checkSolarOpenCircuitVTime =
|
||||
pack->checkSolarOpenCircuitVTime[0] << 8 | pack->checkSolarOpenCircuitVTime[1];
|
||||
// debug(" checkSolarOpenCircuitVTime : %d \n", save_configInfo.checkSolarOpenCircuitVTime);
|
||||
if (save_configInfo.checkSolarOpenCircuitVTime > 1800 || save_configInfo.checkSolarOpenCircuitVTime < 5) {
|
||||
goto err;
|
||||
}
|
||||
// /* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */
|
||||
// save_configInfo.checkSolarOpenCircuitVTime =
|
||||
// pack->checkSolarOpenCircuitVTime[0] << 8 | pack->checkSolarOpenCircuitVTime[1];
|
||||
// if (save_configInfo.checkSolarOpenCircuitVTime > 1800 || save_configInfo.checkSolarOpenCircuitVTime < 5) {
|
||||
// debug(" checkSolarOpenCircuitVTime : %d \n", save_configInfo.checkSolarOpenCircuitVTime);
|
||||
// goto err;
|
||||
// }
|
||||
|
||||
/* 判断传感器运行再次注册的间隔是否正确 */
|
||||
save_configInfo.sensorEnableBroadcastTime =
|
||||
pack->sensorEnableBroadcastTime[0] << 8 | pack->sensorEnableBroadcastTime[1];
|
||||
// debug(" sensorEnableBroadcastTime : %d \n", save_configInfo.sensorEnableBroadcastTime);
|
||||
if (save_configInfo.sensorEnableBroadcastTime > 60 || save_configInfo.sensorEnableBroadcastTime < 10) {
|
||||
goto err;
|
||||
}
|
||||
// /* 判断传感器运行再次注册的间隔是否正确 */
|
||||
// save_configInfo.sensorEnableBroadcastTime =
|
||||
// pack->sensorEnableBroadcastTime[0] << 8 | pack->sensorEnableBroadcastTime[1];
|
||||
// if (save_configInfo.sensorEnableBroadcastTime > 60 || save_configInfo.sensorEnableBroadcastTime < 10) {
|
||||
// debug(" sensorEnableBroadcastTime : %d \n", save_configInfo.sensorEnableBroadcastTime);
|
||||
// goto err;
|
||||
// }
|
||||
|
||||
/* 判断出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出的间隔是否正确 */
|
||||
save_configInfo.outputAgainFlagTime =
|
||||
pack->outputAgainFlagTime[0] << 8 | pack->outputAgainFlagTime[1];
|
||||
// debug(" outputAgainFlagTime : %d \n", save_configInfo.outputAgainFlagTime);
|
||||
if (save_configInfo.sensorEnableBroadcastTime > 30 || save_configInfo.sensorEnableBroadcastTime < 5) {
|
||||
if (!((save_configInfo.sensorEnableBroadcastTime < 30 && save_configInfo.sensorEnableBroadcastTime > 5)
|
||||
|| saveConfigInfo.sensorEnableBroadcastTime == 0)) {
|
||||
// debug(" outputAgainFlagTime : %d \n", save_configInfo.outputAgainFlagTime);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出的间隔是否正确 */
|
||||
save_configInfo.excessiveLoadFlagTime =
|
||||
pack->excessiveLoadFlagTime[0] << 8 | pack->excessiveLoadFlagTime[1];
|
||||
// debug(" excessiveLoadFlagTime : %d \n", save_configInfo.excessiveLoadFlagTime);
|
||||
if (save_configInfo.excessiveLoadFlagTime > 90 || save_configInfo.excessiveLoadFlagTime < 30) {
|
||||
if (!((save_configInfo.excessiveLoadFlagTime < 90 && save_configInfo.excessiveLoadFlagTime > 20)
|
||||
|| save_configInfo.excessiveLoadFlagTime == 0)) {
|
||||
// debug(" excessiveLoadFlagTime : %d \n", save_configInfo.excessiveLoadFlagTime);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断出现过载过载保护后,在该间隔段时间后,再次尝试输出的间隔是否正确 */
|
||||
save_configInfo.eLAgainTime = pack->eLAgainTime[0] << 8 | pack->eLAgainTime[1];
|
||||
// debug(" eLAgainTime : %d \n", save_configInfo.eLAgainTime);
|
||||
if (save_configInfo.eLAgainTime > 3000 || save_configInfo.eLAgainTime < 1000) {
|
||||
debug(" eLAgainTime : %d \n", save_configInfo.eLAgainTime);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* crc校验 */
|
||||
save_configInfo.crc = pack->crc[0] << 8 | pack->crc[1];
|
||||
// debug(" crc : %x%x \n", pack->crc[0], pack->crc[1]);
|
||||
if (save_configInfo.crc != checkModebusCrc(configBuff, RECV_CONFIG_INFO - 3)) {
|
||||
// debug(" checkModebusCrc : %x \n", checkModebusCrc(configBuff, RECV_CONFIG_INFO));
|
||||
debug(" crc : %x%x \n", pack->crc[0], pack->crc[1]);
|
||||
debug(" checkModebusCrc : %x \n", checkModebusCrc(configBuff, RECV_CONFIG_INFO));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
/* 结束标志 */
|
||||
// debug(" end_Flag : %x \n", pack->end_Flag);
|
||||
if (pack->end_Flag != 0x16) {
|
||||
debug(" end_Flag : %x \n", pack->end_Flag);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -351,10 +364,12 @@ void read_and_process_config_data(void)
|
|||
save_configInfo.CommunicationProtocolType = pack->CommunicationProtocolType;
|
||||
|
||||
save_configInfo.onlyPower = pack->onlyPower;
|
||||
|
||||
|
||||
save_configInfo.crc = checkModebusCrc((uint8_t *)&save_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_backups_config_info(&save_configInfo);
|
||||
save_config_info(&save_configInfo);
|
||||
// save_backups_config_info(&save_configInfo);
|
||||
// save_config_info(&save_configInfo);
|
||||
saveConfigInfo(&save_configInfo);
|
||||
|
||||
// memset(config_buff, 0, sizeof(config_buff));
|
||||
zeroConfigBuff();
|
||||
|
@ -391,12 +406,11 @@ void read_and_process_config_data(void)
|
|||
// }
|
||||
// Delay_Ms(randomDelay());
|
||||
// }
|
||||
uart_dev_write(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n"));
|
||||
|
||||
/* 复位 */
|
||||
NVIC_SystemReset();
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
// config_buff_pos--;
|
||||
// memcpy(config_buff, config_buff + 1, sizeof(config_buff) - 1);
|
||||
|
|
|
@ -726,7 +726,7 @@ static int Match_BroadcastCommunicationID(u_int8_t communicationID[4])
|
|||
communicationID[1] == 0xFF && \
|
||||
communicationID[2] == 0xFF && \
|
||||
communicationID[3] == 0xFF) {
|
||||
log_info("Match_BroadcastCommunicationID success\r\n");
|
||||
// log_info("Match_BroadcastCommunicationID success\r\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -744,7 +744,7 @@ static int HY_matchCommunicationID(u_int8_t communicationID[4])
|
|||
(communicationID[1] == g_cfgParameter.communicationID[1]) && \
|
||||
(communicationID[2] == g_cfgParameter.communicationID[2]) && \
|
||||
(communicationID[3] == g_cfgParameter.communicationID[3])) {
|
||||
log_info("Match_CommunicationIDHY success \r\n");
|
||||
// log_info("Match_CommunicationIDHY success \r\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -763,7 +763,7 @@ static int HY_matchHardwareID(u_int8_t hardwareID[6])
|
|||
(hardwareID[3] == g_cfgParameter.hardwareID[3]) && \
|
||||
(hardwareID[4] == g_cfgParameter.hardwareID[4]) && \
|
||||
(hardwareID[5] == g_cfgParameter.hardwareID[5])) {
|
||||
log_info("Match_hardwareIDHY success \r\n");
|
||||
// log_info("Match_hardwareIDHY success \r\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -783,7 +783,7 @@ static int Match_BroadcastHardwareID(u_int8_t hardwareID[6])
|
|||
hardwareID[3] == 0xFF && \
|
||||
hardwareID[4] == 0xFF && \
|
||||
hardwareID[5] == 0xFF) {
|
||||
log_info("Match_BroadcastHardwareID success\r\n");
|
||||
// log_info("Match_BroadcastHardwareID success\r\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -807,7 +807,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
* 0x02 硬件ID
|
||||
**/
|
||||
uint8_t hardwordIDType = 0;
|
||||
char c = 0;
|
||||
uint8_t c = 0;
|
||||
|
||||
HY_Recv_pack *pack = (HY_Recv_pack *)buff;
|
||||
|
||||
|
@ -825,7 +825,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
/* 匹配起始标志位 */
|
||||
if (offset == HY_analyzeStartFlag || (flag_run > 0)) {
|
||||
if (pack->start_Flag != g_cfgParameter.startFlagHY) {
|
||||
log_info(" Match_start_Flag error %x ", pack->start_Flag);
|
||||
// log_info(" Match_start_Flag error %x ", pack->start_Flag);
|
||||
// printf("1 : %x \n", pack->start_Flag);
|
||||
memcpy(buff, buff+1, offset-1);
|
||||
offset--;
|
||||
|
@ -846,7 +846,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
}
|
||||
|
||||
else {
|
||||
log_info("Match_hardwordID error");
|
||||
// log_info("Match_hardwordID error");
|
||||
hardwordIDType = 0x00;
|
||||
if (flag_run < 1) {
|
||||
flag_run = 1;
|
||||
|
@ -863,7 +863,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
if (flag_run < 2) {
|
||||
flag_run = 2;
|
||||
}
|
||||
log_info("Match_CommunicationID error");
|
||||
// log_info("Match_CommunicationID error");
|
||||
memcpy(buff, buff+1, offset-1);
|
||||
offset--;
|
||||
continue;
|
||||
|
@ -942,7 +942,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
if (flag_run < 3) {
|
||||
flag_run = 3;
|
||||
}
|
||||
log_info("Match_controlWord error");
|
||||
// log_info("Match_controlWord error");
|
||||
memcpy(buff, buff+1, offset-1);
|
||||
offset--;
|
||||
continue;
|
||||
|
@ -955,10 +955,10 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
if (flag_run < 4) {
|
||||
flag_run = 4;
|
||||
}
|
||||
log_info("Match_dataLen error: %x", len);
|
||||
log_info("Match_dataLen error: %x", (pack->dataLen[0] << 8 | pack->dataLen[1]) + 16);
|
||||
log_info("Match_dataLen error: %x", pack->dataLen[0]);
|
||||
log_info("Match_dataLen error: %x", pack->dataLen[1]);
|
||||
// log_info("Match_dataLen error: %x", len);
|
||||
// log_info("Match_dataLen error: %x", (pack->dataLen[0] << 8 | pack->dataLen[1]) + 16);
|
||||
// log_info("Match_dataLen error: %x", pack->dataLen[0]);
|
||||
// log_info("Match_dataLen error: %x", pack->dataLen[1]);
|
||||
memcpy(buff, buff+1, offset-1);
|
||||
offset--;
|
||||
continue;
|
||||
|
@ -971,7 +971,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
if (flag_run < 5) {
|
||||
flag_run = 5;
|
||||
}
|
||||
log_info("check: %x, %x", (HY_CheckFunc(buff, len - 2) & 0xff), buff[len - 2]);
|
||||
// log_info("check: %x, %x", (HY_CheckFunc(buff, len - 2) & 0xff), buff[len - 2]);
|
||||
memcpy(buff, buff+1, offset-1);
|
||||
offset--;
|
||||
continue;
|
||||
|
@ -1107,11 +1107,11 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
totalChargCapacityInt(0);
|
||||
totalElectricityConsumptionInt(0);
|
||||
|
||||
float temp = 0;
|
||||
// temp = getTotalChargCapacity();
|
||||
savetotalChargCapacity(&temp);
|
||||
// temp = getTotalElectricityConsumption();
|
||||
savetotalElectricityConsumption(&temp);
|
||||
// float temp = 0;
|
||||
// // temp = getTotalChargCapacity();
|
||||
// savetotalChargCapacity(&temp);
|
||||
// // temp = getTotalElectricityConsumption();
|
||||
// savetotalElectricityConsumption(&temp);
|
||||
|
||||
HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg;
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
@ -1145,7 +1145,7 @@ void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg,
|
|||
temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3];
|
||||
|
||||
temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
saveConfigInfo(&temp_configInfo);
|
||||
|
||||
pack.state = HY_success;
|
||||
}
|
||||
|
@ -1382,7 +1382,7 @@ void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint
|
|||
temp_configInfo.protocolType = Tpack->protocolType;
|
||||
|
||||
temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
saveConfigInfo(&temp_configInfo);
|
||||
|
||||
if (g_cfgParameter.protocolType == 0x01) {
|
||||
g_cfgParameter.gw485_Baud = 9600;
|
||||
|
@ -1420,7 +1420,7 @@ void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint
|
|||
|
||||
uart_dev_write(device, &pack, HY_configProtocolTypeResponse_PACK_SIZE);
|
||||
|
||||
Init_GW485_uart();
|
||||
Init_GW485_uart(g_cfgParameter.gw485_Baud);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32
|
|||
temp_configInfo.hardwareID[5] = Tpack->hardwareID[5];
|
||||
|
||||
temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
saveConfigInfo(&temp_configInfo);
|
||||
|
||||
pack.state = HY_success;
|
||||
}
|
||||
|
@ -1665,7 +1665,7 @@ void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint
|
|||
temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3];
|
||||
|
||||
temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
saveConfigInfo(&temp_configInfo);
|
||||
|
||||
pack.state = HY_success1;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "parameter.h"
|
||||
#include "pDebug.h"
|
||||
|
||||
static void save_config_info(config_info *save_config_info);
|
||||
|
||||
/**
|
||||
* @brief 保存配置信息
|
||||
|
@ -14,15 +15,15 @@ void save_config_info(config_info *save_config_info)
|
|||
write_Flash((uint8_t *)save_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 保存配置信息到备份区
|
||||
* @param save_config_info 需要保存的配置信息
|
||||
* @retval None
|
||||
*/
|
||||
static void save_backups_config_info(config_info *save_config_info)
|
||||
{
|
||||
write_Flash((uint8_t *)save_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE);
|
||||
}
|
||||
// /**
|
||||
// * @brief 保存配置信息到备份区
|
||||
// * @param save_config_info 需要保存的配置信息
|
||||
// * @retval None
|
||||
// */
|
||||
// static void save_backups_config_info(config_info *save_config_info)
|
||||
// {
|
||||
// write_Flash((uint8_t *)save_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief 读取配置信息
|
||||
|
@ -34,14 +35,20 @@ void read_config_info(config_info *output_config_info)
|
|||
read_Flash((uint8_t *)output_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取备份的配置信息
|
||||
* @param read_config_info 读取配置信息并保存在output_config_info中
|
||||
* @retval None
|
||||
*/
|
||||
static void read_backups_config_info(config_info *output_config_info)
|
||||
// /**
|
||||
// * @brief 读取备份的配置信息
|
||||
// * @param read_config_info 读取配置信息并保存在output_config_info中
|
||||
// * @retval None
|
||||
// */
|
||||
// static void read_backups_config_info(config_info *output_config_info)
|
||||
// {
|
||||
// read_Flash((uint8_t *)output_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE);
|
||||
// }
|
||||
|
||||
void saveConfigInfo(config_info *config_info)
|
||||
{
|
||||
read_Flash((uint8_t *)output_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE);
|
||||
save_config_info(config_info);
|
||||
// save_backups_config_info(config_info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,12 +59,11 @@ static void read_backups_config_info(config_info *output_config_info)
|
|||
*/
|
||||
static void readFlashContent(config_info *config_info)
|
||||
{
|
||||
// read_config_info(config_info);
|
||||
|
||||
// /* 配置文件正确就返回 */
|
||||
// if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
|
||||
// return;
|
||||
// }
|
||||
read_config_info(config_info);
|
||||
/* 配置文件正确就返回 */
|
||||
if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// /* 更深处的配置文件正确就返回 */
|
||||
// read_backups_config_info(config_info);
|
||||
|
@ -74,8 +80,8 @@ static void readFlashContent(config_info *config_info)
|
|||
config_info->address[4] = 0x11;
|
||||
config_info->address[5] = 0x11;
|
||||
config_info->address[6] = 0x11;
|
||||
config_info->Access_Node_Type = 0x01;
|
||||
config_info->Communication_Methods = 0x02;
|
||||
// config_info->Access_Node_Type = 0x01;
|
||||
// config_info->Communication_Methods = 0x02;
|
||||
config_info->gw485_Baud = 9600;
|
||||
config_info->bat485_Baud = 115200;
|
||||
|
||||
|
@ -91,7 +97,7 @@ static void readFlashContent(config_info *config_info)
|
|||
config_info->communicationID[3] = 0x01;
|
||||
config_info->protocolType = 0x01;
|
||||
|
||||
// config_info->CommunicationProtocolType = 0x00;
|
||||
config_info->CommunicationProtocolType = 0x01;
|
||||
config_info->onlyPower = 0x01;
|
||||
|
||||
config_info->constantVoltageV = 14;
|
||||
|
@ -104,8 +110,8 @@ static void readFlashContent(config_info *config_info)
|
|||
config_info->HighSideMosTemperature_end = 90;
|
||||
config_info->HighSideMosTemperature_start = 50;
|
||||
|
||||
config_info->checkSolarOpenCircuitVTime = 10;
|
||||
config_info->sensorEnableBroadcastTime = 20;
|
||||
// config_info->checkSolarOpenCircuitVTime = 10;
|
||||
// config_info->sensorEnableBroadcastTime = 20;
|
||||
config_info->outputAgainFlagTime = 10;
|
||||
config_info->excessiveLoadFlagTime = 60;
|
||||
config_info->eLAgainTime = 1800;
|
||||
|
@ -133,8 +139,8 @@ void config_info_start(void)
|
|||
g_cfgParameter.HighSideMosTemperature_stop = temp_configInfo.HighSideMosTemperature_stop;
|
||||
g_cfgParameter.HighSideMosTemperature_end = temp_configInfo.HighSideMosTemperature_end;
|
||||
g_cfgParameter.HighSideMosTemperature_start = temp_configInfo.HighSideMosTemperature_start;
|
||||
g_cfgParameter.sensorEnableBroadcastTime = temp_configInfo.sensorEnableBroadcastTime;
|
||||
g_cfgParameter.checkSolarOpenCircuitVTime = temp_configInfo.checkSolarOpenCircuitVTime;
|
||||
// g_cfgParameter.sensorEnableBroadcastTime = temp_configInfo.sensorEnableBroadcastTime;
|
||||
// g_cfgParameter.checkSolarOpenCircuitVTime = temp_configInfo.checkSolarOpenCircuitVTime;
|
||||
g_cfgParameter.outputAgainFlagTime = temp_configInfo.outputAgainFlagTime;
|
||||
g_cfgParameter.excessiveLoadFlagTime = temp_configInfo.excessiveLoadFlagTime;
|
||||
g_cfgParameter.eLAgainTime = temp_configInfo.eLAgainTime;
|
||||
|
@ -146,8 +152,8 @@ void config_info_start(void)
|
|||
g_cfgParameter.address[4] = temp_configInfo.address[4];
|
||||
g_cfgParameter.address[5] = temp_configInfo.address[5];
|
||||
g_cfgParameter.address[6] = temp_configInfo.address[6];
|
||||
g_cfgParameter.Access_Node_Type = temp_configInfo.Access_Node_Type;
|
||||
g_cfgParameter.Communication_Methods = temp_configInfo.Communication_Methods;
|
||||
// g_cfgParameter.Access_Node_Type = temp_configInfo.Access_Node_Type;
|
||||
// g_cfgParameter.Communication_Methods = temp_configInfo.Communication_Methods;
|
||||
g_cfgParameter.hardwareID[0] = temp_configInfo.hardwareID[0];
|
||||
g_cfgParameter.hardwareID[1] = temp_configInfo.hardwareID[1];
|
||||
g_cfgParameter.hardwareID[2] = temp_configInfo.hardwareID[2];
|
||||
|
@ -178,9 +184,9 @@ void config_info_start(void)
|
|||
// } else if (g_cfgParameter.protocolType == 0x02) {
|
||||
// g_cfgParameter.gw485_Baud = 115200;
|
||||
// }
|
||||
// }
|
||||
g_cfgParameter.gw485_Baud = 9600;
|
||||
// }
|
||||
g_cfgParameter.gw485_Baud = 115200;
|
||||
g_cfgParameter.bat485_Baud = 115200;
|
||||
|
||||
float fTemp;
|
||||
readLoopImpedance(&fTemp);
|
||||
|
|
|
@ -301,7 +301,7 @@ float getTotalElectricityConsumption(void)
|
|||
*/
|
||||
void setTotalElectricityConsumption(void)
|
||||
{
|
||||
g_otherParameter.totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
|
||||
g_otherParameter.totalElectricityConsumption += g_otherParameter.Discharg_Current / 3600000.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,7 +331,7 @@ float getTotalChargCapacity(void)
|
|||
*/
|
||||
void setTotalChargCapacity(void)
|
||||
{
|
||||
g_otherParameter.totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
|
||||
g_otherParameter.totalChargCapacity += g_otherParameter.Charg_Current / 3600000.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#include "chargControlEnum.h"
|
||||
#include "bl_chargControl.h"
|
||||
#include "hy_protocol.h"
|
||||
#include "cfg_protocol.h"
|
||||
#include "uart_dev.h"
|
||||
#include "abnormalManage.h"
|
||||
|
||||
|
||||
/* 控制运行指示灯和喂狗 */
|
||||
// #define runled_reloadVal 1000 /* 任务执行间隔 */
|
||||
|
@ -27,7 +31,7 @@ static STR_TimeSliceOffset m_refreshJudgeData;
|
|||
static void Task_refreshJudgeData(void);
|
||||
|
||||
/* 启动任务 */
|
||||
#define startControl_reloadVal 5000 /* 任务执行间隔 */
|
||||
#define startControl_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define startControl_offset 100 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_startControl;
|
||||
static void Task_startControl(void);
|
||||
|
@ -53,11 +57,40 @@ void Task_collectOpenCircuitVoltage(void);
|
|||
/* 限时开启HY协议配置模式 */
|
||||
#define beginHYconfigMode_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define beginHYconfigMode_offset 0 /* 任务执行偏移量 */
|
||||
STR_TimeSliceOffset m_beginHYconfigMode;
|
||||
void Task_beginHYconfigMode(void);
|
||||
static STR_TimeSliceOffset m_beginHYconfigMode;
|
||||
static void Task_beginHYconfigMode(void);
|
||||
|
||||
/* 串口数据接收判断 */
|
||||
#define usartJudge_reloadVal 100 /* 任务执行间隔 */
|
||||
#define usartJudge_offset 0 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_usartJudge;
|
||||
static void Task_usartJudge(void);
|
||||
|
||||
/* 串口数据解析和处理 */
|
||||
#define usartHandle_reloadVal 20 /* 任务执行间隔 */
|
||||
#define usartHandle_offset 0 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_usartHandle;
|
||||
static void Task_usartHandle(void);
|
||||
typedef void (*uartJudgeHandle)(device_handle device);
|
||||
static uartJudgeHandle uart_judge_handle;
|
||||
|
||||
/* 配置文件数据解析和处理 */
|
||||
#define usartCfg_reloadVal 200 /* 任务执行间隔 */
|
||||
#define usartCfg_offset 0 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_usartCfg;
|
||||
static void Task_usartCfg(void);
|
||||
|
||||
/* 短路保护 */
|
||||
#define shortCircuitProtection_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define shortCircuitProtection_offset 0 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_shortCircuitProtection;
|
||||
static void Task_shortCircuitProtection(void);
|
||||
|
||||
/* 过载保护 */
|
||||
#define excessiveLoad_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define excessiveLoad_offset 0 /* 任务执行偏移量 */
|
||||
STR_TimeSliceOffset m_excessiveLoad;
|
||||
void Task_excessiveLoad(void);
|
||||
|
||||
/**
|
||||
* @brief 启动时初始化各任务
|
||||
|
@ -75,6 +108,9 @@ void task_Init(void)
|
|||
TimeSliceOffset_Register(&m_collectOpenCircuitVoltage, Task_collectOpenCircuitVoltage
|
||||
, collectOpenCircuitVoltage_reloadVal, collectOpenCircuitVoltage_offset);
|
||||
|
||||
uartTaskInit();
|
||||
TimeSliceOffset_Register(&m_usartJudge, Task_usartJudge, usartJudge_reloadVal, usartJudge_offset);
|
||||
TimeSliceOffset_Register(&m_usartCfg, Task_usartCfg, usartCfg_reloadVal, usartCfg_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,17 +133,17 @@ void Task_wdi(void)
|
|||
{
|
||||
feedDog();
|
||||
|
||||
debug_printf("chargCurrent:%f \n", getChargCurrent());
|
||||
debug_printf("outputVoltage:%f \n", getOutputVoltage());
|
||||
debug_printf("BatteryVoltage:%f \n", getBatteryVoltage());
|
||||
debug_printf("dischargCurrent:%f \n", getDischargCurrent());
|
||||
debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
||||
debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
||||
debug_printf("InputVoltage:%f \n", getInputVoltage());
|
||||
debug_printf("DischargMosState:%d \n", getDischargMosState());
|
||||
debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
|
||||
debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance);
|
||||
debug_printf("DutyRatio:%f \n", getDutyRatio());
|
||||
// debug_printf("chargCurrent:%f \n", getChargCurrent());
|
||||
// debug_printf("outputVoltage:%f \n", getOutputVoltage());
|
||||
// debug_printf("BatteryVoltage:%f \n", getBatteryVoltage());
|
||||
// debug_printf("dischargCurrent:%f \n", getDischargCurrent());
|
||||
// debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
||||
// debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
||||
// debug_printf("InputVoltage:%f \n", getInputVoltage());
|
||||
// debug_printf("DischargMosState:%d \n", getDischargMosState());
|
||||
// debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
|
||||
// debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance);
|
||||
// debug_printf("DutyRatio:%f \n", getDutyRatio());
|
||||
|
||||
/* 每天复位一次,复位前将电量信息写入flash中 */
|
||||
static uint32_t temp = 60 * 60 * 24;
|
||||
|
@ -188,7 +224,7 @@ void Task_startControl(void)
|
|||
|
||||
|
||||
/* 判断有无电池 */
|
||||
if (getOutputVoltage() > 10) {
|
||||
if (getOutputVoltage() > 11.0f) {
|
||||
setBatteryState(TRUE);
|
||||
} else {
|
||||
setBatteryState(FALSE);
|
||||
|
@ -389,3 +425,175 @@ void beginHYconfigMode(void)
|
|||
, beginHYconfigMode_reloadVal, beginHYconfigMode_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化串口任务,确定使用的协议
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void uartTaskInit(void)
|
||||
{
|
||||
// if (g_cfgParameter.CommunicationProtocolType == 0x00) {
|
||||
// uart_judge_handle = read_and_process_uart_data;
|
||||
// } else if (g_cfgParameter.CommunicationProtocolType == 0x01) {
|
||||
// uart_judge_handle = HY_read_and_process_uart_data;
|
||||
// }
|
||||
|
||||
uart_judge_handle = HY_read_and_process_uart_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 检测有无通信数据传来
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void Task_usartJudge(void)
|
||||
{
|
||||
/* 检测到对上通信串口有数据启动读取并解析任务 */
|
||||
if (uart_dev_char_present(g_gw485_uart2_handle)) {
|
||||
TimeSliceOffset_Register(&m_usartHandle, Task_usartHandle
|
||||
, usartHandle_reloadVal, usartHandle_offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取并解析对上通讯的数据
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void Task_usartHandle(void)
|
||||
{
|
||||
TimeSliceOffset_Unregister(&m_usartHandle);
|
||||
m_usartHandle.runFlag = 0;
|
||||
uart_judge_handle(g_gw485_uart2_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取并解析配置文件的数据
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void Task_usartCfg(void)
|
||||
{
|
||||
read_and_process_config_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 短路保护任务,短路后启动该任务
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void Task_shortCircuitProtection(void)
|
||||
{
|
||||
static uint8_t num = 0;
|
||||
num++;
|
||||
|
||||
/* 设定输出短路保护时间 */
|
||||
if (num == g_cfgParameter.outputAgainFlagTime) {
|
||||
num = 0;
|
||||
zeroShortCircuit();
|
||||
TimeSliceOffset_Unregister(&m_shortCircuitProtection);
|
||||
m_shortCircuitProtection.runFlag = 0;
|
||||
|
||||
/* 仍然过流,彻底关闭输出 */
|
||||
if (readOverCurrState() == FALSE) {
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
/* 不过流,则状态位复位 */
|
||||
else {
|
||||
setShortCircuitFlag(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 启动短路保护任务
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void startShortCircuitProtection(void)
|
||||
{
|
||||
TimeSliceOffset_Register(&m_shortCircuitProtection, Task_shortCircuitProtection
|
||||
, shortCircuitProtection_reloadVal, shortCircuitProtection_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 关闭短路保护任务
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void stopShortCircuitProtection(void)
|
||||
{
|
||||
TimeSliceOffset_Unregister(&m_shortCircuitProtection);
|
||||
m_shortCircuitProtection.runFlag = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 过载保护任务,输入不够供给输出后启动该任务
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void Task_excessiveLoad(void)
|
||||
{
|
||||
static uint8_t num = 0;
|
||||
static uint16_t numLong = 0;
|
||||
|
||||
/* 短路保护了则退出过载保护 */
|
||||
if (getShortCircuitFlag() == TRUE) {
|
||||
num = 0;
|
||||
numLong = 0;
|
||||
zeroExcessiveLoad();
|
||||
setExcessiveLoadFlag(FALSE);
|
||||
TimeSliceOffset_Unregister(&m_excessiveLoad);
|
||||
m_excessiveLoad.runFlag = 0;
|
||||
}
|
||||
|
||||
/* 过载一次 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
num++;
|
||||
}
|
||||
|
||||
/* 延迟一段时间打开输出接口 */
|
||||
if (num == 1 && getExcessiveLoad() == 1) {
|
||||
setPowerOutput(TRUE);
|
||||
}
|
||||
|
||||
/* 多次过载则关闭输出(关闭输出中断中完成),尝试一段时间后再次输出 */
|
||||
if (getExcessiveLoad() >= 2) {
|
||||
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
|
||||
num = 0;
|
||||
}
|
||||
|
||||
/* 仅过载一次,达到时间后关闭该任务 */
|
||||
if (num == g_cfgParameter.excessiveLoadFlagTime) {
|
||||
num = 0;
|
||||
setExcessiveLoadFlag(FALSE);
|
||||
TimeSliceOffset_Unregister(&m_excessiveLoad);
|
||||
m_excessiveLoad.runFlag = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* 关闭输出后开始计时 */
|
||||
if (readPOW_OUT_PCON_State() == FALSE) {
|
||||
numLong++;
|
||||
}
|
||||
|
||||
/* 达到时间就重新尝试输出 */
|
||||
if (numLong == g_cfgParameter.eLAgainTime) {
|
||||
numLong = 0;
|
||||
TimeSliceOffset_Unregister(&m_excessiveLoad);
|
||||
m_excessiveLoad.runFlag = 0;
|
||||
setPowerOutput(TRUE);
|
||||
setExcessiveLoadFlag(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 启动硬件过载保护任务
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void startExcessiveLoadProtection(void)
|
||||
{
|
||||
TimeSliceOffset_Register(&m_excessiveLoad, Task_excessiveLoad
|
||||
, excessiveLoad_reloadVal, excessiveLoad_offset);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
#include "test.h"
|
||||
#include "checkTime.h"
|
||||
#include "uart_dev.h"
|
||||
#include "HD_TIM.h"
|
||||
#include "pDebug.h"
|
||||
#include "parameter.h"
|
||||
#include "FM_TIM.h"
|
||||
|
||||
void test(void)
|
||||
{
|
||||
tim_Init();
|
||||
Init_debug_uart();
|
||||
|
||||
|
||||
while (1) {
|
||||
HAL_Delay(1000);
|
||||
// debug_printf("time:%f\r\n", checkAbnormalTime);
|
||||
// debug_printf("chargCurrent:%f\r\n", getChargCurrent());
|
||||
// debug_printf("outputVoltage:%f\r\n", getOutputVoltage());
|
||||
// debug_printf("dischargCurrent:%f\r\n", getDischargCurrent());
|
||||
// debug_printf("solarInCircuitVoltage:%f\r\n", getSolarInCircuitVoltage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#define FM_GPIO_H_
|
||||
|
||||
#include "HD_GPIO.h"
|
||||
#include "comm_types.h"
|
||||
|
||||
void FM_GPIO_Init(void);
|
||||
|
||||
|
@ -10,6 +11,7 @@ void POW_FF_PCON_Close(void);
|
|||
|
||||
void POW_OUT_PCON_Open(void);
|
||||
void POW_OUT_PCON_Close(void);
|
||||
BOOL readPOW_OUT_PCON_State(void);
|
||||
|
||||
void RUN_LEN_Open(void);
|
||||
void RUN_LEN_Close(void);
|
||||
|
@ -23,10 +25,12 @@ void EN_PWMOUT_Diseable(void);
|
|||
|
||||
void feedDog(void);
|
||||
|
||||
BOOL readOverCurrState(void);
|
||||
|
||||
BOOL readOnlyPowerOutputState(void);
|
||||
BOOL readOutputState(void);
|
||||
|
||||
// extern void WORK_VOLT_Interrupt(void);
|
||||
// extern void DSG_PROT_Interrupt(void);
|
||||
extern void WORK_VOLT_Interrupt(void);
|
||||
extern void DSG_PROT_Interrupt(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,4 +13,7 @@ extern void chargControl(void);
|
|||
extern void checkAbnormal(void);
|
||||
extern void hw_inc_tick(void);
|
||||
|
||||
extern void setTotalElectricityConsumption(void);
|
||||
extern void setTotalChargCapacity(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,8 +40,8 @@ void uart_close(uartIndex_e uart_index);
|
|||
void uart_sendstr(device_handle device, char *str);
|
||||
void debug_printf(char *format, ...);
|
||||
void Init_debug_uart(void);
|
||||
void Init_BAT485_uart(void);
|
||||
void Init_GW485_uart(void);
|
||||
void Init_BAT485_uart(uint32_t baud);
|
||||
void Init_GW485_uart(uint32_t baud);
|
||||
uint8_t uart_dev_in_char(device_handle device);
|
||||
int uart_dev_char_present(device_handle device);
|
||||
void uart_dev_write(device_handle device, void *data, int len);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#include "FM_GPIO.h"
|
||||
|
||||
#include "uart_dev.h"
|
||||
|
||||
void FM_GPIO_Init(void)
|
||||
{
|
||||
HD_GPIO_Init();
|
||||
|
@ -46,6 +48,21 @@ void POW_OUT_PCON_Close(void)
|
|||
HAL_GPIO_WritePin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取输出控制引脚状态
|
||||
* @param None
|
||||
* @retval TRUE 打开
|
||||
* FALSE 关闭
|
||||
*/
|
||||
BOOL readPOW_OUT_PCON_State(void)
|
||||
{
|
||||
if (HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 打开LED灯
|
||||
* @param None
|
||||
|
@ -127,6 +144,20 @@ void feedDog(void)
|
|||
HAL_GPIO_WritePin(WDI_INPUT_GPIO_Port, WDI_INPUT_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断过流状态
|
||||
* @param None
|
||||
* @retval
|
||||
*/
|
||||
BOOL readOverCurrState(void)
|
||||
{
|
||||
if (HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 仅有充电控制器时,判断输出开关是否打开
|
||||
* @param None
|
||||
|
@ -165,12 +196,12 @@ BOOL readOutputState(void)
|
|||
*/
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
if (GPIO_Pin == WORK_VOLT_Pin) {
|
||||
// WORK_VOLT_Interrupt();
|
||||
if (GPIO_Pin == WORK_VOLT_INT_Pin) {
|
||||
WORK_VOLT_Interrupt();
|
||||
}
|
||||
|
||||
else if (GPIO_Pin == DSG_PROT_Pin) {
|
||||
// DSG_PROT_Interrupt();
|
||||
DSG_PROT_Interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ void tim_Init(void)
|
|||
HD_taskBaseTim_Init();
|
||||
HAL_TIM_Base_Start_IT(&htim16);
|
||||
|
||||
HD_time_Init();
|
||||
HAL_TIM_Base_Start_IT(&htim15);
|
||||
// HD_time_Init();
|
||||
// HAL_TIM_Base_Start_IT(&htim15);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,22 +83,27 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM1) {
|
||||
HAL_IncTick();
|
||||
}
|
||||
// if (htim->Instance == TIM1) {
|
||||
// HAL_IncTick();
|
||||
// }
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
|
||||
else if (htim->Instance == TIM7) {
|
||||
// else if (htim->Instance == TIM7) {
|
||||
// chargControl();
|
||||
// }
|
||||
if (htim->Instance == TIM7) {
|
||||
chargControl();
|
||||
}
|
||||
|
||||
else if (htim->Instance == TIM16) {
|
||||
TimeSliceOffset_Produce();
|
||||
setTotalElectricityConsumption();
|
||||
setTotalChargCapacity();
|
||||
}
|
||||
|
||||
else if (htim->Instance == TIM15) {
|
||||
hw_inc_tick();
|
||||
}
|
||||
// else if (htim->Instance == TIM15) {
|
||||
// hw_inc_tick();
|
||||
// }
|
||||
|
||||
/* USER CODE END Callback 1 */
|
||||
}
|
|
@ -179,8 +179,9 @@ void Init_debug_uart(void)
|
|||
* @brief 初始化向下通信对电池pack串口.
|
||||
* @retval None
|
||||
*/
|
||||
void Init_BAT485_uart(void)
|
||||
void Init_BAT485_uart(uint32_t baud)
|
||||
{
|
||||
uart_devices[1].uart_baudrate = baud;
|
||||
g_bat485_uart3_handle = uart_dev_init(BAT485_UART_INDEX, Bat485_in_buff, sizeof(Bat485_in_buff));
|
||||
}
|
||||
|
||||
|
@ -188,8 +189,9 @@ void Init_BAT485_uart(void)
|
|||
* @brief 初始化向上对网关通信485串口.
|
||||
* @retval None
|
||||
*/
|
||||
void Init_GW485_uart(void)
|
||||
{
|
||||
void Init_GW485_uart(uint32_t baud)
|
||||
{
|
||||
uart_devices[0].uart_baudrate = baud;
|
||||
g_gw485_uart2_handle = uart_dev_init(GW485_UART_INDEX, Gw485_in_buff, sizeof(Gw485_in_buff));
|
||||
}
|
||||
|
||||
|
@ -215,12 +217,12 @@ uint8_t uart_dev_in_char(device_handle device)
|
|||
*/
|
||||
int uart_dev_char_present(device_handle device)
|
||||
{
|
||||
uart_device_info *device_info = (uart_device_info *)device;
|
||||
uart_device_info *device_info = (uart_device_info *)device;
|
||||
|
||||
if((!device) || (!device_info->init))
|
||||
return 0;
|
||||
if((!device) || (!device_info->init))
|
||||
return 0;
|
||||
|
||||
return !RingQueueEmpty(&device_info->uart_ring_queue);
|
||||
return !RingQueueEmpty(&device_info->uart_ring_queue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,7 +244,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
|||
gw485_RxIt();
|
||||
}
|
||||
else if (huart->Instance == USART3) {
|
||||
bat485_RxIt();
|
||||
bat485_RxIt();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ void TIM1_UP_TIM16_IRQHandler(void);
|
|||
void USART2_IRQHandler(void);
|
||||
void USART3_IRQHandler(void);
|
||||
void EXTI15_10_IRQHandler(void);
|
||||
void TIM6_DAC_IRQHandler(void);
|
||||
void TIM7_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void MX_DMA_Init(void)
|
|||
|
||||
/* DMA interrupt init */
|
||||
/* DMA1_Channel1_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 4, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
|
||||
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ void MX_GPIO_Init(void)
|
|||
|
||||
/*Configure GPIO pin : WORK_VOLT_INT_Pin */
|
||||
GPIO_InitStruct.Pin = WORK_VOLT_INT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
HAL_GPIO_Init(WORK_VOLT_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
|
|
|
@ -176,27 +176,6 @@ void SystemClock_Config(void)
|
|||
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @note This function is called when TIM1 interrupt took place, inside
|
||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||
* a global variable "uwTick" used as application time base.
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
// void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
// {
|
||||
// /* USER CODE BEGIN Callback 0 */
|
||||
|
||||
// /* USER CODE END Callback 0 */
|
||||
// if (htim->Instance == TIM1) {
|
||||
// HAL_IncTick();
|
||||
// }
|
||||
// /* USER CODE BEGIN Callback 1 */
|
||||
|
||||
// /* USER CODE END Callback 1 */
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @retval None
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32g4xx_hal_timebase_tim.c
|
||||
* @brief HAL time base based on the hardware TIM.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32g4xx_hal.h"
|
||||
#include "stm32g4xx_hal_tim.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
TIM_HandleTypeDef htim1;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief This function configures the TIM1 as a time base source.
|
||||
* The time source is configured to have 1ms time base with a dedicated
|
||||
* Tick interrupt priority.
|
||||
* @note This function is called automatically at the beginning of program after
|
||||
* reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
|
||||
* @param TickPriority: Tick interrupt priority.
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
||||
{
|
||||
RCC_ClkInitTypeDef clkconfig;
|
||||
uint32_t uwTimclock = 0;
|
||||
uint32_t uwPrescalerValue = 0;
|
||||
uint32_t pFLatency;
|
||||
|
||||
HAL_StatusTypeDef status;
|
||||
|
||||
/* Enable TIM1 clock */
|
||||
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||
|
||||
/* Get clock configuration */
|
||||
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
|
||||
|
||||
/* Compute TIM1 clock */
|
||||
uwTimclock = HAL_RCC_GetPCLK2Freq();
|
||||
|
||||
/* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */
|
||||
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
|
||||
|
||||
/* Initialize TIM1 */
|
||||
htim1.Instance = TIM1;
|
||||
|
||||
/* Initialize TIMx peripheral as follow:
|
||||
|
||||
+ Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base.
|
||||
+ Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
|
||||
+ ClockDivision = 0
|
||||
+ Counter direction = Up
|
||||
*/
|
||||
htim1.Init.Period = (1000000U / 1000U) - 1U;
|
||||
htim1.Init.Prescaler = uwPrescalerValue;
|
||||
htim1.Init.ClockDivision = 0;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
|
||||
status = HAL_TIM_Base_Init(&htim1);
|
||||
if (status == HAL_OK)
|
||||
{
|
||||
/* Start the TIM time Base generation in interrupt mode */
|
||||
status = HAL_TIM_Base_Start_IT(&htim1);
|
||||
if (status == HAL_OK)
|
||||
{
|
||||
/* Enable the TIM1 global Interrupt */
|
||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
|
||||
/* Configure the SysTick IRQ priority */
|
||||
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
|
||||
{
|
||||
/* Configure the TIM IRQ priority */
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, TickPriority, 0U);
|
||||
uwTickPrio = TickPriority;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = HAL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Return function status */
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Suspend Tick increment.
|
||||
* @note Disable the tick increment by disabling TIM1 update interrupt.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SuspendTick(void)
|
||||
{
|
||||
/* Disable TIM1 update Interrupt */
|
||||
__HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resume Tick increment.
|
||||
* @note Enable the tick increment by Enabling TIM1 update interrupt.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ResumeTick(void)
|
||||
{
|
||||
/* Enable TIM1 Update interrupt */
|
||||
__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
|
||||
}
|
||||
|
|
@ -56,14 +56,11 @@
|
|||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern DMA_HandleTypeDef hdma_adc1;
|
||||
extern TIM_HandleTypeDef htim6;
|
||||
extern TIM_HandleTypeDef htim7;
|
||||
extern TIM_HandleTypeDef htim15;
|
||||
extern TIM_HandleTypeDef htim16;
|
||||
extern UART_HandleTypeDef huart2;
|
||||
extern UART_HandleTypeDef huart3;
|
||||
extern TIM_HandleTypeDef htim1;
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
@ -193,7 +190,7 @@ void SysTick_Handler(void)
|
|||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||
|
||||
/* USER CODE END SysTick_IRQn 0 */
|
||||
|
||||
HAL_IncTick();
|
||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||
|
||||
/* USER CODE END SysTick_IRQn 1 */
|
||||
|
@ -242,14 +239,7 @@ void TIM1_UP_TIM16_IRQHandler(void)
|
|||
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM1_UP_TIM16_IRQn 0 */
|
||||
if (htim1.Instance != NULL)
|
||||
{
|
||||
HAL_TIM_IRQHandler(&htim1);
|
||||
}
|
||||
if (htim16.Instance != NULL)
|
||||
{
|
||||
HAL_TIM_IRQHandler(&htim16);
|
||||
}
|
||||
HAL_TIM_IRQHandler(&htim16);
|
||||
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM1_UP_TIM16_IRQn 1 */
|
||||
|
@ -298,20 +288,6 @@ void EXTI15_10_IRQHandler(void)
|
|||
/* USER CODE END EXTI15_10_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM6 global interrupt, DAC1 and DAC3 channel underrun error interrupts.
|
||||
*/
|
||||
void TIM6_DAC_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_DAC_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM6_DAC_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim6);
|
||||
/* USER CODE BEGIN TIM6_DAC_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM6_DAC_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM7 global interrupt.
|
||||
*/
|
||||
|
|
|
@ -235,10 +235,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||
/* USER CODE END TIM6_MspInit 0 */
|
||||
/* TIM6 clock enable */
|
||||
__HAL_RCC_TIM6_CLK_ENABLE();
|
||||
|
||||
/* TIM6 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspInit 1 */
|
||||
|
@ -267,7 +263,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||
__HAL_RCC_TIM15_CLK_ENABLE();
|
||||
|
||||
/* TIM15 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM1_BRK_TIM15_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(TIM1_BRK_TIM15_IRQn, 4, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM1_BRK_TIM15_IRQn);
|
||||
/* USER CODE BEGIN TIM15_MspInit 1 */
|
||||
|
||||
|
@ -282,7 +278,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||
__HAL_RCC_TIM16_CLK_ENABLE();
|
||||
|
||||
/* TIM16 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 15, 0);
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 4, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
|
||||
/* USER CODE BEGIN TIM16_MspInit 1 */
|
||||
|
||||
|
@ -343,9 +339,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||
/* USER CODE END TIM6_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM6_CLK_DISABLE();
|
||||
|
||||
/* TIM6 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspDeInit 1 */
|
||||
|
|
|
@ -223,15 +223,22 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||
PA2 ------> USART2_TX
|
||||
PA3 ------> USART2_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GW485_RDE_Pin|GW485_TX_Pin|GW485_RX_Pin;
|
||||
GPIO_InitStruct.Pin = GW485_RDE_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
||||
HAL_GPIO_Init(GW485_RDE_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GW485_TX_Pin|GW485_RX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USART2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 2, 0);
|
||||
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||
/* USER CODE BEGIN USART2_MspInit 1 */
|
||||
|
||||
|
@ -261,15 +268,22 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||
PB11 ------> USART3_RX
|
||||
PB14 ------> USART3_DE
|
||||
*/
|
||||
GPIO_InitStruct.Pin = BAT485_TX_Pin|BAT485_RX_Pin|BAT_485_RDE_Pin;
|
||||
GPIO_InitStruct.Pin = BAT485_TX_Pin|BAT485_RX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = BAT_485_RDE_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(BAT_485_RDE_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USART3 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(USART3_IRQn, 2, 0);
|
||||
HAL_NVIC_EnableIRQ(USART3_IRQn);
|
||||
/* USER CODE BEGIN USART3_MspInit 1 */
|
||||
|
||||
|
|
|
@ -668,15 +668,15 @@
|
|||
<option>
|
||||
<name>OOCOutputFormat</name>
|
||||
<version>3</version>
|
||||
<state>1</state>
|
||||
<state>3</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCOutputOverride</name>
|
||||
<state>1</state>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OOCOutputFile</name>
|
||||
<state>chargeController.hex</state>
|
||||
<state>chargeController.bin</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OOCCommandLineProducer</name>
|
||||
|
@ -1147,9 +1147,6 @@
|
|||
<file>
|
||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\task.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\test.c</name>
|
||||
</file>
|
||||
</group>
|
||||
<group>
|
||||
<name>functionalModule</name>
|
||||
|
@ -1221,9 +1218,6 @@
|
|||
<file>
|
||||
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_timebase_tim.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_it.c</name>
|
||||
</file>
|
||||
|
|
|
@ -1469,9 +1469,6 @@
|
|||
<file>
|
||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\task.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\APP\businessLogic\Src\test.c</name>
|
||||
</file>
|
||||
</group>
|
||||
<group>
|
||||
<name>functionalModule</name>
|
||||
|
@ -1543,9 +1540,6 @@
|
|||
<file>
|
||||
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_hal_timebase_tim.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\Core\Src\stm32g4xx_it.c</name>
|
||||
</file>
|
||||
|
|
|
@ -67,20 +67,21 @@ Mcu.CPN=STM32G431RBT6
|
|||
Mcu.Family=STM32G4
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=ADC2
|
||||
Mcu.IP10=TIM15
|
||||
Mcu.IP11=TIM16
|
||||
Mcu.IP12=UART4
|
||||
Mcu.IP13=USART2
|
||||
Mcu.IP14=USART3
|
||||
Mcu.IP10=TIM7
|
||||
Mcu.IP11=TIM15
|
||||
Mcu.IP12=TIM16
|
||||
Mcu.IP13=UART4
|
||||
Mcu.IP14=USART2
|
||||
Mcu.IP15=USART3
|
||||
Mcu.IP2=DMA
|
||||
Mcu.IP3=NVIC
|
||||
Mcu.IP4=RCC
|
||||
Mcu.IP5=SPI1
|
||||
Mcu.IP6=SYS
|
||||
Mcu.IP7=TIM3
|
||||
Mcu.IP8=TIM6
|
||||
Mcu.IP9=TIM7
|
||||
Mcu.IPNb=15
|
||||
Mcu.IP5=RTC
|
||||
Mcu.IP6=SPI1
|
||||
Mcu.IP7=SYS
|
||||
Mcu.IP8=TIM3
|
||||
Mcu.IP9=TIM6
|
||||
Mcu.IPNb=16
|
||||
Mcu.Name=STM32G431R(6-8-B)Tx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC13
|
||||
|
@ -108,20 +109,21 @@ Mcu.Pin28=PB6
|
|||
Mcu.Pin29=PB7
|
||||
Mcu.Pin3=PC1
|
||||
Mcu.Pin30=PB8-BOOT0
|
||||
Mcu.Pin31=VP_SYS_VS_tim1
|
||||
Mcu.Pin32=VP_SYS_VS_DBSignals
|
||||
Mcu.Pin33=VP_TIM6_VS_ClockSourceINT
|
||||
Mcu.Pin34=VP_TIM7_VS_ClockSourceINT
|
||||
Mcu.Pin35=VP_TIM15_VS_ClockSourceINT
|
||||
Mcu.Pin36=VP_TIM16_VS_ClockSourceINT
|
||||
Mcu.Pin37=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
|
||||
Mcu.Pin31=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin32=VP_SYS_VS_Systick
|
||||
Mcu.Pin33=VP_SYS_VS_DBSignals
|
||||
Mcu.Pin34=VP_TIM6_VS_ClockSourceINT
|
||||
Mcu.Pin35=VP_TIM7_VS_ClockSourceINT
|
||||
Mcu.Pin36=VP_TIM15_VS_ClockSourceINT
|
||||
Mcu.Pin37=VP_TIM16_VS_ClockSourceINT
|
||||
Mcu.Pin38=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
|
||||
Mcu.Pin4=PC2
|
||||
Mcu.Pin5=PA0
|
||||
Mcu.Pin6=PA1
|
||||
Mcu.Pin7=PA2
|
||||
Mcu.Pin8=PA3
|
||||
Mcu.Pin9=PA4
|
||||
Mcu.PinsNb=38
|
||||
Mcu.PinsNb=39
|
||||
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0
|
||||
Mcu.ThirdPartyNb=1
|
||||
Mcu.UserConstants=
|
||||
|
@ -129,7 +131,7 @@ Mcu.UserName=STM32G431RBTx
|
|||
MxCube.Version=6.13.0
|
||||
MxDb.Version=DB.6.0.130
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.DMA1_Channel1_IRQn=true\:4\:0\:true\:false\:true\:false\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.EXTI15_10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
|
@ -140,21 +142,20 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
|||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||
NVIC.TIM1_BRK_TIM15_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.TIM1_UP_TIM16_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true
|
||||
NVIC.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.TIM7_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.TimeBase=TIM1_UP_TIM16_IRQn
|
||||
NVIC.TimeBaseIP=TIM1
|
||||
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.USART3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.TIM1_BRK_TIM15_IRQn=true\:4\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.TIM1_UP_TIM16_IRQn=true\:4\:0\:true\:false\:true\:false\:true\:true
|
||||
NVIC.TIM7_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART2_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART3_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
PA0.GPIOParameters=GPIO_Label
|
||||
PA0.GPIO_Label=SYS_VOLT_IN
|
||||
PA0.Mode=IN1-Single-Ended
|
||||
PA0.Signal=ADC2_IN1
|
||||
PA1.GPIOParameters=GPIO_Label
|
||||
PA1.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PA1.GPIO_Label=GW485_RDE
|
||||
PA1.GPIO_PuPd=GPIO_NOPULL
|
||||
PA1.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
||||
PA1.Mode=Hardware Flow Control (RS485)
|
||||
PA1.Signal=USART2_DE
|
||||
PA10.GPIOParameters=PinState,GPIO_Label
|
||||
|
@ -169,20 +170,24 @@ PA11.PinState=GPIO_PIN_SET
|
|||
PA11.Signal=GPIO_Output
|
||||
PA12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
||||
PA12.GPIO_Label=WORK_VOLT_INT
|
||||
PA12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
||||
PA12.GPIO_PuPd=GPIO_PULLUP
|
||||
PA12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING
|
||||
PA12.GPIO_PuPd=GPIO_PULLDOWN
|
||||
PA12.Locked=true
|
||||
PA12.Signal=GPXTI12
|
||||
PA13.Mode=Serial_Wire
|
||||
PA13.Signal=SYS_JTMS-SWDIO
|
||||
PA14.Mode=Serial_Wire
|
||||
PA14.Signal=SYS_JTCK-SWCLK
|
||||
PA2.GPIOParameters=GPIO_Label
|
||||
PA2.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PA2.GPIO_Label=GW485_TX
|
||||
PA2.GPIO_PuPd=GPIO_PULLUP
|
||||
PA2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
||||
PA2.Mode=Asynchronous
|
||||
PA2.Signal=USART2_TX
|
||||
PA3.GPIOParameters=GPIO_Label
|
||||
PA3.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PA3.GPIO_Label=GW485_RX
|
||||
PA3.GPIO_PuPd=GPIO_PULLUP
|
||||
PA3.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
||||
PA3.Mode=Asynchronous
|
||||
PA3.Signal=USART2_RX
|
||||
PA4.GPIOParameters=GPIO_Label
|
||||
|
@ -209,12 +214,16 @@ PB1.GPIOParameters=GPIO_Label
|
|||
PB1.GPIO_Label=WDI_INPUT
|
||||
PB1.Locked=true
|
||||
PB1.Signal=GPIO_Output
|
||||
PB10.GPIOParameters=GPIO_Label
|
||||
PB10.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PB10.GPIO_Label=BAT485_TX
|
||||
PB10.GPIO_PuPd=GPIO_PULLUP
|
||||
PB10.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
||||
PB10.Mode=Asynchronous
|
||||
PB10.Signal=USART3_TX
|
||||
PB11.GPIOParameters=GPIO_Label
|
||||
PB11.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PB11.GPIO_Label=BAT485_RX
|
||||
PB11.GPIO_PuPd=GPIO_PULLUP
|
||||
PB11.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
||||
PB11.Mode=Asynchronous
|
||||
PB11.Signal=USART3_RX
|
||||
PB12.GPIOParameters=GPIO_Label
|
||||
|
@ -304,7 +313,7 @@ ProjectManager.ToolChainLocation=
|
|||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_ADC2_Init-ADC2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM6_Init-TIM6-false-HAL-true,9-MX_UART4_Init-UART4-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_TIM7_Init-TIM7-false-HAL-true,13-MX_TIM16_Init-TIM16-false-HAL-true,14-MX_TIM15_Init-TIM15-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_ADC2_Init-ADC2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM6_Init-TIM6-false-HAL-true,9-MX_UART4_Init-UART4-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_TIM7_Init-TIM7-false-HAL-true,13-MX_TIM16_Init-TIM16-false-HAL-true,14-MX_TIM15_Init-TIM15-false-HAL-true,15-MX_RTC_Init-RTC-false-HAL-true
|
||||
RCC.ADC12Freq_Value=72000000
|
||||
RCC.AHBFreq_Value=72000000
|
||||
RCC.APB1Freq_Value=72000000
|
||||
|
@ -391,12 +400,14 @@ USART2.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC
|
|||
USART3.IPParameters=VirtualMode-Asynchronous,VirtualMode-Hardware Flow Control (RS485)
|
||||
USART3.VirtualMode-Asynchronous=VM_ASYNC
|
||||
USART3.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC
|
||||
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
|
||||
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
|
||||
VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0.Mode=DSPOoLibraryJjLibrary
|
||||
VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0.Signal=STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
|
||||
VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
|
||||
VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
|
||||
VP_SYS_VS_tim1.Mode=TIM1
|
||||
VP_SYS_VS_tim1.Signal=SYS_VS_tim1
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
VP_TIM15_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT
|
||||
VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool
|
||||
* Generated by MATLAB(R) 9.13 and Signal Processing Toolbox 9.1.
|
||||
* Generated on: 03-Dec-2024 14:47:22
|
||||
*/
|
||||
|
||||
/*
|
||||
* 离散时间 FIR 滤波器(实数)
|
||||
* ----------------
|
||||
* 滤波器结构 : 直接型 FIR
|
||||
* 滤波器长度 : 6
|
||||
* 稳定 : 是
|
||||
* 线性相位 : 是 (Type 2)
|
||||
*/
|
||||
|
||||
/* General type conversion for MATLAB generated C-code */
|
||||
// #include "tmwtypes.h"
|
||||
/*
|
||||
* Expected path to tmwtypes.h
|
||||
* C:\Program Files\MATLAB\R2022b\extern\include\tmwtypes.h
|
||||
*/
|
||||
/*
|
||||
* Warning - Filter coefficients were truncated to fit specified data type.
|
||||
* The resulting response may not match generated theoretical response.
|
||||
* Use the Filter Design & Analysis Tool to design accurate
|
||||
* single-precision filter coefficients.
|
||||
*/
|
||||
// const int BL = 6;
|
||||
// const real32_T B[6] = {
|
||||
// 0.01861755922, -0.1146286726, 0.5962908864, 0.5962908864, -0.1146286726,
|
||||
// 0.01861755922
|
||||
// };
|
Loading…
Reference in New Issue