Compare commits

..

No commits in common. "df087307529fa0bdf055eb6ed4f6c3cba2d729b8" and "973601bb896e075b20d7c65c58e4959ff7f64106" have entirely different histories.

45 changed files with 1431 additions and 3935 deletions

File diff suppressed because one or more lines are too long

15
.vscode/settings.json vendored
View File

@ -10,19 +10,6 @@
"fm_tim.h": "c", "fm_tim.h": "c",
"timesliceoffset.h": "c", "timesliceoffset.h": "c",
"fm_gpio.h": "c", "fm_gpio.h": "c",
"pdebug.h": "c", "pdebug.h": "c"
"start.h": "c",
"bl_comm.h": "c",
"capture.h": "c",
"arm_math.h": "c",
"abnormalmanage.h": "c",
"stm32g431xx.h": "c",
"uart_dev.h": "c",
"hd_comm.h": "c",
"main.h": "c",
"hd_adc.h": "c",
"hd_tim.h": "c",
"checktime.h": "c",
"test.h": "c"
} }
} }

View File

@ -3,7 +3,6 @@
#define APP_COMM_H_ #define APP_COMM_H_
#include "comm_types.h" #include "comm_types.h"
#include "bl_comm.h"
void uart_comm(void); void uart_comm(void);

View File

