From 0288f9a9a64fa57ccca517225b9145723c5159d6 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: Fri, 6 Dec 2024 17:38:25 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A7=E5=88=B6=E9=83=A8?=
=?UTF-8?q?=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.vscode/settings.json | 9 ++
APP/README.md | 32 ++++
APP/application/Inc/chargControl.h | 11 ++
APP/application/Inc/comm.h | 11 ++
APP/application/Inc/start.h | 10 ++
APP/application/Src/chargControl.c | 22 +++
APP/application/Src/comm.c | 8 +
APP/application/Src/start.c | 12 ++
APP/businessLogic/Inc/bl_chargControl.h | 14 ++
APP/businessLogic/Inc/bl_comm.h | 12 ++
APP/businessLogic/Inc/parameter.h | 88 +++++++++++
APP/businessLogic/Src/bl_chargControl.c | 199 ++++++++++++++++++++++++
APP/businessLogic/Src/bl_comm.c | 22 +++
APP/businessLogic/Src/parameter.c | 7 +
EWARM/chargeController.ewp | 10 +-
tools/RingQueue/ring_queue.c | 87 +++++++++++
tools/RingQueue/ring_queue.h | 46 ++++++
tools/chargControlEnum.h | 13 ++
tools/comm_types.h | 58 +++++++
tools/fdacoefs.h | 32 ++++
tools/pDebug.h | 36 +++++
21 files changed, 737 insertions(+), 2 deletions(-)
create mode 100644 .vscode/settings.json
create mode 100644 APP/README.md
create mode 100644 APP/application/Inc/chargControl.h
create mode 100644 APP/application/Inc/comm.h
create mode 100644 APP/application/Inc/start.h
create mode 100644 APP/application/Src/chargControl.c
create mode 100644 APP/application/Src/comm.c
create mode 100644 APP/application/Src/start.c
create mode 100644 APP/businessLogic/Inc/bl_chargControl.h
create mode 100644 APP/businessLogic/Inc/bl_comm.h
create mode 100644 APP/businessLogic/Inc/parameter.h
create mode 100644 APP/businessLogic/Src/bl_chargControl.c
create mode 100644 APP/businessLogic/Src/bl_comm.c
create mode 100644 APP/businessLogic/Src/parameter.c
create mode 100644 tools/RingQueue/ring_queue.c
create mode 100644 tools/RingQueue/ring_queue.h
create mode 100644 tools/chargControlEnum.h
create mode 100644 tools/comm_types.h
create mode 100644 tools/fdacoefs.h
create mode 100644 tools/pDebug.h
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..3677ba5
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,9 @@
+{
+ "files.associations": {
+ "chargcontrol.h": "c",
+ "parameter.h": "c",
+ "comm.h": "c",
+ "bl_chargcontrol.h": "c",
+ "comm_types.h": "c"
+ }
+}
\ No newline at end of file
diff --git a/APP/README.md b/APP/README.md
new file mode 100644
index 0000000..91b5920
--- /dev/null
+++ b/APP/README.md
@@ -0,0 +1,32 @@
+# application应用层
+
+
+
+
+
+
+
+# businessLogic业务逻辑层
+
+
+
+
+
+
+
+
+
+
+
+# functionalModule功能模块层
+
+
+
+
+
+
+
+
+
+# hardwareDriver硬件驱动层
+
diff --git a/APP/application/Inc/chargControl.h b/APP/application/Inc/chargControl.h
new file mode 100644
index 0000000..9a482eb
--- /dev/null
+++ b/APP/application/Inc/chargControl.h
@@ -0,0 +1,11 @@
+
+#ifndef APP_CHARG_CONTROL_H_
+#define APP_CHARG_CONTROL_H_
+
+#include "bl_chargControl.h"
+
+
+void chargControl(void);
+
+
+#endif
diff --git a/APP/application/Inc/comm.h b/APP/application/Inc/comm.h
new file mode 100644
index 0000000..ccbd4ee
--- /dev/null
+++ b/APP/application/Inc/comm.h
@@ -0,0 +1,11 @@
+
+#ifndef APP_COMM_H_
+#define APP_COMM_H_
+
+#include "comm_types.h"
+
+
+void uart_comm(void);
+
+
+#endif
\ No newline at end of file
diff --git a/APP/application/Inc/start.h b/APP/application/Inc/start.h
new file mode 100644
index 0000000..c5c1739
--- /dev/null
+++ b/APP/application/Inc/start.h
@@ -0,0 +1,10 @@
+#ifndef APP_START_H_
+#define APP_START_H_
+
+
+
+void start(void);
+
+
+
+#endif
diff --git a/APP/application/Src/chargControl.c b/APP/application/Src/chargControl.c
new file mode 100644
index 0000000..b37d090
--- /dev/null
+++ b/APP/application/Src/chargControl.c
@@ -0,0 +1,22 @@
+
+#include "chargControl.h"
+#include "parameter.h"
+#include "comm_types.h"
+
+void chargControl(void)
+{
+ getCVData();
+ judgeYNBattery();
+
+ g_otherParameter.MPPT_Mode = chargControlMode();
+
+ if (g_otherParameter.MPPT_Mode == noWork) {
+ return;
+ }
+
+ if (g_otherParameter.batteryState) {
+ BatteryChargControl();
+ } else {
+ noBatteryChargControl();
+ }
+}
diff --git a/APP/application/Src/comm.c b/APP/application/Src/comm.c
new file mode 100644
index 0000000..1c07fb7
--- /dev/null
+++ b/APP/application/Src/comm.c
@@ -0,0 +1,8 @@
+
+#include "comm.h"
+
+void uart_comm(void)
+{
+ GW485_comm();
+ BAT485_comm();
+}
diff --git a/APP/application/Src/start.c b/APP/application/Src/start.c
new file mode 100644
index 0000000..fa53097
--- /dev/null
+++ b/APP/application/Src/start.c
@@ -0,0 +1,12 @@
+
+#include "start.h"
+
+
+void start(void)
+{
+
+
+
+
+}
+
diff --git a/APP/businessLogic/Inc/bl_chargControl.h b/APP/businessLogic/Inc/bl_chargControl.h
new file mode 100644
index 0000000..6a47c70
--- /dev/null
+++ b/APP/businessLogic/Inc/bl_chargControl.h
@@ -0,0 +1,14 @@
+#ifndef BL_CHARG_CONTROL_H_
+#define BL_CHARG_CONTROL_H_
+
+#include "chargControlEnum.h"
+
+void getCVData(void);
+void judgeYNBattery(void);
+int chargControlMode(void);
+void BatteryChargControl(void);
+void noBatteryChargControl(void);
+
+extern void chargControl(void);
+
+#endif
\ No newline at end of file
diff --git a/APP/businessLogic/Inc/bl_comm.h b/APP/businessLogic/Inc/bl_comm.h
new file mode 100644
index 0000000..c4ed462
--- /dev/null
+++ b/APP/businessLogic/Inc/bl_comm.h
@@ -0,0 +1,12 @@
+
+#ifndef BL_COMM_H_
+#define BL_COMM_H_
+
+#include "comm_types.h"
+
+
+void GW485_comm(void);
+void BAT485_comm(void);
+
+
+#endif
\ No newline at end of file
diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h
new file mode 100644
index 0000000..d6e0c0a
--- /dev/null
+++ b/APP/businessLogic/Inc/parameter.h
@@ -0,0 +1,88 @@
+
+#ifndef BL_PARAMETER_H_
+#define BL_PARAMETER_H_
+
+#include "main.h"
+
+#define softVer "SV01_24101501"
+
+#pragma pack(push,1)
+
+/* 主要有配置文件读取出来的数据 */
+typedef struct _config_parameter{
+ float constantVoltageV; /* 电压高于ConstantVoltageV且电流大于(FloatI + 0.1)进行恒压充电
+ 电压低于该(ConstantVoltageV - 0.2) 进行恒流充电 (V) */
+ float floatI; /* 电压高于该ConstantVoltageV且电流低于FloatI进行浮充充电 (A) */
+ float startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 (V) */
+ float stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压停止充电 (V) */
+ float constantVoltageChargeV; /* 恒压充电时的输出电压 (V) */
+ float FloatV; /* 浮充充电时的输出电压 (V) */
+ float loopImpedance; /* 回路阻抗大小 (mΩ) */
+ float HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 (°C) */
+ float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
+ float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
+
+ uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */
+ uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
+ uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
+ uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
+ uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
+ uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
+
+ /* SL */
+ uint8_t address[7]; /* 地址 */
+ uint16_t Access_Node_Type; /* 接入节点类型 */
+ uint16_t Communication_Methods; /* 通信方式 */
+ uint16_t Registration_Status; /* 注册状态 */
+ uint8_t startFlagSL[2]; /* 起始标志 */
+ uint8_t endFlagSL; /* 结束标志 */
+
+ /* HY */
+ uint8_t hardwareID[6]; /* 硬件ID */
+ uint8_t communicationID[4]; /* 通信ID */
+ uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
+ uint8_t startFlagHY; /* 起始码 */
+ uint8_t endFlagHY; /* 结束码 */
+
+ uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
+ 0x01:是*/
+
+ uint32_t gw485_Baud; /* 串口波特率 */
+ uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
+} config_parameter;
+extern config_parameter g_cfgParameter;
+
+typedef struct _otherParameter{
+ float Battery_Voltage; /* 电池电压 (V) */
+ float Output_Voltage; /* 输出电压 */
+ float Charg_Current; /* 充电电流(流向电池+负载) (A) */
+ float Discharg_Current; /* 放电电流(流向负载) (A) */
+ float Input_Voltage; /* 系统输入电压 (V) */
+ float Solar_Open_Circuit_Voltage; /* 太阳能板开路电压 (V) */
+ float HighSideMos_Temperature; /* 高端mos的温度 (°C) */
+ float Solar_In_Circuit_Voltage; /* 太阳能板输入电压 (V) */
+
+ float Charg_BatteryCurrent; /* 电池充电电流(流向电池) (A) */
+ float totalElectricityConsumption; /* 总电量消耗(W*H) */
+ float totalChargCapacity; /* 总充电电量(W*H) */
+ float SOC; /* 剩余电量 */
+
+ uint16_t chargMos_State; /* 充电开关状态 */
+ uint16_t DischargMos_State; /* 放电mos的状态 */
+ uint16_t MPPT_Mode; /* 工作模式 */
+
+ uint8_t versionInformation[13]; /* 软件版本信息 */
+
+ uint8_t batteryState; /* 有无电池(估计) */
+
+
+
+
+
+
+
+ float dutyRatio; /* 占空比 */
+}otherParameter;
+extern otherParameter g_otherParameter;
+
+
diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c
new file mode 100644
index 0000000..9adcc8f
--- /dev/null
+++ b/APP/businessLogic/Src/bl_chargControl.c
@@ -0,0 +1,199 @@
+
+#include "bl_chargControl.h"
+#include "parameter.h"
+#include "comm_types.h"
+
+static void stopChargWork(void);
+static int stopChargConditions(void);
+static int floatChargConditions(void);
+static int mpptChargConditions(void);
+static int constantVChargConditions(void);
+static void mpptCharge(void);
+static void constantVoltageCharge(void);
+static void floatCharge(void);
+
+/**
+ * @brief 停止充电
+ * @param
+ * @retval
+ *
+ */
+void stopChargWork(void)
+{
+
+}
+
+/**
+ * @brief 判断达到停止充电的条件
+ * @param
+ * @retval TRUE 达到停止充电
+ * FALSE 未达到
+ *
+ */
+BOOL stopChargConditions(void)
+{
+
+
+ return FALSE;
+}
+
+/**
+ * @brief 判断达到浮充充电的条件
+ * @param
+ * @retval TRUE 达到
+ * FALSE 未达到
+ *
+ */
+BOOL floatChargConditions(void)
+{
+
+ return FALSE;
+}
+
+/**
+ * @brief 判断达到最大功率充电的条件
+ * @param
+ * @retval TRUE 达到
+ * FALSE 未达到
+ *
+ */
+BOOL mpptChargConditions(void)
+{
+
+ return FALSE;
+}
+
+/**
+ * @brief 判断达到恒压充电的条件
+ * @param
+ * @retval TRUE 达到
+ * FALSE 未达到
+ *
+ */
+BOOL constantVChargConditions(void)
+{
+
+ return FALSE;
+}
+
+/**
+ * @brief 判断充电控制的模式
+ * @param
+ * @retval 返回充电控制器的模式
+ *
+ */
+int chargControlMode(void)
+{
+ if (stopChargConditions()) {
+ stopChargWork();
+ return noWork;
+ }
+
+ if (floatChargConditions()) {
+ return floatCharg;
+ }
+
+ if (mpptChargConditions()) {
+ return MPPT;
+ }
+
+ if (constantVChargConditions()) {
+ return constantVoltage;
+ }
+}
+
+/**
+ * @brief 得到充电控制器控制所需的电流电压
+ * @param
+ * @retval
+ *
+ */
+void getCVData(void)
+{
+
+}
+
+/**
+ * @brief 判断有无电池
+ * @param
+ * @retval
+ *
+ */
+void judgeYNBattery(void)
+{
+
+}
+
+/**
+ * @brief 无电池时控制
+ * @param
+ * @retval
+ *
+ */
+void noBatteryChargControl(void)
+{
+
+}
+
+/**
+ * @brief 最大功率充电
+ * @param
+ * @retval
+ *
+ */
+void mpptCharge(void)
+{
+
+}
+
+/**
+ * @brief 恒压充电
+ * @param
+ * @retval
+ *
+ */
+void constantVoltageCharge(void)
+{
+
+
+}
+
+/**
+ * @brief 浮充充电
+ * @param
+ * @retval
+ *
+ */
+ void floatCharge(void)
+ {
+
+ }
+
+/**
+ * @brief 有电池时控制
+ * @param
+ * @retval
+ *
+ */
+void BatteryChargControl(void)
+{
+ switch(g_otherParameter.MPPT_Mode) {
+
+ case CONSTANTCURRENT:
+ mpptCharge();
+ break;
+
+ case CONSTANTVOLTAGE:
+ constantVoltageCharge();
+ break;
+
+ case FLOAT:
+ floatCharge();
+ break;
+
+ default:
+ stopChargWork();
+ break;
+ }
+}
+
diff --git a/APP/businessLogic/Src/bl_comm.c b/APP/businessLogic/Src/bl_comm.c
new file mode 100644
index 0000000..5b4655a
--- /dev/null
+++ b/APP/businessLogic/Src/bl_comm.c
@@ -0,0 +1,22 @@
+
+#include "bl_comm.h"
+
+
+
+
+
+
+
+
+void GW485_comm(void)
+{
+
+}
+
+
+
+
+void BAT485_comm(void)
+{
+
+}
\ No newline at end of file
diff --git a/APP/businessLogic/Src/parameter.c b/APP/businessLogic/Src/parameter.c
new file mode 100644
index 0000000..1355057
--- /dev/null
+++ b/APP/businessLogic/Src/parameter.c
@@ -0,0 +1,7 @@
+
+#include "parameter.h"
+
+config_parameter g_cfgParameter = {0};
+otherParameter g_otherParameter = {0};
+
+
diff --git a/EWARM/chargeController.ewp b/EWARM/chargeController.ewp
index 10a9b39..efd1f26 100644
--- a/EWARM/chargeController.ewp
+++ b/EWARM/chargeController.ewp
@@ -62,7 +62,7 @@