From 0fcdfa75d38549970666d3c8492dd936cc2abf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B7=E5=BA=8A=E5=B0=B1=E7=8A=AF=E5=9B=B0?= <11730503+psx123456@user.noreply.gitee.com> Date: Tue, 24 Dec 2024 14:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A7=E5=88=B6=E5=92=8C?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +- APP/application/Src/start.c | 2 + APP/businessLogic/Inc/bl_comm.h | 1 - APP/businessLogic/Inc/inFlash.h | 4 + APP/businessLogic/Inc/parameter.h | 10 +- APP/businessLogic/Inc/task.h | 3 +- APP/businessLogic/Src/Init.c | 5 +- APP/businessLogic/Src/abnormalManage.c | 93 ++++++++++++++--- APP/businessLogic/Src/bl_chargControl.c | 53 +++++++--- APP/businessLogic/Src/bl_comm.c | 2 - APP/businessLogic/Src/cfg_protocol.c | 2 + APP/businessLogic/Src/hy_protocol.c | 79 +++++++++----- APP/businessLogic/Src/inFlash.c | 21 ++++ APP/businessLogic/Src/interruptSend.c | 9 +- APP/businessLogic/Src/parameter.c | 38 +++++-- APP/businessLogic/Src/task.c | 131 ++++++++++++++++++++++-- APP/functionalModule/Src/FM_GPIO.c | 28 +++-- APP/functionalModule/Src/FM_RTC.c | 8 +- APP/functionalModule/Src/capture.c | 4 +- APP/hardwareDriver/Src/HD_GPIO.c | 4 +- APP/hardwareDriver/Src/HD_RTC.c | 16 ++- Core/Src/tim.c | 2 +- EWARM/chargeController.ewd | 82 +++++++-------- EWARM/chargeController.ewp | 4 +- chargeController.ioc | 2 +- tools/chargControlTypes.h | 6 +- 26 files changed, 470 insertions(+), 142 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 58377b2..4776e21 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -31,6 +31,7 @@ "chargcontrolenum.h": "c", "chargcontroltypes.h": "c", "fm_rtc.h": "c", - "interruptsend.h": "c" + "interruptsend.h": "c", + "rtc.h": "c" } } \ No newline at end of file diff --git a/APP/application/Src/start.c b/APP/application/Src/start.c index 3239aa3..2d73a71 100644 --- a/APP/application/Src/start.c +++ b/APP/application/Src/start.c @@ -59,6 +59,8 @@ void start(void) startInfo(); + HAL_Delay(5000); + TimeSliceOffset_Start(); } diff --git a/APP/businessLogic/Inc/bl_comm.h b/APP/businessLogic/Inc/bl_comm.h index 72d6800..199d1c7 100644 --- a/APP/businessLogic/Inc/bl_comm.h +++ b/APP/businessLogic/Inc/bl_comm.h @@ -9,7 +9,6 @@ #define buffLen 100 extern uint8_t rs485_buff[buffLen]; - void gw485_RxIt(void); void bat485_RxIt(void); diff --git a/APP/businessLogic/Inc/inFlash.h b/APP/businessLogic/Inc/inFlash.h index 042ff59..3ef8401 100644 --- a/APP/businessLogic/Inc/inFlash.h +++ b/APP/businessLogic/Inc/inFlash.h @@ -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 diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h index 46798fa..401d247 100644 --- a/APP/businessLogic/Inc/parameter.h +++ b/APP/businessLogic/Inc/parameter.h @@ -3,6 +3,7 @@ #include "main.h" #include "comm_types.h" +#include "chargControlTypes.h" #define softVer "SV01_24101501" @@ -22,12 +23,15 @@ typedef struct _config_parameter{ float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */ float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */ - // uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */ - // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ + // uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */ + // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ 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; /* 接入节点类型 */ @@ -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); diff --git a/APP/businessLogic/Inc/task.h b/APP/businessLogic/Inc/task.h index 4461a10..73038a2 100644 --- a/APP/businessLogic/Inc/task.h +++ b/APP/businessLogic/Inc/task.h @@ -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 diff --git a/APP/businessLogic/Src/Init.c b/APP/businessLogic/Src/Init.c index 5bf3f8f..406a701 100644 --- a/APP/businessLogic/Src/Init.c +++ b/APP/businessLogic/Src/Init.c @@ -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); diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index d16dc47..2b97327 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -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(); } } @@ -91,8 +139,7 @@ void setShortCircuitFlag(BOOL state) { if (state == TRUE || state == FALSE) { shortCircuitFlag = state; - } - + } } /** @@ -150,8 +197,7 @@ 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) @@ -218,10 +284,13 @@ void checkAbnormal(void) /* 判断 */ checkFFMOS_CON(); - setDisChargOverLoad(); - + setDisChargOverLoad(); + setSoftShortCircuit(); + + + // checkAbnormalTime = getCheckTime(); } @@ -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); } } @@ -260,7 +329,7 @@ void DSG_PROT_Interrupt(void) if (getShortCircuit() == 1) { setShortCircuitFlag(TRUE); startShortCircuitProtection(); - } + } /* 一定时间内第二次进入输出短路保护,关闭输出 */ else if (getShortCircuit() >= 2) { diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index 0a93269..0d687d1 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -38,15 +38,20 @@ void mppt_constantVoltage(float InVoltage) static float ki = 0.00001; // static float solarInCircuitVoltage; static float error; - static float stepPwm; - + 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; // } @@ -104,7 +114,12 @@ void mppt_constantVoltageO(float OutVoltage) // } else { // g_controlParameter.dutyRatio += StepPwm; // } - setDutyRatio((getDutyRatio() - StepPwm)); + setDutyRatio((getDutyRatio() - StepPwm)); + // if (getMosTemperState() == mosTemperEnd) { + // setDutyRatio((getDutyRatio() + StepPwm - 0.1)); + // } else { + // setDutyRatio((getDutyRatio() + StepPwm)); + // } } // lastVolt = outVolt; @@ -315,7 +330,7 @@ void mppt_readJust(void) if (powerIndex >= 50) { powerIndex = 0; } - + static float lPower = 0; static float lLPower = 0; // static float lLLPower = 0; @@ -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 @@ -465,12 +485,12 @@ void startChargWork(void) * FALSE 未达到 * */ -BOOL stopChargConditions(void) +BOOL stopChargConditions(void) { if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV - && getChargCurrent() < 0.1f) { - return TRUE; - } + && getChargCurrent() < 1) { + return TRUE; + } return FALSE; } @@ -517,8 +537,8 @@ BOOL mpptChargConditions(void) */ BOOL constantVChargConditions(void) { - if ((g_cfgParameter.constantVoltageChargeV < getBatteryVoltage()) - && ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) { + if ((g_cfgParameter.constantVoltageV < getBatteryVoltage()) + && ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) { return TRUE; } @@ -553,7 +573,7 @@ void chargControlMode(void) /** * @brief 判断有无电池 * @param - * @retval + * @retval * */ void judgeYNBattery(void) @@ -658,7 +678,14 @@ void setChargControlFlag(BOOL state) { if (state == TRUE || state == FALSE) { chargControlFlag = state; - } + } + + if (state == TRUE) { + chargRunLed(runLedChargMode); + } else if (state == FALSE) { + chargRunLed(runLedOtherMode); + } + } /** diff --git a/APP/businessLogic/Src/bl_comm.c b/APP/businessLogic/Src/bl_comm.c index 3177137..3a0a154 100644 --- a/APP/businessLogic/Src/bl_comm.c +++ b/APP/businessLogic/Src/bl_comm.c @@ -6,8 +6,6 @@ uint8_t rs485_buff[buffLen]={0x00}; - - /** * @brief gw485串口接收中断回调函数 * @param diff --git a/APP/businessLogic/Src/cfg_protocol.c b/APP/businessLogic/Src/cfg_protocol.c index aeb4864..0b5b05a 100644 --- a/APP/businessLogic/Src/cfg_protocol.c +++ b/APP/businessLogic/Src/cfg_protocol.c @@ -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(); diff --git a/APP/businessLogic/Src/hy_protocol.c b/APP/businessLogic/Src/hy_protocol.c index 04becb1..37f7067 100644 --- a/APP/businessLogic/Src/hy_protocol.c +++ b/APP/businessLogic/Src/hy_protocol.c @@ -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; @@ -1851,8 +1876,9 @@ 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); } \ No newline at end of file diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index 5d1e1a6..501d159 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -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)); +} \ No newline at end of file diff --git a/APP/businessLogic/Src/interruptSend.c b/APP/businessLogic/Src/interruptSend.c index 08b255a..17fc49c 100644 --- a/APP/businessLogic/Src/interruptSend.c +++ b/APP/businessLogic/Src/interruptSend.c @@ -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--; + + uart_send.insertData->dataState = TRUE; + uart_send.insertState--; break; } - } while (1); - - uart_send.insertData->dataState = TRUE; - uart_send.insertState--; + /* 0执行一次, 1一直循环直到能插入 */ + } while (0); /* 可插入数据大于0时,将插入指针指向空的储存位置,否则指向NULL */ if (uart_send.insertState > 0) { diff --git a/APP/businessLogic/Src/parameter.c b/APP/businessLogic/Src/parameter.c index d6bfe91..13f03ee 100644 --- a/APP/businessLogic/Src/parameter.c +++ b/APP/businessLogic/Src/parameter.c @@ -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,15 +55,16 @@ 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; } 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(); } } diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index deb6916..7c55abf 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -11,10 +11,11 @@ #include "abnormalManage.h" #include "interruptSend.h" +#include /* 控制运行指示灯和喂狗 */ -// #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); } @@ -212,7 +291,7 @@ void Task_refreshJudgeData(void) } else if ((getMosTemperState() == mosTemperStart) && getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_end) { - setMosTemperState(mosTemperEnd); + setMosTemperState(mosTemperEnd); } else if ((getMosTemperState() == mosTemperEnd) && getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_stop) { @@ -513,7 +592,7 @@ void Task_shortCircuitProtection(void) /* 仍然过流,彻底关闭输出 */ if (readOverCurrState() == FALSE) { setPowerOutput(FALSE); - } + } /* 不过流,则状态位复位 */ else { setShortCircuitFlag(FALSE); @@ -648,4 +727,40 @@ void Task_busFree(void) // { // TimeSliceOffset_Register(&m_interruptSend, Task_interruptSend // , interruptSend_reloadVal, interruptSend_offset); -// } \ No newline at end of file +// } + +/** + * @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); +} \ No newline at end of file diff --git a/APP/functionalModule/Src/FM_GPIO.c b/APP/functionalModule/Src/FM_GPIO.c index 9a4d97a..b79c3f5 100644 --- a/APP/functionalModule/Src/FM_GPIO.c +++ b/APP/functionalModule/Src/FM_GPIO.c @@ -165,11 +165,23 @@ 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)) { - return TRUE; - } + 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(); + // } } diff --git a/APP/functionalModule/Src/FM_RTC.c b/APP/functionalModule/Src/FM_RTC.c index e486188..796d67b 100644 --- a/APP/functionalModule/Src/FM_RTC.c +++ b/APP/functionalModule/Src/FM_RTC.c @@ -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); diff --git a/APP/functionalModule/Src/capture.c b/APP/functionalModule/Src/capture.c index e873f52..95309c2 100644 --- a/APP/functionalModule/Src/capture.c +++ b/APP/functionalModule/Src/capture.c @@ -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开路输出电压比例 */ diff --git a/APP/hardwareDriver/Src/HD_GPIO.c b/APP/hardwareDriver/Src/HD_GPIO.c index 322fa56..407ee0b 100644 --- a/APP/hardwareDriver/Src/HD_GPIO.c +++ b/APP/hardwareDriver/Src/HD_GPIO.c @@ -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*/ diff --git a/APP/hardwareDriver/Src/HD_RTC.c b/APP/hardwareDriver/Src/HD_RTC.c index 5453880..d174c73 100644 --- a/APP/hardwareDriver/Src/HD_RTC.c +++ b/APP/hardwareDriver/Src/HD_RTC.c @@ -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(); + } } diff --git a/Core/Src/tim.c b/Core/Src/tim.c index 68aaaab..8a32d2f 100644 --- a/Core/Src/tim.c +++ b/Core/Src/tim.c @@ -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 */ diff --git a/EWARM/chargeController.ewd b/EWARM/chargeController.ewd index b6097fb..ae5b760 100644 --- a/EWARM/chargeController.ewd +++ b/EWARM/chargeController.ewd @@ -36,7 +36,7 @@ @@ -294,7 +294,7 @@