@ -3,24 +3,18 @@
#include "parameter.h" #include "parameter.h"
#include "comm_types.h" #include "comm_types.h"
/**
* @brief
* @param
* @retval
*
*/
void chargControl(void) void chargControl(void)
{ {
// getCVData(); getCVData();
judgeYNBattery(); judgeYNBattery();
chargControlMode(); chargControlMode();
if (getMPPT_Mode() == noWork) { if (g_otherParameter.MPPT_Mode == noWork) {
return; return;
} }
if (getBatteryState()) { if (g_otherParameter.batteryState) {
BatteryChargControl(); BatteryChargControl();
} else { } else {
noBatteryChargControl(); noBatteryChargControl();

View File

@ -1,8 +1,6 @@
#include "start.h" #include "start.h"
#include "inFlash.h" #include "inFlash.h"
#include "TimeSliceOffset.h"
void start(void) void start(void)
{ {

View File

@ -1,11 +0,0 @@
#ifndef BL_PARAMETER_H_
#define BL_PARAMETER_H_
void Init(void);
#endif

View File

@ -1,15 +0,0 @@
#ifndef BL_ABNORMAL_MANAGE_H_
#define BL_ABNORMAL_MANAGE_H_
#include "FM_TIM.h"
void checkAbnormal(void);
#endif

View File

@ -3,13 +3,10 @@
#define BL_COMM_H_ #define BL_COMM_H_
#include "comm_types.h" #include "comm_types.h"
#include "uart_dev.h"
void GW485_comm(void); void GW485_comm(void);
void BAT485_comm(void); void BAT485_comm(void);
void gw485_RxIt(void);
void bat485_RxIt(void);
#endif #endif

View File

@ -1,12 +1,12 @@
#ifndef BL_PARAMETER_H_ #ifndef BL_PARAMETER_H_
#define BL_PARAMETER_H_ #define BL_PARAMETER_H_
#include "main.h" #include "main.h"
#include "comm_types.h"
#define softVer "SV01_24101501" #define softVer "SV01_24101501"
// #pragma pack(push,1) #pragma pack(push,1)
/* 主要有配置文件读取出来的数据 */ /* 主要有配置文件读取出来的数据 */
typedef struct _config_parameter{ typedef struct _config_parameter{
@ -30,10 +30,10 @@ typedef struct _config_parameter{
uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */ uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
/* SL */ /* SL */
uint8_t address[7]; /* 地址 */
uint16_t Access_Node_Type; /* 接入节点类型 */ uint16_t Access_Node_Type; /* 接入节点类型 */
uint16_t Communication_Methods; /* 通信方式 */ uint16_t Communication_Methods; /* 通信方式 */
uint16_t Registration_Status; /* 注册状态 */ uint16_t Registration_Status; /* 注册状态 */
uint8_t address[7]; /* 地址 */
uint8_t startFlagSL[2]; /* 起始标志 */ uint8_t startFlagSL[2]; /* 起始标志 */
uint8_t endFlagSL; /* 结束标志 */ uint8_t endFlagSL; /* 结束标志 */
@ -51,6 +51,7 @@ typedef struct _config_parameter{
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */ uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
} config_parameter; } config_parameter;
extern config_parameter g_cfgParameter; extern config_parameter g_cfgParameter;
typedef struct _otherParameter{ typedef struct _otherParameter{
float Battery_Voltage; /* 电池电压 (V) */ float Battery_Voltage; /* 电池电压 (V) */
float Output_Voltage; /* 输出电压 */ float Output_Voltage; /* 输出电压 */
@ -61,56 +62,26 @@ typedef struct _otherParameter{
float HighSideMos_Temperature; /* 高端mos的温度 (°C) */ float HighSideMos_Temperature; /* 高端mos的温度 (°C) */
float Solar_In_Circuit_Voltage; /* 太阳能板输入电压 (V) */ float Solar_In_Circuit_Voltage; /* 太阳能板输入电压 (V) */
float Charg_BatteryCurrent; /* 电池充电电流(流向电池) (A) */
float totalElectricityConsumption; /* 总电量消耗(W*H) */ float totalElectricityConsumption; /* 总电量消耗(W*H) */
float totalChargCapacity; /* 总充电电量(W*H) */ float totalChargCapacity; /* 总充电电量(W*H) */
float SOC; /* 剩余电量 */ float SOC; /* 剩余电量 */
int MPPT_Mode; /* 工作模式 */ uint16_t chargMos_State; /* 充电开关状态 */
uint16_t DischargMos_State; /* 放电mos的状态 */
uint16_t MPPT_Mode; /* 工作模式 */
uint8_t versionInformation[13]; /* 软件版本信息 */ uint8_t versionInformation[13]; /* 软件版本信息 */
uint8_t batteryState; /* 有无电池(估计) */
float dutyRatio; /* 占空比 */
}otherParameter; }otherParameter;
extern otherParameter g_otherParameter;
// #pragma pack(pop)
BOOL getBatteryState(void);
void setBatteryState(BOOL state);
float getDutyRatio(void);
void setDutyRatio(float DutyRatio);
void setDutyRatioToZero(void);
float getBatteryVoltage(void);
void setBatteryVoltage(void);
float getOutputVoltage(void);
void setOutputVoltage(void);
float getChargCurrent(void);
void setChargCurrent(void);
float getDischargCurrent(void);
void setDischargCurrent(void);
float getInputVoltage(void);
void setInputVoltage(void);
float getSolarOpenCircuitVoltage(void);
void setSolarOpenCircuitVoltage(void);
float getHighSideMosTemperature(void);
void setHighSideMosTemperature(void);
float getSolarInCircuitVoltage(void);
void setSolarInCircuitVoltage(void);
float getTotalElectricityConsumption(void);
void setTotalElectricityConsumption(void);
void totalElectricityConsumptionInt(float totalPower);
float getTotalChargCapacity(void);
void setTotalChargCapacity(void);
void totalChargCapacityInt(float totalPower);
float getSOC(void);
void setSOC(void);
int getMPPT_Mode(void);
void setMPPT_Mode(int MPPT_Mode);
float getChargBatteryCurrent(void);
BOOL getChargMosState(void);
void setChargMosState(BOOL state);
BOOL getDischargMosState(void);
uint8_t *getVersionInformation(void);

View File

@ -1,8 +0,0 @@
#ifndef BL_TEST_H_
#define BL_TEST_H_
void test(void);
#endif

View File

@ -1,23 +0,0 @@
#include "Init.h"
#include "capture.h"
#include "FM_GPIO.h"
#include "inFlash.h"
#include "parameter.h"
#include "FM_GPIO.h"
#include "FM_TIM.h"
extern int getMPPT_Mode(void);
void Init(void)
{
config_info_start();
ADC_Capture_Init();
proportionalInt(getMPPT_Mode());
FM_GPIO_Init();
tim_Init();
}

View File

@ -1,25 +0,0 @@
#include "abnormalManage.h"
#include "parameter.h"
#include "capture.h"
void checkAbnormal(void)
{
/* 滤波 */
adcCaptureFir();
/* 转换 */
setChargCurrent();
setDischargCurrent();
setOutputVoltage();
setSolarInCircuitVoltage();
/* 判断异常状态 */
}

View File

@ -2,8 +2,6 @@
#include "bl_chargControl.h" #include "bl_chargControl.h"
#include "parameter.h" #include "parameter.h"
#include "comm_types.h" #include "comm_types.h"
#include "FM_GPIO.h"
static void stopChargWork(void); static void stopChargWork(void);
static BOOL stopChargConditions(void); static BOOL stopChargConditions(void);
@ -13,378 +11,6 @@ static BOOL constantVChargConditions(void);
static void mpptCharge(void); static void mpptCharge(void);
static void constantVoltageCharge(void); static void constantVoltageCharge(void);
static void floatCharge(void); static void floatCharge(void);
static void mppt_constantVoltage(float InVoltage);
static void mppt_constantVoltageNoBatteryO(float OutVoltage);
static void mppt_constantVoltageO(float OutVoltage);
/**
* @brief
* @param InVoltage
* @retval
*
*/
void mppt_constantVoltage(float InVoltage)
{
static float kp = 0.005;
static float ki = 0.00001;
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;
setDutyRatio((getDutyRatio() + stepPwm));
set_pwmDutyRatio(getDutyRatio());
}
/**
* @brief ()
* @param
* @retval
*
*/
void mppt_constantVoltageNoBatteryO(float OutVoltage)
{
static float kp = 0.005;
static float ki = 0.00001;
static float outVolt;
static float error;
static float stepPwm;
outVolt = getOutputVoltage();
error = OutVoltage - outVolt;
stepPwm = kp * error + ki * outVolt;
setDutyRatio((getDutyRatio() + stepPwm));
set_pwmDutyRatio(getDutyRatio());
}
/**
* @brief
* @param
* @retval
*
*/
void mppt_constantVoltageO(float OutVoltage)
{
// static float lastVolt = 0;
// static float lastStepPwm = 0;
static float lastDutyRatio = 0;
static float kp = 0.005;
static float ki = 0.00001;
static float outVolt;
static float error;
static float StepPwm;
outVolt = getOutputVoltage();
error = OutVoltage - outVolt;
StepPwm = kp * error + ki * outVolt;
/* 当有电池时,输出电压的曲线是先上升后下降 */
if (lastDutyRatio >= getDutyRatio()) {
// if (lastVolt >= outVolt) {
setDutyRatio((getDutyRatio() - StepPwm));
// } else {
// g_controlParameter.dutyRatio -= StepPwm;
// }
} else {
// if (lastVolt >= outVolt) {
// g_controlParameter.dutyRatio -= StepPwm;
// } else {
// g_controlParameter.dutyRatio += StepPwm;
// }
setDutyRatio((getDutyRatio() + StepPwm));
}
// lastVolt = outVolt;
// lastStepPwm = StepPwm;
lastDutyRatio = getDutyRatio();
set_pwmDutyRatio(getDutyRatio());
}
/**
* @brief
* @param
* @retval
*
*/
void mppt_readJust(void)
{
/* 调节占空比 */
// static float_t step1 = 0.01;
// static float_t step2 = 0.003;
// static float_t tempV = 0.2;
// static float_t i = 0.005;
// static uint16_t flag = 0;
// static float_t lastSolarInCircuitVoltage = 0;
// static float_t lastPower = 0;
// flag++;
// if (flag < 500) {
// return;
// }
// flag = 0;
//
// float_t SolarInCircuitVoltage = get_PV1_VOLT_IN();
// float_t power = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
//
// float_t voltageDifference = SolarInCircuitVoltage - lastSolarInCircuitVoltage;
//
// /* 输出电压随占空比增加电压减小 */
// if (power <= lastPower) {
// if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
// if (voltageDifference > tempV) {
// g_controlParameter.dutyRatio += step2 + voltageDifference / i;
// } else {
// g_controlParameter.dutyRatio += step1 + voltageDifference / i;
// }
// } else {
// if (voltageDifference < -tempV) {
// g_controlParameter.dutyRatio -= step2 + voltageDifference / i;
// } else {
// g_controlParameter.dutyRatio -= step1 + voltageDifference / i;
// }
// }
// } else {
// if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
// if (voltageDifference > tempV) {
// g_controlParameter.dutyRatio -= step2 - voltageDifference / i;
// } else {
// g_controlParameter.dutyRatio -= step1 - voltageDifference / i;
// }
// } else {
// if (voltageDifference < -tempV) {
// g_controlParameter.dutyRatio += step2 - voltageDifference / i;
// } else {
// g_controlParameter.dutyRatio += step1 - voltageDifference / i;
// }
// }
// }
//
// lastPower = power;
// lastSolarInCircuitVoltage = SolarInCircuitVoltage;
//
// Set_duty_ratio(&g_controlParameter.dutyRatio);
/* 调节电压,变步长调节 */
// static float_t Power3 = 0; //上上次功率
// static float_t Power2 = 0; //上次功率
// static float_t Power1 = 0; //当前功率
// static float_t power23 = 0; //上次和上上次功率的绝对值
// static float_t power12 = 0; //当前功率和上次功率的绝对值
//// static float_t SolarInCircuitVoltage3 = 0; //上上次太阳能板电压
// static float_t SolarInCircuitVoltage2 = 0; //上次太阳能板电压
// static float_t SolarInCircuitVoltage1 = 0; //当前太阳能板电压
// static float_t SolarInCircuitVoltage12 = 0; //当前太阳能板电压和上次太阳能板电压的绝对值
// SolarInCircuitVoltage1 = get_PV1_VOLT_IN();
// Power1 = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
// static float_t power12Abs = 0;
// static float_t power23Abs = 0;
// static float_t SolarInCircuitVoltage12Abs = 0;
// static float_t dk = 0; //变步长因子
// static float_t stepV = 0;
// static float_t SolarInCircuitV = 18; //控制太阳能板的输出电压稳定在该值
//
// static float_t kp = 0.005;
// static float_t ki = 0.00001;
//
// /* 延时一段时间才判断 */
// static uint16_t flag = 0;
// flag++;
// if (flag < 1000) {
//// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
// float_t pv1Volt = SolarInCircuitVoltage1;
// float_t error = pv1Volt - SolarInCircuitV;
// float_t stepPwm = kp * error + ki * pv1Volt;
//
// g_controlParameter.dutyRatio += stepPwm;
//
// /* 过温保护 */
// if (g_otherParameter.overTemperature == 0) {
//
// } else if (g_otherParameter.overTemperature == 1) {
// g_controlParameter.dutyRatio -= 0.1;
// } else if (g_otherParameter.overTemperature == 2) {
// g_controlParameter.dutyRatio -= 0.2;
// } else if (g_otherParameter.overTemperature == 3) {
// g_controlParameter.dutyRatio -= 0.3;
// }
//
// Set_duty_ratio(&g_controlParameter.dutyRatio);
//
// return;
// }
// flag = 0;
//
// power23 = Power2 - Power3;
// if (power23 < 0) {
// power23Abs = -power23;
// } else {
// power23Abs = power23;
// }
//
// power12 = Power1 - Power2;
// if (power12 < 0) {
// power12Abs = -power12;
// } else {
// power12Abs = power12;
// }
//
//// SolarInCircuitVoltage23 = SolarInCircuitVoltage2 - SolarInCircuitVoltage3;
//
// SolarInCircuitVoltage12 = SolarInCircuitVoltage1 - SolarInCircuitVoltage2;
//
// dk = power12Abs / power23Abs;
// stepV = dk * SolarInCircuitVoltage12Abs;
//
//// printf(" dk : %d/10000 \n", (int)(dk * 10000));
//
// if (power12 > 0) {
// if (SolarInCircuitVoltage12 > 0) {
// SolarInCircuitV = SolarInCircuitVoltage1 + stepV;
// } else {
// SolarInCircuitV = SolarInCircuitVoltage1 - stepV;
// }
// } else {
// if (SolarInCircuitVoltage12 > 0) {
// SolarInCircuitV = SolarInCircuitVoltage1 - stepV;
// } else {
// SolarInCircuitV = SolarInCircuitVoltage1 + stepV;
// }
// }
//
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
//
// if (SolarInCircuitV > 21) {
// SolarInCircuitV = 21;
// }
// else if (SolarInCircuitV < 15) {
// SolarInCircuitV = 15;
// }
//
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
//
// Power3 = Power2;
// Power2 = Power1;
//// SolarInCircuitVoltage3 = SolarInCircuitVoltage2;
// SolarInCircuitVoltage2 = SolarInCircuitVoltage1;
//
//// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
// float_t pv1Volt = SolarInCircuitVoltage1;
// float_t error = pv1Volt - SolarInCircuitV;
// float_t stepPwm = kp * error + ki * pv1Volt;
//
// g_controlParameter.dutyRatio += stepPwm;
//
// /* 过温保护 */
// if (g_otherParameter.overTemperature == 0) {
//
// } else if (g_otherParameter.overTemperature == 1) {
// g_controlParameter.dutyRatio -= 0.1;
// } else if (g_otherParameter.overTemperature == 2) {
// g_controlParameter.dutyRatio -= 0.2;
// } else if (g_otherParameter.overTemperature == 3) {
// g_controlParameter.dutyRatio -= 0.3;
// }
//
// Set_duty_ratio(&g_controlParameter.dutyRatio);
//
// return;
/* 调节电压,两个电压步调节 */
static float Power = 0;
Power = getOutputVoltage() * getChargCurrent();
static float lPower = 0;
// static float lLPower = 0;
// static float lLLPower = 0;
static float SolarInCircuitV = 17; //控制太阳能板的输出电压稳定在该值,初始为17V
// static float kp = 0.005;
// static float ki = 0.00001;
static float stepV1 = 0.5;
static float stepV2 = 0.2;
static uint8_t flag1 = 0; //表明上次运算是加还是减
/* 延时一段时间才判断 */
static uint16_t flag = 0;
flag++;
if (flag < 150) {
// float pv1Volt = getSolarInCircuitVoltage();
// float error = pv1Volt - SolarInCircuitV;
// float stepPwm = kp * error + ki * pv1Volt;
// setDutyRatio((getDutyRatio() + stepPwm));
// set_pwmDutyRatio(getDutyRatio());
mppt_constantVoltage(SolarInCircuitV);
return;
}
flag = 0;
static float powerT = 0;
powerT = Power - lPower;
if (powerT < 0) {
powerT = -powerT;
}
// if ((lPower + 0.7 < Power) && (lLPower + 0.7 < Power) && (lLLPower + 0.7 < Power)) {
// if ((lPower + 0.7 < Power) && (lLPower + 0.7 < Power)) {
if ((lPower + 0.3f < Power)) {
if (powerT > 5) {
if (flag1) {
SolarInCircuitV += stepV1;
flag1 = 1;
} else {
SolarInCircuitV -= stepV1;
flag1 = 0;
}
} else {
if (flag1) {
SolarInCircuitV += stepV2;
flag1 = 1;
} else {
SolarInCircuitV -= stepV2;
flag1 = 0;
}
}
// } else if ((lPower - 0.7 > Power) && (lLPower - 0.7 > Power) && (lLLPower - 0.7 > Power)) {
// } else if ((lPower - 0.7 > Power) && (lLPower - 0.7 > Power)) {
} else if ((lPower - 0.3f > Power)) {
if (powerT > 5) {
if (flag1) {
SolarInCircuitV -= stepV1;
flag1 = 0;
} else {
SolarInCircuitV += stepV1;
flag1 = 1;
}
} else {
if (flag1) {
SolarInCircuitV -= stepV2;
flag1 = 0;
} else {
SolarInCircuitV += stepV2;
flag1 = 1;
}
}
}
if (SolarInCircuitV > 18.5f) {
SolarInCircuitV = 18.5f;
}
else if (SolarInCircuitV < 16.0f) {
SolarInCircuitV = 16.0f;
}
lPower = Power;
}
/** /**
* @brief * @brief
@ -394,8 +20,7 @@ void mppt_readJust(void)
*/ */
void stopChargWork(void) void stopChargWork(void)
{ {
EN_PWMOUT_Diseable();
pwm_Stop();
} }
/** /**
@ -407,10 +32,7 @@ void stopChargWork(void)
*/ */
BOOL stopChargConditions(void) BOOL stopChargConditions(void)
{ {
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV
&& getChargCurrent() < 0.1f) {
return TRUE;
}
return FALSE; return FALSE;
} }
@ -424,12 +46,7 @@ BOOL stopChargConditions(void)
*/ */
BOOL floatChargConditions(void) BOOL floatChargConditions(void)
{ {
if (g_cfgParameter.constantVoltageChargeV < getBatteryVoltage()
&& g_cfgParameter.floatI > getChargCurrent()) {
return TRUE;
}
return FALSE; return FALSE;
} }
@ -469,19 +86,19 @@ void chargControlMode(void)
{ {
if (stopChargConditions()) { if (stopChargConditions()) {
stopChargWork(); stopChargWork();
setMPPT_Mode(noWork); g_otherParameter.MPPT_Mode = noWork;
} }
if (floatChargConditions()) { if (floatChargConditions()) {
setMPPT_Mode(floatCharg); g_otherParameter.MPPT_Mode = floatCharg;
} }
if (mpptChargConditions()) { if (mpptChargConditions()) {
setMPPT_Mode(MPPT); g_otherParameter.MPPT_Mode = MPPT;
} }
if (constantVChargConditions()) { if (constantVChargConditions()) {
setMPPT_Mode(constantVoltage); g_otherParameter.MPPT_Mode = constantVoltage;
} }
} }
@ -504,10 +121,7 @@ void getCVData(void)
*/ */
void judgeYNBattery(void) void judgeYNBattery(void)
{ {
if (getBatteryVoltage() > 16 || getBatteryVoltage() < 10) {
setBatteryState(FALSE);
return;
}
} }
/** /**
@ -518,7 +132,7 @@ void judgeYNBattery(void)
*/ */
void noBatteryChargControl(void) void noBatteryChargControl(void)
{ {
mppt_constantVoltageNoBatteryO(g_cfgParameter.FloatV);
} }
/** /**
@ -529,7 +143,7 @@ void noBatteryChargControl(void)
*/ */
void mpptCharge(void) void mpptCharge(void)
{ {
mppt_readJust();
} }
/** /**
@ -540,7 +154,8 @@ void mpptCharge(void)
*/ */
void constantVoltageCharge(void) void constantVoltageCharge(void)
{ {
mppt_constantVoltageO(g_cfgParameter.constantVoltageChargeV);
} }
/** /**
@ -551,7 +166,7 @@ void constantVoltageCharge(void)
*/ */
void floatCharge(void) void floatCharge(void)
{ {
mppt_constantVoltageO(g_cfgParameter.FloatV);
} }
/** /**
@ -562,7 +177,7 @@ void constantVoltageCharge(void)
*/ */
void BatteryChargControl(void) void BatteryChargControl(void)
{ {
switch(getMPPT_Mode()) { switch(g_otherParameter.MPPT_Mode) {
case MPPT: case MPPT:
mpptCharge(); mpptCharge();
@ -577,7 +192,7 @@ void BatteryChargControl(void)
break; break;
default: default:
setMPPT_Mode(noWork); g_otherParameter.MPPT_Mode = noWork;
stopChargWork(); stopChargWork();
break; break;
} }

View File

@ -5,6 +5,9 @@
void GW485_comm(void) void GW485_comm(void)
{ {
@ -16,14 +19,4 @@ void GW485_comm(void)
void BAT485_comm(void) void BAT485_comm(void)
{ {
}
void gw485_RxIt(void)
{
}
void bat485_RxIt(void)
{
} }

View File

@ -218,10 +218,8 @@ void config_info_start(void)
g_cfgParameter.loopImpedance = 0; g_cfgParameter.loopImpedance = 0;
saveLoopImpedance(&g_cfgParameter.loopImpedance); saveLoopImpedance(&g_cfgParameter.loopImpedance);
} }
readtotalElectricityConsumption(&fTemp); readtotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
totalElectricityConsumptionInt(fTemp); readtotalChargCapacity(&g_otherParameter.totalChargCapacity);
readtotalChargCapacity(&fTemp);
totalChargCapacityInt(fTemp);
} }
/** /**

View File

@ -1,408 +1,7 @@
#include "parameter.h" #include "parameter.h"
#include "FM_TIM.h"
#include "FM_GPIO.h"
#include "capture.h"
config_parameter g_cfgParameter = {0}; config_parameter g_cfgParameter = {0};
static otherParameter g_otherParameter = {0}; otherParameter g_otherParameter = {0};
static BOOL batteryState = FALSE; /* 有无电池(估计) */
static float dutyRatio; /* 占空比 */
/**
* @brief
* @param
* @retval batteryState电池状态 FALSE
* TRUE
*/
BOOL getBatteryState(void)
{
return batteryState;
}
/**
* @brief
* @param state
* @retval
*
*/
void setBatteryState(BOOL state)
{
if (state != TRUE && state != FALSE) {
return;
}
batteryState = state;
}
/**
* @brief
* @param
* @retval dutyRatio
*/
float getDutyRatio(void)
{
return dutyRatio;
}
/**
* @brief ,01
* @param dutyRatio
* @retval
*/
void setDutyRatio(float DutyRatio)
{
if (DutyRatio > 0.9f) {
dutyRatio = 0.9f;
}
else if (DutyRatio < 0.05f) {
dutyRatio = 0.05f;
}
else {
dutyRatio = DutyRatio;
}
set_pwmDutyRatio(dutyRatio);
}
/**
* @brief 0pwm下桥的输出
* @param
* @retval
*/
void setDutyRatioToZero(void)
{
EN_PWMOUT_Diseable();
dutyRatio = 0;
set_pwmDutyRatio(dutyRatio);
}
/**
* @brief
* @param
* @retval
*/
float getBatteryVoltage(void)
{
return g_otherParameter.Battery_Voltage;
}
/**
* @brief
* @param
* @retval
*/
void setBatteryVoltage(void)
{
g_otherParameter.Battery_Voltage = g_otherParameter.Output_Voltage
+ getChargBatteryCurrent() * g_cfgParameter.loopImpedance;
}
/**
* @brief
* @param
* @retval
*/
float getOutputVoltage(void)
{
return g_otherParameter.Output_Voltage;
}
/**
* @brief
* @param
* @retval
*/
void setOutputVoltage(void)
{
g_otherParameter.Output_Voltage = get_PV_VOLT_OUT() ;
}
/**
* @brief
* @param
* @retval
*/
float getChargCurrent(void)
{
return g_otherParameter.Charg_Current;
}
/**
* @brief
* @param
* @retval
*/
void setChargCurrent(void)
{
g_otherParameter.Charg_Current = get_CHG_CURR();
}
/**
* @brief
* @param
* @retval
*/
float getDischargCurrent(void)
{
return g_otherParameter.Discharg_Current;
}
/**
* @brief
* @param
* @retval
*/
void setDischargCurrent(void)
{
g_otherParameter.Discharg_Current = get_DSG_CURR();
}
/**
* @brief
* @param
* @retval
*/
float getInputVoltage(void)
{
return g_otherParameter.Input_Voltage;
}
/**
* @brief
* @param
* @retval
*/
void setInputVoltage(void)
{
g_otherParameter.Discharg_Current = get_PV_VOLT_IN1();
}
/**
* @brief
* @param
* @retval
*/
float getSolarOpenCircuitVoltage(void)
{
return g_otherParameter.Solar_Open_Circuit_Voltage;
}
/**
* @brief
* @param
* @retval
*/
void setSolarOpenCircuitVoltage(void)
{
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
}
/**
* @brief mos管的温度
* @param
* @retval mos管的温度
*/
float getHighSideMosTemperature(void)
{
return g_otherParameter.HighSideMos_Temperature;
}
/**
* @brief mos管温度
* @param
* @retval
*/
void setHighSideMosTemperature(void)
{
g_otherParameter.HighSideMos_Temperature = get_MOSFET_Temper();
}
/**
* @brief
* @param
* @retval
*/
float getSolarInCircuitVoltage(void)
{
return g_otherParameter.Solar_In_Circuit_Voltage;
}
/**
* @brief
* @param
* @retval
*/
void setSolarInCircuitVoltage(void)
{
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
}
/**
* @brief
* @param
* @retval
*/
float getTotalElectricityConsumption(void)
{
return g_otherParameter.totalElectricityConsumption;
}
/**
* @brief
* @param
* @retval
*/
void setTotalElectricityConsumption(void)
{
g_otherParameter.totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
}
/**
* @brief
* @param totalPower
* @retval
*/
void totalElectricityConsumptionInt(float totalPower)
{
g_otherParameter.totalElectricityConsumption = totalPower;
}
/**
* @brief
* @param
* @retval
*/
float getTotalChargCapacity(void)
{
return g_otherParameter.totalChargCapacity;
}
/**
* @brief
* @param
* @retval
*/
void setTotalChargCapacity(void)
{
g_otherParameter.totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
}
/**
* @brief
* @param totalPower
* @retval
*/
void totalChargCapacityInt(float totalPower)
{
g_otherParameter.totalChargCapacity = totalPower;
}
/**
* @brief
* @param
* @retval
*/
float getSOC(void)
{
return g_otherParameter.SOC;
}
/**
* @brief
* @param
* @retval
*/
void setSOC(void)
{
}
/**
* @brief
* @param
* @retval
*/
int getMPPT_Mode(void)
{
return g_otherParameter.MPPT_Mode;
}
/**
* @brief
* @param
* @retval
*/
void setMPPT_Mode(int MPPT_Mode)
{
g_otherParameter.MPPT_Mode = MPPT_Mode;
}
/**
* @brief
* @param
* @retval
*/
float getChargBatteryCurrent(void)
{
return (g_otherParameter.Charg_Current - g_otherParameter.Discharg_Current);
}
/**
* @brief
* @param
* @retval
*/
BOOL getChargMosState(void)
{
if (getDutyRatio() > 0 && getDutyRatio() < 1) {
return TRUE;
} else {
return FALSE;
}
}
/**
* @brief
* @param state FALSE
* @retval
*/
void setChargMosState(BOOL state)
{
if (state == FALSE) {
/* 关闭充电 */
} else if (state == TRUE) {
/* 打开充电 */
}
}
/**
* @brief
* @param
* @retval state FALSE
*/
BOOL getDischargMosState(void)
{
if (g_cfgParameter.onlyPower) {
return readOnlyPowerOutputState();
} else {
return readOutputState();
}
}
/**
* @brief
* @param
* @retval softVer
*/
uint8_t *getVersionInformation(void)
{
return softVer;
}

View File

@ -1,24 +0,0 @@
#include "test.h"
#include "checkTime.h"
#include "uart_dev.h"
#include "HD_TIM.h"
#include "pDebug.h"
void test(void)
{
Init_debug_uart();
HD_time_Init();
HAL_TIM_Base_Start_IT(&htim15);
while (1) {
checkTimeInit();
HAL_Delay(1000);
debug("time:%f\r\n", getCheckTime());
}
}

View File

@ -20,9 +20,6 @@ void FFMOS_CON_Close(void);
void EN_PWMOUT_Eable(void); void EN_PWMOUT_Eable(void);
void EN_PWMOUT_Diseable(void); void EN_PWMOUT_Diseable(void);
BOOL readOnlyPowerOutputState(void);
BOOL readOutputState(void);
// extern void WORK_VOLT_Interrupt(void); // extern void WORK_VOLT_Interrupt(void);
// extern void DSG_PROT_Interrupt(void); // extern void DSG_PROT_Interrupt(void);

View File

@ -4,13 +4,10 @@
#include "HD_TIM.h" #include "HD_TIM.h"
void tim_Init(void); void pwm_Init(void);
void pwm_Stop(void);
void set_pwmDutyRatio(float DutyRatio); void set_pwmDutyRatio(float DutyRatio);
void set_pwmPulse(uint32_t Pulse); void set_pwmPulse(uint32_t Pulse);
extern void chargControl(void); extern void chargControl(void);
extern void checkAbnormal(void);
extern void hw_inc_tick(void);
#endif #endif

View File

@ -1,33 +0,0 @@
#ifndef FM_CAPTURE_H_
#define FM_CAPTURE_H_
#include "arm_math.h"
#pragma pack(push,4)
typedef struct _adcCapture
{
float32_t inDataF[6];
int16_t outData;
}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;
void ADC_Capture_Init(void);
void proportionalInt(int mode);
float get_CHG_CURR(void);
float get_PV_VOLT_OUT(void);
float get_DSG_CURR(void);
float get_PV1_VOLT_IN(void);
float get_PV_VOLT_IN1(void);
float get_MOSFET_Temper(void);
void adcCaptureFir();
#endif

View File

@ -1,16 +0,0 @@
#ifndef FM_CHECK_TIME_H_
#define FM_CHECK_TIME_H_
#include "HD_TIM.h"
#include "FM_TIM.h"
void hw_inc_tick(void);
void checkTimeInit(void);
float getCheckTime(void);
#endif

View File

@ -1,52 +0,0 @@
#ifndef FM_UART_DEV_H_
#define FM_UART_DEV_H_
#include "main.h"
#include "HD_COMM.h"
#include "comm_types.h"
#define ASCII_CHAR_BACKSPACE 0x08 /* '\b' */
#define ASCII_CHAR_CHARACTER_TABULATION 0x09 /* '\t' */
#define ASCII_CHAR_LINE_FEED 0x0A /* '\n' */
#define ASCII_CHAR_LINE_TABULATION 0x0B /* '\v' */
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
typedef enum{
DEBUG_UART_INDEX = 4,
BAT485_UART_INDEX = 3,
GW485_UART_INDEX = 2,
}uartIndex_e;
/* UART 驱动数据结构对应一个uart设备 */
typedef struct _uart_device_info{
uint8_t init;
uartIndex_e uart_index;
uint32_t uart_baudrate;
RingQueue uart_ring_queue;
}uart_device_info;
typedef uint32_t device_handle;
extern device_handle g_gw485_uart2_handle;
extern device_handle g_bat485_uart3_handle;
extern device_handle g_debug_uart4_handle;
extern uint8_t rx_gw485_buf[1];
extern uint8_t rx_bat485_buf[1];
void uart_close(uartIndex_e uart_index);
void uart_sendstr(device_handle device, char *str);
void debug_printf(char *format, ...);
void Init_debug_uart(void);
void Init_BAT485_uart(void);
void Init_GW485_uart(void);
void start_gw485Rx_It(void);
void start_bat485Rx_It(void);
extern void gw485_RxIt(void);
extern void bat485_RxIt(void);
#endif

View File

@ -106,36 +106,6 @@ void EN_PWMOUT_Diseable(void)
HAL_GPIO_WritePin(EN_PWMOUT_GPIO_Port, EN_PWMOUT_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(EN_PWMOUT_GPIO_Port, EN_PWMOUT_Pin, GPIO_PIN_SET);
} }
/**
* @brief
* @param None
* @retval None
*/
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;
}
return FALSE;
}
/**
* @brief
* @param None
* @retval None
*/
BOOL readOutputState(void)
{
if (1) {
return TRUE;
}
return FALSE;
}
/** /**
* @brief GPIO外部中断的回调函数 * @brief GPIO外部中断的回调函数
* @param GPIO_Pin * @param GPIO_Pin

View File

@ -1,47 +1,19 @@
#include "FM_TIM.h" #include "FM_TIM.h"
#include "timeSliceOffset.h" #include "timeSliceOffset.h"
#include "capture.h"
static int PWM_RESOLUTION; static int PWM_RESOLUTION;
/** void pwm_Init(void)
* @brief
* @param None
* @retval None
*/
void tim_Init(void)
{ {
HD_PWM_Init(); HD_PWM_Init();
/* 得到pwm的分辨率 */
PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000; PWM_RESOLUTION = HAL_RCC_GetHCLKFreq() / 100000;
HD_controlTim_Init();
HD_taskBaseTim_Init();
HD_checkAbnormalTim_Init();
HD_time_Init();
} }
/**
* @brief PWM信号输出
*
* PWM脉冲宽度为0来停止PWM信号输出HAL库函数进行PWM相关的硬件资源初始化
* 使HALSTM32微控制器
*/
void pwm_Stop(void) void pwm_Stop(void)
{ {
// 设置PWM脉冲宽度为0 effectively停止PWM信号输出
set_pwmPulse(0); set_pwmPulse(0);
HAL_TIM_Base_Stop_IT(&htim15); HAL_TIM_OC_MspDeInit(&htim3);
// HAL_TIM_OC_MspDeInit(&htim3);
// 调用HAL库函数进行PWM相关的硬件资源De初始化
// HAL_TIM_PWM_MspDeInit(&htim3);
} }
/** /**
@ -64,6 +36,10 @@ void set_pwmPulse(uint32_t Pulse)
*/ */
void set_pwmDutyRatio(float DutyRatio) void set_pwmDutyRatio(float DutyRatio)
{ {
if (DutyRatio > (float)0.9 || DutyRatio < (float)0.05) {
return;
}
uint32_t Pulse = (int)(DutyRatio * PWM_RESOLUTION); uint32_t Pulse = (int)(DutyRatio * PWM_RESOLUTION);
set_pwmPulse(Pulse); set_pwmPulse(Pulse);
@ -92,20 +68,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
} }
/* USER CODE BEGIN Callback 1 */ /* USER CODE BEGIN Callback 1 */
else if (htim->Instance == TIM7) { if (htim->Instance == TIM7) {
chargControl();
}
else if (htim->Instance == TIM16) {
TimeSliceOffset_Produce(); TimeSliceOffset_Produce();
} chargControl();
else if (htim->Instance == TIM17) {
checkAbnormal();
}
else if (htim->Instance == TIM15) {
hw_inc_tick();
} }
/* USER CODE END Callback 1 */ /* USER CODE END Callback 1 */

View File

@ -1,446 +0,0 @@
#include "capture.h"
#include "HD_ADC.h"
/* 温度的adc值的个数 */
#define mosTemperADCLen 241
///* 3.3V参考电压温度adc值 */
//const uint16_t mosTemperADC[mosTemperADCLen] = {
// 3707, 3697, 3687, 3676, 3665, 3654, 3643, 3632, 3620, 3608, /* -20 - -15.5 ℃ */
// 3596, 3584, 3571, 3559, 3546, 3533, 3519, 3506, 3492, 3478, /* -15 - -10.5 ℃ */
// 3464, 3449, 3434, 3419, 3404, 3389, 3373, 3358, 3341, 3325, /* -10 - -5.5 ℃ */
// 3309, 3292, 3275, 3258, 3241, 3223, 3205, 3187, 3169, 3151, /* -5 - -0.5 ℃ */
// 3132, 3114, 3095, 3075, 3056, 3037, 3017, 2997, 2977, 2957, /* 0 - 4.5 ℃ */
// 2936, 2916, 2895, 2874, 2854, 2832, 2811, 2790, 2768, 2747, /* 9 - 9.5 ℃ */
// 2725, 2703, 2681, 2659, 2637, 2615, 2592, 2570, 2548, 2525, /* 10 - 14.5 ℃ */
// 2503, 2480, 2457, 2435, 2412, 2389, 2366, 2343, 2321, 2298, /* 15 - 19.5 ℃ */
// 2275, 2252, 2229, 2207, 2184, 2161, 2138, 2116, 2093, 2071, /* 20 - 24.5 ℃ */
// 2048, 2026, 2003, 1981, 1959, 1937, 1914, 1893, 1871, 1849, /* 25 - 29.5 ℃ */
// 1827, 1806, 1784, 1763, 1742, 1721, 1700, 1679, 1658, 1638, /* 30 - 34.5 ℃ */
// 1617, 1597, 1577, 1557, 1537, 1518, 1498, 1479, 1460, 1441, /* 35 - 39.5 ℃ */
// 1422, 1403, 1385, 1366, 1348, 1330, 1312, 1295, 1277, 1260, /* 40 - 44.5 ℃ */
// 1243, 1226, 1209, 1192, 1176, 1160, 1144, 1128, 1112, 1097, /* 45 - 49.5 ℃ */
// 1081, 1066, 1051, 1036, 1022, 1007, 993, 979, 965, 951, /* 50 - 54.5 ℃ */
// 938, 924, 911, 898, 885, 872, 860, 848, 835, 823, /* 55 - 59.5 ℃ */
// 811, 800, 788, 777, 765, 754, 743, 732, 722, 711, /* 60 - 64.5 ℃ */
// 701, 691, 681, 671, 661, 651, 642, 632, 623, 614, /* 65 - 69.5 ℃ */
// 605, 596, 588, 579, 571, 562, 554, 546, 538, 530, /* 70 - 74.5 ℃ */
// 522, 515, 507, 500, 493, 486, 478, 471, 465, 458, /* 75 - 79.5 ℃ */
// 451, 445, 438, 432, 426, 420, 414, 408, 402, 396, /* 80 - 84.5 ℃ */
// 390, 385, 379, 374, 368, 363, 358, 353, 348, 343, /* 85 - 89.5 ℃ */
// 338, 333, 328, 324, 319, 315, 310, 306, 301, 297, /* 90 - 94.5 ℃ */
// 293, 289, 285, 281, 277, 273, 269, 266, 262, 258, /* 95 - 99.5 ℃ */
// 255 /* 100 ℃ */
//};
/* 3.0V参考电压温度adc值 */
const uint16_t mosTemperADC[mosTemperADCLen] = {
4077, 4066, 4055, 4043, 4031, 4019, 4007, 3994, 3982, 3969, /* -20 - -15.5 ℃ */
3955, 3942, 3928, 3914, 3900, 3885, 3871, 3856, 3841, 3825, /* -15 - -10.5 ℃ */
3809, 3794, 3777, 3761, 3744, 3727, 3710, 3693, 3675, 3657, /* -10 - -5.5 ℃ */
3639, 3621, 3602, 3583, 3564, 3545, 3525, 3506, 3486, 3465, /* -5 - -0.5 ℃ */
3445, 3424, 3404, 3383, 3361, 3340, 3318, 3296, 3274, 3252, /* 0 - 4.5 ℃ */
3230, 3207, 3184, 3162, 3138, 3115, 3092, 3068, 3045, 3021, /* 5 - 9.5 ℃ */
2997, 2973, 2949, 2925, 2900, 2876, 2851, 2827, 2802, 2777, /* 10 - 14.5 ℃ */
2752, 2728, 2703, 2678, 2653, 2628, 2602, 2577, 2552, 2527, /* 15 - 19.5 ℃ */
2502, 2477, 2452, 2427, 2402, 2377, 2352, 2327, 2302, 2277, /* 20 - 24.5 ℃ */
2253, 2228, 2203, 2179, 2154, 2130, 2106, 2082, 2057, 2034, /* 25 - 29.5 ℃ */
2010, 1986, 1962, 1939, 1916, 1893, 1869, 1847, 1824, 1801, /* 30 - 34.5 ℃ */
1779, 1757, 1734, 1713, 1691, 1669, 1648, 1626, 1605, 1584, /* 35 - 39.5 ℃ */
1564, 1543, 1523, 1503, 1483, 1463, 1443, 1424, 1405, 1386, /* 40 - 44.5 ℃ */
1367, 1348, 1330, 1312, 1293, 1276, 1258, 1241, 1223, 1206, /* 45 - 49.5 ℃ */
1189, 1173, 1156, 1140, 1124, 1108, 1092, 1077, 1061, 1046, /* 50 - 54.5 ℃ */
1031, 1017, 1002, 988, 974, 960, 946, 932, 919, 905, /* 55 - 59.5 ℃ */
892, 879, 867, 854, 842, 829, 817, 806, 794, 782, /* 60 - 64.5 ℃ */
771, 760, 749, 738, 727, 716, 706, 696, 685, 675, /* 65 - 69.5 ℃ */
666, 656, 646, 637, 627, 618, 609, 600, 592, 583, /* 70 - 74.5 ℃ */
575, 566, 558, 550, 542, 534, 526, 519, 511, 504, /* 75 - 79.5 ℃ */
496, 489, 482, 475, 468, 461, 455, 448, 442, 435, /* 80 - 84.5 ℃ */
429, 423, 417, 411, 405, 399, 394, 388, 382, 377, /* 85 - 89.5 ℃ */
372, 366, 361, 356, 351, 346, 341, 336, 332, 327, /* 90 - 94.5 ℃ */
322, 318, 313, 309, 305, 300, 296, 292, 288, 284, /* 95 - 99.5 ℃ */
280 /* 100 ℃ */
};
// /* 2.5V参考电压温度adc值 */
// const uint16_t mosTemperADC[mosTemperADCLen] = {
// 4893, 4879, 4866, 4852, 4838, 4823, 4808, 4793, 4778, 4762, /* -20 - -15.5 ℃ */
// 4746, 4730, 4714, 4697, 4680, 4663, 4645, 4627, 4609, 4590, /* -15 - -10.5 ℃ */
// 4571, 4552, 4533, 4513, 4493, 4473, 4452, 4431, 4410, 4389, /* -10 - -5.5 ℃ */
// 4367, 4345, 4323, 4300, 4277, 4254, 4231, 4207, 4183, 4159, /* -5 - -0.5 ℃ */
// 4134, 4109, 4084, 4059, 4034, 4008, 3982, 3956, 3929, 3903, /* 0 - 4.5 ℃ */
// 3876, 3849, 3821, 3794, 3766, 3738, 3710, 3682, 3654, 3625, /* 5 - 9.5 ℃ */
// 3596, 3568, 3539, 3510, 3480, 3451, 3422, 3392, 3362, 3333, /* 10 - 14.5 ℃ */
// 3303, 3273, 3243, 3213, 3183, 3153, 3123, 3093, 3063, 3033, /* 15 - 19.5 ℃ */
// 3003, 2972, 2942, 2912, 2882, 2852, 2822, 2792, 2762, 2733, /* 20 - 24.5 ℃ */
// 2703, 2673, 2644, 2614, 2585, 2556, 2527, 2498, 2469, 2440, /* 25 - 29.5 ℃ */
// 2412, 2383, 2355, 2327, 2299, 2271, 2243, 2216, 2189, 2162, /* 30 - 34.5 ℃ */
// 2135, 2108, 2081, 2055, 2029, 2003, 1977, 1952, 1926, 1901, /* 35 - 39.5 ℃ */
// 1876, 1852, 1827, 1803, 1779, 1755, 1732, 1709, 1686, 1663, /* 40 - 44.5 ℃ */
// 1640, 1618, 1596, 1574, 1552, 1531, 1510, 1489, 1468, 1447, /* 45 - 49.5 ℃ */
// 1427, 1407, 1387, 1368, 1349, 1330, 1311, 1292, 1274, 1256, /* 50 - 54.5 ℃ */
// 1238, 1220, 1203, 1185, 1168, 1151, 1135, 1119, 1102, 1086, /* 55 - 59.5 ℃ */
// 1071, 1055, 1040, 1025, 1010, 995, 981, 967, 953, 939, /* 60 - 64.5 ℃ */
// 925, 912, 898, 885, 872, 860, 847, 835, 822, 810, /* 65 - 69.5 ℃ */
// 799, 787, 775, 764, 753, 742, 731, 721, 710, 700, /* 70 - 74.5 ℃ */
// 690, 679, 670, 660, 650, 641, 631, 622, 613, 604, /* 75 - 79.5 ℃ */
// 596, 587, 578, 570, 562, 554, 546, 538, 530, 523, /* 80 - 84.5 ℃ */
// 515, 508, 500, 493, 486, 479, 472, 466, 459, 452, /* 85 - 89.5 ℃ */
// 446, 440, 433, 427, 421, 415, 409, 404, 398, 392, /* 90 - 94.5 ℃ */
// 387, 381, 376, 371, 366, 361, 355, 350, 346, 341, /* 95 - 99.5 ℃ */
// 336 /* 100 ℃ */
// };
enum {
WORK_VOLT_NUM = 0,
DSG_CURR_NUM = 1,
PV_VOLT_IN_NUM = 2,
CHG_CURR_NUM = 3,
};
int16_t adcBuff[4];
adcCapture WORK_VOLT_capture = {0};
adcCapture DSG_CURR_capture = {0};
adcCapture PV_VOLT_IN_capture = {0};
adcCapture CHG_CURR_capture = {0};
/* 电流电压采集转换的 */
static float P_CHG_CURR = 0;
static float P_PV_VOLT_OUT = 0;
static float P_DSG_CURR = 0;
static float P_PV1_VOLT_IN = 0;
static float P_PV_VOLT_IN1 = 0;
/* 2.5为adc的电压4095是2^adc的位数 - 1 */
// const float32_t Proportion = 2.5 / 4095;
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
};
/**
* @brief adc
* @param
* @retval None
*/
void ADC_Capture_Init(void)
{
HD_adc_Init();
/* 将回调函数与dma的转换完成中断绑定 */
// hdma_adc1.XferCpltCallback = dmaFerCpltCallback;
HAL_Delay(100);
/* adc校准 */
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
HAL_TIM_Base_Start(&htim6);
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adcBuff, 4);
// /* 光伏充电输出电流比例,放大倍数*电阻 */
// 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;
}
/**
* @brief
* @param
* @retval None
*/
void proportionalInt(int mode)
{
/* 仅充当电源盒 */
if (mode) {
/* 光伏充电输出电流比例,放大倍数*电阻 */
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;
}
/* 电源盒外还有网关功能 */
else {
/* 光伏充电输出电流比例,放大倍数*电阻 */
P_CHG_CURR = (1.0 / (50 * 0.005)) * Proportion;
/* 光伏充电输出电压比例,分压系数 */
P_PV_VOLT_OUT = ((47.0 + 4.7) / 4.7) * Proportion;
/* 放电电流采集电流倍数 */
P_DSG_CURR = (1.0 / (50 * 0.005)) * Proportion;
/* 光伏1开路输出电压比例 */
P_PV1_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion;
/* 系统电源电压比例 */
P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion;
}
}
#define N 4
/**
* @brief
* @param funtion ADC的函数
* @param ADC_Channel ADC通道
* @retval None
*/
static int16_t middleAverageFilter(int16_t funtion(uint32_t Channel), uint32_t ADC_Channel)
{
int16_t i,j,k;
int16_t temp,sum = 0;
int16_t value_buf[N];
for (i = 0; i < N; ++i) {
value_buf[i] = funtion(ADC_Channel);
}
/*从小到大冒泡排序*/
for(j = 0; j < N-1; ++j) {
for (k = 0; k < N-j-1; ++k) {
if(value_buf[k] > value_buf[k+1]) {
temp = value_buf[k];
value_buf[k] = value_buf[k+1];
value_buf[k+1] = temp;
}
}
}
for(i = 1; i < N-1; ++i) {
sum += value_buf[i];
}
return sum / (N-2);
}
/**
* @brief adc2的采集值
* @param Channel ADC通道
* @retval None
*/
static int16_t ADC2_Capture(uint32_t Channel)
{
return middleAverageFilter(get_adc2Value, Channel);
}
// /**
// * @brief 获取adc1的采集值
// * @param Channel ADC通道
// * @retval None
// */
// static int16_t ADC1_Capture(uint32_t Channel)
// {
// return middleAverageFilter(get_adc1Value, Channel);
// }
/**
* @brief
* @param
* @retval I
*/
float get_CHG_CURR(void)
{
float I;
I = CHG_CURR_capture.outData * P_CHG_CURR;
// I = ADC1_Capture(ADC_CHANNEL_11) * P_CHG_CURR;
#ifdef enable_Printf_VI
debug("\n CHG_CURR ADC : %d \n", (int)CHG_CURR_capture.outDataF);
debug(" CHG_CURR I : %f \n", I);
#endif
return I;
}
/**
* @brief
* @param
* @retval V
*/
float get_PV_VOLT_OUT(void)
{
float V;
V = WORK_VOLT_capture.outData * P_PV_VOLT_OUT;
// V = ADC1_Capture(ADC_CHANNEL_7) * P_PV_VOLT_OUT;
#ifdef enable_Printf_VI
debug("\n PV_VOLT_OUT ADC : %d \n", (int)WORK_VOLT_capture.outDataF);
debug(" PV_VOLT_OUT V : %f \n", V);
#endif
return V;
}
/**
* @brief
* @param
* @retval I
*/
float get_DSG_CURR(void)
{
float I;
I = DSG_CURR_capture.outData * P_DSG_CURR;
// I = ADC1_Capture(ADC_CHANNEL_8) * P_DSG_CURR;
#ifdef enable_Printf_VI
debug("\n DSG_CURR ADC : %d \n", (int)DSG_CURR_capture.outDataF);
debug(" DSG_CURR I : %f \n", I);
#endif
return I;
}
/**
* @brief
* @param
* @retval V
*/
float get_PV1_VOLT_IN(void)
{
float V;
V = PV_VOLT_IN_capture.outData * P_PV1_VOLT_IN;
// V = ADC1_Capture(ADC_CHANNEL_15) * P_PV1_VOLT_IN;
#ifdef enable_Printf_VI
debug("\n PV1_VOLT_IN ADC : %d \n", (int)PV_VOLT_IN_capture.outDataF);
debug(" PV1_VOLT_IN V1 : %f \n", V);
#endif
return V;
}
/**
* @brief
* @param
* @retval V
*/
float get_PV_VOLT_IN1(void)
{
float V;
uint16_t V_ADC;
V_ADC = ADC2_Capture(SYS_VOLT_IN_CHANNEL);
V = (float)(V_ADC) * P_PV_VOLT_IN1;
#ifdef enable_Printf_VI
debug("\n PV_VOLT_IN1 ADC : %d \n", V_ADC);
debug(" PV_VOLT_IN1 V : %f \n", V);
#endif
return V;
}
//const float Rp = 10000.0; //10K
//const float T2 = (273.15+25.0);//T2
//const float Bx = 3950.0;//B
//const float Bx = 3435.0;//B
//const float Ka = 273.15;
/**
* @brief
* @param
* @retval V
*/
float get_MOSFET_Temper(void)
{
float T = 0;
uint16_t T_ADC;
T_ADC = ADC2_Capture(MOSFET_Temper_CHANNEL);
for (int i = 0; i < mosTemperADCLen; ++i) {
if (T_ADC >= mosTemperADC[i]) {
T = -20 + i * 0.5;
break;
}
}
#ifdef enable_Printf_VI
debug("\n MOSFET_Temper ADC : %d \n", T_ADC);
debug(" MOSFET_Temper T : %f \n", T);
#endif
return T;
}
/**
* @brief adc转换并传输完成后进入该回调函数
* @param hdma dma
* @retval None
*/
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.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];
}
}
/**
* @brief adc进行滤波
* @param None
* @retval None
*/
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];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
WORK_VOLT_capture.outData = (int16_t)outputf;
/* 初始化输入输出缓存指针 */
inputF32 = &DSG_CURR_capture.inDataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
DSG_CURR_capture.outData = (int16_t)outputf;
/* 初始化输入输出缓存指针 */
inputF32 = &PV_VOLT_IN_capture.inDataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
PV_VOLT_IN_capture.outData = (int16_t)outputf;
/* 初始化输入输出缓存指针 */
inputF32 = &CHG_CURR_capture.inDataF[0];
outputF32 = &outputf;
arm_fir_f32(&armFirInstanceF32, inputF32, outputF32, blockSize);
CHG_CURR_capture.outData = (int16_t)outputf;
}

