完善控制和保护
This commit is contained in:
parent
eca3fd058a
commit
0fcdfa75d3
|
@ -31,6 +31,7 @@
|
|||
"chargcontrolenum.h": "c",
|
||||
"chargcontroltypes.h": "c",
|
||||
"fm_rtc.h": "c",
|
||||
"interruptsend.h": "c"
|
||||
"interruptsend.h": "c",
|
||||
"rtc.h": "c"
|
||||
}
|
||||
}
|
|
@ -59,6 +59,8 @@ void start(void)
|
|||
|
||||
startInfo();
|
||||
|
||||
HAL_Delay(5000);
|
||||
|
||||
TimeSliceOffset_Start();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#define buffLen 100
|
||||
extern uint8_t rs485_buff[buffLen];
|
||||
|
||||
|
||||
void gw485_RxIt(void);
|
||||
void bat485_RxIt(void);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "flash.h"
|
||||
#include "stm32g431xx.h"
|
||||
#include "chargControlTypes.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
@ -94,6 +95,7 @@ typedef struct _config_info{
|
|||
#define LoopImpedance_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 10)
|
||||
#define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20)
|
||||
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
|
||||
#define time_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 40)
|
||||
|
||||
// void save_config_info(config_info *save_config_info);
|
||||
void read_config_info(config_info *output_config_info);
|
||||
|
@ -106,5 +108,7 @@ void savetotalElectricityConsumption(float *totalElectricityConsumption);
|
|||
void readtotalElectricityConsumption(float *totalElectricityConsumption);
|
||||
void savetotalChargCapacity(float *totalChargCapacity);
|
||||
void readtotalChargCapacity(float *totalChargCapacity);
|
||||
void saveTime(timeInfo *time);
|
||||
void readTime(timeInfo *time);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "main.h"
|
||||
#include "comm_types.h"
|
||||
#include "chargControlTypes.h"
|
||||
|
||||
#define softVer "SV01_24101501"
|
||||
|
||||
|
@ -27,8 +28,11 @@ typedef struct _config_parameter{
|
|||
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
// uint16_t softShortTime; /* 软件短路保护延时 时间(100uS) */
|
||||
|
||||
uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔 */
|
||||
|
||||
|
||||
/* SL */
|
||||
uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
uint16_t Communication_Methods; /* 通信方式 */
|
||||
|
@ -83,6 +87,8 @@ uint8_t getMosTemperState(void);
|
|||
void setMosTemperState(uint8_t state);
|
||||
BOOL getCheckImpedanceState(void);
|
||||
void setCheckImpedanceState(void);
|
||||
void setLastTime(timeInfo time);
|
||||
timeInfo getLastTime(void);
|
||||
|
||||
float getBatteryVoltage(void);
|
||||
void setBatteryVoltage(void);
|
||||
|
|
|
@ -16,8 +16,9 @@ void uartTaskInit(void);
|
|||
void startShortCircuitProtection(void);
|
||||
void stopShortCircuitProtection(void);
|
||||
void startExcessiveLoadProtection(void);
|
||||
void startSoftShortCircuitProtection(void);
|
||||
|
||||
|
||||
void chargRunLed(uint8_t mode);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "abnormalManage.h"
|
||||
#include "pDebug.h"
|
||||
#include "interruptSend.h"
|
||||
#include "FM_RTC.h"
|
||||
|
||||
/**
|
||||
* @brief 初始化外设,同时通过配置文件初始化系统参数
|
||||
|
@ -18,7 +19,7 @@
|
|||
*/
|
||||
void Init(void)
|
||||
{
|
||||
HAL_Delay(10000);
|
||||
// HAL_Delay(10000);
|
||||
|
||||
config_info_start();
|
||||
ADC_Capture_Init();
|
||||
|
@ -27,6 +28,8 @@ void Init(void)
|
|||
FM_GPIO_Init();
|
||||
tim_Init();
|
||||
|
||||
FM_RTC_Init();
|
||||
|
||||
Init_debug_uart();
|
||||
Init_BAT485_uart(g_cfgParameter.bat485_Baud);
|
||||
Init_GW485_uart(g_cfgParameter.gw485_Baud);
|
||||
|
|
|
@ -22,17 +22,65 @@ static BOOL excessiveLoadFlag = FALSE;
|
|||
|
||||
/**
|
||||
* @brief 设定放电过载状态
|
||||
* @param state TRUE 过载
|
||||
* FALSE 未过载
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setDisChargOverLoad(void)
|
||||
{
|
||||
/* 三段式保护中的两段 */
|
||||
static int num1 = 0;
|
||||
if (getDischargCurrent() > 30.0f) {
|
||||
disChargOverLoad = TRUE;
|
||||
// disChargOverLoad = TRUE;
|
||||
num1++;
|
||||
} else {
|
||||
disChargOverLoad = FALSE;
|
||||
// disChargOverLoad = FALSE;
|
||||
num1 = 0;
|
||||
}
|
||||
|
||||
/* 过载时间过长关闭输出(120S) */
|
||||
if (num1 >= 1200000) {
|
||||
num1 = 0;
|
||||
disChargOverLoad = TRUE;
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
|
||||
static int num2 = 0;
|
||||
if (getDischargCurrent() > 35.0f) {
|
||||
num2++;
|
||||
} else {
|
||||
num2 = 0;
|
||||
}
|
||||
|
||||
/* 过载时间过长关闭输出(5S) */
|
||||
if (num1 >= 50000) {
|
||||
num1 = 0;
|
||||
disChargOverLoad = TRUE;
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 软件短路保护
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setSoftShortCircuit(void)
|
||||
{
|
||||
static int num = 0;
|
||||
if (getDischargCurrent() > 50.0f) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
}
|
||||
|
||||
/* 200uS内都短路则关闭输出 */
|
||||
if (num >= 2) {
|
||||
shortCircuitFlag = TRUE;
|
||||
shortCircuit++;
|
||||
setPowerOutput(FALSE);
|
||||
startSoftShortCircuitProtection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +140,6 @@ void setShortCircuitFlag(BOOL state)
|
|||
if (state == TRUE || state == FALSE) {
|
||||
shortCircuitFlag = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,7 +198,6 @@ void setExcessiveLoadFlag(BOOL state)
|
|||
if (state == TRUE || state == FALSE) {
|
||||
excessiveLoadFlag = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,7 +247,27 @@ void checkFFMOS_CON(void)
|
|||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @brief 判断是否短路
|
||||
// * @param
|
||||
// * @retval
|
||||
// *
|
||||
// */
|
||||
// void checkShortCircuit(void)
|
||||
// {
|
||||
// static num = 0;
|
||||
// if (getChargCurrent() > 50.0f) {
|
||||
// num++;
|
||||
// } else {
|
||||
// num = 0;
|
||||
// }
|
||||
|
||||
// if (num == g_cfgParameter.softShortTime) {
|
||||
// setPowerOutput(FALSE);
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
void checkAbnormal(void)
|
||||
|
@ -219,6 +285,9 @@ void checkAbnormal(void)
|
|||
/* 判断 */
|
||||
checkFFMOS_CON();
|
||||
setDisChargOverLoad();
|
||||
setSoftShortCircuit();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -233,6 +302,7 @@ void checkAbnormal(void)
|
|||
*/
|
||||
void WORK_VOLT_Interrupt(void)
|
||||
{
|
||||
setPowerOutput(FALSE);
|
||||
setExcessiveLoad();
|
||||
/* 第一次进入输出过载,启动过载保护任务 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
|
@ -243,7 +313,6 @@ void WORK_VOLT_Interrupt(void)
|
|||
/* 多次进入输出过载,关闭输出 */
|
||||
if (getExcessiveLoad() > 2) {
|
||||
zeroExcessiveLoad();
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,13 +40,18 @@ void mppt_constantVoltage(float InVoltage)
|
|||
static float error;
|
||||
static float stepPwm;
|
||||
|
||||
|
||||
// solarInCircuitVoltage = getSolarInCircuitVoltage();
|
||||
// error = InVoltage - getSolarInCircuitVoltage();
|
||||
error = getSolarInCircuitVoltage() - InVoltage;
|
||||
stepPwm = kp * error + ki * getSolarInCircuitVoltage();
|
||||
|
||||
|
||||
setDutyRatio((getDutyRatio() + stepPwm));
|
||||
// if (getMosTemperState() == mosTemperEnd) {
|
||||
// setDutyRatio((getDutyRatio() + stepPwm - 0.1));
|
||||
// } else {
|
||||
// setDutyRatio((getDutyRatio() + stepPwm));
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,6 +100,11 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
if (lastDutyRatio >= getDutyRatio()) {
|
||||
// if (lastVolt >= outVolt) {
|
||||
setDutyRatio((getDutyRatio() + StepPwm));
|
||||
// if (getMosTemperState() == mosTemperEnd) {
|
||||
// setDutyRatio((getDutyRatio() + StepPwm - 0.1));
|
||||
// } else {
|
||||
// setDutyRatio((getDutyRatio() + StepPwm));
|
||||
// }
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio -= StepPwm;
|
||||
// }
|
||||
|
@ -105,6 +115,11 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
// g_controlParameter.dutyRatio += StepPwm;
|
||||
// }
|
||||
setDutyRatio((getDutyRatio() - StepPwm));
|
||||
// if (getMosTemperState() == mosTemperEnd) {
|
||||
// setDutyRatio((getDutyRatio() + StepPwm - 0.1));
|
||||
// } else {
|
||||
// setDutyRatio((getDutyRatio() + StepPwm));
|
||||
// }
|
||||
}
|
||||
|
||||
// lastVolt = outVolt;
|
||||
|
@ -344,6 +359,12 @@ void mppt_readJust(void)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if (getMosTemperState() == mosTemperEnd) {
|
||||
SolarInCircuitV = 16;
|
||||
}
|
||||
|
||||
|
||||
flag = 0;
|
||||
Power = totalPower / 50.0f;
|
||||
|
||||
|
@ -457,7 +478,6 @@ void startChargWork(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 判断达到停止充电的条件
|
||||
* @param
|
||||
|
@ -468,7 +488,7 @@ void startChargWork(void)
|
|||
BOOL stopChargConditions(void)
|
||||
{
|
||||
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV
|
||||
&& getChargCurrent() < 0.1f) {
|
||||
&& getChargCurrent() < 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -517,7 +537,7 @@ BOOL mpptChargConditions(void)
|
|||
*/
|
||||
BOOL constantVChargConditions(void)
|
||||
{
|
||||
if ((g_cfgParameter.constantVoltageChargeV < getBatteryVoltage())
|
||||
if ((g_cfgParameter.constantVoltageV < getBatteryVoltage())
|
||||
&& ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -659,6 +679,13 @@ void setChargControlFlag(BOOL state)
|
|||
if (state == TRUE || state == FALSE) {
|
||||
chargControlFlag = state;
|
||||
}
|
||||
|
||||
if (state == TRUE) {
|
||||
chargRunLed(runLedChargMode);
|
||||
} else if (state == FALSE) {
|
||||
chargRunLed(runLedOtherMode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
uint8_t rs485_buff[buffLen]={0x00};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief gw485串口接收中断回调函数
|
||||
* @param
|
||||
|
|
|
@ -408,6 +408,8 @@ void read_and_process_config_data(void)
|
|||
// }
|
||||
uart_dev_write(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n"));
|
||||
|
||||
HAL_Delay(1000);
|
||||
|
||||
/* 复位 */
|
||||
NVIC_SystemReset();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "bl_comm.h"
|
||||
#include "chargControlTypes.h"
|
||||
#include "FM_RTC.h"
|
||||
#include "interruptSend.h"
|
||||
|
||||
|
||||
// #include "RingQueue.h"
|
||||
|
@ -160,7 +161,7 @@ typedef struct _HY_electricityStatisticsResponse{
|
|||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
uint8_t controlWord; /* 控制字 */
|
||||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
float_t statisticalDuration; /* 统计时长 */
|
||||
uint32_t statisticalDuration; /* 统计时长 */
|
||||
float_t totalElectricityConsumption; /* 总电量消耗 */
|
||||
float_t totalChargCapacity; /* 总充电电量 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
|
@ -613,8 +614,8 @@ typedef struct _HY_configTime {
|
|||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
uint8_t controlWord; /* 控制字 */
|
||||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
timeInfo time; /* 年月日时分秒 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
uint8_t check_Bit; /* 校验码 */
|
||||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_configTime;
|
||||
|
@ -1048,7 +1049,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
|
||||
if (offset == len) {
|
||||
if (buff[len - 2] != HY_CheckFunc(buff, len - 2)
|
||||
&& buff[len - 1] != g_cfgParameter.endFlagHY) {
|
||||
|| buff[len - 1] != g_cfgParameter.endFlagHY) {
|
||||
if (flag_run < 5) {
|
||||
flag_run = 5;
|
||||
}
|
||||
|
@ -1153,8 +1154,8 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
|
|||
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
// uart_interruptSend(device, (uint8_t *)&pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 电量统计数据报 */
|
||||
|
@ -1180,7 +1181,13 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
pack.dataLen[0] = HY_electricityStatisticsResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_electricityStatisticsResponse_dataLen;
|
||||
|
||||
pack.statisticalDuration = 0;
|
||||
timeInfo time1, time2 = {0};
|
||||
getRTC_Time(&time1);
|
||||
time2 = getLastTime();
|
||||
pack.statisticalDuration = differTime(&time1, &time2);
|
||||
setLastTime(time1);
|
||||
|
||||
// pack.statisticalDuration = 0;
|
||||
pack.totalChargCapacity = getTotalChargCapacity();
|
||||
pack.totalElectricityConsumption = getTotalElectricityConsumption();
|
||||
|
||||
|
@ -1194,6 +1201,7 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
// // temp = getTotalElectricityConsumption();
|
||||
// savetotalElectricityConsumption(&temp);
|
||||
|
||||
|
||||
HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg;
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
|
@ -1201,8 +1209,8 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
|
||||
// uart_interruptSend(device, (uint8_t *)&pack, HY_electricityStatisticsResponse_PACK_SIZE);
|
||||
uart_dev_write(device, &pack, HY_electricityStatisticsResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_electricityStatisticsResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, &pack, HY_electricityStatisticsResponse_PACK_SIZE);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1258,7 +1266,8 @@ void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg,
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfigurationResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_sensorNumberConfigurationResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_sensorNumberConfigurationResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_sensorNumberConfigurationResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 传感器号码查询 */
|
||||
|
@ -1304,7 +1313,8 @@ void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberInquiryResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_sensorNumberInquiryResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_sensorNumberInquiryResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_sensorNumberInquiryResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 充电阈值电压配置 */
|
||||
|
@ -1352,7 +1362,8 @@ void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_resetInstructionResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_resetInstructionResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_resetInstructionResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_resetInstructionResponse_PACK_SIZE);
|
||||
|
||||
/* 复位 */
|
||||
NVIC_SystemReset();
|
||||
|
@ -1404,7 +1415,8 @@ void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMs
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_chargingControlConfigResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_chargingControlConfigResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_chargingControlConfigResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_chargingControlConfigResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 充电控制查询 */
|
||||
|
@ -1447,7 +1459,8 @@ static void HY_MsgProcFunc_chargingControlQuery(device_handle device, void *pMsg
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryChargingControlResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_QueryChargingControlResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_QueryChargingControlResponse_PACK_SIZE);
|
||||
uart_dev_write(device, (uint8_t *)&pack, HY_QueryChargingControlResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1499,7 +1512,9 @@ void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configProtocolTypeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_configProtocolTypeResponse_PACK_SIZE);
|
||||
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_configProtocolTypeResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_configProtocolTypeResponse_PACK_SIZE);
|
||||
|
||||
Init_GW485_uart(g_cfgParameter.gw485_Baud);
|
||||
}
|
||||
|
@ -1542,7 +1557,8 @@ void HY_MsgProcFunc_queryControlBoxConfiguration(device_handle device, void *pMs
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryControlBoxConfigurationResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 查询电池控制盒软件版本 */
|
||||
|
@ -1579,7 +1595,8 @@ void HY_MsgProcFunc_querySoftwareVersion(device_handle device, void *pMsg, uint3
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_SoftwareVersionQueryResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_SoftwareVersionQueryResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_SoftwareVersionQueryResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_SoftwareVersionQueryResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 进入配置模式 */
|
||||
|
@ -1615,7 +1632,8 @@ void HY_MsgProcFunc_enterConfigurationMode(device_handle device, void *pMsg, uin
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_enterConfigModeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_enterConfigModeResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_enterConfigModeResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_enterConfigModeResponse_PACK_SIZE);
|
||||
|
||||
beginHYconfigMode();
|
||||
}
|
||||
|
@ -1677,7 +1695,8 @@ void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configHardwareIDResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_configHardwareIDResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_configHardwareIDResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_configHardwareIDResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */
|
||||
|
@ -1723,7 +1742,8 @@ void HY_MsgProcFunc_hardwareID_communicationIDQuery(device_handle device, void *
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryhardwareID_communicationIDResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 修改通信ID号(原传感器号) */
|
||||
|
@ -1778,7 +1798,8 @@ void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_modifyCommunicationIDChangeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 查询主板温度值 */
|
||||
|
@ -1814,7 +1835,8 @@ void HY_MsgProcFunc_checkMotherboardTemperature(device_handle device, void *pMsg
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_checkMotherboardTemperatureResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
/* 配置时间 */
|
||||
|
@ -1822,7 +1844,10 @@ void HY_MsgProcFunc_configTime(device_handle device, void *pMsg, uint32_t MsgLen
|
|||
{
|
||||
HY_configTime *Tpack = (HY_configTime *)pMsg;
|
||||
|
||||
setRTC_Time(&Tpack->time);
|
||||
// static timeInfo time;
|
||||
// time = Tpack->time;
|
||||
// setRTC_Time(&time);
|
||||
setRTC_Time((timeInfo *)&Tpack->time);
|
||||
|
||||
HY_configTimeResponse pack;
|
||||
|
||||
|
@ -1852,7 +1877,8 @@ void HY_MsgProcFunc_configTime(device_handle device, void *pMsg, uint32_t MsgLen
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configTimeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_configTimeResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_configTimeResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_configTimeResponse_PACK_SIZE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1884,7 +1910,7 @@ static void HY_MsgProcFunc_queryTime(device_handle device, void *pMsg, uint32_t
|
|||
pack.dataLen[0] = HY_queryTimeResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_queryTimeResponse_dataLen;
|
||||
|
||||
timeInfo time;
|
||||
static timeInfo time;
|
||||
getRTC_Time(&time);
|
||||
|
||||
pack.time = time;
|
||||
|
@ -1894,5 +1920,6 @@ static void HY_MsgProcFunc_queryTime(device_handle device, void *pMsg, uint32_t
|
|||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryTimeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_cfgParameter.endFlagHY;
|
||||
|
||||
uart_dev_write(device, &pack, HY_queryTimeResponse_PACK_SIZE);
|
||||
uart_interruptSend(device, (uint8_t *)&pack, HY_queryTimeResponse_PACK_SIZE);
|
||||
// uart_dev_write(device, (uint8_t *)&pack, HY_queryTimeResponse_PACK_SIZE);
|
||||
}
|
|
@ -212,6 +212,10 @@ void config_info_start(void)
|
|||
readtotalChargCapacity(&fTemp);
|
||||
totalChargCapacityInt(fTemp);
|
||||
|
||||
timeInfo time;
|
||||
readTime(&time);
|
||||
setLastTime(time);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -269,3 +273,20 @@ void readtotalChargCapacity(float *totalChargCapacity)
|
|||
read_Flash((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取flash中的时间,这个时间是上次读取充放电量的时间
|
||||
* @param
|
||||
*/
|
||||
void saveTime(timeInfo *time)
|
||||
{
|
||||
write_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取flash中的时间
|
||||
* @param
|
||||
*/
|
||||
void readTime(timeInfo *time)
|
||||
{
|
||||
read_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
|
||||
}
|
|
@ -291,12 +291,13 @@ void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len)
|
|||
uart_send.insertData->device = device;
|
||||
// uart_send.insertData->dataState = 1;
|
||||
// uart_send.insertState--;
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
uart_send.insertData->dataState = TRUE;
|
||||
uart_send.insertState--;
|
||||
break;
|
||||
}
|
||||
/* 0执行一次, 1一直循环直到能插入 */
|
||||
} while (0);
|
||||
|
||||
/* 可插入数据大于0时,将插入指针指向空的储存位置,否则指向NULL */
|
||||
if (uart_send.insertState > 0) {
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
#include "FM_TIM.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "capture.h"
|
||||
#include "chargControlTypes.h"
|
||||
|
||||
config_parameter g_cfgParameter = {0};
|
||||
static otherParameter g_otherParameter = {0};
|
||||
|
||||
static BOOL batteryState = FALSE; /* 有无电池(估计) */
|
||||
static float dutyRatio; /* 占空比 */
|
||||
static uint8_t mosTemperState = mosTemperStop; /* mos管温度状态 */
|
||||
static uint8_t mosTemperState = mosTemperStart; /* mos管温度状态 */
|
||||
static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */
|
||||
static timeInfo lastTime = {0}; /* 上次读取充放电量参数的时间 */
|
||||
|
||||
/**
|
||||
* @brief 获取电池状态
|
||||
|
@ -55,8 +55,8 @@ float getDutyRatio(void)
|
|||
*/
|
||||
void setDutyRatio(float DutyRatio)
|
||||
{
|
||||
if (DutyRatio > 0.9f) {
|
||||
dutyRatio = 0.9f;
|
||||
if (DutyRatio > 0.95f) {
|
||||
dutyRatio = 0.95f;
|
||||
}
|
||||
else if (DutyRatio < 0.05f) {
|
||||
dutyRatio = 0.05f;
|
||||
|
@ -64,6 +64,7 @@ void setDutyRatio(float DutyRatio)
|
|||
else {
|
||||
dutyRatio = DutyRatio;
|
||||
}
|
||||
|
||||
set_pwmDutyRatio(dutyRatio);
|
||||
}
|
||||
|
||||
|
@ -123,6 +124,29 @@ void setCheckImpedanceState(void)
|
|||
checkImpedanceState = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设置上次读取充放电量参数的时间
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setLastTime(timeInfo time)
|
||||
{
|
||||
lastTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置上次读取充放电量参数的时间
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
timeInfo getLastTime(void)
|
||||
{
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到电池电压
|
||||
* @param
|
||||
|
@ -417,10 +441,10 @@ void setChargMosState(BOOL state)
|
|||
{
|
||||
if (state == FALSE) {
|
||||
/* 关闭充电 */
|
||||
|
||||
stopChargWork();
|
||||
} else if (state == TRUE) {
|
||||
/* 打开充电 */
|
||||
|
||||
beginChargWork();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@
|
|||
#include "abnormalManage.h"
|
||||
#include "interruptSend.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* 控制运行指示灯和喂狗 */
|
||||
// #define runled_reloadVal 1000 /* 任务执行间隔 */
|
||||
static uint16_t runled_reloadVal = 1000; /* 任务执行间隔 */
|
||||
#define runled_reloadVal 2000 /* 任务执行间隔 */
|
||||
// static uint16_t runled_reloadVal = 1000; /* 任务执行间隔 */
|
||||
#define runled_offset 0 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_runled;
|
||||
static void Task_Runled(void);
|
||||
|
@ -105,6 +106,18 @@ void Task_busFree(void);
|
|||
// STR_TimeSliceOffset m_interruptSend;
|
||||
// void Task_interruptSend(void);
|
||||
|
||||
// /* 软件过载保护 */
|
||||
// #define softExcessiveLoad_reloadVal 1000 /* 任务执行间隔 */
|
||||
// #define softExcessiveLoad_offset 0 /* 任务执行偏移量 */
|
||||
// STR_TimeSliceOffset m_softExcessiveLoad;
|
||||
// void Task_softExcessiveLoad(void);
|
||||
|
||||
/* 软件短路保护 */
|
||||
#define softShortCircuit_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define softShortCircuit_offset 0 /* 任务执行偏移量 */
|
||||
STR_TimeSliceOffset m_softShortCircuit;
|
||||
void Task_softShortCircuit(void);
|
||||
|
||||
/**
|
||||
* @brief 启动时初始化各任务
|
||||
* @param None
|
||||
|
@ -138,6 +151,23 @@ void Task_Runled(void)
|
|||
RUN_LED();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 修改运行指示灯状态
|
||||
* @param mode 充电时1Hz的频率闪烁
|
||||
* 其余时间2Hz的频率闪烁
|
||||
* @retval None
|
||||
*
|
||||
*/
|
||||
void chargRunLed(uint8_t mode)
|
||||
{
|
||||
if (mode == runLedChargMode) {
|
||||
m_runled.reloadVal = 500;
|
||||
}
|
||||
else if (mode == runLedOtherMode) {
|
||||
m_runled.reloadVal = 2000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 喂狗任务
|
||||
* @param None
|
||||
|
@ -159,7 +189,52 @@ void Task_wdi(void)
|
|||
debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance);
|
||||
debug_printf("DutyRatio:%f \n", getDutyRatio());
|
||||
|
||||
uart_interruptSend(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n"));
|
||||
// char buf[100];
|
||||
// sprintf(buf, "chargCurrent:%f \n", getChargCurrent());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "outputVoltage:%f \n", getOutputVoltage());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "BatteryVoltage:%f \n", getBatteryVoltage());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "dischargCurrent:%f \n", getDischargCurrent());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "InputVoltage:%f \n", getInputVoltage());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "DischargMosState:%d \n", getDischargMosState());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "MPPT_Mode:%d \n", getMPPT_Mode());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "loopImpedance:%f \n", g_cfgParameter.loopImpedance);
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
// memset(buf, 0, sizeof(buf));
|
||||
// sprintf(buf, "DutyRatio:%f \n", getDutyRatio());
|
||||
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
|
||||
|
||||
|
||||
// uart_interruptSend(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n"));
|
||||
|
||||
/* 每天复位一次,复位前将电量信息写入flash中 */
|
||||
static uint32_t temp = 60 * 60 * 24;
|
||||
|
@ -170,6 +245,9 @@ void Task_wdi(void)
|
|||
savetotalElectricityConsumption(&tempF);
|
||||
tempF = getTotalChargCapacity();
|
||||
savetotalChargCapacity(&tempF);
|
||||
timeInfo time;
|
||||
time = getLastTime();
|
||||
saveTime(&time);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
@ -193,10 +271,11 @@ void Task_refreshJudgeData(void)
|
|||
setBatteryState(TRUE);
|
||||
}
|
||||
|
||||
/* 有电池,太阳能输出功率大,同时回路阻抗未测试或需要重新测试 */
|
||||
/* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */
|
||||
if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f)
|
||||
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)) {
|
||||
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
|
||||
&& (getBatteryVoltage() < 14)) {
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
|
||||
}
|
||||
|
@ -649,3 +728,39 @@ void Task_busFree(void)
|
|||
// TimeSliceOffset_Register(&m_interruptSend, Task_interruptSend
|
||||
// , interruptSend_reloadVal, interruptSend_offset);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief 软件短路保护任务,一段时间中连续出现短路,则关闭输出
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void Task_softShortCircuit(void)
|
||||
{
|
||||
static uint8_t num = 0;
|
||||
|
||||
if (2 == num++) {
|
||||
setPowerOutput(TRUE);
|
||||
}
|
||||
|
||||
if (num >= g_cfgParameter.outputAgainFlagTime) {
|
||||
num = 0;
|
||||
if (getShortCircuit() == 1) {
|
||||
setShortCircuitFlag(FALSE);
|
||||
}
|
||||
zeroShortCircuit();
|
||||
TimeSliceOffset_Unregister(&m_softShortCircuit);
|
||||
m_softShortCircuit.runFlag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 启动软件短路保护任务
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void startSoftShortCircuitProtection(void)
|
||||
{
|
||||
TimeSliceOffset_Register(&m_softShortCircuit, Task_softShortCircuit
|
||||
, softShortCircuit_reloadVal, softShortCircuit_offset);
|
||||
}
|
|
@ -165,12 +165,24 @@ BOOL readOverCurrState(void)
|
|||
*/
|
||||
BOOL readOnlyPowerOutputState(void)
|
||||
{
|
||||
if (HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin)
|
||||
&& HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
|
||||
&& HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
|
||||
static volatile GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
||||
|
||||
gpioTemp1 = HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
|
||||
gpioTemp2 = HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin);
|
||||
gpioTemp3 = HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin);
|
||||
|
||||
if (gpioTemp1 == GPIO_PIN_SET
|
||||
&& gpioTemp2 == GPIO_PIN_SET
|
||||
&& gpioTemp3 == GPIO_PIN_SET) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// if (HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin)
|
||||
// && HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
|
||||
// && HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -200,9 +212,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
WORK_VOLT_Interrupt();
|
||||
}
|
||||
|
||||
else if (GPIO_Pin == DSG_PROT_Pin) {
|
||||
DSG_PROT_Interrupt();
|
||||
}
|
||||
// else if (GPIO_Pin == DSG_PROT_Pin) {
|
||||
// DSG_PROT_Interrupt();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ void FM_RTC_Init(void)
|
|||
void setRTC_Time(timeInfo *time)
|
||||
{
|
||||
/* 日期结构体 */
|
||||
RTC_DateTypeDef setData;
|
||||
static RTC_DateTypeDef setData;
|
||||
/* 时间结构体 */
|
||||
RTC_TimeTypeDef setTime;
|
||||
static RTC_TimeTypeDef setTime;
|
||||
|
||||
setData.Year = time->year;
|
||||
setData.Month = time->month;
|
||||
|
@ -46,9 +46,9 @@ void setRTC_Time(timeInfo *time)
|
|||
void getRTC_Time(timeInfo *time)
|
||||
{
|
||||
/* 日期结构体 */
|
||||
RTC_DateTypeDef getData;
|
||||
static RTC_DateTypeDef getData;
|
||||
/* 时间结构体 */
|
||||
RTC_TimeTypeDef getTime;
|
||||
static RTC_TimeTypeDef getTime;
|
||||
|
||||
HAL_RTC_GetDate(&hrtc, &getData, RTC_FORMAT_BIN);
|
||||
HAL_RTC_GetTime(&hrtc, &getTime, RTC_FORMAT_BIN);
|
||||
|
|
|
@ -187,7 +187,7 @@ void proportionalInt(int mode)
|
|||
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
||||
P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002)))) * Proportion;
|
||||
/* 充电控制盒输出电压比例,分压系数 */
|
||||
P_PV_VOLT_OUT = ((47.0 + 4.7) / 4.7) * Proportion;
|
||||
P_PV_VOLT_OUT = ((56.0 + 10.0) / 10.0) * Proportion;
|
||||
/* 放电电流采集电流倍数 */
|
||||
P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2)))) * Proportion;
|
||||
/* 光伏板输出电压比例 */
|
||||
|
@ -203,7 +203,7 @@ void proportionalInt(int mode)
|
|||
/* 光伏充电输出电流比例,放大倍数*电阻 */
|
||||
P_CHG_CURR = (1.0 / (50 * 0.005)) * Proportion;
|
||||
/* 光伏充电输出电压比例,分压系数 */
|
||||
P_PV_VOLT_OUT = ((47.0 + 4.7) / 4.7) * Proportion;
|
||||
P_PV_VOLT_OUT = ((56.0 + 10.0) / 10.0) * Proportion;
|
||||
/* 放电电流采集电流倍数 */
|
||||
P_DSG_CURR = (1.0 / (50 * 0.005)) * Proportion;
|
||||
/* 光伏1开路输出电压比例 */
|
||||
|
|
|
@ -48,8 +48,8 @@ void HD_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*/
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
|
||||
#include "HD_RTC.h"
|
||||
|
||||
#include "stm32g431xx.h"
|
||||
|
||||
|
||||
void HD_RTC_Init(void)
|
||||
{
|
||||
MX_RTC_Init();
|
||||
hrtc.Instance = RTC;
|
||||
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
|
||||
hrtc.Init.AsynchPrediv = 127;
|
||||
hrtc.Init.SynchPrediv = 255;
|
||||
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
|
||||
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
|
||||
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
|
||||
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
|
||||
hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
|
||||
if (HAL_RTC_Init(&hrtc) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||
__HAL_RCC_TIM7_CLK_ENABLE();
|
||||
|
||||
/* TIM7 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0);
|
||||
HAL_NVIC_SetPriority(TIM7_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM7_IRQn);
|
||||
/* USER CODE BEGIN TIM7_MspInit 1 */
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>MacFile</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>MemOverride</name>
|
||||
|
@ -60,7 +60,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CExtraOptions</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CFpuProcessor</name>
|
||||
|
@ -68,7 +68,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCDDFArgumentProducer</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCDownloadSuppressDownload</name>
|
||||
|
@ -104,7 +104,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>MacFile2</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CDevice</name>
|
||||
|
@ -120,7 +120,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCImagesPath1</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCImagesSuppressCheck2</name>
|
||||
|
@ -128,7 +128,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCImagesPath2</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCImagesSuppressCheck3</name>
|
||||
|
@ -136,7 +136,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCImagesPath3</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OverrideDefFlashBoard</name>
|
||||
|
@ -148,11 +148,11 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCImagesOffset2</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCImagesOffset3</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCImagesUse1</name>
|
||||
|
@ -184,15 +184,15 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCMulticoreWorkspace</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCMulticoreSlaveProject</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCMulticoreSlaveConfiguration</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCDownloadExtraImage</name>
|
||||
|
@ -216,7 +216,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCMulticoreSessionFile</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCTpiuBaseOption</name>
|
||||
|
@ -228,7 +228,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCOverrideSlavePath</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>C_32_64Device</name>
|
||||
|
@ -244,11 +244,11 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>AuthSdmManifest</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>AuthSdmExplicitLib</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>AuthEnforce</name>
|
||||
|
@ -277,7 +277,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCSimPspConfigFile</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
|
@ -294,7 +294,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>Fast Model</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCADILogFileCheck</name>
|
||||
|
@ -328,7 +328,7 @@
|
|||
<option>
|
||||
<name>CMSISDAPResetList</name>
|
||||
<version>1</version>
|
||||
<state>10</state>
|
||||
<state>9</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CMSISDAPHWResetDuration</name>
|
||||
|
@ -348,7 +348,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CMSISDAPInterfaceRadio</name>
|
||||
<state>0</state>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CMSISDAPInterfaceCmdLine</name>
|
||||
|
@ -461,7 +461,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCProbeConfig</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CMSISDAPProbeConfigRadio</name>
|
||||
|
@ -469,11 +469,11 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CMSISDAPSelectedCPUBehaviour</name>
|
||||
<state>0</state>
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>ICpuName</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCJetEmuParams</name>
|
||||
|
@ -481,7 +481,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCCMSISDAPUsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCCMSISDAPUsbSerialNoSelect</name>
|
||||
|
@ -502,7 +502,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CE2UsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CE2IdCodeEditB</name>
|
||||
|
@ -642,7 +642,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>IjetCpuClockEdit</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>IjetSwoPrescalerList</name>
|
||||
|
@ -735,7 +735,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>OCProbeConfig</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>IjetProbeConfigRadio</name>
|
||||
|
@ -755,7 +755,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>ICpuName</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCJetEmuParams</name>
|
||||
|
@ -781,7 +781,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCIjetUsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCIjetUsbSerialNoSelect</name>
|
||||
|
@ -1004,7 +1004,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCJLinkUsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCTcpIpAlt</name>
|
||||
|
@ -1013,11 +1013,11 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCJLinkTcpIpSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCCpuClockEdit</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCSwoClockAuto</name>
|
||||
|
@ -1074,7 +1074,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCLmiftdiUsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCLmiftdiUsbSerialNoSelect</name>
|
||||
|
@ -1163,7 +1163,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCSwoClockAuto</name>
|
||||
<state>0</state>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCSwoClockEdit</name>
|
||||
|
@ -1227,7 +1227,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCSTLinkUsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCSTLinkUsbSerialNoSelect</name>
|
||||
|
@ -1240,7 +1240,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCSTLinkDAPNumber</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCSTLinkDebugAccessPortRadio</name>
|
||||
|
@ -1253,7 +1253,7 @@
|
|||
<option>
|
||||
<name>CCSTLinkProbeList</name>
|
||||
<version>2</version>
|
||||
<state>0</state>
|
||||
<state>2</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCSTLinkTargetVccEnable</name>
|
||||
|
@ -1378,11 +1378,11 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>TIPackage</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>BoardFile</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>DoLogfile</name>
|
||||
|
@ -1474,7 +1474,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCXds100CpuClockEdit</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCXds100SwoClockAuto</name>
|
||||
|
@ -1495,7 +1495,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>CCXds100UsbSerialNo</name>
|
||||
<state />
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCXds100UsbSerialNoSelect</name>
|
||||
|
|
|
@ -189,7 +189,7 @@
|
|||
<option>
|
||||
<name>TrustZoneModes</name>
|
||||
<version>0</version>
|
||||
<state>1</state>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OGAarch64Abi</name>
|
||||
|
@ -694,7 +694,7 @@
|
|||
<data>
|
||||
<extensions></extensions>
|
||||
<cmdline></cmdline>
|
||||
<hasPrio>0</hasPrio>
|
||||
<hasPrio>160</hasPrio>
|
||||
<buildSequence>inputOutputBased</buildSequence>
|
||||
</data>
|
||||
</settings>
|
||||
|
|
|
@ -148,7 +148,7 @@ 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\: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.TIM7_IRQn=true\:1\: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
|
||||
|
|
|
@ -48,6 +48,10 @@ typedef struct _timeInfo {
|
|||
uint8_t second;
|
||||
}timeInfo;
|
||||
|
||||
|
||||
/* 方式 */
|
||||
typedef enum {
|
||||
runLedChargMode = 1,
|
||||
runLedOtherMode = 2,
|
||||
}runLedMode;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue