diff --git a/APP/application/Src/start.c b/APP/application/Src/start.c index 0193923..278b375 100644 --- a/APP/application/Src/start.c +++ b/APP/application/Src/start.c @@ -8,7 +8,7 @@ void start(void) { Init(); - + task_Init(); TimeSliceOffset_Start(); } diff --git a/APP/businessLogic/Inc/bl_chargControl.h b/APP/businessLogic/Inc/bl_chargControl.h index 5c0005b..92a6e05 100644 --- a/APP/businessLogic/Inc/bl_chargControl.h +++ b/APP/businessLogic/Inc/bl_chargControl.h @@ -8,6 +8,9 @@ void setChargControlFlag(BOOL state); void bl_chargControl(void); +void endChargWork(void); +void stopChargWork(void); +void startChargWork(void); extern void chargControl(void); diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h index db913bb..d8ae50f 100644 --- a/APP/businessLogic/Inc/parameter.h +++ b/APP/businessLogic/Inc/parameter.h @@ -79,6 +79,10 @@ void setBatteryState(BOOL state); float getDutyRatio(void); void setDutyRatio(float DutyRatio); void setDutyRatioToZero(void); +uint8_t getMosTemperState(void); +void setMosTemperState(uint8_t state); +BOOL getCheckImpedanceState(void); +void setCheckImpedanceState(void); float getBatteryVoltage(void); void setBatteryVoltage(void); diff --git a/APP/businessLogic/Inc/task.h b/APP/businessLogic/Inc/task.h index bc31773..a8fbbad 100644 --- a/APP/businessLogic/Inc/task.h +++ b/APP/businessLogic/Inc/task.h @@ -9,7 +9,7 @@ void task_Init(void); void beginStartControlTask(void); - +void beginSoftStartTask(void); diff --git a/APP/businessLogic/Src/Init.c b/APP/businessLogic/Src/Init.c index 202126d..ec6ae00 100644 --- a/APP/businessLogic/Src/Init.c +++ b/APP/businessLogic/Src/Init.c @@ -30,4 +30,8 @@ void Init(void) Init_GW485_uart(); start_gw485Rx_It(); start_bat485Rx_It(); + + POW_FF_PCON_Open(); + POW_OUT_PCON_Open(); + } diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index 3375a3d..4bfce1f 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -3,7 +3,7 @@ #include "parameter.h" #include "capture.h" #include "checkTime.h" - +#include "FM_GPIO.h" void checkAbnormal(void) @@ -18,9 +18,18 @@ void checkAbnormal(void) setOutputVoltage(); setSolarInCircuitVoltage(); - /* 判断异常状态 */ + /* 判断 */ + + /* 是否打开充电理想二极管 */ + if (get_CHG_CURR() > 2.0f) { + FFMOS_CON_Open(); + } + else if (get_CHG_CURR() < 1.0f) { + FFMOS_CON_Close(); + } + - // checkAbnormalTime = getCheckTime(); + // checkAbnormalTime = getCheckTime(); } diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index ce583c0..2eb54cd 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -6,7 +6,6 @@ #include "task.h" -static void stopChargWork(void); static BOOL stopChargConditions(void); static BOOL floatChargConditions(void); static BOOL mpptChargConditions(void); @@ -37,18 +36,17 @@ void mppt_constantVoltage(float InVoltage) { static float kp = 0.005; static float ki = 0.00001; - static float solarInCircuitVoltage; + // static float solarInCircuitVoltage; static float error; static float stepPwm; - solarInCircuitVoltage = getSolarInCircuitVoltage(); - error = solarInCircuitVoltage - InVoltage; -// float error = InVoltage - g_otherParameter.Solar_In_Circuit_Voltage; - stepPwm = kp * error + ki * solarInCircuitVoltage; + // solarInCircuitVoltage = getSolarInCircuitVoltage(); +// error = InVoltage - getSolarInCircuitVoltage(); + error = getSolarInCircuitVoltage() - InVoltage; + stepPwm = kp * error + ki * getSolarInCircuitVoltage(); setDutyRatio((getDutyRatio() + stepPwm)); - set_pwmDutyRatio(getDutyRatio()); } /** @@ -70,7 +68,6 @@ void mppt_constantVoltageNoBatteryO(float OutVoltage) stepPwm = kp * error + ki * outVolt; setDutyRatio((getDutyRatio() + stepPwm)); - set_pwmDutyRatio(getDutyRatio()); } /** @@ -113,7 +110,6 @@ void mppt_constantVoltageO(float OutVoltage) // lastVolt = outVolt; // lastStepPwm = StepPwm; lastDutyRatio = getDutyRatio(); - set_pwmDutyRatio(getDutyRatio()); } /** @@ -397,7 +393,21 @@ void mppt_readJust(void) } /** - * @brief 停止充电 + * @brief 停止充电,并打开启动任务 + * @param + * @retval + * + */ +void endChargWork(void) +{ + EN_PWMOUT_Diseable(); + pwm_Stop(); + setMPPT_Mode(noWork); + beginStartControlTask(); +} + +/** + * @brief 停止充电,不开启启动任务 * @param * @retval * @@ -407,9 +417,23 @@ void stopChargWork(void) EN_PWMOUT_Diseable(); pwm_Stop(); setMPPT_Mode(noWork); - beginStartControlTask(); } +/** + * @brief 启动充电,直接软启动 + * @param + * @retval + * + */ +void startChargWork(void) +{ + beginSoftStartTask(); +} + + + + + /** * @brief 判断达到停止充电的条件 * @param @@ -470,7 +494,7 @@ BOOL mpptChargConditions(void) BOOL constantVChargConditions(void) { if ((g_cfgParameter.constantVoltageChargeV < getBatteryVoltage()) - && ((g_cfgParameter.floatI + 0.1) <= getChargBatteryCurrent())) { + && ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) { return TRUE; } @@ -486,7 +510,7 @@ BOOL constantVChargConditions(void) void chargControlMode(void) { if (stopChargConditions()) { - stopChargWork(); + endChargWork(); } if (floatChargConditions()) { @@ -510,7 +534,11 @@ void chargControlMode(void) */ void judgeYNBattery(void) { - if (getBatteryVoltage() > 16 || getBatteryVoltage() < 10) { + // if (getBatteryVoltage() > 16 || getBatteryVoltage() < 10) { + // setBatteryState(FALSE); + // return; + // } + if (getOutputVoltage() > 16 || getOutputVoltage() < 10) { setBatteryState(FALSE); return; } @@ -572,6 +600,7 @@ void BatteryChargControl(void) case MPPT: mpptCharge(); + // mppt_constantVoltage(17.0f); break; case constantVoltage: diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index 9b27191..70a20e2 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -78,19 +78,19 @@ static void read_backups_config_info(config_info *output_config_info) */ static void readFlashContent(config_info *config_info) { - read_config_info(config_info); + // read_config_info(config_info); - /* 配置文件正确就返回 */ - if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) { - return; - } + // /* 配置文件正确就返回 */ + // if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) { + // return; + // } - /* 更深处的配置文件正确就返回 */ - read_backups_config_info(config_info); - if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) { - save_config_info(config_info); - return; - } + // /* 更深处的配置文件正确就返回 */ + // read_backups_config_info(config_info); + // if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) { + // save_config_info(config_info); + // return; + // } /* 配置文件错误使用默认配置 */ config_info->address[0] = 0x11; diff --git a/APP/businessLogic/Src/parameter.c b/APP/businessLogic/Src/parameter.c index 2d8c846..2d1e079 100644 --- a/APP/businessLogic/Src/parameter.c +++ b/APP/businessLogic/Src/parameter.c @@ -3,14 +3,15 @@ #include "FM_TIM.h" #include "FM_GPIO.h" #include "capture.h" - +#include "chargControlEnum.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 BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */ /** * @brief 获取电池状态 @@ -78,6 +79,50 @@ void setDutyRatioToZero(void) set_pwmDutyRatio(dutyRatio); } +/** + * @brief 获取mos管温度状态 + * @param + * @retval mosTemperState mos管温度状态 + */ +uint8_t getMosTemperState(void) +{ + return mosTemperState; +} + +/** + * @brief 设置mos管温度状态 + * @param state 需要设置的mos管状态 + * @retval + */ +void setMosTemperState(uint8_t state) +{ + if (state == mosTemperStart || state == mosTemperEnd || state == mosTemperStop) { + mosTemperState = state; + } +} + +/** + * @brief 获取回路阻抗检测状态 + * @param + * @retval checkImpedanceState FALSE:未检测或检测失败 + * TRUE: 检测成功 + */ +BOOL getCheckImpedanceState(void) +{ + return checkImpedanceState; +} + +/** + * @brief 回路阻抗检测成功后设置回路阻抗检测状态 + * @param + * @retval + * + */ +void setCheckImpedanceState(void) +{ + checkImpedanceState = TRUE; +} + /** * @brief 得到电池电压 * @param @@ -176,7 +221,7 @@ float getInputVoltage(void) */ void setInputVoltage(void) { - g_otherParameter.Discharg_Current = get_PV_VOLT_IN1(); + g_otherParameter.Input_Voltage = get_PV_VOLT_IN1(); } /** @@ -390,7 +435,7 @@ BOOL getDischargMosState(void) return readOnlyPowerOutputState(); } else { return readOutputState(); - } + } } /** diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index ecbfc6b..9e46a8f 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -15,7 +15,7 @@ static void Task_Runled(void); /* 喂狗 */ #define wdi_reloadVal 1000 /* 任务执行间隔 */ -#define wdi_offset 100 /* 任务执行偏移量 */ +#define wdi_offset 0 /* 任务执行偏移量 */ static STR_TimeSliceOffset m_wdi; static void Task_wdi(void); @@ -38,7 +38,7 @@ static STR_TimeSliceOffset m_softStart; static void Task_softStart(void); /* 回路阻抗检测 */ -#define impedanceCalculation_reloadVal 100 /* 任务执行间隔 */ +#define impedanceCalculation_reloadVal 20 /* 任务执行间隔 */ #define impedanceCalculation_offset 0 /* 任务执行偏移量 */ static STR_TimeSliceOffset m_impedanceCalculation; static void Task_impedanceCalculation(void); @@ -56,7 +56,8 @@ void task_Init(void) { TimeSliceOffset_Register(&m_runled, Task_Runled, runled_reloadVal, runled_offset); TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset); - + beginStartControlTask(); + TimeSliceOffset_Register(&m_refreshJudgeData, Task_refreshJudgeData, refreshJudgeData_reloadVal, refreshJudgeData_offset); } /** @@ -76,7 +77,19 @@ void Task_Runled(void) * @retval None */ void Task_wdi(void) -{ +{ + feedDog(); + + debug_printf("chargCurrent:%f \n", getChargCurrent()); + debug_printf("outputVoltage:%f \n", getOutputVoltage()); + 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("DutyRatio:%f \n", getDutyRatio()); + /* 每天复位一次,复位前将电量信息写入flash中 */ static uint32_t temp = 60 * 60 * 24; if (!(--temp)) { @@ -89,7 +102,6 @@ void Task_wdi(void) NVIC_SystemReset(); } - feedDog(); } /** @@ -102,7 +114,7 @@ void Task_refreshJudgeData(void) { /* 获取数据 */ setInputVoltage(); - setHighSideMosTemperature(); + setHighSideMosTemperature(); /* 判断有无电池 */ if (getBatteryState() == FALSE && (getChargBatteryCurrent() > 1 || getChargBatteryCurrent() < -1) @@ -110,9 +122,34 @@ void Task_refreshJudgeData(void) setBatteryState(TRUE); } + /* 有电池,太阳能输出功率大,同时回路阻抗未测试或需要重新测试 */ + if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f) + && (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f) + && (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)) { + TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation + , impedanceCalculation_reloadVal, impedanceCalculation_reloadVal); + } + /* 温度检测 */ - if (1) { - + if ((getMosTemperState() != mosTemperStart) + && (getHighSideMosTemperature() < g_cfgParameter.HighSideMosTemperature_start)) { + /* 状态处于停止运行则打开充电开关 */ + if (getMosTemperState() == mosTemperStop) { + + } + setMosTemperState(mosTemperStart); + } + else if ((getMosTemperState() == mosTemperStart) + && getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_end) { + setMosTemperState(mosTemperEnd); + } + else if ((getMosTemperState() == mosTemperEnd) + && getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_stop) { + setMosTemperState(mosTemperStop); + /* 停止充电 */ + EN_PWMOUT_Diseable(); + pwm_Stop(); + setMPPT_Mode(noWork); } @@ -154,7 +191,7 @@ void Task_startControl(void) */ void beginStartControlTask(void) { - TimeSliceOffset_Register(&m_wdi, Task_startControl, startControl_reloadVal, startControl_offset); + TimeSliceOffset_Register(&m_startControl, Task_startControl, startControl_reloadVal, startControl_offset); } /** @@ -170,7 +207,8 @@ void Task_softStart(void) num++; if (num < 5) { - set_pwmPulse(100); + set_pwmDutyRatio(0.1f); + EN_PWMOUT_Eable(); } else if (num > 70 || dutyRatio > 0.75f) { @@ -179,7 +217,7 @@ void Task_softStart(void) dutyRatio = 0; num = 0; - setDutyRatio(0.75); + setDutyRatio(0.75f); set_pwmDutyRatio(getDutyRatio()); if (getBatteryState() == TRUE) { @@ -188,13 +226,22 @@ void Task_softStart(void) setMPPT_Mode(floatCharg); } setChargControlFlag(TRUE); - } + } else { setDutyRatio(getDutyRatio() + 0.01f); set_pwmDutyRatio(getDutyRatio()); } } +/** + * @brief 启动软启动任务 + * @param + * @retval + */ +void beginSoftStartTask(void) +{ + TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset); +} /** * @brief 满足一定条件后启动该任务,测量回路阻抗 @@ -239,6 +286,7 @@ void Task_impedanceCalculation(void) if (tempLoopImpedance < 1.0f && tempLoopImpedance > 0.05f) { g_cfgParameter.loopImpedance = tempLoopImpedance; saveLoopImpedance(&g_cfgParameter.loopImpedance); + setCheckImpedanceState(); } num = 0; diff --git a/APP/businessLogic/Src/test.c b/APP/businessLogic/Src/test.c index 27a9ed4..bc28a6a 100644 --- a/APP/businessLogic/Src/test.c +++ b/APP/businessLogic/Src/test.c @@ -15,11 +15,11 @@ void test(void) 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()); + // 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()); } } diff --git a/APP/functionalModule/Inc/FM_TIM.h b/APP/functionalModule/Inc/FM_TIM.h index beaf1f4..19554dc 100644 --- a/APP/functionalModule/Inc/FM_TIM.h +++ b/APP/functionalModule/Inc/FM_TIM.h @@ -7,7 +7,7 @@ void tim_Init(void); void pwm_Stop(void); void set_pwmDutyRatio(float DutyRatio); -void set_pwmPulse(uint32_t Pulse); +// void set_pwmPulse(uint32_t Pulse); extern void chargControl(void); extern void checkAbnormal(void); diff --git a/APP/functionalModule/Inc/capture.h b/APP/functionalModule/Inc/capture.h index f64465b..3494bd5 100644 --- a/APP/functionalModule/Inc/capture.h +++ b/APP/functionalModule/Inc/capture.h @@ -16,10 +16,10 @@ typedef struct _adcCapture }adcCapture; #pragma pack(pop) -extern adcCapture WORK_VOLT_capture; -extern adcCapture DSG_CURR_capture; -extern adcCapture PV_VOLT_IN_capture; -extern adcCapture CHG_CURR_capture; +// extern adcCapture WORK_VOLT_capture; +// extern adcCapture DSG_CURR_capture; +// extern adcCapture PV_VOLT_IN_capture; +// extern adcCapture CHG_CURR_capture; void ADC_Capture_Init(void); void proportionalInt(int mode); diff --git a/APP/functionalModule/Src/FM_GPIO.c b/APP/functionalModule/Src/FM_GPIO.c index db993f4..1573679 100644 --- a/APP/functionalModule/Src/FM_GPIO.c +++ b/APP/functionalModule/Src/FM_GPIO.c @@ -150,7 +150,8 @@ BOOL readOnlyPowerOutputState(void) */ BOOL readOutputState(void) { - if (1) { + if (HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin) + && HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) { return TRUE; } diff --git a/APP/functionalModule/Src/FM_TIM.c b/APP/functionalModule/Src/FM_TIM.c index 0065b42..d465741 100644 --- a/APP/functionalModule/Src/FM_TIM.c +++ b/APP/functionalModule/Src/FM_TIM.c @@ -16,7 +16,8 @@ void tim_Init(void) HD_PWM_Init(); /* 得到pwm的分辨率 */ PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000; - HAL_TIM_Base_Start(&htim3); + // HAL_TIM_Base_Start(&htim3); + HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); HD_controlTim_Init(); HAL_TIM_Base_Start_IT(&htim7); @@ -28,17 +29,6 @@ void tim_Init(void) HAL_TIM_Base_Start_IT(&htim15); } - -/** - * @brief 停止PWM信号输出 - */ -void pwm_Stop(void) -{ - // 设置PWM脉冲宽度为0, effectively停止PWM信号输出 - set_pwmPulse(0); - HAL_TIM_Base_Stop(&htim3); -} - /** * @brief 设置占空比的大小 * @param Pulse 高电平所占的数 @@ -52,6 +42,17 @@ void set_pwmPulse(uint32_t Pulse) __HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_4, Pulse); } +/** + * @brief 停止PWM信号输出 + */ +void pwm_Stop(void) +{ + // 设置PWM脉冲宽度为0, effectively停止PWM信号输出 + set_pwmPulse(0); + // HAL_TIM_Base_Stop(&htim3); +} + + /** * @brief 设置占空比的大小 * @param DutyRatio 占空比 diff --git a/APP/functionalModule/Src/capture.c b/APP/functionalModule/Src/capture.c index 0fe6440..673f8b1 100644 --- a/APP/functionalModule/Src/capture.c +++ b/APP/functionalModule/Src/capture.c @@ -95,8 +95,8 @@ const uint16_t mosTemperADC[mosTemperADCLen] = { enum { WORK_VOLT_NUM = 0, DSG_CURR_NUM = 1, - PV_VOLT_IN_NUM = 2, - CHG_CURR_NUM = 3, + CHG_CURR_NUM = 2, + PV_VOLT_IN_NUM = 3, }; int16_t adcBuff[4]; /* 指向adcCapture中的inData16数组中的第一位也是最后一位 */ @@ -125,13 +125,20 @@ const float32_t Proportion = 3.0 / 4095.0; // 0.01861755922 // }; -/* matlab生成的3阶滤波器系数 */ +// /* matlab生成的3阶滤波器系数 */ +// const int firLen = 4; +// const float32_t firLP[4] = { +// 0.178709805, 0.3671073616, 0.3671073616, 0.178709805 +// }; + +/* matlab生成的3阶滤波器系数,乘比例使和接近为1 */ const int firLen = 4; -const float firLP[4] = { - 0.178709805, 0.3671073616, 0.3671073616, 0.178709805 +const float32_t firLP[4] = { + 0.163708486, 0.336291513, 0.336291513, 0.163708486 }; -void captureFirInit(void); + +// void captureFirInit(void); /** * @brief 初始化adc @@ -149,8 +156,8 @@ void ADC_Capture_Init(void) HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED); HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED); - /* 初始化滤波器 */ - captureFirInit(); + // /* 初始化滤波器 */ + // captureFirInit(); HAL_TIM_Base_Start(&htim6); HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuff, 4); @@ -201,6 +208,17 @@ void proportionalInt(int mode) /* 系统电源电压比例 */ P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion; } + + /* 光伏充电输出电流比例,放大倍数*电阻 */ + P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002)))) * Proportion; + /* 充电控制盒输出电压比例,分压系数 */ + P_PV_VOLT_OUT = ((47.0 + 10.0) / 10.0) * Proportion; + /* 放电电流采集电流倍数 */ + P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2)))) * Proportion; + /* 光伏板输出电压比例 */ + P_PV1_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion; + /* 系统电源电压比例 */ + P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion; } #define N 4 @@ -416,7 +434,7 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma) CHG_CURR_capture.totalInData += CHG_CURR_capture.inData16[pointer]; pointer++; - if (pointer >= indata16_size) { + if (pointer >= 10) { pointer = 0; } @@ -432,20 +450,20 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma) } } -static arm_fir_instance_f32 armFirInstanceF32; -static float32_t *inputF32, *outputF32; -static uint32_t blockSize = 1; -static float32_t firStateF32[4]; /* 状态缓存 */ -static float32_t outputf; -void captureFirInit(void) -{ - /* 初始化结构体 */ - arm_fir_init_f32(&armFirInstanceF32, - firLen, - (float_t *)&firLP[0], - &firStateF32[0], - blockSize); -} +// static arm_fir_instance_f32 armFirInstanceF32; +// static float32_t *inputF32, *outputF32; +// static uint32_t blockSize = 4; +// static float32_t firStateF32[4]; /* 状态缓存 */ +// static float32_t outputf; +// void captureFirInit(void) +// { +// /* 初始化结构体 */ +// arm_fir_init_f32(&armFirInstanceF32, +// firLen, +// (float_t *)&firLP[0], +// &firStateF32[0], +// blockSize); +// } /** @@ -455,28 +473,62 @@ void captureFirInit(void) */ void adcCaptureFir(void) { - /* 初始化输入输出缓存指针 */ - inputF32 = &WORK_VOLT_capture.IODataF[0]; - outputF32 = &outputf; - arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + // static arm_fir_instance_f32 armFirInstanceF32; + // static volatile float32_t *inputF32; + // static volatile float32_t *outputF32; + // static uint32_t blockSize = 4; + // static float32_t firStateF32[4]; /* 状态缓存 */ + // static volatile float32_t outputf; + + // /* 初始化结构体 */ + // arm_fir_init_f32(&armFirInstanceF32, + // firLen, + // &firLP[0], + // &firStateF32[0], + // blockSize); + + // /* 初始化输入输出缓存指针 */ + // inputF32 = &WORK_VOLT_capture.IODataF[0]; + // outputF32 = &outputf; + // // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + // arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1); + // WORK_VOLT_capture.outData = (int16_t)outputf; + + // /* 初始化输入输出缓存指针 */ + // inputF32 = &DSG_CURR_capture.IODataF[0]; + // outputF32 = &outputf; + // // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + // arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1); + // DSG_CURR_capture.outData = (int16_t)outputf; + + // /* 初始化输入输出缓存指针 */ + // inputF32 = &PV_VOLT_IN_capture.IODataF[0]; + // outputF32 = &outputf; + // // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + // arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1); + // PV_VOLT_IN_capture.outData = (int16_t)outputf; + + // /* 初始化输入输出缓存指针 */ + // inputF32 = &CHG_CURR_capture.IODataF[0]; + // outputF32 = &outputf; + // // arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + // arm_fir_f32(&armFirInstanceF32, (const float32_t *)inputF32, (float32_t *)outputF32, 1); + // CHG_CURR_capture.outData = (int16_t)outputf; + + // WORK_VOLT_capture.outData = 1; + // DSG_CURR_capture.outData = 1; + // PV_VOLT_IN_capture.outData = 1; + // CHG_CURR_capture.outData = 1; + + static float32_t outputf; + arm_dot_prod_f32(WORK_VOLT_capture.IODataF, firLP, firLen, &outputf); WORK_VOLT_capture.outData = (int16_t)outputf; - - /* 初始化输入输出缓存指针 */ - inputF32 = &DSG_CURR_capture.IODataF[0]; - outputF32 = &outputf; - arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + arm_dot_prod_f32(DSG_CURR_capture.IODataF, firLP, firLen, &outputf); DSG_CURR_capture.outData = (int16_t)outputf; - - /* 初始化输入输出缓存指针 */ - inputF32 = &PV_VOLT_IN_capture.IODataF[0]; - outputF32 = &outputf; - arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + arm_dot_prod_f32(PV_VOLT_IN_capture.IODataF, firLP, firLen, &outputf); PV_VOLT_IN_capture.outData = (int16_t)outputf; - - /* 初始化输入输出缓存指针 */ - inputF32 = &CHG_CURR_capture.IODataF[0]; - outputF32 = &outputf; - arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); + arm_dot_prod_f32(CHG_CURR_capture.IODataF, firLP, firLen, &outputf); CHG_CURR_capture.outData = (int16_t)outputf; + } diff --git a/Core/Src/main.c b/Core/Src/main.c index fbf2108..0a9700f 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -27,7 +27,8 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ -#include "test.h" +// #include "test.h" +#include "start.h" @@ -93,22 +94,22 @@ int main(void) /* USER CODE END SysInit */ /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - MX_ADC1_Init(); - MX_ADC2_Init(); - MX_SPI1_Init(); - MX_TIM3_Init(); - MX_TIM6_Init(); - MX_UART4_Init(); - MX_USART2_UART_Init(); - MX_USART3_UART_Init(); - MX_TIM7_Init(); - MX_TIM16_Init(); - MX_TIM15_Init(); +// MX_GPIO_Init(); +// MX_DMA_Init(); +// MX_ADC1_Init(); +// MX_ADC2_Init(); +// MX_SPI1_Init(); +// MX_TIM3_Init(); +// MX_TIM6_Init(); +// MX_UART4_Init(); +// MX_USART2_UART_Init(); +// MX_USART3_UART_Init(); +// MX_TIM7_Init(); +// MX_TIM16_Init(); +// MX_TIM15_Init(); /* USER CODE BEGIN 2 */ - test(); + start(); diff --git a/Core/Src/tim.c b/Core/Src/tim.c index 333d3eb..8e523a8 100644 --- a/Core/Src/tim.c +++ b/Core/Src/tim.c @@ -90,7 +90,7 @@ void MX_TIM6_Init(void) htim6.Instance = TIM6; htim6.Init.Prescaler = 71; htim6.Init.CounterMode = TIM_COUNTERMODE_UP; - htim6.Init.Period = 29; + htim6.Init.Period = 9; htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim6) != HAL_OK) { @@ -123,7 +123,7 @@ void MX_TIM7_Init(void) htim7.Instance = TIM7; htim7.Init.Prescaler = 71; htim7.Init.CounterMode = TIM_COUNTERMODE_UP; - htim7.Init.Period = 999; + htim7.Init.Period = 99; htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim7) != HAL_OK) { @@ -155,9 +155,9 @@ void MX_TIM15_Init(void) /* USER CODE END TIM15_Init 1 */ htim15.Instance = TIM15; - htim15.Init.Prescaler = 10; + htim15.Init.Prescaler = 1; htim15.Init.CounterMode = TIM_COUNTERMODE_UP; - htim15.Init.Period = 7199; + htim15.Init.Period = 35999; htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim15.Init.RepetitionCounter = 0; htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; diff --git a/EWARM/chargeController.ewp b/EWARM/chargeController.ewp index 993727d..09576df 100644 --- a/EWARM/chargeController.ewp +++ b/EWARM/chargeController.ewp @@ -1,1332 +1,1333 @@ - 4 - - chargeController - - ARM - + 4 + + chargeController + + ARM + + 1 + + General + 3 + + 36 + 1 1 - - General - 3 - - 36 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 38 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 12 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - 0 - inputOutputBased - - - - ILINK - 0 - - 27 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BUILDACTION - 2 - - - - Coder - 0 - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 38 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 12 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + 0 + inputOutputBased + + + + ILINK + 0 + + 27 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BUILDACTION + 2 + + + + Coder + 0 + + + + + APP - APP - - application - - $PROJ_DIR$\..\APP\application\Src\chargControl.c - - - $PROJ_DIR$\..\APP\application\Src\comm.c - - - $PROJ_DIR$\..\APP\application\Src\start.c - - - - businessLogic - - $PROJ_DIR$\..\APP\businessLogic\Src\abnormalManage.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\bl_chargControl.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\bl_comm.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\Init.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\parameter.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\task.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\test.c - - - - functionalModule - - $PROJ_DIR$\..\APP\functionalModule\Src\capture.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\checkTime.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\flash.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\FM_GPIO.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\FM_TIM.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\uart_dev.c - - - - hardwareDriver - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_ADC.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_COMM.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_GPIO.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_TIM.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\w25qxx.c - - + application + + $PROJ_DIR$\..\APP\application\Src\chargControl.c + + + $PROJ_DIR$\..\APP\application\Src\comm.c + + + $PROJ_DIR$\..\APP\application\Src\start.c + - Application - - EWARM - - $PROJ_DIR$\startup_stm32g431xx.s - - - - User - - Core - - $PROJ_DIR$\..\Core\Src\adc.c - - - $PROJ_DIR$\..\Core\Src\dma.c - - - $PROJ_DIR$\..\Core\Src\gpio.c - - - $PROJ_DIR$\..\Core\Src\main.c - - - $PROJ_DIR$\..\Core\Src\spi.c - - - $PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c - - - $PROJ_DIR$\..\Core\Src\stm32g4xx_hal_timebase_tim.c - - - $PROJ_DIR$\..\Core\Src\stm32g4xx_it.c - - - $PROJ_DIR$\..\Core\Src\tim.c - - - $PROJ_DIR$\..\Core\Src\usart.c - - - + businessLogic + + $PROJ_DIR$\..\APP\businessLogic\Src\abnormalManage.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\bl_chargControl.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\bl_comm.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\Init.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\parameter.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\task.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\test.c + - Drivers - - CMSIS - - $PROJ_DIR$\..\Core\Src\system_stm32g4xx.c - - - - STM32G4xx_HAL_Driver - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c - - + functionalModule + + $PROJ_DIR$\..\APP\functionalModule\Src\capture.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\checkTime.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\flash.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\FM_GPIO.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\FM_TIM.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\uart_dev.c + - Middlewares - - Library - - DSP Library/DSP Library - - $PROJ_DIR$\..\Middlewares\ST\ARM\DSP\Lib\iar_cortexM4lf_math.a - - - + hardwareDriver + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_ADC.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_COMM.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_GPIO.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_TIM.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\w25qxx.c + + + + + Application + + EWARM + + $PROJ_DIR$\startup_stm32g431xx.s + - tools + User + + Core - $PROJ_DIR$\..\tools\RingQueue\ring_queue.c + $PROJ_DIR$\..\Core\Src\main.c - $PROJ_DIR$\..\tools\TimeSliceOffset\timeSliceOffset.c + $PROJ_DIR$\..\Core\Src\gpio.c + + $PROJ_DIR$\..\Core\Src\adc.c + + + $PROJ_DIR$\..\Core\Src\dma.c + + + $PROJ_DIR$\..\Core\Src\spi.c + + + $PROJ_DIR$\..\Core\Src\tim.c + + + $PROJ_DIR$\..\Core\Src\usart.c + + + $PROJ_DIR$\..\Core\Src\stm32g4xx_it.c + + + $PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c + + + $PROJ_DIR$\..\Core\Src\stm32g4xx_hal_timebase_tim.c + + + + + Drivers + + CMSIS + + $PROJ_DIR$\..\Core\Src\system_stm32g4xx.c + + + + STM32G4xx_HAL_Driver + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c + + + + + tools + + $PROJ_DIR$\..\tools\RingQueue\ring_queue.c + + + $PROJ_DIR$\..\tools\TimeSliceOffset\timeSliceOffset.c + + + + Middlewares + + Library + + DSP Library/DSP Library + + $PROJ_DIR$/../Middlewares/ST/ARM/DSP/Lib/iar_cortexM4lf_math.a + + + + + diff --git a/chargeController.ioc b/chargeController.ioc index 88b4319..d5ef55b 100644 --- a/chargeController.ioc +++ b/chargeController.ioc @@ -304,7 +304,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_TIM17_Init-TIM17-false-HAL-true,15-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 RCC.ADC12Freq_Value=72000000 RCC.AHBFreq_Value=72000000 RCC.APB1Freq_Value=72000000 @@ -369,8 +369,8 @@ STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.IPParameters=LibraryCcDSPOoLibraryJjDS STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.LibraryCcDSPOoLibraryJjDSPOoLibrary=true STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0_SwParameter=LibraryCcDSPOoLibraryJjDSPOoLibrary\:true; TIM15.IPParameters=PeriodNoDither,Prescaler -TIM15.PeriodNoDither=7199 -TIM15.Prescaler=10 +TIM15.PeriodNoDither=35999 +TIM15.Prescaler=1 TIM16.IPParameters=Prescaler,PeriodNoDither TIM16.PeriodNoDither=999 TIM16.Prescaler=71 @@ -378,11 +378,11 @@ TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4 TIM3.PeriodNoDither=720 TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger -TIM6.PeriodNoDither=29 +TIM6.PeriodNoDither=9 TIM6.Prescaler=71 TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE TIM7.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger -TIM7.PeriodNoDither=999 +TIM7.PeriodNoDither=99 TIM7.Prescaler=71 TIM7.TIM_MasterOutputTrigger=TIM_TRGO_RESET USART2.IPParameters=VirtualMode-Asynchronous,VirtualMode-Hardware Flow Control (RS485) diff --git a/tools/chargControlEnum.h b/tools/chargControlEnum.h index 6e97b1f..b5f41a1 100644 --- a/tools/chargControlEnum.h +++ b/tools/chargControlEnum.h @@ -2,12 +2,18 @@ #ifndef CHARG_CONTROL_ENUM_ #define CHARG_CONTROL_ENUM_ -typedef enum { +typedef enum _chargMode{ noWork = 0, /* 未进行充电 */ MPPT = 1, /* 最大功率充电 */ constantVoltage = 2, /* 恒压充电 */ floatCharg = 3 /* 浮充充电 */ -}_chargControlMode; +}chargMode; + +typedef enum _mosTState{ + mosTemperStart = 0, /* 满功率充电mos状态 */ + mosTemperEnd = 1, /* 降功率充电mos状态 */ + mosTemperStop = 2, /* 停止充电mos状态 */ +}mosTState; #endif