View File

@ -1,59 +0,0 @@
#include "checkTime.h"
typedef struct _timeData {
/* 程序执行前的时间 */
uint32_t time_ms1;
uint16_t time_tick1;
/* 程序执行完的时间 */
uint32_t time_ms2;
uint16_t time_tick2;
/* 程序执行所用的时间ms */
float time_s;
}timeData;
static timeData checkTimeData;
volatile static uint32_t hw_sys_tick_ms = 0; //ms 自增计数变量
#define tim TIM15
#define timLard 36000.0
/**
* hw_inc_tick函数
*
* hw_sys_tick_ms
* hw_sys_tick_ms将增加1
*
*
*/
void hw_inc_tick(void)
{
++hw_sys_tick_ms;
}
void checkTimeInit(void)
{
checkTimeData.time_ms1 = hw_sys_tick_ms;
checkTimeData.time_tick1 = tim->CNT;
}
float getCheckTime(void)
{
checkTimeData.time_ms2 = hw_sys_tick_ms;
checkTimeData.time_tick2 = tim->CNT;
checkTimeData.time_s = checkTimeData.time_ms2 - checkTimeData.time_ms1
+ (checkTimeData.time_tick2 - checkTimeData.time_tick1) / timLard;
return checkTimeData.time_s;
}

