From de2fb8134e3229048426e7807a294a57c2362021 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, 10 Dec 2024 18:29:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=AF=E5=8A=A8=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=88=B7=E6=96=B0=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BB=BB=E5=8A=A1=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 4 +- APP/application/Inc/task.h | 10 - APP/application/Src/chargControl.c | 20 +- APP/application/Src/start.c | 5 +- APP/application/Src/task.c | 9 - APP/businessLogic/Inc/bl_chargControl.h | 9 +- APP/businessLogic/Inc/task.h | 54 + APP/businessLogic/Src/Init.c | 14 +- APP/businessLogic/Src/abnormalManage.c | 5 +- APP/businessLogic/Src/bl_chargControl.c | 67 +- APP/businessLogic/Src/parameter.c | 3 - APP/businessLogic/Src/task.c | 212 ++ APP/businessLogic/Src/test.c | 13 +- APP/functionalModule/Inc/FM_GPIO.h | 3 + APP/functionalModule/Inc/capture.h | 7 +- APP/functionalModule/Inc/checkTime.h | 2 +- APP/functionalModule/Src/FM_GPIO.c | 21 + APP/functionalModule/Src/FM_TIM.c | 21 +- APP/functionalModule/Src/capture.c | 94 +- APP/functionalModule/Src/checkTime.c | 3 + APP/hardwareDriver/Src/HD_TIM.c | 10 - Core/Inc/stm32g4xx_it.h | 1 - Core/Inc/tim.h | 3 - Core/Src/main.c | 27 +- Core/Src/stm32g4xx_it.c | 15 - Core/Src/tim.c | 61 +- EWARM/chargeController.ewp | 2629 +++++++++++------------ EWARM/chargeController.ewt | 6 +- chargeController.ioc | 20 +- tools/fdacoefs-3(100-10-30).h | 31 + 30 files changed, 1831 insertions(+), 1548 deletions(-) delete mode 100644 APP/application/Inc/task.h delete mode 100644 APP/application/Src/task.c create mode 100644 APP/businessLogic/Inc/task.h create mode 100644 APP/businessLogic/Src/task.c create mode 100644 tools/fdacoefs-3(100-10-30).h diff --git a/.vscode/settings.json b/.vscode/settings.json index 2260a0d..a153ddf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,6 +23,8 @@ "hd_adc.h": "c", "hd_tim.h": "c", "checktime.h": "c", - "test.h": "c" + "test.h": "c", + "task.h": "c", + "other.h": "c" } } \ No newline at end of file diff --git a/APP/application/Inc/task.h b/APP/application/Inc/task.h deleted file mode 100644 index c36225c..0000000 --- a/APP/application/Inc/task.h +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef APP_TASK_H_ -#define APP_TASK_H_ - -#include "timeSliceOffset.h" - - - - -#endif diff --git a/APP/application/Src/chargControl.c b/APP/application/Src/chargControl.c index 703beaf..dcfe765 100644 --- a/APP/application/Src/chargControl.c +++ b/APP/application/Src/chargControl.c @@ -2,27 +2,17 @@ #include "chargControl.h" #include "parameter.h" #include "comm_types.h" +#include "abnormalManage.h" + /** - * @brief 完成充电控制 + * @brief 完成滤波和充电控制 * @param * @retval * */ void chargControl(void) { - // getCVData(); - judgeYNBattery(); - - chargControlMode(); - - if (getMPPT_Mode() == noWork) { - return; - } - - if (getBatteryState()) { - BatteryChargControl(); - } else { - noBatteryChargControl(); - } + checkAbnormal(); + bl_chargControl(); } diff --git a/APP/application/Src/start.c b/APP/application/Src/start.c index 1ca98a1..0193923 100644 --- a/APP/application/Src/start.c +++ b/APP/application/Src/start.c @@ -1,12 +1,13 @@ #include "start.h" -#include "inFlash.h" #include "TimeSliceOffset.h" +#include "Init.h" +#include "task.h" void start(void) { - config_info_start(); + Init(); TimeSliceOffset_Start(); diff --git a/APP/application/Src/task.c b/APP/application/Src/task.c deleted file mode 100644 index 1de6eed..0000000 --- a/APP/application/Src/task.c +++ /dev/null @@ -1,9 +0,0 @@ - -#include "task.h" - - - - - - - diff --git a/APP/businessLogic/Inc/bl_chargControl.h b/APP/businessLogic/Inc/bl_chargControl.h index cf07bc5..5c0005b 100644 --- a/APP/businessLogic/Inc/bl_chargControl.h +++ b/APP/businessLogic/Inc/bl_chargControl.h @@ -3,12 +3,11 @@ #include "chargControlEnum.h" #include "FM_TIM.h" +#include "comm_types.h" -void getCVData(void); -void judgeYNBattery(void); -void chargControlMode(void); -void BatteryChargControl(void); -void noBatteryChargControl(void); + +void setChargControlFlag(BOOL state); +void bl_chargControl(void); extern void chargControl(void); diff --git a/APP/businessLogic/Inc/task.h b/APP/businessLogic/Inc/task.h new file mode 100644 index 0000000..207cb78 --- /dev/null +++ b/APP/businessLogic/Inc/task.h @@ -0,0 +1,54 @@ + +#ifndef BL_TASK_H_ +#define BL_TASK_H_ + +#include "timeSliceOffset.h" + +void task_Init(void); + +/* 控制运行指示灯和喂狗 */ +#define runled_reloadVal 1000 /* 任务执行间隔 */ +#define runled_offset 0 /* 任务执行偏移量 */ +extern STR_TimeSliceOffset m_runled; +void Task_Runled(void); + +/* 喂狗 */ +#define wdi_reloadVal 1000 /* 任务执行间隔 */ +#define wdi_offset 100 /* 任务执行偏移量 */ +extern STR_TimeSliceOffset m_wdi; +void Task_wdi(void); + +/* 刷新寄存器中的数据 */ +#define refreshJudgeData_reloadVal 1000 /* 任务执行间隔 */ +#define refreshJudgeData_offset 0 /* 任务执行偏移量 */ +extern STR_TimeSliceOffset m_refreshJudgeData; +void Task_refreshJudgeData(void); + +/* 启动任务 */ +#define startControl_reloadVal 5000 /* 任务执行间隔 */ +#define startControl_offset 100 /* 任务执行偏移量 */ +extern STR_TimeSliceOffset g_startControl; +void Task_startControl(void); + +/* 软启动 */ +#define softStart_reloadVal 10 /* 任务执行间隔 */ +#define softStart_offset 0 /* 任务执行偏移量 */ +extern STR_TimeSliceOffset m_softStart; +void Task_softStart(void); + +/* 回路阻抗检测 */ +#define impedanceCalculation_reloadVal 100 /* 任务执行间隔 */ +#define impedanceCalculation_offset 0 /* 任务执行偏移量 */ +extern STR_TimeSliceOffset m_impedanceCalculation; +void Task_impedanceCalculation(void); + + + + + + + + + + +#endif diff --git a/APP/businessLogic/Src/Init.c b/APP/businessLogic/Src/Init.c index 79dabf9..202126d 100644 --- a/APP/businessLogic/Src/Init.c +++ b/APP/businessLogic/Src/Init.c @@ -6,9 +6,16 @@ #include "parameter.h" #include "FM_GPIO.h" #include "FM_TIM.h" +#include "uart_dev.h" extern int getMPPT_Mode(void); +/** + * @brief 初始化外设,同时通过配置文件初始化系统参数 + * @param None + * @retval None + * + */ void Init(void) { config_info_start(); @@ -18,6 +25,9 @@ void Init(void) FM_GPIO_Init(); tim_Init(); - - + Init_debug_uart(); + Init_BAT485_uart(); + Init_GW485_uart(); + start_gw485Rx_It(); + start_bat485Rx_It(); } diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index cc34350..3375a3d 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -2,12 +2,13 @@ #include "abnormalManage.h" #include "parameter.h" #include "capture.h" - +#include "checkTime.h" void checkAbnormal(void) { + // checkTimeInit(); /* 滤波 */ adcCaptureFir(); @@ -20,6 +21,6 @@ void checkAbnormal(void) /* 判断异常状态 */ - + // checkAbnormalTime = getCheckTime(); } diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index 8de5c67..f0678bc 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -17,6 +17,15 @@ static void mppt_constantVoltage(float InVoltage); static void mppt_constantVoltageNoBatteryO(float OutVoltage); static void mppt_constantVoltageO(float OutVoltage); +static void judgeYNBattery(void); +static void chargControlMode(void); +static void BatteryChargControl(void); +static void noBatteryChargControl(void); + +static BOOL chargControlFlag = FALSE; +static BOOL getChargControlFlag(void); +void setChargControlFlag(BOOL state); + /** * @brief 恒定输入电压 * @param InVoltage 需要控制到的输入电压 @@ -86,7 +95,7 @@ void mppt_constantVoltageO(float OutVoltage) /* 当有电池时,输出电压的曲线是先上升后下降 */ if (lastDutyRatio >= getDutyRatio()) { -// if (lastVolt >= outVolt) { +// if (lastVolt >= outVolt) { setDutyRatio((getDutyRatio() - StepPwm)); // } else { // g_controlParameter.dutyRatio -= StepPwm; @@ -475,27 +484,16 @@ void chargControlMode(void) if (floatChargConditions()) { setMPPT_Mode(floatCharg); } - + if (mpptChargConditions()) { setMPPT_Mode(MPPT); } - + if (constantVChargConditions()) { setMPPT_Mode(constantVoltage); } } -/** - * @brief 得到充电控制器控制所需的电流电压 - * @param - * @retval - * - */ -void getCVData(void) -{ - -} - /** * @brief 判断有无电池 * @param @@ -583,3 +581,44 @@ void BatteryChargControl(void) } } +BOOL getChargControlFlag(void) +{ + return chargControlFlag; +} + + +void setChargControlFlag(BOOL state) +{ + if (state == TRUE || state == FALSE) { + chargControlFlag = state; + } +} + +/** + * @brief 完成充电控制 + * @param + * @retval + * + */ +void bl_chargControl(void) +{ + if (getChargControlFlag() == FALSE) { + return; + } + + // getCVData(); + judgeYNBattery(); + + chargControlMode(); + + if (getMPPT_Mode() == noWork) { + return; + } + + if (getBatteryState()) { + BatteryChargControl(); + } else { + noBatteryChargControl(); + } +} + diff --git a/APP/businessLogic/Src/parameter.c b/APP/businessLogic/Src/parameter.c index 9ebff0b..2d8c846 100644 --- a/APP/businessLogic/Src/parameter.c +++ b/APP/businessLogic/Src/parameter.c @@ -5,8 +5,6 @@ #include "capture.h" - - config_parameter g_cfgParameter = {0}; static otherParameter g_otherParameter = {0}; @@ -14,7 +12,6 @@ static BOOL batteryState = FALSE; /* 有无电池(估计) */ static float dutyRatio; /* 占空比 */ - /** * @brief 获取电池状态 * @param diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c new file mode 100644 index 0000000..ed50fc9 --- /dev/null +++ b/APP/businessLogic/Src/task.c @@ -0,0 +1,212 @@ + +#include "task.h" +#include "inFlash.h" +#include "parameter.h" +#include "FM_GPIO.h" +#include "chargControlEnum.h" +#include "bl_chargControl.h" + +/** + * @brief 启动时初始化各任务 + * @param None + * @retval None + * + */ +void task_Init(void) +{ + TimeSliceOffset_Register(&m_runled, Task_Runled, runled_reloadVal, runled_offset); + TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset); + + + + + +} + +/** + * @brief 运行指示灯任务 + * @param None + * @retval None + * + */ +STR_TimeSliceOffset m_runled; +void Task_Runled(void) +{ + RUN_LED(); +} + +/** + * @brief 喂狗任务 + * @param None + * @retval None + */ +STR_TimeSliceOffset m_wdi; +void Task_wdi(void) +{ + /* 每天复位一次,复位前将电量信息写入flash中 */ + static uint32_t temp = 60 * 60 * 24; + if (!(--temp)) { + temp = 0; + float tempF; + tempF = getTotalElectricityConsumption(); + savetotalElectricityConsumption(&tempF); + tempF = getTotalChargCapacity(); + savetotalChargCapacity(&tempF); + NVIC_SystemReset(); + } + + feedDog(); +} + +/** + * @brief 刷新并判断数据 + * @param None + * @retval None + * + */ +STR_TimeSliceOffset m_refreshJudgeData; +void Task_refreshJudgeData(void) +{ + /* 获取数据 */ + setInputVoltage(); + setHighSideMosTemperature(); + + + + /* 判断有无电池 */ + if (getBatteryState() == FALSE && (getChargBatteryCurrent() > 1 || getChargBatteryCurrent() < -1) + && getOutputVoltage() < 14.2f) { + setBatteryState(TRUE); + } + + /* 温度检测 */ + if () { + + } + + + +} + +/** + * @brief 停止充电或系统启动时后开启该任务,每隔一段时间检测开路电压 + * 检测电池电压是否大于充电电压,大于则开启充电,否则关闭充电 + * 能否达到充电标准,达到后检测电压判断系统中是否有电池同时启 + * 动软启动任务 + * @param None + * @retval None + * + */ +STR_TimeSliceOffset g_startControl; +void Task_startControl(void) +{ + if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV) { + TimeSliceOffset_Unregister(&g_startControl); + g_startControl.runFlag = 0; + if (getOutputVoltage() > 10) { + setBatteryState(TRUE); + } else { + setBatteryState(FALSE); + } + TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset); + } +} + +/** + * @brief 软启动 + * @param + * @retval + * + */ +STR_TimeSliceOffset m_softStart; +void Task_softStart(void) +{ + static uint16_t num = 0; + static float dutyRatio = 0; + num++; + + if (num < 5) { + set_pwmPulse(100); + } + + else if (num > 70 || dutyRatio > 0.75f) { + TimeSliceOffset_Unregister(&m_softStart); + m_softStart.runFlag = 0; + + dutyRatio = 0; + num = 0; + setDutyRatio(0.75); + set_pwmDutyRatio(getDutyRatio()); + + if (getBatteryState() == TRUE) { + setMPPT_Mode(MPPT); + } else { + setMPPT_Mode(floatCharg); + } + setChargControlFlag(TRUE); + } + + else { + setDutyRatio(getDutyRatio() + 0.05f); + set_pwmDutyRatio(getDutyRatio()); + } +} + +/** + * @brief 满足一定条件后启动该任务,测量回路阻抗 + * @param + * @retval + */ +STR_TimeSliceOffset m_impedanceCalculation; +void Task_impedanceCalculation(void) +{ + static uint8_t num = 0; + static float currOne = 0; + static float voltOne = 0; + static float currTwo = 0; + static float voltTwo = 0; + + num++; + + if (num == 1) { + setChargControlFlag(FALSE); + setDutyRatio(0.7); + set_pwmDutyRatio(getDutyRatio()); + return; + } + + if (num == 11) { + currOne = getChargCurrent() - getDischargCurrent(); + voltOne = getOutputVoltage(); + setDutyRatio(0.85); + set_pwmDutyRatio(getDutyRatio()); + return; + } + + if (num == 21) { + TimeSliceOffset_Unregister(&m_impedanceCalculation); + m_impedanceCalculation.runFlag = 0; + + currTwo = getChargCurrent() - getDischargCurrent(); + voltTwo = getOutputVoltage(); + float tempLoopImpedance = 0; + tempLoopImpedance = (voltOne - voltTwo) / (currOne - currTwo); + + /* 判断回路阻抗是否合理 */ + if (tempLoopImpedance < 1.0f && tempLoopImpedance > 0.05f) { + g_cfgParameter.loopImpedance = tempLoopImpedance; + saveLoopImpedance(&g_cfgParameter.loopImpedance); + } + num = 0; + + setMPPT_Mode(MPPT); + setChargControlFlag(TRUE); + return; + } +} + + + + + + diff --git a/APP/businessLogic/Src/test.c b/APP/businessLogic/Src/test.c index 94de3cd..27a9ed4 100644 --- a/APP/businessLogic/Src/test.c +++ b/APP/businessLogic/Src/test.c @@ -4,17 +4,22 @@ #include "uart_dev.h" #include "HD_TIM.h" #include "pDebug.h" +#include "parameter.h" +#include "FM_TIM.h" void test(void) { + tim_Init(); Init_debug_uart(); - HD_time_Init(); - HAL_TIM_Base_Start_IT(&htim15); + while (1) { - checkTimeInit(); HAL_Delay(1000); - debug("time:%f\r\n", getCheckTime()); + 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_GPIO.h b/APP/functionalModule/Inc/FM_GPIO.h index e2007e2..0ec5672 100644 --- a/APP/functionalModule/Inc/FM_GPIO.h +++ b/APP/functionalModule/Inc/FM_GPIO.h @@ -13,6 +13,7 @@ void POW_OUT_PCON_Close(void); void RUN_LEN_Open(void); void RUN_LEN_Close(void); +void RUN_LED(void); void FFMOS_CON_Open(void); void FFMOS_CON_Close(void); @@ -20,6 +21,8 @@ void FFMOS_CON_Close(void); void EN_PWMOUT_Eable(void); void EN_PWMOUT_Diseable(void); +void feedDog(void); + BOOL readOnlyPowerOutputState(void); BOOL readOutputState(void); diff --git a/APP/functionalModule/Inc/capture.h b/APP/functionalModule/Inc/capture.h index 8b72b18..f64465b 100644 --- a/APP/functionalModule/Inc/capture.h +++ b/APP/functionalModule/Inc/capture.h @@ -4,11 +4,14 @@ #include "arm_math.h" - +#define indata16_size 10 +#define IODataF_size 4 #pragma pack(push,4) typedef struct _adcCapture { - float32_t inDataF[6]; + int16_t inData16[indata16_size]; + uint32_t totalInData; + float32_t IODataF[IODataF_size]; int16_t outData; }adcCapture; #pragma pack(pop) diff --git a/APP/functionalModule/Inc/checkTime.h b/APP/functionalModule/Inc/checkTime.h index af57826..67266c5 100644 --- a/APP/functionalModule/Inc/checkTime.h +++ b/APP/functionalModule/Inc/checkTime.h @@ -5,7 +5,7 @@ #include "HD_TIM.h" #include "FM_TIM.h" - +extern float checkAbnormalTime; void hw_inc_tick(void); void checkTimeInit(void); diff --git a/APP/functionalModule/Src/FM_GPIO.c b/APP/functionalModule/Src/FM_GPIO.c index 7f27341..db993f4 100644 --- a/APP/functionalModule/Src/FM_GPIO.c +++ b/APP/functionalModule/Src/FM_GPIO.c @@ -66,6 +66,16 @@ void RUN_LEN_Close(void) HAL_GPIO_WritePin(RUN_LED_GPIO_Port, RUN_LED_Pin, GPIO_PIN_RESET); } +/** + * @brief 翻转LED状态 + * @param None + * @retval None + */ +void RUN_LED(void) +{ + HAL_GPIO_TogglePin(RUN_LED_GPIO_Port, RUN_LED_Pin); +} + /** * @brief 打开mppt电感后的输出mos管 * @param None @@ -106,6 +116,17 @@ void EN_PWMOUT_Diseable(void) HAL_GPIO_WritePin(EN_PWMOUT_GPIO_Port, EN_PWMOUT_Pin, GPIO_PIN_SET); } +/** + * @brief 喂狗 + * @param None + * @retval None + */ +void feedDog(void) +{ + HAL_GPIO_WritePin(WDI_INPUT_GPIO_Port, WDI_INPUT_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(WDI_INPUT_GPIO_Port, WDI_INPUT_Pin, GPIO_PIN_RESET); +} + /** * @brief 仅有充电控制器时,判断输出开关是否打开 * @param None diff --git a/APP/functionalModule/Src/FM_TIM.c b/APP/functionalModule/Src/FM_TIM.c index 9401923..0065b42 100644 --- a/APP/functionalModule/Src/FM_TIM.c +++ b/APP/functionalModule/Src/FM_TIM.c @@ -16,32 +16,27 @@ void tim_Init(void) HD_PWM_Init(); /* 得到pwm的分辨率 */ PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000; + HAL_TIM_Base_Start(&htim3); HD_controlTim_Init(); + HAL_TIM_Base_Start_IT(&htim7); HD_taskBaseTim_Init(); - - HD_checkAbnormalTim_Init(); + HAL_TIM_Base_Start_IT(&htim16); HD_time_Init(); + HAL_TIM_Base_Start_IT(&htim15); } + /** * @brief 停止PWM信号输出 - * - * 本函数通过设置PWM脉冲宽度为0来停止PWM信号输出,然后调用HAL库函数进行PWM相关的硬件资源初始化。 - * 注意:这里使用了硬件抽象层(HAL)库提供的函数,特定于STM32微控制器。 */ void pwm_Stop(void) { // 设置PWM脉冲宽度为0, effectively停止PWM信号输出 set_pwmPulse(0); - HAL_TIM_Base_Stop_IT(&htim15); - - // HAL_TIM_OC_MspDeInit(&htim3); - - // 调用HAL库函数进行PWM相关的硬件资源De初始化 - // HAL_TIM_PWM_MspDeInit(&htim3); + HAL_TIM_Base_Stop(&htim3); } /** @@ -100,10 +95,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) TimeSliceOffset_Produce(); } - else if (htim->Instance == TIM17) { - checkAbnormal(); - } - else if (htim->Instance == TIM15) { hw_inc_tick(); } diff --git a/APP/functionalModule/Src/capture.c b/APP/functionalModule/Src/capture.c index ad2913e..0fe6440 100644 --- a/APP/functionalModule/Src/capture.c +++ b/APP/functionalModule/Src/capture.c @@ -99,6 +99,8 @@ enum { CHG_CURR_NUM = 3, }; int16_t adcBuff[4]; +/* 指向adcCapture中的inData16数组中的第一位也是最后一位 */ +uint8_t pointer; adcCapture WORK_VOLT_capture = {0}; adcCapture DSG_CURR_capture = {0}; @@ -117,12 +119,20 @@ static float P_PV_VOLT_IN1 = 0; const float32_t Proportion = 3.0 / 4095.0; /* matlab生成的5阶滤波器系数 */ -const int firLen = 6; -const float firLP[6] = { - 0.01861755922, -0.1146286726, 0.5962908864, 0.5962908864, -0.1146286726, - 0.01861755922 +// const int firLen = 6; +// const float firLP[6] = { +// 0.01861755922, -0.1146286726, 0.5962908864, 0.5962908864, -0.1146286726, +// 0.01861755922 +// }; + +/* matlab生成的3阶滤波器系数 */ +const int firLen = 4; +const float firLP[4] = { + 0.178709805, 0.3671073616, 0.3671073616, 0.178709805 }; +void captureFirInit(void); + /** * @brief 初始化adc * @param @@ -139,6 +149,9 @@ void ADC_Capture_Init(void) HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED); HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED); + /* 初始化滤波器 */ + captureFirInit(); + HAL_TIM_Base_Start(&htim6); HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuff, 4); @@ -387,18 +400,54 @@ float get_MOSFET_Temper(void) void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma) { if (hdma->Instance == ADC1) { - arm_copy_f32(WORK_VOLT_capture.inDataF, WORK_VOLT_capture.inDataF + 1, 5); - arm_copy_f32(DSG_CURR_capture.inDataF, DSG_CURR_capture.inDataF + 1, 5); - arm_copy_f32(PV_VOLT_IN_capture.inDataF, PV_VOLT_IN_capture.inDataF + 1, 5); - arm_copy_f32(CHG_CURR_capture.inDataF, CHG_CURR_capture.inDataF + 1, 5); + WORK_VOLT_capture.totalInData -= WORK_VOLT_capture.inData16[pointer]; + DSG_CURR_capture.totalInData -= DSG_CURR_capture.inData16[pointer]; + PV_VOLT_IN_capture.totalInData -= PV_VOLT_IN_capture.inData16[pointer]; + CHG_CURR_capture.totalInData -= CHG_CURR_capture.inData16[pointer]; - WORK_VOLT_capture.inDataF[5] = (float32_t)adcBuff[WORK_VOLT_NUM]; - DSG_CURR_capture.inDataF[5] = (float32_t)adcBuff[DSG_CURR_NUM]; - PV_VOLT_IN_capture.inDataF[5] = (float32_t)adcBuff[PV_VOLT_IN_NUM]; - CHG_CURR_capture.inDataF[5] = (float32_t)adcBuff[CHG_CURR_NUM]; + WORK_VOLT_capture.inData16[pointer] = adcBuff[WORK_VOLT_NUM]; + DSG_CURR_capture.inData16[pointer] = adcBuff[DSG_CURR_NUM]; + PV_VOLT_IN_capture.inData16[pointer] = adcBuff[PV_VOLT_IN_NUM]; + CHG_CURR_capture.inData16[pointer] = adcBuff[CHG_CURR_NUM]; + + WORK_VOLT_capture.totalInData += WORK_VOLT_capture.inData16[pointer]; + DSG_CURR_capture.totalInData += DSG_CURR_capture.inData16[pointer]; + PV_VOLT_IN_capture.totalInData += PV_VOLT_IN_capture.inData16[pointer]; + CHG_CURR_capture.totalInData += CHG_CURR_capture.inData16[pointer]; + + pointer++; + if (pointer >= indata16_size) { + pointer = 0; + } + + arm_copy_f32(WORK_VOLT_capture.IODataF + 1, WORK_VOLT_capture.IODataF, 3); + arm_copy_f32(DSG_CURR_capture.IODataF + 1, DSG_CURR_capture.IODataF, 3); + arm_copy_f32(PV_VOLT_IN_capture.IODataF + 1, PV_VOLT_IN_capture.IODataF, 3); + arm_copy_f32(CHG_CURR_capture.IODataF + 1, CHG_CURR_capture.IODataF, 3); + + WORK_VOLT_capture.IODataF[3] = (float32_t)WORK_VOLT_capture.totalInData / indata16_size; + DSG_CURR_capture.IODataF[3] = (float32_t)DSG_CURR_capture.totalInData / indata16_size; + PV_VOLT_IN_capture.IODataF[3] = (float32_t)PV_VOLT_IN_capture.totalInData / indata16_size; + CHG_CURR_capture.IODataF[3] = (float32_t)CHG_CURR_capture.totalInData / indata16_size; } } +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); +} + + /** * @brief 将采集得到的adc进行滤波 * @param None @@ -406,39 +455,26 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma) */ void adcCaptureFir(void) { - static arm_fir_instance_f32 armFirInstanceF32; - static float32_t *inputF32, *outputF32; - static uint32_t blockSize = 1; - static float32_t firStateF32[6]; /* 状态缓存 */ - static float32_t outputf; - - /* 初始化结构体 */ - arm_fir_init_f32(&armFirInstanceF32, - firLen, - (float_t *)&firLP[0], - &firStateF32[0], - blockSize); - /* 初始化输入输出缓存指针 */ - inputF32 = &WORK_VOLT_capture.inDataF[0]; + inputF32 = &WORK_VOLT_capture.IODataF[0]; outputF32 = &outputf; arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); WORK_VOLT_capture.outData = (int16_t)outputf; /* 初始化输入输出缓存指针 */ - inputF32 = &DSG_CURR_capture.inDataF[0]; + inputF32 = &DSG_CURR_capture.IODataF[0]; outputF32 = &outputf; arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); DSG_CURR_capture.outData = (int16_t)outputf; /* 初始化输入输出缓存指针 */ - inputF32 = &PV_VOLT_IN_capture.inDataF[0]; + inputF32 = &PV_VOLT_IN_capture.IODataF[0]; outputF32 = &outputf; arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); PV_VOLT_IN_capture.outData = (int16_t)outputf; /* 初始化输入输出缓存指针 */ - inputF32 = &CHG_CURR_capture.inDataF[0]; + inputF32 = &CHG_CURR_capture.IODataF[0]; outputF32 = &outputf; arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize); CHG_CURR_capture.outData = (int16_t)outputf; diff --git a/APP/functionalModule/Src/checkTime.c b/APP/functionalModule/Src/checkTime.c index fe24e09..6e78bd3 100644 --- a/APP/functionalModule/Src/checkTime.c +++ b/APP/functionalModule/Src/checkTime.c @@ -21,6 +21,9 @@ static timeData checkTimeData; volatile static uint32_t hw_sys_tick_ms = 0; //ms 自增计数变量 +float checkAbnormalTime; + + #define tim TIM15 #define timLard 36000.0 diff --git a/APP/hardwareDriver/Src/HD_TIM.c b/APP/hardwareDriver/Src/HD_TIM.c index b81fad7..5a900e9 100644 --- a/APP/hardwareDriver/Src/HD_TIM.c +++ b/APP/hardwareDriver/Src/HD_TIM.c @@ -30,16 +30,6 @@ void HD_taskBaseTim_Init(void) MX_TIM16_Init(); } -/** - * @brief 该定时器中断中检测异常情况,并完成数据的采集 - * @param None - * @retval None - */ -void HD_checkAbnormalTim_Init(void) -{ - MX_TIM17_Init(); -} - /** * @brief 该定时器用来计时从而判断执行时间 * @param None diff --git a/Core/Inc/stm32g4xx_it.h b/Core/Inc/stm32g4xx_it.h index cf273fc..6ae9d66 100644 --- a/Core/Inc/stm32g4xx_it.h +++ b/Core/Inc/stm32g4xx_it.h @@ -58,7 +58,6 @@ void SysTick_Handler(void); void DMA1_Channel1_IRQHandler(void); void TIM1_BRK_TIM15_IRQHandler(void); void TIM1_UP_TIM16_IRQHandler(void); -void TIM1_TRG_COM_TIM17_IRQHandler(void); void USART2_IRQHandler(void); void USART3_IRQHandler(void); void EXTI15_10_IRQHandler(void); diff --git a/Core/Inc/tim.h b/Core/Inc/tim.h index d3df754..99c8c91 100644 --- a/Core/Inc/tim.h +++ b/Core/Inc/tim.h @@ -42,8 +42,6 @@ extern TIM_HandleTypeDef htim15; extern TIM_HandleTypeDef htim16; -extern TIM_HandleTypeDef htim17; - /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ @@ -53,7 +51,6 @@ void MX_TIM6_Init(void); void MX_TIM7_Init(void); void MX_TIM15_Init(void); void MX_TIM16_Init(void); -void MX_TIM17_Init(void); void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); diff --git a/Core/Src/main.c b/Core/Src/main.c index cd83a32..fbf2108 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -93,20 +93,19 @@ 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_TIM17_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(); diff --git a/Core/Src/stm32g4xx_it.c b/Core/Src/stm32g4xx_it.c index 0493bcb..529c085 100644 --- a/Core/Src/stm32g4xx_it.c +++ b/Core/Src/stm32g4xx_it.c @@ -60,7 +60,6 @@ extern TIM_HandleTypeDef htim6; extern TIM_HandleTypeDef htim7; extern TIM_HandleTypeDef htim15; extern TIM_HandleTypeDef htim16; -extern TIM_HandleTypeDef htim17; extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; extern TIM_HandleTypeDef htim1; @@ -256,20 +255,6 @@ void TIM1_UP_TIM16_IRQHandler(void) /* USER CODE END TIM1_UP_TIM16_IRQn 1 */ } -/** - * @brief This function handles TIM1 trigger and commutation interrupts and TIM17 global interrupt. - */ -void TIM1_TRG_COM_TIM17_IRQHandler(void) -{ - /* USER CODE BEGIN TIM1_TRG_COM_TIM17_IRQn 0 */ - - /* USER CODE END TIM1_TRG_COM_TIM17_IRQn 0 */ - HAL_TIM_IRQHandler(&htim17); - /* USER CODE BEGIN TIM1_TRG_COM_TIM17_IRQn 1 */ - - /* USER CODE END TIM1_TRG_COM_TIM17_IRQn 1 */ -} - /** * @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26. */ diff --git a/Core/Src/tim.c b/Core/Src/tim.c index b486d70..333d3eb 100644 --- a/Core/Src/tim.c +++ b/Core/Src/tim.c @@ -29,7 +29,6 @@ TIM_HandleTypeDef htim6; TIM_HandleTypeDef htim7; TIM_HandleTypeDef htim15; TIM_HandleTypeDef htim16; -TIM_HandleTypeDef htim17; /* TIM3 init function */ void MX_TIM3_Init(void) @@ -156,9 +155,9 @@ void MX_TIM15_Init(void) /* USER CODE END TIM15_Init 1 */ htim15.Instance = TIM15; - htim15.Init.Prescaler = 1; + htim15.Init.Prescaler = 10; htim15.Init.CounterMode = TIM_COUNTERMODE_UP; - htim15.Init.Period = 35999; + htim15.Init.Period = 7199; htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim15.Init.RepetitionCounter = 0; htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; @@ -208,33 +207,6 @@ void MX_TIM16_Init(void) /* USER CODE END TIM16_Init 2 */ -} -/* TIM17 init function */ -void MX_TIM17_Init(void) -{ - - /* USER CODE BEGIN TIM17_Init 0 */ - - /* USER CODE END TIM17_Init 0 */ - - /* USER CODE BEGIN TIM17_Init 1 */ - - /* USER CODE END TIM17_Init 1 */ - htim17.Instance = TIM17; - htim17.Init.Prescaler = 71; - htim17.Init.CounterMode = TIM_COUNTERMODE_UP; - htim17.Init.Period = 199; - htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - htim17.Init.RepetitionCounter = 0; - htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - if (HAL_TIM_Base_Init(&htim17) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN TIM17_Init 2 */ - - /* USER CODE END TIM17_Init 2 */ - } void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle) @@ -316,21 +288,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) /* USER CODE END TIM16_MspInit 1 */ } - else if(tim_baseHandle->Instance==TIM17) - { - /* USER CODE BEGIN TIM17_MspInit 0 */ - - /* USER CODE END TIM17_MspInit 0 */ - /* TIM17 clock enable */ - __HAL_RCC_TIM17_CLK_ENABLE(); - - /* TIM17 interrupt Init */ - HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM17_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM17_IRQn); - /* USER CODE BEGIN TIM17_MspInit 1 */ - - /* USER CODE END TIM17_MspInit 1 */ - } } void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle) { @@ -435,20 +392,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) /* USER CODE END TIM16_MspDeInit 1 */ } - else if(tim_baseHandle->Instance==TIM17) - { - /* USER CODE BEGIN TIM17_MspDeInit 0 */ - - /* USER CODE END TIM17_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_TIM17_CLK_DISABLE(); - - /* TIM17 interrupt Deinit */ - HAL_NVIC_DisableIRQ(TIM1_TRG_COM_TIM17_IRQn); - /* USER CODE BEGIN TIM17_MspDeInit 1 */ - - /* USER CODE END TIM17_MspDeInit 1 */ - } } /* USER CODE BEGIN 1 */ diff --git a/EWARM/chargeController.ewp b/EWARM/chargeController.ewp index e2e3c56..993727d 100644 --- a/EWARM/chargeController.ewp +++ b/EWARM/chargeController.ewp @@ -1,1333 +1,1332 @@ - 4 - - chargeController - - ARM - - 1 - - General - 3 - - 36 - 1 + 4 + + chargeController + + ARM + 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 - - - - - APP + + 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 + + + - application - - $PROJ_DIR$\..\APP\application\Src\chargControl.c - - - $PROJ_DIR$\..\APP\application\Src\comm.c - - - $PROJ_DIR$\..\APP\application\Src\start.c - - - $PROJ_DIR$\..\APP\application\Src\task.c - + 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 + + - 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\test.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 + + + - 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 - + 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 + + - 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 - + Middlewares + + Library + + DSP Library/DSP Library + + $PROJ_DIR$\..\Middlewares\ST\ARM\DSP\Lib\iar_cortexM4lf_math.a + + + - User - - Core + tools - $PROJ_DIR$\..\Core\Src\main.c + $PROJ_DIR$\..\tools\RingQueue\ring_queue.c - $PROJ_DIR$\..\Core\Src\gpio.c + $PROJ_DIR$\..\tools\TimeSliceOffset\timeSliceOffset.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/EWARM/chargeController.ewt b/EWARM/chargeController.ewt index 328c086..41080e0 100644 --- a/EWARM/chargeController.ewt +++ b/EWARM/chargeController.ewt @@ -1439,9 +1439,6 @@ $PROJ_DIR$\..\APP\application\Src\start.c - - $PROJ_DIR$\..\APP\application\Src\task.c - businessLogic @@ -1463,6 +1460,9 @@ $PROJ_DIR$\..\APP\businessLogic\Src\parameter.c + + $PROJ_DIR$\..\APP\businessLogic\Src\task.c + $PROJ_DIR$\..\APP\businessLogic\Src\test.c diff --git a/chargeController.ioc b/chargeController.ioc index 00bb2a3..88b4319 100644 --- a/chargeController.ioc +++ b/chargeController.ioc @@ -69,10 +69,9 @@ Mcu.IP0=ADC1 Mcu.IP1=ADC2 Mcu.IP10=TIM15 Mcu.IP11=TIM16 -Mcu.IP12=TIM17 -Mcu.IP13=UART4 -Mcu.IP14=USART2 -Mcu.IP15=USART3 +Mcu.IP12=UART4 +Mcu.IP13=USART2 +Mcu.IP14=USART3 Mcu.IP2=DMA Mcu.IP3=NVIC Mcu.IP4=RCC @@ -81,7 +80,7 @@ Mcu.IP6=SYS Mcu.IP7=TIM3 Mcu.IP8=TIM6 Mcu.IP9=TIM7 -Mcu.IPNb=16 +Mcu.IPNb=15 Mcu.Name=STM32G431R(6-8-B)Tx Mcu.Package=LQFP64 Mcu.Pin0=PC13 @@ -115,15 +114,14 @@ Mcu.Pin33=VP_TIM6_VS_ClockSourceINT Mcu.Pin34=VP_TIM7_VS_ClockSourceINT Mcu.Pin35=VP_TIM15_VS_ClockSourceINT Mcu.Pin36=VP_TIM16_VS_ClockSourceINT -Mcu.Pin37=VP_TIM17_VS_ClockSourceINT -Mcu.Pin38=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0 +Mcu.Pin37=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0 Mcu.Pin4=PC2 Mcu.Pin5=PA0 Mcu.Pin6=PA1 Mcu.Pin7=PA2 Mcu.Pin8=PA3 Mcu.Pin9=PA4 -Mcu.PinsNb=39 +Mcu.PinsNb=38 Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0 Mcu.ThirdPartyNb=1 Mcu.UserConstants= @@ -143,7 +141,6 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false NVIC.TIM1_BRK_TIM15_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.TIM1_TRG_COM_TIM17_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.TIM1_UP_TIM16_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true NVIC.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.TIM7_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true @@ -377,9 +374,6 @@ TIM15.Prescaler=10 TIM16.IPParameters=Prescaler,PeriodNoDither TIM16.PeriodNoDither=999 TIM16.Prescaler=71 -TIM17.IPParameters=Prescaler,PeriodNoDither -TIM17.PeriodNoDither=199 -TIM17.Prescaler=71 TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4 TIM3.PeriodNoDither=720 @@ -407,8 +401,6 @@ VP_TIM15_VS_ClockSourceINT.Mode=Internal VP_TIM15_VS_ClockSourceINT.Signal=TIM15_VS_ClockSourceINT VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT -VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer -VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer diff --git a/tools/fdacoefs-3(100-10-30).h b/tools/fdacoefs-3(100-10-30).h new file mode 100644 index 0000000..b6001df --- /dev/null +++ b/tools/fdacoefs-3(100-10-30).h @@ -0,0 +1,31 @@ +/* + * Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool + * Generated by MATLAB(R) 9.13 and Signal Processing Toolbox 9.1. + * Generated on: 09-Dec-2024 10:57:55 + */ + +/* + * 离散时间 FIR 滤波器(实数) + * ---------------- + * 滤波器结构 : 直接型 FIR + * 滤波器长度 : 4 + * 稳定 : 是 + * 线性相位 : 是 (Type 2) + */ + +/* General type conversion for MATLAB generated C-code */ +// #include "tmwtypes.h" +/* + * Expected path to tmwtypes.h + * C:\Program Files\MATLAB\R2022b\extern\include\tmwtypes.h + */ +/* + * Warning - Filter coefficients were truncated to fit specified data type. + * The resulting response may not match generated theoretical response. + * Use the Filter Design & Analysis Tool to design accurate + * single-precision filter coefficients. + */ +// const int BL = 4; +// const real32_T B[4] = { +// 0.178709805, 0.3671073616, 0.3671073616, 0.178709805 +// };