View File

@ -1,229 +0,0 @@
#include "uart_dev.h"
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
device_handle g_gw485_uart2_handle;
device_handle g_bat485_uart3_handle;
device_handle g_debug_uart4_handle;
static uint8_t Debug_in_buff[200];
static uint8_t Gw485_in_buff[200];
static uint8_t Bat485_in_buff[200];
uint8_t rx_gw485_buf[1];
uint8_t rx_bat485_buf[1];
static uint8_t debug_out_buff[100];
/**
* @brief .
* @param uart_index
* @param uart_baudrate
*/
uart_device_info uart_devices[]={
[0] = {
.init = 0,
.uart_index = GW485_UART_INDEX,
.uart_baudrate = 115200,
},
[1] = {
.init = 0,
.uart_index = BAT485_UART_INDEX,
.uart_baudrate = 115200,
},
[2] = {
.init = 0,
.uart_index = DEBUG_UART_INDEX,
.uart_baudrate = 115200,
},
};
static device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size);
static void uart_init(uartIndex_e uart_index, uint32_t baud);
static u_int8_t uart_putchar(device_handle device, char ch);
/**
* @brief .
* @param uart_index
* @param buff buff地址
* @param buff_size buff对应大小
* @retval
*/
device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size)
{
int i = 0;
for (; i < ELEMENT_OF(uart_devices); i++) {
if (uart_devices[i].uart_index == uart_index) {
if (!uart_devices[i].init) {
InitRingQueue(&uart_devices[i].uart_ring_queue, buff, buff_size);
uart_init(uart_index, uart_devices[i].uart_baudrate);
uart_devices[i].init = 1;
}
return (device_handle)(&uart_devices[i]);
}
}
return 0;
}
/**
* @brief .
* @param uart_index
* @param baud
* @retval None
*/
void uart_init(uartIndex_e uart_index, uint32_t baud)
{
if (uart_index == GW485_UART_INDEX) {
HD_GW485_Init(baud);
} else if (uart_index == BAT485_UART_INDEX) {
HD_BAT485_Init(baud);
} else if (uart_index == DEBUG_UART_INDEX) {
HD_DEBUG_Uart_Init(baud);
}
}
/**
* @brief
* @param uart_index
* @retval None
*/
void uart_close(uartIndex_e uart_index)
{
if(uart_index == GW485_UART_INDEX){
HAL_UART_MspDeInit(&huart2);
}else if(uart_index == BAT485_UART_INDEX){
HAL_UART_MspDeInit(&huart3);
}else if(uart_index == DEBUG_UART_INDEX){
HAL_UART_MspDeInit(&huart4);
}
}
/**
* @brief .
* @param uart_index
* @param ch
* @retval 1 0
*/
static u_int8_t uart_putchar(device_handle device, char ch)
{
int ret = HAL_ERROR;
uart_device_info *device_info = (uart_device_info *)device;
if((!device) || (!device_info->init))
return 0;
if (device_info->uart_index == GW485_UART_INDEX) {
ret = HAL_UART_Transmit(&huart2, (uint8_t*)&ch, 1, 10);
} else if (device_info->uart_index == BAT485_UART_INDEX) {
ret = HAL_UART_Transmit(&huart3, (uint8_t*)&ch, 1, 10);
} else if (device_info->uart_index == DEBUG_UART_INDEX) {
ret = HAL_UART_Transmit(&huart4, (uint8_t*)&ch, 1, 10);
}
if (ret == HAL_OK) {
return 1;
} else {
return 0;
}
}
/**
* @brief .
* @param uart_index
* @param str
* @retval None
*/
void uart_sendstr(device_handle device, char *str)
{
while ((*str) != (char )0u) {
if (*str == ASCII_CHAR_LINE_FEED){
uart_putchar(device, (ASCII_CHAR_CARRIAGE_RETURN));
uart_putchar(device, ASCII_CHAR_LINE_FEED);
str++;
}else{
uart_putchar(device, *str++);
}
}
}
/**
* @brief .
* @param
* @retval Null
*/
void debug_printf(char *format, ...)
{
memset(debug_out_buff, 0, sizeof(debug_out_buff));
va_list va_ptr;
va_start(va_ptr, format);
vsprintf((char*)debug_out_buff, (char const *)format, va_ptr);
va_end(va_ptr);
uart_sendstr(g_debug_uart4_handle, (char*)debug_out_buff);
}
/**
* @brief .
* @retval None
*/
void Init_debug_uart(void)
{
g_debug_uart4_handle = uart_dev_init(DEBUG_UART_INDEX, Debug_in_buff, sizeof(Debug_in_buff));
}
/**
* @brief pack串口.
* @retval None
*/
void Init_BAT485_uart(void)
{
g_bat485_uart3_handle = uart_dev_init(BAT485_UART_INDEX, Bat485_in_buff, sizeof(Bat485_in_buff));
}
/**
* @brief 485.
* @retval None
*/
void Init_GW485_uart(void)
{
g_gw485_uart2_handle = uart_dev_init(GW485_UART_INDEX, Gw485_in_buff, sizeof(Gw485_in_buff));
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART2) {
gw485_RxIt();
}
else if (huart->Instance == USART3) {
bat485_RxIt();
}
}
/**
* @brief 485.
* @retval None
*/
void start_gw485Rx_It(void)
{
HAL_UART_Receive_IT(&huart2, rx_gw485_buf, 1);
}
/**
* @brief pack串口的中断接收.
* @retval None
*/
void start_bat485Rx_It(void)
{
HAL_UART_Receive_IT(&huart3, rx_bat485_buf, 1);
}

View File

@ -1,20 +0,0 @@
#ifndef HD_ADC_H_
#define HD_ADC_H_
#include "main.h"
#include "adc.h"
#include "dma.h"
#include "tim.h"
#include "comm_types.h"
#include "stm32g431xx.h"
#define SYS_VOLT_IN_CHANNEL ADC_CHANNEL_1
#define MOSFET_Temper_CHANNEL ADC_CHANNEL_15
void HD_adc_Init(void);
int16_t get_adc1Value(uint32_t Channel);
int16_t get_adc2Value(uint32_t Channel);
#endif

View File

@ -1,15 +0,0 @@
#ifndef CCB_HD_COMM_H_
#define CCB_HD_COMM_H_
#include "main.h"
#include "usart.h"
#include "ring_queue.h"
void HD_COMM_Init(uint32_t GW485_BaudRate, uint32_t BAT485_BaudRate);
void HD_BAT485_Init(uint32_t BAT485_BaudRate);
void HD_GW485_Init(uint32_t GW485_BaudRate);
void HD_DEBUG_Uart_Init(uint32_t DEBUG_Uart_BaudRate);
#endif

View File

@ -8,9 +8,6 @@
void HD_PWM_Init(void); void HD_PWM_Init(void);
void HD_controlTim_Init(void); void HD_controlTim_Init(void);
void HD_taskBaseTim_Init(void);
void HD_checkAbnormalTim_Init(void);
void HD_time_Init(void);
#endif #endif

View File

@ -1,61 +0,0 @@
#include "HD_ADC.h"
#define ADC_SAMPLETIME ADC_SAMPLETIME_2CYCLES_5 //采样时间
void HD_adc_Init(void)
{
MX_DMA_Init();
MX_TIM6_Init();
MX_ADC1_Init();
MX_ADC2_Init();
}
/**
* @brief adc1中某通道的值
* @param Channel
*/
int16_t get_adc1Value(uint32_t Channel)
{
ADC_ChannelConfTypeDef sConfig;
/* 更改读取的adc的通道 */
sConfig.Channel = Channel;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
/* 启动转换 */
HAL_ADC_Start(&hadc1);
/* 等待转化结束 */
HAL_ADC_PollForConversion(&hadc1, 30);
u_int16_t adcValue = HAL_ADC_GetValue(&hadc1);
return adcValue;
}
int16_t get_adc2Value(uint32_t Channel)
{
ADC_ChannelConfTypeDef sConfig;
/* 更改读取的adc的通道 */
sConfig.Channel = Channel;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
/* 启动转换 */
HAL_ADC_Start(&hadc2);
/* 等待转化结束 */
HAL_ADC_PollForConversion(&hadc2, 30);
u_int16_t adcValue = HAL_ADC_GetValue(&hadc2);
return adcValue;
}

View File

@ -1,162 +0,0 @@
#include "HD_COMM.h"
void HD_BAT485_Init(uint32_t BAT485_BaudRate)
{
/* BAT485初始化 */
huart3.Instance = USART3;
huart3.Init.BaudRate = BAT485_BaudRate;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_RS485Ex_Init(&huart3, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK)
{
Error_Handler();
}
}
void HD_GW485_Init(uint32_t GW485_BaudRate)
{
/* GW485初始化 */
huart2.Instance = USART2;
huart2.Init.BaudRate = GW485_BaudRate;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_RS485Ex_Init(&huart2, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK)
{
Error_Handler();
}
}
void HD_DEBUG_Uart_Init(uint32_t DEBUG_Uart_BaudRate)
{
huart4.Instance = UART4;
huart4.Init.BaudRate = DEBUG_Uart_BaudRate;
huart4.Init.WordLength = UART_WORDLENGTH_8B;
huart4.Init.StopBits = UART_STOPBITS_1;
huart4.Init.Parity = UART_PARITY_NONE;
huart4.Init.Mode = UART_MODE_TX_RX;
huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart4.Init.OverSampling = UART_OVERSAMPLING_16;
huart4.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart4.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart4.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart4) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart4, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart4, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart4) != HAL_OK)
{
Error_Handler();
}
}
void HD_COMM_Init(uint32_t GW485_BaudRate, uint32_t BAT485_BaudRate)
{
MX_UART4_Init();
/* GW485初始化 */
huart2.Instance = USART2;
huart2.Init.BaudRate = GW485_BaudRate;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_RS485Ex_Init(&huart2, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK)
{
Error_Handler();
}
/* BAT485初始化 */
huart3.Instance = USART3;
huart3.Init.BaudRate = BAT485_BaudRate;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_RS485Ex_Init(&huart3, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK)
{
Error_Handler();
}
}

View File

@ -1,51 +1,11 @@
#include "HD_TIM.h" #include "HD_TIM.h"
/**
* @brief pwm的定时器初始化
* @param None
* @retval None
*/
void HD_PWM_Init(void) void HD_PWM_Init(void)
{ {
MX_TIM3_Init(); MX_TIM3_Init();
} }
/**
* @brief
* @param None
* @retval None
*/
void HD_controlTim_Init(void) void HD_controlTim_Init(void)
{ {
MX_TIM7_Init(); MX_TIM7_Init();
} }
/**
* @brief
* @param None
* @retval None
*/
void HD_taskBaseTim_Init(void)
{
MX_TIM16_Init();
}
/**
* @brief
* @param None
* @retval None
*/
void HD_checkAbnormalTim_Init(void)
{
MX_TIM17_Init();
}
/**
* @brief
* @param None
* @retval None
*/
void HD_time_Init(void)
{
MX_TIM15_Init();
}

View File

@ -56,14 +56,11 @@ void DebugMon_Handler(void);
void PendSV_Handler(void); void PendSV_Handler(void);
void SysTick_Handler(void); void SysTick_Handler(void);
void DMA1_Channel1_IRQHandler(void); void DMA1_Channel1_IRQHandler(void);
void TIM1_BRK_TIM15_IRQHandler(void);
void TIM1_UP_TIM16_IRQHandler(void); void TIM1_UP_TIM16_IRQHandler(void);
void TIM1_TRG_COM_TIM17_IRQHandler(void);
void USART2_IRQHandler(void); void USART2_IRQHandler(void);
void USART3_IRQHandler(void); void USART3_IRQHandler(void);
void EXTI15_10_IRQHandler(void); void EXTI15_10_IRQHandler(void);
void TIM6_DAC_IRQHandler(void); void TIM6_DAC_IRQHandler(void);
void TIM7_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
/* USER CODE END EFP */ /* USER CODE END EFP */

View File

@ -38,12 +38,6 @@ extern TIM_HandleTypeDef htim6;
extern TIM_HandleTypeDef htim7; extern TIM_HandleTypeDef htim7;
extern TIM_HandleTypeDef htim15;
extern TIM_HandleTypeDef htim16;
extern TIM_HandleTypeDef htim17;
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */ /* USER CODE END Private defines */
@ -51,9 +45,6 @@ extern TIM_HandleTypeDef htim17;
void MX_TIM3_Init(void); void MX_TIM3_Init(void);
void MX_TIM6_Init(void); void MX_TIM6_Init(void);
void MX_TIM7_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); void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);

View File

@ -27,9 +27,6 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "test.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
@ -93,37 +90,29 @@ int main(void)
/* USER CODE END SysInit */ /* USER CODE END SysInit */
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
// MX_GPIO_Init(); MX_GPIO_Init();
// MX_DMA_Init(); MX_DMA_Init();
// MX_ADC1_Init(); MX_ADC1_Init();
// MX_ADC2_Init(); MX_ADC2_Init();
// MX_SPI1_Init(); MX_SPI1_Init();
// MX_TIM3_Init(); MX_TIM3_Init();
// MX_TIM6_Init(); MX_TIM6_Init();
// MX_UART4_Init(); MX_UART4_Init();
// MX_USART2_UART_Init(); MX_USART2_UART_Init();
// MX_USART3_UART_Init(); MX_USART3_UART_Init();
// MX_TIM7_Init(); MX_TIM7_Init();
// MX_TIM16_Init();
// MX_TIM17_Init();
// MX_TIM15_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
test();
/* USER CODE END 2 */ /* USER CODE END 2 */
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
// while (1) while (1)
// { {
/* USER CODE END WHILE */ /* USER CODE END WHILE */
/* USER CODE BEGIN 3 */ /* USER CODE BEGIN 3 */
// } }
/* USER CODE END 3 */ /* USER CODE END 3 */
} }

View File

@ -57,10 +57,6 @@
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern DMA_HandleTypeDef hdma_adc1; extern DMA_HandleTypeDef hdma_adc1;
extern TIM_HandleTypeDef htim6; 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 huart2;
extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart3;
extern TIM_HandleTypeDef htim1; extern TIM_HandleTypeDef htim1;
@ -221,20 +217,6 @@ void DMA1_Channel1_IRQHandler(void)
/* USER CODE END DMA1_Channel1_IRQn 1 */ /* USER CODE END DMA1_Channel1_IRQn 1 */
} }
/**
* @brief This function handles TIM1 break interrupt and TIM15 global interrupt.
*/
void TIM1_BRK_TIM15_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 0 */
/* USER CODE END TIM1_BRK_TIM15_IRQn 0 */
HAL_TIM_IRQHandler(&htim15);
/* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 1 */
/* USER CODE END TIM1_BRK_TIM15_IRQn 1 */
}
/** /**
* @brief This function handles TIM1 update interrupt and TIM16 global interrupt. * @brief This function handles TIM1 update interrupt and TIM16 global interrupt.
*/ */
@ -243,33 +225,12 @@ void TIM1_UP_TIM16_IRQHandler(void)
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */ /* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */
/* USER CODE END TIM1_UP_TIM16_IRQn 0 */ /* USER CODE END TIM1_UP_TIM16_IRQn 0 */
if (htim1.Instance != NULL) HAL_TIM_IRQHandler(&htim1);
{
HAL_TIM_IRQHandler(&htim1);
}
if (htim16.Instance != NULL)
{
HAL_TIM_IRQHandler(&htim16);
}
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */ /* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */
/* USER CODE END TIM1_UP_TIM16_IRQn 1 */ /* 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. * @brief This function handles USART2 global interrupt / USART2 wake-up interrupt through EXTI line 26.
*/ */
@ -327,20 +288,6 @@ void TIM6_DAC_IRQHandler(void)
/* USER CODE END TIM6_DAC_IRQn 1 */ /* USER CODE END TIM6_DAC_IRQn 1 */
} }
/**
* @brief This function handles TIM7 global interrupt.
*/
void TIM7_IRQHandler(void)
{
/* USER CODE BEGIN TIM7_IRQn 0 */
/* USER CODE END TIM7_IRQn 0 */
HAL_TIM_IRQHandler(&htim7);
/* USER CODE BEGIN TIM7_IRQn 1 */
/* USER CODE END TIM7_IRQn 1 */
}
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */

View File

@ -179,9 +179,9 @@
void SystemInit(void) void SystemInit(void)
{ {
/* FPU settings ------------------------------------------------------------*/ /* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */
#endif #endif
/* Configure the Vector Table location add offset address ------------------*/ /* Configure the Vector Table location add offset address ------------------*/
#if defined(USER_VECT_TAB_ADDRESS) #if defined(USER_VECT_TAB_ADDRESS)

View File

@ -27,9 +27,6 @@
TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim3;
TIM_HandleTypeDef htim6; TIM_HandleTypeDef htim6;
TIM_HandleTypeDef htim7; TIM_HandleTypeDef htim7;
TIM_HandleTypeDef htim15;
TIM_HandleTypeDef htim16;
TIM_HandleTypeDef htim17;
/* TIM3 init function */ /* TIM3 init function */
void MX_TIM3_Init(void) void MX_TIM3_Init(void)
@ -91,7 +88,7 @@ void MX_TIM6_Init(void)
htim6.Instance = TIM6; htim6.Instance = TIM6;
htim6.Init.Prescaler = 71; htim6.Init.Prescaler = 71;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP; htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 29; htim6.Init.Period = 499;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK) if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{ {
@ -140,101 +137,6 @@ void MX_TIM7_Init(void)
/* USER CODE END TIM7_Init 2 */ /* USER CODE END TIM7_Init 2 */
}
/* TIM15 init function */
void MX_TIM15_Init(void)
{
/* USER CODE BEGIN TIM15_Init 0 */
/* USER CODE END TIM15_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM15_Init 1 */
/* USER CODE END TIM15_Init 1 */
htim15.Instance = TIM15;
htim15.Init.Prescaler = 1;
htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
htim15.Init.Period = 35999;
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim15.Init.RepetitionCounter = 0;
htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim15) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim15, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM15_Init 2 */
/* USER CODE END TIM15_Init 2 */
}
/* TIM16 init function */
void MX_TIM16_Init(void)
{
/* USER CODE BEGIN TIM16_Init 0 */
/* USER CODE END TIM16_Init 0 */
/* USER CODE BEGIN TIM16_Init 1 */
/* USER CODE END TIM16_Init 1 */
htim16.Instance = TIM16;
htim16.Init.Prescaler = 71;
htim16.Init.CounterMode = TIM_COUNTERMODE_UP;
htim16.Init.Period = 999;
htim16.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim16.Init.RepetitionCounter = 0;
htim16.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim16) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM16_Init 2 */
/* 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) void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* tim_pwmHandle)
@ -278,59 +180,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
/* USER CODE END TIM7_MspInit 0 */ /* USER CODE END TIM7_MspInit 0 */
/* TIM7 clock enable */ /* TIM7 clock enable */
__HAL_RCC_TIM7_CLK_ENABLE(); __HAL_RCC_TIM7_CLK_ENABLE();
/* TIM7 interrupt Init */
HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspInit 1 */ /* USER CODE BEGIN TIM7_MspInit 1 */
/* USER CODE END TIM7_MspInit 1 */ /* USER CODE END TIM7_MspInit 1 */
} }
else if(tim_baseHandle->Instance==TIM15)
{
/* USER CODE BEGIN TIM15_MspInit 0 */
/* USER CODE END TIM15_MspInit 0 */
/* TIM15 clock enable */
__HAL_RCC_TIM15_CLK_ENABLE();
/* TIM15 interrupt Init */
HAL_NVIC_SetPriority(TIM1_BRK_TIM15_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_BRK_TIM15_IRQn);
/* USER CODE BEGIN TIM15_MspInit 1 */
/* USER CODE END TIM15_MspInit 1 */
}
else if(tim_baseHandle->Instance==TIM16)
{
/* USER CODE BEGIN TIM16_MspInit 0 */
/* USER CODE END TIM16_MspInit 0 */
/* TIM16 clock enable */
__HAL_RCC_TIM16_CLK_ENABLE();
/* TIM16 interrupt Init */
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
/* USER CODE BEGIN TIM16_MspInit 1 */
/* 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) void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
{ {
@ -400,55 +253,10 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
/* USER CODE END TIM7_MspDeInit 0 */ /* USER CODE END TIM7_MspDeInit 0 */
/* Peripheral clock disable */ /* Peripheral clock disable */
__HAL_RCC_TIM7_CLK_DISABLE(); __HAL_RCC_TIM7_CLK_DISABLE();
/* TIM7 interrupt Deinit */
HAL_NVIC_DisableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspDeInit 1 */ /* USER CODE BEGIN TIM7_MspDeInit 1 */
/* USER CODE END TIM7_MspDeInit 1 */ /* USER CODE END TIM7_MspDeInit 1 */
} }
else if(tim_baseHandle->Instance==TIM15)
{
/* USER CODE BEGIN TIM15_MspDeInit 0 */
/* USER CODE END TIM15_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM15_CLK_DISABLE();
/* TIM15 interrupt Deinit */
HAL_NVIC_DisableIRQ(TIM1_BRK_TIM15_IRQn);
/* USER CODE BEGIN TIM15_MspDeInit 1 */
/* USER CODE END TIM15_MspDeInit 1 */
}
else if(tim_baseHandle->Instance==TIM16)
{
/* USER CODE BEGIN TIM16_MspDeInit 0 */
/* USER CODE END TIM16_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM16_CLK_DISABLE();
/* TIM16 interrupt Deinit */
HAL_NVIC_DisableIRQ(TIM1_UP_TIM16_IRQn);
/* USER CODE BEGIN TIM16_MspDeInit 1 */
/* 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 */ /* USER CODE BEGIN 1 */

View File

@ -36,7 +36,7 @@
</option> </option>
<option> <option>
<name>MacFile</name> <name>MacFile</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>MemOverride</name> <name>MemOverride</name>
@ -60,7 +60,7 @@
</option> </option>
<option> <option>
<name>CExtraOptions</name> <name>CExtraOptions</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CFpuProcessor</name> <name>CFpuProcessor</name>
@ -68,7 +68,7 @@
</option> </option>
<option> <option>
<name>OCDDFArgumentProducer</name> <name>OCDDFArgumentProducer</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCDownloadSuppressDownload</name> <name>OCDownloadSuppressDownload</name>
@ -104,7 +104,7 @@
</option> </option>
<option> <option>
<name>MacFile2</name> <name>MacFile2</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CDevice</name> <name>CDevice</name>
@ -120,7 +120,7 @@
</option> </option>
<option> <option>
<name>OCImagesPath1</name> <name>OCImagesPath1</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesSuppressCheck2</name> <name>OCImagesSuppressCheck2</name>
@ -128,7 +128,7 @@
</option> </option>
<option> <option>
<name>OCImagesPath2</name> <name>OCImagesPath2</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesSuppressCheck3</name> <name>OCImagesSuppressCheck3</name>
@ -136,7 +136,7 @@
</option> </option>
<option> <option>
<name>OCImagesPath3</name> <name>OCImagesPath3</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OverrideDefFlashBoard</name> <name>OverrideDefFlashBoard</name>
@ -148,11 +148,11 @@
</option> </option>
<option> <option>
<name>OCImagesOffset2</name> <name>OCImagesOffset2</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesOffset3</name> <name>OCImagesOffset3</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesUse1</name> <name>OCImagesUse1</name>
@ -184,15 +184,15 @@
</option> </option>
<option> <option>
<name>OCMulticoreWorkspace</name> <name>OCMulticoreWorkspace</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCMulticoreSlaveProject</name> <name>OCMulticoreSlaveProject</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCMulticoreSlaveConfiguration</name> <name>OCMulticoreSlaveConfiguration</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCDownloadExtraImage</name> <name>OCDownloadExtraImage</name>
@ -216,7 +216,7 @@
</option> </option>
<option> <option>
<name>OCMulticoreSessionFile</name> <name>OCMulticoreSessionFile</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCTpiuBaseOption</name> <name>OCTpiuBaseOption</name>
@ -228,7 +228,7 @@
</option> </option>
<option> <option>
<name>OCOverrideSlavePath</name> <name>OCOverrideSlavePath</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>C_32_64Device</name> <name>C_32_64Device</name>
@ -244,11 +244,11 @@
</option> </option>
<option> <option>
<name>AuthSdmManifest</name> <name>AuthSdmManifest</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>AuthSdmExplicitLib</name> <name>AuthSdmExplicitLib</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>AuthEnforce</name> <name>AuthEnforce</name>
@ -277,7 +277,7 @@
</option> </option>
<option> <option>
<name>OCSimPspConfigFile</name> <name>OCSimPspConfigFile</name>
<state /> <state></state>
</option> </option>
</data> </data>
</settings> </settings>
@ -294,7 +294,7 @@
</option> </option>
<option> <option>
<name>Fast Model</name> <name>Fast Model</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCADILogFileCheck</name> <name>CCADILogFileCheck</name>
@ -461,7 +461,7 @@
</option> </option>
<option> <option>
<name>OCProbeConfig</name> <name>OCProbeConfig</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CMSISDAPProbeConfigRadio</name> <name>CMSISDAPProbeConfigRadio</name>
@ -473,7 +473,7 @@
</option> </option>
<option> <option>
<name>ICpuName</name> <name>ICpuName</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCJetEmuParams</name> <name>OCJetEmuParams</name>
@ -481,7 +481,7 @@
</option> </option>
<option> <option>
<name>CCCMSISDAPUsbSerialNo</name> <name>CCCMSISDAPUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCCMSISDAPUsbSerialNoSelect</name> <name>CCCMSISDAPUsbSerialNoSelect</name>
@ -502,7 +502,7 @@
</option> </option>
<option> <option>
<name>CE2UsbSerialNo</name> <name>CE2UsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CE2IdCodeEditB</name> <name>CE2IdCodeEditB</name>
@ -642,7 +642,7 @@
</option> </option>
<option> <option>
<name>IjetCpuClockEdit</name> <name>IjetCpuClockEdit</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>IjetSwoPrescalerList</name> <name>IjetSwoPrescalerList</name>
@ -735,7 +735,7 @@
</option> </option>
<option> <option>
<name>OCProbeConfig</name> <name>OCProbeConfig</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>IjetProbeConfigRadio</name> <name>IjetProbeConfigRadio</name>
@ -755,7 +755,7 @@
</option> </option>
<option> <option>
<name>ICpuName</name> <name>ICpuName</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCJetEmuParams</name> <name>OCJetEmuParams</name>
@ -781,7 +781,7 @@
</option> </option>
<option> <option>
<name>CCIjetUsbSerialNo</name> <name>CCIjetUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCIjetUsbSerialNoSelect</name> <name>CCIjetUsbSerialNoSelect</name>
@ -1004,7 +1004,7 @@
</option> </option>
<option> <option>
<name>CCJLinkUsbSerialNo</name> <name>CCJLinkUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCTcpIpAlt</name> <name>CCTcpIpAlt</name>
@ -1013,11 +1013,11 @@
</option> </option>
<option> <option>
<name>CCJLinkTcpIpSerialNo</name> <name>CCJLinkTcpIpSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCCpuClockEdit</name> <name>CCCpuClockEdit</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCSwoClockAuto</name> <name>CCSwoClockAuto</name>
@ -1074,7 +1074,7 @@
</option> </option>
<option> <option>
<name>CCLmiftdiUsbSerialNo</name> <name>CCLmiftdiUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCLmiftdiUsbSerialNoSelect</name> <name>CCLmiftdiUsbSerialNoSelect</name>
@ -1227,7 +1227,7 @@
</option> </option>
<option> <option>
<name>CCSTLinkUsbSerialNo</name> <name>CCSTLinkUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCSTLinkUsbSerialNoSelect</name> <name>CCSTLinkUsbSerialNoSelect</name>
@ -1240,7 +1240,7 @@
</option> </option>
<option> <option>
<name>CCSTLinkDAPNumber</name> <name>CCSTLinkDAPNumber</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCSTLinkDebugAccessPortRadio</name> <name>CCSTLinkDebugAccessPortRadio</name>
@ -1378,11 +1378,11 @@
</option> </option>
<option> <option>
<name>TIPackage</name> <name>TIPackage</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>BoardFile</name> <name>BoardFile</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>DoLogfile</name> <name>DoLogfile</name>
@ -1474,7 +1474,7 @@
</option> </option>
<option> <option>
<name>CCXds100CpuClockEdit</name> <name>CCXds100CpuClockEdit</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCXds100SwoClockAuto</name> <name>CCXds100SwoClockAuto</name>
@ -1495,7 +1495,7 @@
</option> </option>
<option> <option>
<name>CCXds100UsbSerialNo</name> <name>CCXds100UsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCXds100UsbSerialNoSelect</name> <name>CCXds100UsbSerialNoSelect</name>

File diff suppressed because it is too large Load Diff

View File

@ -1445,9 +1445,6 @@
</group> </group>
<group> <group>
<name>businessLogic</name> <name>businessLogic</name>
<file>
<name>$PROJ_DIR$\..\APP\businessLogic\Src\abnormalManage.c</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\APP\businessLogic\Src\bl_chargControl.c</name> <name>$PROJ_DIR$\..\APP\businessLogic\Src\bl_chargControl.c</name>
</file> </file>
@ -1457,24 +1454,12 @@
<file> <file>
<name>$PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c</name> <name>$PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c</name>
</file> </file>
<file>
<name>$PROJ_DIR$\..\APP\businessLogic\Src\Init.c</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\APP\businessLogic\Src\parameter.c</name> <name>$PROJ_DIR$\..\APP\businessLogic\Src\parameter.c</name>
</file> </file>
<file>
<name>$PROJ_DIR$\..\APP\businessLogic\Src\test.c</name>
</file>
</group> </group>
<group> <group>
<name>functionalModule</name> <name>functionalModule</name>
<file>
<name>$PROJ_DIR$\..\APP\functionalModule\Src\capture.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\APP\functionalModule\Src\checkTime.c</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\APP\functionalModule\Src\flash.c</name> <name>$PROJ_DIR$\..\APP\functionalModule\Src\flash.c</name>
</file> </file>
@ -1484,18 +1469,9 @@
<file> <file>
<name>$PROJ_DIR$\..\APP\functionalModule\Src\FM_TIM.c</name> <name>$PROJ_DIR$\..\APP\functionalModule\Src\FM_TIM.c</name>
</file> </file>
<file>
<name>$PROJ_DIR$\..\APP\functionalModule\Src\uart_dev.c</name>
</file>
</group> </group>
<group> <group>
<name>hardwareDriver</name> <name>hardwareDriver</name>
<file>
<name>$PROJ_DIR$\..\APP\hardwareDriver\Src\HD_ADC.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\APP\hardwareDriver\Src\HD_COMM.c</name>
</file>
<file> <file>
<name>$PROJ_DIR$\..\APP\hardwareDriver\Src\HD_GPIO.c</name> <name>$PROJ_DIR$\..\APP\hardwareDriver\Src\HD_GPIO.c</name>
</file> </file>

View File

@ -38,8 +38,8 @@ ADC2.NbrOfConversionFlag=1
ADC2.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE ADC2.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE
ADC2.Rank-0\#ChannelRegularConversion=1 ADC2.Rank-0\#ChannelRegularConversion=1
ADC2.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_6CYCLES_5 ADC2.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_6CYCLES_5
CAD.formats=[] CAD.formats=
CAD.pinconfig=Dual CAD.pinconfig=
CAD.provider= CAD.provider=
Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY
Dma.ADC1.0.EventEnable=DISABLE Dma.ADC1.0.EventEnable=DISABLE
@ -67,12 +67,9 @@ Mcu.CPN=STM32G431RBT6
Mcu.Family=STM32G4 Mcu.Family=STM32G4
Mcu.IP0=ADC1 Mcu.IP0=ADC1
Mcu.IP1=ADC2 Mcu.IP1=ADC2
Mcu.IP10=TIM15 Mcu.IP10=UART4
Mcu.IP11=TIM16 Mcu.IP11=USART2
Mcu.IP12=TIM17 Mcu.IP12=USART3
Mcu.IP13=UART4
Mcu.IP14=USART2
Mcu.IP15=USART3
Mcu.IP2=DMA Mcu.IP2=DMA
Mcu.IP3=NVIC Mcu.IP3=NVIC
Mcu.IP4=RCC Mcu.IP4=RCC
@ -81,7 +78,7 @@ Mcu.IP6=SYS
Mcu.IP7=TIM3 Mcu.IP7=TIM3
Mcu.IP8=TIM6 Mcu.IP8=TIM6
Mcu.IP9=TIM7 Mcu.IP9=TIM7
Mcu.IPNb=16 Mcu.IPNb=13
Mcu.Name=STM32G431R(6-8-B)Tx Mcu.Name=STM32G431R(6-8-B)Tx
Mcu.Package=LQFP64 Mcu.Package=LQFP64
Mcu.Pin0=PC13 Mcu.Pin0=PC13
@ -113,17 +110,14 @@ Mcu.Pin31=VP_SYS_VS_tim1
Mcu.Pin32=VP_SYS_VS_DBSignals Mcu.Pin32=VP_SYS_VS_DBSignals
Mcu.Pin33=VP_TIM6_VS_ClockSourceINT Mcu.Pin33=VP_TIM6_VS_ClockSourceINT
Mcu.Pin34=VP_TIM7_VS_ClockSourceINT Mcu.Pin34=VP_TIM7_VS_ClockSourceINT
Mcu.Pin35=VP_TIM15_VS_ClockSourceINT Mcu.Pin35=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.4.0_1.4.0
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.Pin4=PC2 Mcu.Pin4=PC2
Mcu.Pin5=PA0 Mcu.Pin5=PA0
Mcu.Pin6=PA1 Mcu.Pin6=PA1
Mcu.Pin7=PA2 Mcu.Pin7=PA2
Mcu.Pin8=PA3 Mcu.Pin8=PA3
Mcu.Pin9=PA4 Mcu.Pin9=PA4
Mcu.PinsNb=39 Mcu.PinsNb=36
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0 Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0
Mcu.ThirdPartyNb=1 Mcu.ThirdPartyNb=1
Mcu.UserConstants= Mcu.UserConstants=
@ -142,11 +136,8 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 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.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.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.TIM6_DAC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.TIM7_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.TimeBase=TIM1_UP_TIM16_IRQn NVIC.TimeBase=TIM1_UP_TIM16_IRQn
NVIC.TimeBaseIP=TIM1 NVIC.TimeBaseIP=TIM1
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
@ -307,7 +298,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath= ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false 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
RCC.ADC12Freq_Value=72000000 RCC.ADC12Freq_Value=72000000
RCC.AHBFreq_Value=72000000 RCC.AHBFreq_Value=72000000
RCC.APB1Freq_Value=72000000 RCC.APB1Freq_Value=72000000
@ -371,20 +362,11 @@ STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.DSPOoLibraryJjLibrary_Checked=true
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.IPParameters=LibraryCcDSPOoLibraryJjDSPOoLibrary STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.IPParameters=LibraryCcDSPOoLibraryJjDSPOoLibrary
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.LibraryCcDSPOoLibraryJjDSPOoLibrary=true STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0.LibraryCcDSPOoLibraryJjDSPOoLibrary=true
STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0_SwParameter=LibraryCcDSPOoLibraryJjDSPOoLibrary\:true; STMicroelectronics.X-CUBE-ALGOBUILD.1.4.0_SwParameter=LibraryCcDSPOoLibraryJjDSPOoLibrary\:true;
TIM15.IPParameters=PeriodNoDither,Prescaler
TIM15.PeriodNoDither=7199
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.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4 TIM3.IPParameters=PeriodNoDither,Channel-PWM Generation4 CH4
TIM3.PeriodNoDither=720 TIM3.PeriodNoDither=720
TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger TIM6.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
TIM6.PeriodNoDither=29 TIM6.PeriodNoDither=499
TIM6.Prescaler=71 TIM6.Prescaler=71
TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE
TIM7.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger TIM7.IPParameters=Prescaler,PeriodNoDither,TIM_MasterOutputTrigger
@ -403,12 +385,6 @@ VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
VP_SYS_VS_tim1.Mode=TIM1 VP_SYS_VS_tim1.Mode=TIM1
VP_SYS_VS_tim1.Signal=SYS_VS_tim1 VP_SYS_VS_tim1.Signal=SYS_VS_tim1
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.Mode=Enable_Timer
VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer

View File

@ -1,12 +1,12 @@
/* /*
* ring_queue.c * ring_queue.c
* *
* Created on: 2024621 * Created on: 2024621
* Author: psx * Author: psx
*/ */
//循环队列 //循环队列
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "ring_queue.h" #include "ring_queue.h"
@ -19,7 +19,7 @@
//void rq_debug(const char *fmt, ...){}; //void rq_debug(const char *fmt, ...){};
//#endif //#endif
//初始化队列 //初始化队列
int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size) int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size)
{ {
q->elems = buff; q->elems = buff;
@ -28,8 +28,8 @@ int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size)
return RQ_OK; return RQ_OK;
} }
//遍历队列, //遍历队列,
//消费者使用故对生产者可能修改的rear先读取缓存 //消费者使用故对生产者可能修改的rear先读取缓存
int ShowRingQueue(RingQueue *q) int ShowRingQueue(RingQueue *q)
{ {
//int i; //int i;
@ -37,25 +37,25 @@ int ShowRingQueue(RingQueue *q)
if(q->front == rear) if(q->front == rear)
{ {
//rq_debug("队列为空\n"); //rq_debug("队列为空\n");
return RQ_ERROR; return RQ_ERROR;
} }
//rq_debug("队列中的元素为:\n"); //rq_debug("队列中的元素为:\n");
//for(i=((q->front)%q->size); i != rear; i=((i+1)%q->size)) //for(i=((q->front)%q->size); i != rear; i=((i+1)%q->size))
//rq_debug(" %c\n",q->elems[i]); //rq_debug(" %c\n",q->elems[i]);
//rq_debug("\n"); //rq_debug("\n");
//rq_debug("队首元素为%c\n",q->elems[q->front]); //rq_debug("队首元素为%c\n",q->elems[q->front]);
//rq_debug("队尾元素为%c\n",q->elems[rear - 1]); //rq_debug("队尾元素为%c\n",q->elems[rear - 1]);
return RQ_OK; return RQ_OK;
} }
//向队尾插入元素e //向队尾插入元素e
int InRingQueue(RingQueue *q,RQ_ElementType e) int InRingQueue(RingQueue *q,RQ_ElementType e)
{ {
if(RingQueueFull(q)) if(RingQueueFull(q))
{ {
//rq_debug("空间不足\n"); //rq_debug("空间不足\n");
return(RQ_OVERFLOW); return(RQ_OVERFLOW);
} }
q->elems[q->rear] = e; q->elems[q->rear] = e;
@ -64,21 +64,21 @@ int InRingQueue(RingQueue *q,RQ_ElementType e)
return RQ_OK; return RQ_OK;
} }
//从队首取回并删除元素 //从队首取回并删除元素
int OutRingQueue(RingQueue *q, RQ_ElementType *e) int OutRingQueue(RingQueue *q, RQ_ElementType *e)
{ {
if(RingQueueEmpty(q)) if(RingQueueEmpty(q))
{ {
//rq_debug("队列为空\n"); //rq_debug("队列为空\n");
return RQ_ERROR; return RQ_ERROR;
} }
*e = q->elems[q->front]; *e = q->elems[q->front];
//rq_debug("被删除的队首元素为%c\n",q->elems[q->front]); //rq_debug("被删除的队首元素为%c\n",q->elems[q->front]);
q->front = (q->front+1) % q->size; q->front = (q->front+1) % q->size;
return RQ_OK; return RQ_OK;
} }
//队列中的元素个数 //队列中的元素个数
int RingQueueLength(RingQueue *q) int RingQueueLength(RingQueue *q)
{ {
return ((q->rear - q->front) + q->size) % q->size; return ((q->rear - q->front) + q->size) % q->size;

View File

@ -4,18 +4,18 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "uart_dev.h" // #include "uart_dev.h"
// #include "pdebug.h" // #include "pdebug.h"
/* Comment out this define to include debug messages */ /* Comment out this define to include debug messages */
// #define NDEBUG #define NDEBUG
#define log_info_enable 1 #define log_info_enable 1
#define log_warn_enable 0 #define log_warn_enable 0
#define log_error_enable 0 #define log_error_enable 0
/* Comment out this define to include log messages */ /* Comment out this define to include log messages */
// #define NLOG #define NLOG
#ifdef NDEBUG #ifdef NDEBUG
#define debug(M, ...) do {}while(0) #define debug(M, ...) do {}while(0)