Compare commits

...

10 Commits

Author SHA1 Message Date
起床就犯困 1743b311fb 尝试使用中断发送串口数据 2024-11-20 14:12:33 +08:00
起床就犯困 a3b56a4252 修改mppt的方式为扰动干扰法 2024-11-18 10:48:07 +08:00
起床就犯困 a768f1cf3f 241113.16 2024-11-13 16:44:13 +08:00
起床就犯困 daec605235 修改存入flash的时间 2024-11-08 16:51:14 +08:00
起床就犯困 8f1a9d9b2b 完善通信协议部分,发现有概率flash出错 2024-11-08 09:05:42 +08:00
起床就犯困 a83d788afb 增加配置文件升级 2024-10-26 09:07:30 +08:00
起床就犯困 20d2cfe02f 修改部分全局变量的存放,同时启用hy和sl协议(未更改完) 2024-10-18 16:55:39 +08:00
起床就犯困 a3d0cc2c68 增加一个环形buff 2024-10-14 10:50:02 +08:00
起床就犯困 f72590e9a8 修改flash中保存的数据,设置两个结构体,保存全局所需数据 2024-10-12 17:51:15 +08:00
起床就犯困 3ec7ad0781 串口主体 2024-10-12 10:23:32 +08:00
77 changed files with 25429 additions and 17957 deletions

View File

@ -69,8 +69,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Peripheral/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mppt_Nos_V0.4/App/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mppt_Nos_V0.4/Hardware/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mppt_Nos_V0.4/Drivers/RingQueue}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mppt_Nos_V0.4/Drivers/TimeSliceOffset}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mppt_Nos_V0.4/Drivers/RingQueue}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mppt_Nos_V0.4/Drivers/RingQueue2}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
@ -150,4 +151,5 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="998107432084761222" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="742743566734499151" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -1,6 +1,6 @@
Address=0x08000000
Target Path=obj\mppt_Nos_V0.4.hex
Erase All=true
Erase All=false
Program=true
Verify=true
Reset=true

View File

@ -10,6 +10,19 @@
#include "debug.h"
#include "adc.h"
#include "ring_queue2.h"
#define adcBuffSize 100
typedef struct _ADC_DATA{
RingQueue2 RQCHG_CURR;
RingQueue2 RQDSG_CURR;
int32_t total_CHG_CURR; /* 充电电流adc之和 */
int32_t total_DSG_CURR; /* 放电电流adc之和 */
}ADC_DATA;
extern ADC_DATA g_adcData;
void currBuffInit(void);
void adcChangeProportionalInit(void);
float get_CHG_CURR(void);
float get_PV_VOLT_OUT(void);
@ -17,6 +30,6 @@ float get_DSG_CURR(void);
float get_PV1_VOLT_IN(void);
float get_PV_VOLT_IN1(void);
float get_MOSFET_Temper(void);
float get_PV2_VOLT_IN(void);
//float get_PV2_VOLT_IN(void);
#endif /* APP_INC_COLLECT_CONVERSION_H_ */

607
App/inc/hy_protocol.h Normal file
View File

@ -0,0 +1,607 @@
/*
* hy_protocol.h
*
* Created on: 20241011
* Author: psx
*/
#ifndef APP_INC_HY_PROTOCOL_H_
#define APP_INC_HY_PROTOCOL_H_
#include "debug.h"
#include "uart_dev.h"
#include "math.h"
/* 功能码 */
typedef enum
{
HY_batteryStatus = 0x60, /* 电池状态数据报 */
HY_electricityStatistics = 0x61, /* 电量统计数据报 */
HY_sensorNumberConfiguration = 0x62, /* 传感器号码配置 */
HY_sensorNumberInquiry = 0x63, /* 传感器号码查询 */
HY_chargingThresholdVoltageConfiguration = 0x64, /* 充电阈值电压配置 */
HY_chargingRangeVoltageQuery = 0x65, /* 充电域值电压查询 */
HY_resetInstruction = 0x66, /* 复位指令 */
HY_chargingControlConfiguration = 0x6C, /* 充电控制配置 */
HY_chargingControlQuery = 0x6D, /* 充电控制查询 */
HY_configureProtocolType = 0x70, /* 配置协议类型 */
HY_responseConfigureProtocolType = 0x71, /* 响应配置协议类型 */
HY_queryControlBoxConfiguration = 0x74, /* 查询电池控制盒当前配置 */
HY_querySoftwareVersion = 0x75, /* 查询电池控制盒软件版本 */
HY_enterConfigurationMode = 0x76, /* 进入配置模式 */
HY_configureHardwareID = 0x7B, /* 配置控制盒硬件ID号 */
HY_hardwareID_communicationIDQuery = 0x7C, /* 控制盒硬件ID号及通信ID号原传感器号查询 */
HY_modifyCommunicationID = 0x7D, /* 修改通信ID号原传感器号 */
HY_checkMotherboardTemperature = 0x7E, /* 查询主板温度值 */
}HY_MsgFunctionCode;
/* 解析数据包的长度 */
typedef enum
{
HY_analyzeStartFlag = 1, /* 长度为1时解析起始标志 */
HY_analyzeHardwareID = 7, /* 长度为7时解析硬件ID */
HY_analyzeCommunicationID = 11, /* 长度为10时解析通信ID */
HY_analyzeControlWord = 12, /* 长度为12时解析控制字 */
HY_analyzeDataLen = 14, /* 长度为14时解析数据长度 */
}HY_AnalyzeDataLen;
/* 执行状态 */
typedef enum
{
/* 返回状态 */
HY_success = 0xFF, /* 成功 */
HY_fail = 0x00, /* 失败 */
/* 返回状态 */
HY_success1 = 0x01, /* 成功 */
/* 充电开关状态 */
HY_switchON = 0x01, /* 打开 */
HY_switchOFF = 0x00, /* 关闭 */
/* 控制开关状态 */
HY_cSwitchON = 0x00, /* 打开 */
HY_cSwitchOFF = 0x01, /* 关闭 */
}HY_state;
/* 指定对齐方式为1字节 */
#pragma pack(push,1)
/* 通用参数 */
typedef struct _HY_Recv_pack{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
}HY_Recv_pack;
/* 功能码处理函数 */
typedef void (*HYMsgProcFunc)(device_handle device, void*, uint32_t MsgLen);
typedef struct _HY_FunctionMsgProcTable{
u_int32_t msgId;
HYMsgProcFunc pMsgProc;
}HY_FuncionMsgProcTable;
/* 电池状态数据报查询 */
typedef struct _HY_batteryStatusQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_batteryStatusQuery;
#define HY_batteryStatusQuery_PACK_SIZE (sizeof(HY_batteryStatusQuery))
/* 电池状态数据报响应 */
typedef struct _HY_batteryStatusResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
float_t batteryVoltage; /* 电池电压 */
float_t dischargCurrent; /* 输出电流(流向负载) */
float_t chargCurrent1; /* 充电电流(流向电池+负载) */
float_t SOC; /* 剩余电量 */
float_t openCircuitVoltage1; /* 充电开路电压 */
uint8_t chargSwitchStatus1; /* 充电开关状态 */
float_t chargCurrent2; /* 充电电流(流向电池+负载) */
float_t openCircuitVoltage2; /* 充电开路电压 */
uint8_t chargSwitchStatus2; /* 充电开关状态 */
float_t Mos_Temperature; /* 工作温度 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_batteryStatusResponse;
#define HY_batteryStatusResponse_PACK_SIZE (sizeof(HY_batteryStatusResponse))
#define HY_batteryStatusResponse_dataLen 38
/* 电量统计数据报查询 */
typedef struct _HY_electricityStatisticsQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_electricityStatisticsQuery;
#define HY_electricityStatisticsQuery_PACK_SIZE (sizeof(HY_electricityStatisticsQuery))
/* 电量统计数据报响应 */
typedef struct _HY_electricityStatisticsResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
float_t statisticalDuration; /* 统计时长 */
float_t totalElectricityConsumption; /* 总电量消耗 */
float_t totalChargCapacity; /* 总充电电量 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_electricityStatisticsResponse;
#define HY_electricityStatisticsResponse_PACK_SIZE (sizeof(HY_electricityStatisticsResponse))
#define HY_electricityStatisticsResponse_dataLen 16
/* 传感器号码配置 */
typedef struct _HY_sensorNumberConfig{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t newHardwareID[6]; /* 新硬件ID高字节在前低字节在后保持不变 */
uint8_t newCommunicationID[4]; /* 新通信ID高字节在前低字节在后 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_sensorNumberConfig;
#define HY_sensorNumberConfiguration_PACK_SIZE (sizeof(HY_sensorNumberConfig))
/* 传感器号码配置响应 */
typedef struct _HY_sensorNumberConfigurationResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_sensorNumberConfigurationResponse;
#define HY_sensorNumberConfigurationResponse_PACK_SIZE (sizeof(HY_sensorNumberConfigurationResponse))
#define HY_sensorNumberConfigurationResponse_dataLen 5
/* 传感器号码查询 */
typedef struct _HY_sensorNumberInquiryQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t broadcastTerminal[6]; /* 广播终端ID:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF */
uint8_t broadcastCommunication[4]; /* 广播通信ID:0xFF 0xFF 0xFF 0xFF */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_sensorNumberInquiryQuery;
#define HY_sensorNumberInquiryQuery_PACK_SIZE (sizeof(HY_sensorNumberInquiryQuery))
/* 传感器号码查询响应 */
typedef struct _HY_sensorNumberInquiryResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t hardwareIDR[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationIDR[4]; /* 通信ID高字节在前低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_sensorNumberInquiryResponse;
#define HY_sensorNumberInquiryResponse_PACK_SIZE (sizeof(HY_sensorNumberInquiryResponse))
#define HY_sensorNumberInquiryResponse_dataLen 14
/* 充电阈值电压配置 */
typedef struct _HY_chargingThresholdVoltageConfig{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
float_t chargOpenVoltage; /* 充电开电池电压 */
float_t chargCloseVoltage; /* 充电关电池电压 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_chargingThresholdVoltageConfig;
#define HY_chargingThresholdVoltageConfig_PACK_SIZE (sizeof(HY_chargingThresholdVoltageConfig))
/* 充电阈值电压配置响应 */
typedef struct _HY_chargingThresholdVoltageConfigResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_chargingThresholdVoltageConfigResponse;
#define HY_chargingThresholdVoltageConfigResponse_PACK_SIZE (sizeof(HY_chargingThresholdVoltageConfigResponse))
/* 充电域值电压查询 */
typedef struct _HY_chargRangeVoltageQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_chargRangeVoltageQuery;
#define HY_chargRangeVoltageQuery_PACK_SIZE (sizeof(HY_chargRangeVoltageQuery))
/* 充电域值电压查询响应 */
typedef struct _HY_chargRangeVoltageQueryResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
float_t chargOpenVoltage; /* 充电开电池电压 */
float_t chargCloseVoltage; /* 充电关电池电压 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_chargRangeVoltageQueryResponse;
#define HY_chargRangeVoltageQueryResponse_PACK_SIZE (sizeof(HY_chargRangeVoltageQueryResponse))
/* 复位指令 */
typedef struct _HY_resetInstructionQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_resetInstructionQuery;
#define HY_resetInstructionQuery_PACK_SIZE (sizeof(HY_resetInstructionQuery))
/* 复位指令响应 */
typedef struct _HY_resetInstructionResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_resetInstructionResponse;
#define HY_resetInstructionResponse_PACK_SIZE (sizeof(HY_resetInstructionResponse))
#define HY_resetInstructionResponse_dataLen 5
/* 充电控制配置 */
typedef struct _HY_chargingControlConfig{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t chargInterface; /* 充电接口 */
uint8_t chargInterfaceControl; /* 充电接口控制 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_chargingControlConfig;
#define HY_chargingControlConfig_PACK_SIZE (sizeof(HY_chargingControlConfig))
/* 充电控制配置响应 */
typedef struct _HY_chargingControlConfigResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_chargingControlConfigResponse;
#define HY_chargingControlConfigResponse_PACK_SIZE (sizeof(HY_chargingControlConfigResponse))
#define HY_chargingControlConfigResponse_dataLen 5
/* 充电控制查询 */
typedef struct _HY_QueryChargingControl{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_QueryChargingControl;
#define HY_QueryChargingControl_PACK_SIZE (sizeof(HY_QueryChargingControl))
/* 充电控制查询响应 */
typedef struct _HY_QueryChargingControlResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t chargInterface1; /* 充电接口1状态 */
uint8_t chargInterface2; /* 充电接口2状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_QueryChargingControlResponse;
#define HY_QueryChargingControlResponse_PACK_SIZE (sizeof(HY_QueryChargingControlResponse))
#define HY_QueryChargingControlResponse_dataLen 6
/* 配置协议类型 */
typedef struct _HY_configProtocolType{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t protocolType; /* 协议类型; 0x01表示汇源协议(波特率9600) 0x02表示南瑞协议(波特率115200)*/
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_configProtocolType;
#define HY_configProtocolType_PACK_SIZE (sizeof(HY_configProtocolType))
/* 配置协议类型响应 */
typedef struct _HY_configProtocolTypeResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_configProtocolTypeResponse;
#define HY_configProtocolTypeResponse_PACK_SIZE (sizeof(HY_configProtocolTypeResponse))
#define HY_configProtocolTypeResponse_dataLen 5
/* 查询电池控制盒当前配置 */
typedef struct _HY_queryControlBoxConfigurationQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_queryControlBoxConfigurationQuery;
#define HY_queryControlBoxConfigurationQuery_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationQuery))
/* 查询电池控制盒当前配置响应 */
typedef struct _HY_queryControlBoxConfigurationResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t protocolType; /* 协议类型; 0x01表示汇源协议(波特率9600) 0x02表示南瑞协议(波特率115200)*/
uint8_t voltageLevel; /* 电压等级 */
uint8_t mainBoardTemperatureSensorType; /* 主板温度传感器类型 */
uint8_t batteryTemperatureSensorType; /* 电池温度传感器类型 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_queryControlBoxConfigurationResponse;
#define HY_queryControlBoxConfigurationResponse_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationResponse))
#define HY_queryControlBoxConfigurationResponse_dataLen 8
/* 查询电池控制盒软件版本 */
typedef struct _HY_SoftwareVersionQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_SoftwareVersionQuery;
#define HY_SoftwareVersionQuery_PACK_SIZE (sizeof(HY_SoftwareVersionQuery))
/* 查询电池控制盒软件版本响应 */
typedef struct _HY_SoftwareVersionQueryResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t versionInformation[13]; /* 版本信息 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_SoftwareVersionQueryResponse;
#define HY_SoftwareVersionQueryResponse_PACK_SIZE (sizeof(HY_SoftwareVersionQueryResponse))
#define HY_SoftwareVersionQueryResponse_dataLen 17
/* 进入配置模式 */
typedef struct _HY_enterConfigMode{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_enterConfigMode;
#define HY_enterConfigMode_PACK_SIZE (sizeof(HY_enterConfigMode))
/* 进入配置模式响应 */
typedef struct _HY_enterConfigModeResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_enterConfigModeResponse;
#define HY_enterConfigModeResponse_PACK_SIZE (sizeof(HY_enterConfigModeResponse))
#define HY_enterConfigModeResponse_dataLen 5
/* 配置控制盒硬件ID号 */
typedef struct _HY_configHardwareID{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t newHardwareID[6]; /* 新硬件ID高字节在前低字节在后 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_configHardwareID;
#define HY_configHardwareID_PACK_SIZE (sizeof(HY_configHardwareID))
/* 配置控制盒硬件ID号 响应*/
typedef struct _HY_configHardwareIDResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_configHardwareIDResponse;
#define HY_configHardwareIDResponse_PACK_SIZE (sizeof(HY_configHardwareIDResponse))
#define HY_configHardwareIDResponse_dataLen 5
/* 控制盒硬件ID号及通信ID号原传感器号查询 */
typedef struct _HY_QueryhardwareID_communicationID{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_QueryhardwareID_communicationID;
#define HY_QueryhardwareID_communicationID_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationID))
/* 控制盒硬件ID号及通信ID号原传感器号查询响应 */
typedef struct _HY_QueryhardwareID_communicationIDResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t hardwareIDR[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationIDR[4]; /* 通信ID高字节在前低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_QueryhardwareID_communicationIDResponse;
#define HY_QueryhardwareID_communicationIDResponse_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationIDResponse))
#define HY_QueryhardwareID_dataLen 14
/* 修改通信ID号原传感器号 */
typedef struct _HY_modifyCommunicationIDChange{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t newHardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t newCommunicationID[4]; /* 新通信ID高字节在前低字节在后 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_modifyCommunicationIDChange;
#define HY_modifyCommunicationIDChange_PACK_SIZE (sizeof(HY_modifyCommunicationIDChange))
/* 修改通信ID号原传感器号响应 */
typedef struct _HY_modifyCommunicationIDChangeResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint8_t state; /* 状态 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_modifyCommunicationIDChangeResponse;
#define HY_modifyCommunicationIDChangeResponse_PACK_SIZE (sizeof(HY_modifyCommunicationIDChangeResponse))
#define HY_modifyCommunicationIDChangeResponse_dataLen 5
/* 查询主板温度值 */
typedef struct _HY_checkMotherboardTemperatureQuery{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_checkMotherboardTemperatureQuery;
#define HY_checkMotherboardTemperatureQuery_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureQuery))
/* 查询主板温度值响应 */
typedef struct _HY_checkMotherboardTemperatureResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
float_t MotherboardTemperature; /* 主板温度 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */
}HY_checkMotherboardTemperatureResponse;
#define HY_checkMotherboardTemperatureResponse_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureResponse))
#define HY_checkMotherboardTemperatureResponse_dataLen 8
/* 恢复默认的对齐设置 */
#pragma pack(pop)
uint8_t HY_CheckFunc(uint8_t *arr_buff, uint8_t len);
void HY_read_and_process_uart_data(device_handle device);
#endif /* APP_INC_HY_PROTOCOL_H_ */

View File

@ -9,74 +9,124 @@
#define APP_INC_INFLASH_H_
#include "debug.h"
#include "math.h"
#define softVer "SV01_24101501"
#pragma pack(push,1)
typedef struct _uint8_config_info{
uint8_t start_Flag[2]; /* 起始标志 */
/* 高字节在前,低字节在后 */
typedef struct _recv_config_info{
uint8_t start_Flag[2]; /* 开始标志 */
/* SL */
uint8_t address[7]; /* 地址 */
uint8_t end_Flag; /* 结束标志 */
uint8_t Access_Node_Type[2]; /* 接入节点类型 */
uint8_t Communication_Methods[2]; /* 通信方式 */
uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
uint8_t gw485_Baud[4]; /* 串口波特率 */
uint8_t ConstantCurrentV[2]; /* 高于该(电压 / 100),小于ConstantVoltageV * 100电压进行恒流充电 */
uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
/* HY */
uint8_t hardwareID[6]; /* 硬件ID */
uint8_t communicationID[4]; /* 通信ID */
uint8_t protocolType; /* 协议类型; 0x01表示汇源协议(波特率9600) 0x02表示南瑞协议(波特率115200)*/
uint8_t CommunicationProtocolType; /* 0x00:SL
0x01:HY*/
uint8_t onlyPower; /* 是否只充当电源板0x00:不是
0x01*/
uint8_t ConstantVoltageV[2]; /* 高于该(电压 / 100)且电流大于FloatI * 100进行恒压充电 */
uint8_t FloatI[2]; /* 高于该(电压 / 100)且电流低于FloatI * 100进行浮充充电 */
uint8_t startSolarOpenCircuitV[2]; /* 高于该(电压 / 100)开始充电 */
}uint8_config_info;
uint8_t stopSolarOpenCircuitV[2]; /* 太阳能板开路电压高于该电压停止充电 (V) */
uint8_t constantVoltageChargeV[2]; /* 恒压充电时的输出电压 (V) */
uint8_t FloatChargeV[2]; /* 浮充充电时的输出电压 (V) */
uint8_t HighSideMosTemperature_stop[2]; /* 当上桥温度达到该值时,停止输出 (°C) */
uint8_t HighSideMosTemperature_end[2]; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
uint8_t HighSideMosTemperature_start[2];/* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
// uint8_t loopImpedance[2]; /* 回路阻抗大小 (Ω) */
// uint8_t totalElectricityConsumption[2]; /* 总电量消耗 */
// uint8_t totalChargCapacity[2]; /* 总充电电量 */
//typedef struct _config_info{
// uint8_t start_Flag[2]; /* 起始标志 */
// uint8_t address[7]; /* 地址 */
// uint8_t end_Flag; /* 结束标志 */
// uint16_t Access_Node_Type; /* 接入节点类型 */
// uint16_t Communication_Methods; /* 通信方式 */
// uint32_t bat485_Baud; /* 串口波特率 */
// uint32_t gw485_Baud; /* 串口波特率 */
// uint16_t ConstantCurrentV; /* 高于该(电压 / 100),小于ConstantVoltageV / 100电压进行恒流充电 */
// uint16_t ConstantVoltageV; /* 高于该(电压 / 100)且电流大于FloatI / 100进行恒压充电 */
// uint16_t FloatI; /* 高于该(电压 / 100)且电流低于FloatI / 100进行浮充充电 */
// uint16_t startSolarOpenCircuitV;/* 高于该(电压 / 100)开始充电 */
//}config_info;
uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
// uint8_t registerRefreshTime[2]; /* 寄存器数据刷新时间 (S) */
uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */
uint8_t outputAgainFlagTime[2]; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
uint8_t excessiveLoadFlagTime[2]; /* 出现过载后在该间隔时间中多次2次出现过载则关闭输出 (S) */
uint8_t eLAgainTime[2]; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
uint8_t crc[2]; /* 校验 */
uint8_t end_Flag; /* 结束标志 */
}recv_config_info;
#define RECV_CONFIG_INFO sizeof(recv_config_info)
typedef struct _config_info{
uint8_t start_Flag[2]; /* 起始标志 */
/* SL */
uint8_t address[7]; /* 地址 */
uint32_t baud_485; /* 串口波特率 */
uint16_t constantCurrentV; /* 电压高于(ConstantCurrentV / 100 + 0.4),小于ConstantVoltageV / 100 - 0.4进入mppt模式 */
uint16_t constantVoltageV; /* 电压高于该(ConstantVoltageV / 100)且电流大于FloatI / 100 + 0.1)进行恒压充电 */
uint16_t floatI; /* 电压高于该(ConstantVoltageV / 100)且电流低于FloatI / 100进行浮充充电 */
uint16_t startSolarOpenCircuitV; /* 太阳能板开路电压高于该(电压 / 100)开始充电 */
uint16_t stopSolarOpenCircuitV; /* 太阳能板开路电压高于该(电压 / 100)停止充电 */
uint16_t constantVoltageChargeV; /* 恒压充电时的输出电压 */
uint16_t trickleChargeC; /* 涓流充电电流 */
// uint16_t FloatTime; /* 浮充时间(秒) */
uint16_t FloatV; /* 浮充电压 */
uint16_t Access_Node_Type; /* 接入节点类型 */
uint16_t Communication_Methods; /* 通信方式 */
uint32_t gw485_Baud; /* 串口波特率,为0代表bms不支持通信 */
uint32_t bat485_Baud; /* 串口波特率 */
/* HY */
uint8_t hardwareID[6]; /* 硬件ID */
uint8_t communicationID[4]; /* 通信ID */
uint8_t protocolType; /* 协议类型; 0x01表示汇源协议(波特率9600) 0x02表示南瑞协议(波特率115200)*/
uint8_t CommunicationProtocolType; /* 0x00:SL
0x01:HY*/
uint8_t onlyPower; /* 是否只充当电源板0x00:不是
0x01*/
float_t constantVoltageV; /* 电压高于ConstantVoltageV且电流大于FloatI + 0.1)进行恒压充电 */
float_t floatI; /* 电压高于ConstantVoltageV且电流低于FloatI进行浮充充电 */
float_t startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 */
float_t stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压 停止充电 */
float_t constantVoltageChargeV; /* 恒压充电时的输出电压 */
float_t FloatChargeV; /* 浮充电压 */
float_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
float_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
float_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
// float_t loopImpedance; /* 回路阻抗大小 (Ω) */
// float_t totalElectricityConsumption; /* 总电量消耗 */
// float_t totalChargCapacity; /* 总充电电量 */
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
uint16_t registerRefreshTime; /* 寄存器数据刷新时间 */
uint16_t loopImpedance; /* 回路阻抗大小 */
// uint16_t resRefreshTime; /* 回路阻抗计算间隔时长 */
// uint16_t registerRefreshTime; /* 寄存器数据刷新时间 */
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
uint16_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
uint16_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
uint16_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 */
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该段时间中再次出现过载,则关闭输出 */
uint16_t eLAgainTime; /* 出现过载过载保护后,该段时间后,再次尝试输出 */
uint8_t end_Flag; /* 结束标志 */
uint16_t crc; /* 校验 */
}config_info;
#define CONFIG_INFO_SIZE (sizeof(config_info))
#pragma pack(pop)
extern config_info g_slConfigInfo;
#define FLASH_SAVE_ADDR_BEGIN (0x00)
#define FLASH_SAVE_ADDR_END (0x00 + CONFIG_INFO_SIZE)
#define CONFIG_SAVE_addr (0)
#define CONFIG_SAVE_ADDR_BEGIN (CONFIG_INFO_SIZE)
#define CONFIG_SAVE_ADDR_END (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE)
#define LoopImpedance_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 10)
#define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20)
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
void save_config_info(config_info *save_config_info);
uint8_t read_config_info(void);
uint8_t read_config_info1(config_info *in_config_info);
void read_config_info(config_info *output_config_info);
void checkFlashContent(void);
void config_info_start(void);
void read_and_process_config_data(void);
void saveLoopImpedance(float_t *loopImpedance);
void readLoopImpedance(float_t *loopImpedance);
void savetotalElectricityConsumption(float_t *totalElectricityConsumption);
void readtotalElectricityConsumption(float_t *totalElectricityConsumption);
void savetotalChargCapacity(float_t *totalChargCapacity);
void readtotalChargCapacity(float_t *totalChargCapacity);
extern uint16_t configCheckFunc(uint8_t *arr_buff, uint8_t len);
#endif /* APP_INC_INFLASH_H_ */

View File

@ -11,14 +11,7 @@
#include "debug.h"
#include <math.h>
extern float g_duty_ratio;
extern void MpptContorl(void);
void mppt_readJust(void);
void MpptMode(void);
void mppt_constantVoltage(float InVoltage);
void test(void);
void printf_data(void);
//float_t get_capturedata(float_t (*fun)(void));
uint16_t get_mpptMode(void);
#endif /* APP_INC_MPPT_CONTROL_H_ */

101
App/inc/parameter.h Normal file
View File

@ -0,0 +1,101 @@
/*
* parameter.h
*
* Created on: 20241012
* Author: psx
*/
#ifndef APP_INC_PARAMETER_H_
#define APP_INC_PARAMETER_H_
#include "debug.h"
#include "math.h"
#include "uart_dev.h"
typedef struct _Mppt_controlparameter{
float_t constantVoltageV; /* 电压高于ConstantVoltageV且电流大于FloatI + 0.1)进行恒压充电
(ConstantVoltageV - 0.2) (V) */
float_t floatI; /* 电压高于该ConstantVoltageV且电流低于FloatI进行浮充充电 (A) */
float_t startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 (V) */
float_t stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压停止充电 (V) */
float_t constantVoltageChargeV; /* 恒压充电时的输出电压 (V) */
float_t FloatV; /* 浮充充电时的输出电压 (V) */
float_t loopImpedance; /* 回路阻抗大小 (mΩ) */
float_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 (°C) */
float_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
float_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
float_t dutyRatio; /* 占空比 */
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
uint16_t excessiveLoadFlagTime; /* 出现过载后在该间隔时间中多次2次出现过载则关闭输出 (S) */
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
} Mppt_controlparameter;
extern Mppt_controlparameter g_controlParameter;
typedef struct _Mppt_otherParameter{
/* 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 CommunicationProtocolType; /* 0x00:SL
0x01:HY*/
uint8_t onlyPower; /* 是否只充当电源板0x00:不是
0x01*/
uint32_t gw485_Baud; /* 串口波特率 */
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
float_t Battery_Voltage; /* 电池电压 (V) */
float_t Output_Voltage; /* 输出电压 */
float_t Charg_Current; /* 充电电流(流向电池+负载) (A) */
float_t Discharg_Current; /* 放电电流(流向负载) (A) */
float_t Input_Voltage; /* 系统输入电压 (V) */
float_t Solar_Open_Circuit_Voltage; /* 太阳能板开路电压 (V) */
float_t HighSideMos_Temperature; /* 高端mos的温度 (°C) */
float_t Solar_In_Circuit_Voltage; /* 太阳能板输入电压 (V) */
float_t Charg_BatteryCurrent; /* 电池充电电流(流向电池) (A) */
float_t totalElectricityConsumption; /* 总电量消耗(W*H) */
float_t totalChargCapacity; /* 总充电电量(W*H) */
float_t SOC; /* 剩余电量 */
uint16_t chargMos_State; /* 充电开关状态 */
uint16_t DischargMos_State; /* 放电mos的状态 */
uint16_t MPPT_Mode; /* 工作模式 */
uint8_t versionInformation[13]; /* 软件版本信息 */
uint8_t batteryState; /* 有无电池(估计) */
uint8_t impedanceStart; /* 能否开始测量回路阻抗 */
uint8_t outputAgainFlag; /* 一段时间中输出短路次数 */
uint8_t excessiveLoadFlag; /* 一段时间中输出过载次数 */
uint8_t overTemperature; /* 温度检测保护标志位 */
uint8_t RegistrationRequestFlag; /* 回复广播标志位 */
uint8_t runBroadcast; /* 是否接收广播帧标志位 */
uint16_t RegisterNumberMax; /* 寄存器个数 */
uint16_t RegisterStartAddressMax; /* 读写的寄存器的最大起始位置,由设备决定 */
uint32_t collectOpenCircuitVoltageNUM; /* 距离上次开路电压采集,运行次数 */
uint8_t HYconfigModeState; /* HY通信协议是否进入了配置模式0x00未进入0xFF进入 */
uint8_t HYconfigModeT; /* HY通信协议进入配置模式后的延时时间 */
uint8_t randomNumber; /* 随机数 */
}Mppt_otherParameter;
extern Mppt_otherParameter g_otherParameter;
#endif /* APP_INC_PARAMETER_H_ */

View File

@ -17,9 +17,8 @@
//#define NDEBUG
#define log_info_enable 1
#define log_warn_enable 1
#define log_error_enable 1
#define log_warn_enable 0
#define log_error_enable 0
/* Comment out this define to include log messages */
//#define NLOG

View File

@ -12,6 +12,12 @@
#include "uart_dev.h"
#include "math.h"
#define buffLen 100
#define configBuffLen 300
extern uint8_t rs485_buff[buffLen];
extern uint8_t config_buff[configBuffLen];
extern uint32_t cfig_len;
/* 功能码 */
typedef enum
{
@ -30,14 +36,18 @@ typedef enum
SL_Register_address = 0x0001, /* 地址 */
SL_Register_Access_Node_Type = 0x0002, /* 接入节点类型 */
SL_Register_Communication_Methods = 0x0003, /* 通信方式 */
SL_Register_Output_Voltage = 0x0100, /* 输出电压 */
SL_Register_Solar_Open_Circuit_Voltage = 0x0100, /* 太阳能开路电压 */
SL_Register_Battery_Voltage = 0x0101, /* 电池电压 */
SL_Register_Charg_Current = 0x0102, /* 充电电流(流向电池+负载) */
SL_Register_Discharg_Current = 0x0103, /* 放电电流(流向负载) */
SL_Register_Solar_Open_Circuit_Voltage = 0x0104, /* 太阳能开路电压 */
SL_Register_HighSideMos_Temperature = 0x0105, /* 高端mos的温度 */
SL_Register_DischargMos_State = 0x0106, /* 放电mos的状态 */
SL_Register_MPPT_Mode = 0x0107, /* 工作模式 */
SL_Register_HighSideMos_Temperature = 0x0104, /* 高端mos的温度 */
SL_Register_SOC = 0x0105, /* 剩余电量 */
SL_Register_chargState = 0x0106, /* 充电状态 */
SL_Register_totalChargCapacity = 0x0107, /* 总充电量 */
SL_Register_totalElectricityConsumption = 0x0108, /* 总放电量 */
SL_Register_MPPT_Mode = 0x0109, /* 工作模式 */
SL_Register_eliminateStatistical = 0x0110, /* 消除统计 */
}SL_Mppt_MsgRegister;
/* 注册状态 */
@ -60,7 +70,7 @@ typedef enum
{
RS485 = 1,
RJ45 = 2,
Lora = 3,
// Lora = 3, //暂时未使用
}SL_COMMUNICATIONMETHODS;
/* 放电mos管状态 */
@ -74,11 +84,9 @@ typedef enum
typedef enum
{
NoWork = 0, /* 没有工作 */
TRICKLE = 1, /* 涓流模式 */
CONSTANTCURRENT = 2, /* 恒流模式 */
CONSTANTVOLTAGE = 3, /* 恒压模式 */
FLOAT = 4, /* 浮充模式 */
NoBattery = 5, /* 没有电池 */
CONSTANTCURRENT = 1, /* 恒流模式 */
CONSTANTVOLTAGE = 2, /* 恒压模式 */
FLOAT = 3, /* 浮充模式 */
}SL_MPPT_MODE;
#define chang_8_to_16(L,H) (L | (H<<8))
@ -185,12 +193,10 @@ typedef struct _SL_Mppt_SOther_pack{
/* */
#define RECV_LENGTH 20
typedef struct _SL_Mppt_Recv_pack{
uint8_t start_Flag[2]; /* 起始标志 */
uint8_t address[7]; /* 地址 */
uint8_t function_Code; /* 功能码 */
uint8_t recv_Data[RECV_LENGTH]; /* 其他部分 */
}SL_Mppt_Recv_pack;
/* 功能码处理函数 */
@ -219,28 +225,11 @@ typedef struct _default_Value{
extern default_Value defaultValue;
typedef struct _SL_Mppt_para{
uint16_t Registration_Status; /* 注册状态 */
uint8_t address[7]; /* 地址 */
uint16_t Access_Node_Type; /* 接入节点类型 */
uint16_t Communication_Methods; /* 通信方式 */
float_t Output_Voltage; /* 输出电压 */
float_t Battery_Voltage; /* 电池电压 */
float_t Charg_Current; /* 充电电流(流向电池+负载) */
float_t Discharg_Current; /* 放电电流(流向负载) */
float_t Input_Voltage; /* 太阳能板输出电压 */
float_t Solar_Open_Circuit_Voltage; /* 太阳能板开路电压 */
float_t HighSideMos_Temperature; /* 高端mos的温度 */
uint16_t DischargMos_State; /* 放电mos的状态 */
uint16_t MPPT_Mode; /* 工作模式 */
}SL_Mppt_para;
extern SL_Mppt_para g_Mppt_Para;
/* 恢复默认的对齐设置 */
#pragma pack(pop)
void read_and_process_uart_data(device_handle device);
uint16_t CheckFunc(uint8_t *arr_buff, uint8_t len);
uint16_t CheckFuncSL(uint8_t *arr_buff, uint8_t len);
int randomDelay();
uint8_t Check_485_bus_busy(device_handle device);

View File

@ -13,79 +13,108 @@
#include "uart_dev.h"
#include "math.h"
//extern uint8_t g_interruptNum;
void stop_mpptWork(void);
void start_mpptWork(void);
void Init();
#define runled_reloadVal 1000 /* 任务执行间隔 */
#define runled_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_runled;
extern void Task_RunLED(void);
/* 控制运行指示灯和喂狗 */
#define WdiRunled_reloadVal 1000 /* 任务执行间隔 */
#define WdiRunled_offset 100 /* 任务执行偏移量 */
#define wdi_RESET (60 * 60 * 24) /* 一天复位一次 */
extern STR_TimeSliceOffset m_WdiRunled;
extern void Task_WdiRunled(void);
#define startMpptControl_reloadVal 1000 /* 任务执行间隔 */
#define startMpptControl_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_startMpptControl;;
extern void Task_startMpptControl(void);
/* 刷新寄存器中的数据 */
#define refreshRegister_reloadVal 1000 /* 任务执行间隔 */
#define refreshRegister_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_refreshRegister;
extern void Task_refreshRegister(void);
#define softStart_reloadVal 30 /* 任务执行间隔 */
/* 回路阻抗检测 */
#define impedanceCalculation_reloadVal 100 /* 任务执行间隔 */
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_impedanceCalculation;
extern void Task_impedanceCalculation(void);
/* 短路保护 */
#define outputAgain_reloadVal 1000 /* 任务执行间隔 */
#define outputAgain_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_outputAgain;
extern void Task_outputAgain(void);
/* 过载保护 */
#define excessiveLoad_reloadVal 1000 /* 任务执行间隔 */
#define excessiveLoad_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_excessiveLoad;
extern void Task_excessiveLoad(void);
/* 软启动 */
#define softStart_reloadVal 10 /* 任务执行间隔 */
#define softStart_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_softStart;
extern void Task_softStart(void);
#define usart_reloadVal 100 /* 任务执行间隔 */
#define usart_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_usart;
extern uint8_t RegistrationRequestFlag; /* 接收到广播帧标志位 */
void Task_usart(void);
/* 启动任务 */
#define startMpptControl_reloadVal 1000 /* 任务执行间隔 */
#define startMpptControl_offset 200 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_startMpptControl;
extern void Task_startMpptControl(void);
#define wdi_reloadVal 1000 /* 任务执行间隔 */
#define wdi_offset 30 /* 任务执行偏移量 */
#define wdi_RESET (60 * 60 * 24) /* 一天复位一次 */
extern STR_TimeSliceOffset m_wdi;
extern void Task_wdi(void);
/* 根据寄存器数据完成一些判断 */
#define dataJudgment_reloadVal 1000 /* 任务执行间隔 */
#define dataJudgment_offset 500 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_dataJudgment;
extern void Task_dataJudgment(void);
#define refreshRegister_reloadVal 1000 /* 任务执行间隔 */
#define refreshRegister_offset 100 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_refreshRegister;
extern uint8_t overTemperature;
extern void Task_refreshRegister(void);
/* 串口数据解析和处理 */
#define usartJudge_reloadVal 100 /* 任务执行间隔 */
#define usartJudge_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_usartJudge;
extern void Task_usartJudge(void);
#define usartHandle_reloadVal 20 /* 任务执行间隔 */
#define usartHandle_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_usartHandle;
extern void Task_usartHandle(void);
typedef void (*uartJudgeHandle)(device_handle device);
extern uartJudgeHandle uart_judge_handle;
/* 广播回应 */
#define recvbroadcast_reloadVal 3000 /* 任务执行间隔 */
#define recvbroadcast_offset 0 /* 任务执行偏移量 */
extern uint8_t recvbroadcast_flag; /* 是否需要再次发送标志 */
extern device_handle g_recvBroadcastDevice; /* 串口句柄 */
extern uint8_t g_recvBroadcastRegisterNumber; /* 寄存器长度 */
extern STR_TimeSliceOffset m_recvbroadcast;
extern STR_TimeSliceOffset g_recvbroadcast;
extern void Task_recvbroadcast(void);
#define impedanceCalculation_reloadVal 200 /* 任务执行间隔 */
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
extern float_t g_impedance;
extern uint8_t g_batteryState;
extern uint8_t g_impedanceStart;
extern STR_TimeSliceOffset m_impedanceCalculation;
extern void Task_impedanceCalculation(void);
#define outputAgain_reloadVal 1000 /* 任务执行间隔 */
#define outputAgain_offset 0 /* 任务执行偏移量 */
extern uint8_t outputAgainFlag;
extern STR_TimeSliceOffset m_outputAgain;
extern void Task_outputAgain(void);
#define excessiveLoad_reloadVal 1000 /* 任务执行间隔 */
#define excessiveLoad_offset 0 /* 任务执行偏移量 */
extern uint8_t excessiveLoadFlag;
extern STR_TimeSliceOffset m_excessiveLoad;
extern void Task_excessiveLoad(void);
/* 再次注册延时 */
#define sensorEnableBroadcast_reloadVal 1000 /* 任务执行间隔 */
#define sensorEnableBroadcast_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_sensorEnableBroadcast;
/* 是否接收广播帧标志位 */
extern uint8_t run_Broadcast;
extern STR_TimeSliceOffset g_sensorEnableBroadcast;
extern void Task_sensorEnableBroadcast(void);
void task_Init(void);
void hardware_Init(void);
/* 配置文件读取 */
#define uartConfigFile_reloadVal 200 /* 任务执行间隔 */
#define uartConfigFile_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_uartConfigFile;
extern void Task_uartConfigFile(void);
///* 过载延时 */
//#define overloadDelay_reloadVal 10 /* 任务执行间隔 */
//#define overloadDelay_offset 0 /* 任务执行偏移量 */
//extern STR_TimeSliceOffset g_overloadDelay;
//extern void Task_overloadDelay(void);
/* 开路电压采集 */
#define collectOpenCircuitVoltage_reloadVal 1000 /* 任务执行间隔 */
#define collectOpenCircuitVoltage_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_collectOpenCircuitVoltage;
extern uint8_t g_collectOpenCircuitVoltageFlag;
extern void Task_collectOpenCircuitVoltage(void);
/* HY进入配置模式延迟后退出 */
#define configurationModeDelayedExit_reloadVal 1000 /* 任务执行间隔 */
#define configurationModeDelayedExit_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_configurationModeDelayedExit;
extern void Task_configurationModeDelayedExit(void);
#endif /* APP_INC_TASK_H_ */

View File

@ -20,15 +20,10 @@
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
#define RS485_MAX_PACK_DATA_LEN 30
typedef uint32_t device_handle;
extern device_handle g_bat485_uart3_handle;
extern device_handle g_gw485_uart4_handle;
extern uint8_t rs485_out_buff[100];
//extern uint8_t rs485_out_buff[100];
typedef enum{
@ -45,6 +40,10 @@ typedef struct _uart_device_info{
RingQueue uart_ring_queue;
}uart_device_info;
void bat485_tx_enabla(void);
void bat485_tx_disenabla(void);
void gw485_tx_enabla(void);
void gw485_tx_disenabla(void);
//device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size);
device_handle uart_dev_init(void);

61
App/inc/uart_send.h Normal file
View File

@ -0,0 +1,61 @@
/*
* uart_send.h
*
* Created on: 20241119
* Author: psx
*/
#ifndef APP_INC_UART_SEND_H_
#define APP_INC_UART_SEND_H_
#include "uart_dev.h"
#define RS485_MAX_PACK_DATA_LEN 60
/* 指定对齐方式为1字节 */
#pragma pack(push,1)
typedef struct _send_data_info{
device_handle device;
uint8_t dataState; //储存数据的状态1有数据0无数据
uint8_t dataLen; //数据长度
uint8_t Counter; //已经发送的长度
uint8_t *data; //储存数据的内容
}send_data_info;
typedef struct _uart_send_info {
uint8_t insertState; //能否插入指示大于0代表能插入
uint8_t sendStateGw:1; //能否发送指示1需要发送0不需要发送
uint8_t sendStateBat:1; //能否发送指示
uint8_t sendOverStateGw:1; //发送完成指示1发送完成0发送中
uint8_t sendOverStateBat:1; //发送完成指示
uint8_t GwState:1; //向上通信485总线空闲状态1空闲0繁忙
uint8_t idleStateGw:1; //向上通信空闲状态1没数据到来0有数据到来
uint8_t BatState:1; //向下通信485总线空闲状态
uint8_t idleStateBat:1; //向下通信空闲状态
// uint8_t sendStateGw; //能否发送指示1需要发送0不需要发送
// uint8_t sendStateBat; //能否发送指示
// uint8_t sendOverStateGw; //发送完成指示1发送完成0发送中
// uint8_t sendOverStateBat; //发送完成指示
// uint8_t GwState; //向上通信485总线空闲状态1空闲0繁忙
// uint8_t idleStateGw; //向上通信空闲状态1没数据到来0有数据到来
// uint8_t BatState; //向下通信485总线空闲状态
// uint8_t idleStateBat; //向下通信空闲状态
send_data_info *insertData; //通过该指针写入数据
send_data_info *sendDataGw; //通过该指针发送数据
send_data_info *sendDataBat; //通过该指针发送数据
send_data_info data1; //储存数据的第1个位置
send_data_info data2; //储存数据的第2个位置
send_data_info data3; //储存数据的第3个位置
}uart_send_info;
/* 恢复默认的对齐设置 */
#pragma pack(pop)
extern uart_send_info uart_send;
void send_init(void);
void check_sendState(void);
void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len);
void uartDMA_Init(device_handle device, uint8_t buff[], uint8_t len);
#endif /* APP_INC_UART_SEND_H_ */

View File

@ -11,6 +11,7 @@
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include "parameter.h"
#include "uart_dev.h"
#include <string.h>
@ -27,48 +28,11 @@
//#define enable_Printf_VI
#ifdef ONLYPOWER
/* 光伏充电输出电流比例,放大倍数*电阻 */
const float P_CHG_CURR = (1.0 / (50 * 0.005 / 2));
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
//const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
//const float P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
const float P_PV_VOLT_OUT = (56.0 + 10.0) / 10.0;
/* 放电电流采集电流倍数 */
const float P_DSG_CURR = (1.0 / (50 * 0.005 / 2));
///* 光伏1开路输出电压比例 */
const float P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
//const float P_PV1_VOLT_IN = (47.0 + 4.7) / 4.7;
/* 光伏1开路输出电压比例 */
//const float P_PV1_VOLT_IN = (47 + 4.7) / 4.7;
/* 系统电源电压比例 */
const float P_PV_VOLT_IN1 = (47 + 4.7) / 4.7;
/* 温度采集比例 */
//const float P_MOSFET_TEMPER = 0;
/* 光伏2开路输出电压比例 */
const float P_PV2_VOLT_IN = (100.0 + 4.7) / 4.7;
#endif
#ifndef ONLYPOWER
/* 光伏充电输出电流比例,放大倍数*电阻 */
const float P_CHG_CURR = (1.0 / (50 * 0.005));
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
//const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
const float P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
/* 放电电流采集电流倍数 */
const float P_DSG_CURR = (1.0 / (50 * 0.005));
///* 光伏1开路输出电压比例 */
//const float P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
const float P_PV1_VOLT_IN = (47.0 + 4.7) / 4.7;
/* 光伏1开路输出电压比例 */
//const float P_PV1_VOLT_IN = (47 + 4.7) / 4.7;
/* 系统电源电压比例 */
const float P_PV_VOLT_IN1 = (47 + 4.7) / 4.7;
/* 温度采集比例 */
//const float P_MOSFET_TEMPER = 0;
/* 光伏2开路输出电压比例 */
const float P_PV2_VOLT_IN = (47 + 4.7) / 4.7;
#endif
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;
/* 温度的adc值的个数 */
#define mosTemperADCLen 241
@ -134,6 +98,65 @@ static uint16_t get_adc(uint8_t ADC_Channel);
static uint16_t get_aftercalculationAdc(uint8_t ADC_Channel);
static uint16_t middleAverageFilter(uint8_t ADC_Channel);
ADC_DATA g_adcData;
static uint16_t CHG_buff[adcBuffSize];
static uint16_t DSG_buff[adcBuffSize];
/**
* @brief buff
* @param
* @retval None
*/
void currBuffInit(void)
{
InitRingQueue2(&g_adcData.RQCHG_CURR, CHG_buff, adcBuffSize);
InitRingQueue2(&g_adcData.RQDSG_CURR, DSG_buff, adcBuffSize);
while (InRingQueue2(&g_adcData.RQCHG_CURR, 0) != -2);
while (InRingQueue2(&g_adcData.RQDSG_CURR, 0) != -2);
g_adcData.total_CHG_CURR = 0;
g_adcData.total_DSG_CURR = 0;
}
/**
* @brief AD转换的比例初始化
* @param
* @retval None
*/
void adcChangeProportionalInit(void)
{
if (g_otherParameter.onlyPower) {
/* 光伏充电输出电流比例,放大倍数*电阻 */
// P_CHG_CURR = (1.0 / (50 * 0.005 / 2));
P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002))));
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
//const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
//const float P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
P_PV_VOLT_OUT = (56.0 + 10.0) / 10.0;
/* 放电电流采集电流倍数 */
// P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.005 * 5))));
P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2))));
///* 光伏1开路输出电压比例 */
// P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
P_PV1_VOLT_IN = (47.0 + 4.7) / 4.7;
/* 光伏1开路输出电压比例 */
//const float P_PV1_VOLT_IN = (47 + 4.7) / 4.7;
/* 系统电源电压比例 */
P_PV_VOLT_IN1 = (47 + 4.7) / 4.7;
} else {
/* 光伏充电输出电流比例,放大倍数*电阻 */
P_CHG_CURR = (1.0 / (50 * 0.005));
/* 光伏充电输出电压比例,分压系数 */
P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
/* 放电电流采集电流倍数 */
P_DSG_CURR = (1.0 / (50 * 0.005));
///* 光伏1开路输出电压比例 */
P_PV1_VOLT_IN = (47.0 + 4.7) / 4.7;
/* 系统电源电压比例 */
P_PV_VOLT_IN1 = (47 + 4.7) / 4.7;
}
}
/**
* @brief adc的值
* @param ADC_Channel ADC通道
@ -394,26 +417,26 @@ float get_MOSFET_Temper(void)
* @param
* @retval V
*/
float get_PV2_VOLT_IN(void)
{
float V;
uint16_t V_ADC;
// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, SET);
// V_ADC = Get_ConversionVal(get_adc(PV2_VOLT_IN));
V_ADC = get_aftercalculationAdc(PV2_VOLT_IN);
// V_ADC = get_adc(PV2_VOLT_IN);
// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, RESET);
V = (float)(V_ADC) / 4095 * 2.5 * P_PV2_VOLT_IN;
#ifdef enable_Printf_VI
printf("\n PV2_VOLT_IN ADC : %d \n", V_ADC);
printf(" PV2_VOLT_IN V : %d /100 \n", (int)(V * 100));
#endif
return V;
}
//float get_PV2_VOLT_IN(void)
//{
// float V;
// uint16_t V_ADC;
//
//// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, SET);
//// V_ADC = Get_ConversionVal(get_adc(PV2_VOLT_IN));
// V_ADC = get_aftercalculationAdc(PV2_VOLT_IN);
//// V_ADC = get_adc(PV2_VOLT_IN);
//// GPIO_WriteBit(G_FFMOS_CON2_GPIO, G_FFMOS_CON2_PIN, RESET);
//
// V = (float)(V_ADC) / 4095 * 2.5 * P_PV2_VOLT_IN;
//
//#ifdef enable_Printf_VI
// printf("\n PV2_VOLT_IN ADC : %d \n", V_ADC);
// printf(" PV2_VOLT_IN V : %d /100 \n", (int)(V * 100));
//#endif
//
// return V;
//}

1365
App/src/hy_protocol.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,30 +8,32 @@
#include "inflash.h"
#include "flash.h"
#include "sl_protocol.h"
#include "parameter.h"
#include <string.h>
config_info g_slConfigInfo = {
.constantCurrentV = 1000,
.constantVoltageV = 1420,
.floatI = 20,
.startSolarOpenCircuitV = 1700,
.stopSolarOpenCircuitV = 1500,
.constantVoltageChargeV = 1440,
.trickleChargeC = 100,
// .FloatTime = 10,
.FloatV = 1420,
.checkSolarOpenCircuitVTime = 10,
.registerRefreshTime = 1,
.loopImpedance = 20,
// .resRefreshTime = 1,
.sensorEnableBroadcastTime = 20,
.HighSideMosTemperature_stop = 70,
.HighSideMosTemperature_end = 50,
.HighSideMosTemperature_start = 40,
.outputAgainFlagTime = 10,
.excessiveLoadFlagTime = 60,
.eLAgainTime = 3600,
};
/**
* @brief
* @param
* @retval
*/
uint16_t configCheckFunc(uint8_t *arr_buff, uint8_t len)
{
uint16_t crc = 0xFFFF;
uint16_t i, j;
for (j = 0; j < len; ++j) {
crc = crc ^ (*arr_buff++);
for (i = 0; i < 8; ++i) {
if ((crc&0x0001) > 0) {
crc = crc >> 1;
crc = crc ^ 0xa001;
}
else {
crc = crc >> 1;
}
}
}
return crc;
}
/**
* @brief
@ -40,72 +42,779 @@ config_info g_slConfigInfo = {
*/
void save_config_info(config_info *save_config_info)
{
SPI_Flash_Write((uint8_t *)save_config_info, FLASH_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
SPI_Flash_Write((uint8_t *)save_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
}
/**
* @brief
* @param save_config_info
* @retval
*/
static void save_backups_config_info(config_info *save_config_info)
{
SPI_Flash_Write((uint8_t *)save_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE);
}
/**
* @brief
* @param read_config_info
* @retval 0 flash中读取配置失败
* 1 flash中读取配置成功
* @param read_config_info output_config_info中
*/
uint8_t read_config_info(void)
void read_config_info(config_info *output_config_info)
{
config_info temp_config_info;
SPI_Flash_Read((uint8_t *)&temp_config_info, FLASH_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
if (temp_config_info.start_Flag[0] == 'S'
&& temp_config_info.start_Flag[1] == 'L'
&& temp_config_info.end_Flag == 0x16) {
g_slConfigInfo = temp_config_info;
return 1;
SPI_Flash_Read((uint8_t *)output_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
}
/**
* @brief
* @param read_config_info output_config_info中
*/
static void read_backups_config_info(config_info *output_config_info)
{
SPI_Flash_Read((uint8_t *)output_config_info, CONFIG_SAVE_addr, CONFIG_INFO_SIZE);
}
/**
* @brief flash中是否有配置文件或者文件是否有损坏
* @param read_config_info1 in_config_info中
* @retval
*
*/
void checkFlashContent(void)
{
config_info temp_configInfo;
read_config_info(&temp_configInfo);
/* 配置文件正确就返回 */
// printf("crc : %x %x\n", temp_configInfo.crc, configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2));
if (temp_configInfo.crc == configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2)) {
// printf("config\n");
return;
}
/* 更深处的配置文件正确就返回 */
read_backups_config_info(&temp_configInfo);
if (temp_configInfo.crc == configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2)) {
// printf("backups config\n");
save_config_info(&temp_configInfo);
return;
}
/* 配置文件错误使用默认配置 */
config_info configInfo = {
.address = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
.Access_Node_Type = 0x01,
.Communication_Methods = 0x02,
.gw485_Baud = 9600,
.bat485_Baud = 115200,
.hardwareID = {0x48, 0x59, 0x30, 0x30, 0x30, 0x31},
.communicationID = {0x00, 0x00, 0x00, 0x01},
.protocolType = 0x01,
.CommunicationProtocolType = 0x00,
.onlyPower = 0x01,
.constantVoltageV = 14,
.floatI = 0.02,
.startSolarOpenCircuitV = 17,
.stopSolarOpenCircuitV = 15,
.constantVoltageChargeV = 14.4,
.FloatChargeV = 14,
.HighSideMosTemperature_stop = 100,
.HighSideMosTemperature_end = 90,
.HighSideMosTemperature_start = 50,
// .loopImpedance = 0.0,
// .totalElectricityConsumption = 0.0,
// .totalChargCapacity = 0.0,
.checkSolarOpenCircuitVTime = 10,
// .registerRefreshTime = 1,
.sensorEnableBroadcastTime = 20,
.outputAgainFlagTime = 10,
.excessiveLoadFlagTime = 60,
.eLAgainTime = 1800,
};
configInfo.crc = configCheckFunc((uint8_t *)&configInfo, CONFIG_INFO_SIZE - 2);
save_config_info(&configInfo);
}
///**
// * @brief 保存回路阻抗的值
// * @param loopImpedance 需要保存的回路阻抗的值
// * @retval
// *
// */
//void saveLoopImpedance(float_t *loopImpedance)
//{
// config_info temp_configInfo;
// read_config_info(&temp_configInfo);
//
// temp_configInfo.loopImpedance = *loopImpedance;
//
// temp_configInfo.crc = configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
// save_config_info(&temp_configInfo);
//}
//
///**
// * @brief 保存总充电电量和总消耗电量的值
// * @param totalElectricityConsumption 需要保存的总消耗电量
// * totalChargCapacity 需要保存的总充电电量
// * @retval
// *
// */
//void saveTotalPower(float_t *totalElectricityConsumption, float_t *totalChargCapacity)
//{
// config_info temp_configInfo;
// read_config_info(&temp_configInfo);
//
// temp_configInfo.totalElectricityConsumption = *totalElectricityConsumption;
// temp_configInfo.totalChargCapacity = *totalChargCapacity;
//
// temp_configInfo.crc = configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
// save_config_info(&temp_configInfo);
//}
/**
* @brief
* @param
* @retval
*
*/
void config_info_start(void)
{
checkFlashContent();
/* 读取配置文件并将需要的参数保存在全局变量中 */
config_info temp_configInfo;
read_config_info(&temp_configInfo);
g_controlParameter.constantVoltageV = temp_configInfo.constantVoltageV;
g_controlParameter.floatI = temp_configInfo.floatI;
g_controlParameter.startSolarOpenCircuitV = temp_configInfo.startSolarOpenCircuitV;
g_controlParameter.stopSolarOpenCircuitV = temp_configInfo.stopSolarOpenCircuitV;
g_controlParameter.constantVoltageChargeV = temp_configInfo.constantVoltageChargeV;
g_controlParameter.FloatV = temp_configInfo.FloatChargeV;
// g_controlParameter.loopImpedance = temp_configInfo.loopImpedance;
g_controlParameter.HighSideMosTemperature_stop = temp_configInfo.HighSideMosTemperature_stop;
g_controlParameter.HighSideMosTemperature_end = temp_configInfo.HighSideMosTemperature_end;
g_controlParameter.HighSideMosTemperature_start = temp_configInfo.HighSideMosTemperature_start;
g_controlParameter.sensorEnableBroadcastTime = temp_configInfo.sensorEnableBroadcastTime;
g_controlParameter.checkSolarOpenCircuitVTime = temp_configInfo.checkSolarOpenCircuitVTime;
g_controlParameter.outputAgainFlagTime = temp_configInfo.outputAgainFlagTime;
g_controlParameter.excessiveLoadFlagTime = temp_configInfo.excessiveLoadFlagTime;
g_controlParameter.eLAgainTime = temp_configInfo.eLAgainTime;
g_controlParameter.collectOpenCircuitVoltageTime= 3600;
// strlcpy(g_otherParameter.address, temp_configInfo.address, 7);
g_otherParameter.address[0] = temp_configInfo.address[0];
g_otherParameter.address[1] = temp_configInfo.address[1];
g_otherParameter.address[2] = temp_configInfo.address[2];
g_otherParameter.address[3] = temp_configInfo.address[3];
g_otherParameter.address[4] = temp_configInfo.address[4];
g_otherParameter.address[5] = temp_configInfo.address[5];
g_otherParameter.address[6] = temp_configInfo.address[6];
// printf("address : 0x %x %x %x %x %x %x %x\n", temp_configInfo.address[0]
// , temp_configInfo.address[1], temp_configInfo.address[2], temp_configInfo.address[3]
// , temp_configInfo.address[4], temp_configInfo.address[5], temp_configInfo.address[6]);
g_otherParameter.Access_Node_Type = temp_configInfo.Access_Node_Type;
g_otherParameter.Communication_Methods = temp_configInfo.Communication_Methods;
// strlcpy(g_otherParameter.hardwareID, temp_configInfo.hardwareID, 6);
g_otherParameter.hardwareID[0] = temp_configInfo.hardwareID[0];
g_otherParameter.hardwareID[1] = temp_configInfo.hardwareID[1];
g_otherParameter.hardwareID[2] = temp_configInfo.hardwareID[2];
g_otherParameter.hardwareID[3] = temp_configInfo.hardwareID[3];
g_otherParameter.hardwareID[4] = temp_configInfo.hardwareID[4];
g_otherParameter.hardwareID[5] = temp_configInfo.hardwareID[5];
// strlcpy(g_otherParameter.communicationID, temp_configInfo.communicationID, 4);
g_otherParameter.communicationID[0] = temp_configInfo.communicationID[0];
g_otherParameter.communicationID[1] = temp_configInfo.communicationID[1];
g_otherParameter.communicationID[2] = temp_configInfo.communicationID[2];
g_otherParameter.communicationID[3] = temp_configInfo.communicationID[3];
g_otherParameter.protocolType = temp_configInfo.protocolType;
g_otherParameter.CommunicationProtocolType = temp_configInfo.CommunicationProtocolType;
// g_otherParameter.CommunicationProtocolType = 0x01;
g_otherParameter.onlyPower = temp_configInfo.onlyPower;
g_otherParameter.Battery_Voltage = 0;
g_otherParameter.Output_Voltage = 0;
g_otherParameter.Charg_Current = 0;
g_otherParameter.Discharg_Current = 0;
g_otherParameter.Input_Voltage = 0;
g_otherParameter.Solar_Open_Circuit_Voltage = 0;
g_otherParameter.HighSideMos_Temperature = 0;
g_otherParameter.Solar_In_Circuit_Voltage = 0;
g_otherParameter.Charg_BatteryCurrent = 0;
// g_otherParameter.totalElectricityConsumption = temp_configInfo.totalElectricityConsumption;
// g_otherParameter.totalChargCapacity = temp_configInfo.totalChargCapacity;
g_otherParameter.SOC = 0;
g_otherParameter.chargMos_State = 0;
g_otherParameter.DischargMos_State = 0;
g_otherParameter.MPPT_Mode = 0;
strlcpy(g_otherParameter.versionInformation, softVer, 13);
// strlcpy(g_otherParameter.startFlagSL, "SL", 2);
// printf("%s", g_otherParameter.startFlagSL);
g_otherParameter.startFlagSL[0] = 'S';
g_otherParameter.startFlagSL[1] = 'L';
g_otherParameter.endFlagSL = 0x16;
g_otherParameter.startFlagHY = 0x68;
g_otherParameter.endFlagHY = 0x16;
g_otherParameter.batteryState = 0;
g_otherParameter.impedanceStart = 1;
g_otherParameter.overTemperature = 0;
g_otherParameter.RegistrationRequestFlag = 0;
g_otherParameter.runBroadcast = 1;
g_otherParameter.RegisterNumberMax = 10;
g_otherParameter.RegisterStartAddressMax = 0x150;
g_otherParameter.HYconfigModeState = 0;
g_otherParameter.HYconfigModeT = 0;
if (g_otherParameter.CommunicationProtocolType == 0x00) {
g_otherParameter.gw485_Baud = temp_configInfo.gw485_Baud;
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
} else if (g_otherParameter.CommunicationProtocolType == 0x01) {
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
if (g_otherParameter.protocolType == 0x01) {
g_otherParameter.gw485_Baud = 9600;
} else if (g_otherParameter.protocolType == 0x02) {
g_otherParameter.gw485_Baud = 115200;
}
}
// readLoopImpedance(&g_controlParameter.loopImpedance);
float_t fTemp;
readLoopImpedance(&fTemp);
/* 读取的回路阻抗偏差过大则不使用 */
if (fTemp > 0.005 && fTemp < 1) {
g_controlParameter.loopImpedance = fTemp;
}
else {
g_slConfigInfo.start_Flag[0] = defaultValue.start_Flag[0];
g_slConfigInfo.start_Flag[1] = defaultValue.start_Flag[1];
g_slConfigInfo.address[0] = defaultValue.address[0];
g_slConfigInfo.address[1] = defaultValue.address[1];
g_slConfigInfo.address[2] = defaultValue.address[2];
g_slConfigInfo.address[3] = defaultValue.address[3];
g_slConfigInfo.address[4] = defaultValue.address[4];
g_slConfigInfo.address[5] = defaultValue.address[5];
g_slConfigInfo.address[6] = defaultValue.address[6];
g_slConfigInfo.end_Flag = defaultValue.end_Flag;
g_controlParameter.loopImpedance = 0;
saveLoopImpedance(&g_controlParameter.loopImpedance);
}
readtotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
readtotalChargCapacity(&g_otherParameter.totalChargCapacity);
return 0;
// printf("");
printf("%s\n", g_otherParameter.versionInformation);
printf("address : 0x %x %x %x %x %x %x %x\n", g_otherParameter.address[0]
, g_otherParameter.address[1], g_otherParameter.address[2], g_otherParameter.address[3]
, g_otherParameter.address[4], g_otherParameter.address[5], g_otherParameter.address[6]);
printf("Access_Node_Type : 0x%x\n", g_otherParameter.Access_Node_Type);
printf("Communication_Methods : 0x%x\n", g_otherParameter.Communication_Methods);
printf("gw485_Baud : %d\n", g_otherParameter.gw485_Baud);
printf("bat485_Baud : %d\n", g_otherParameter.bat485_Baud);
printf("hardwareID : 0x %x %x %x %x %x %x\n", g_otherParameter.hardwareID[0]
, g_otherParameter.hardwareID[1], g_otherParameter.hardwareID[2], g_otherParameter.hardwareID[3]
, g_otherParameter.hardwareID[4], g_otherParameter.hardwareID[5]);
printf("communicationID : 0x %x %x %x %x\n", g_otherParameter.communicationID[0], g_otherParameter.communicationID[1]
, g_otherParameter.communicationID[2], g_otherParameter.communicationID[3]);
printf("Communication_Methods : 0x%x\n", g_otherParameter.CommunicationProtocolType);
printf("onlyPower : 0x%x\n", g_otherParameter.onlyPower);
printf("constantVoltageV : %d/100\n", (int)(g_controlParameter.constantVoltageV * 100));
printf("floatI : %d/100\n", (int)(g_controlParameter.floatI * 100));
printf("startSolarOpenCircuitV : %d/100\n", (int)(g_controlParameter.startSolarOpenCircuitV * 100));
printf("stopSolarOpenCircuitV : %d/100\n", (int)(g_controlParameter.stopSolarOpenCircuitV * 100));
printf("constantVoltageChargeV : %d/100\n", (int)(g_controlParameter.constantVoltageChargeV * 100));
printf("FloatV : %d/100\n", (int)(g_controlParameter.FloatV * 100));
printf("loopImpedance : %d/100\n", (int)(g_controlParameter.loopImpedance * 100));
printf("HighSideMosTemperature_stop : %d/100\n", (int)(g_controlParameter.HighSideMosTemperature_stop * 100));
printf("HighSideMosTemperature_end : %d/100\n", (int)(g_controlParameter.HighSideMosTemperature_end * 100));
printf("HighSideMosTemperature_start : %d/100\n", (int)(g_controlParameter.HighSideMosTemperature_start * 100));
printf("totalChargCapacity : %d/10000\n", (int)(g_otherParameter.totalChargCapacity * 10000));
printf("totalElectricityConsumption : %d/10000\n", (int)(g_otherParameter.totalElectricityConsumption * 10000));
printf("checkSolarOpenCircuitVTime : %d\n", g_controlParameter.checkSolarOpenCircuitVTime);
printf("sensorEnableBroadcastTime : %d\n", g_controlParameter.sensorEnableBroadcastTime);
printf("outputAgainFlagTime : %d\n", g_controlParameter.outputAgainFlagTime);
printf("excessiveLoadFlagTime : %d\n", g_controlParameter.excessiveLoadFlagTime);
printf("eLAgainTime : %d\n", g_controlParameter.eLAgainTime);
}
/**
* @brief
* @param read_config_info1 in_config_info中
* @retval 0 flash中读取配置失败使
* 1 flash中读取配置成功
* @brief flash中
* @param
* @retval
*
*/
uint8_t read_config_info1(config_info *in_config_info)
#define enlargeScale 100
void read_and_process_config_data(void)
{
config_info temp_config_info;
SPI_Flash_Read((uint8_t *)&temp_config_info, FLASH_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
if (temp_config_info.start_Flag[0] == 'S'
&& temp_config_info.start_Flag[1] == 'L'
&& temp_config_info.end_Flag == 0x16) {
*in_config_info = temp_config_info;
return 1;
recv_config_info *pack = (recv_config_info *)config_buff;
config_info save_configInfo;
// uint32_t len = strlen(config_buff);
// char buffer[80];
// printf("%d %d\n", cfig_len, RECV_CONFIG_INFO);
while (cfig_len >= RECV_CONFIG_INFO) {
// printf("1\n");
/* 判断起始标志是否正确 */
if (pack->start_Flag[0] != g_otherParameter.startFlagSL[0]
|| pack->start_Flag[1] != g_otherParameter.startFlagSL[1]) {
// printf(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
goto err;
}
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
// if (pack->address[0] != g_otherParameter.address[0]
// || pack->address[1] != g_otherParameter.address[1]
// || pack->address[2] != g_otherParameter.address[2]
// || pack->address[3] != g_otherParameter.address[3]
// || pack->address[4] != g_otherParameter.address[4]
// || pack->address[5] != g_otherParameter.address[5]
// || pack->address[6] != g_otherParameter.address[6]) {
// memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
// continue;
// }
/* 判断接入节点类型是否正确 */
save_configInfo.Access_Node_Type = (uint16_t)pack->Access_Node_Type[0] << 8
| (uint16_t)pack->Access_Node_Type[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " Access_Node_Type : 0x%x \n", save_configInfo.Access_Node_Type);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.Access_Node_Type != POWERBOX) {
goto err;
}
/* 判断通信方式是否正确 */
save_configInfo.Communication_Methods = (uint16_t)pack->Communication_Methods[0] << 8
| (uint16_t)pack->Communication_Methods[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " Communication_Methods : 0x%x \n", save_configInfo.Communication_Methods);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
// if (temp_u16 != RS485 || temp_u16 != RJ45) {
if (save_configInfo.Communication_Methods != RS485) {
goto err;
}
/* 判断波特率是否正确 */
save_configInfo.gw485_Baud = (uint32_t)pack->gw485_Baud[0] << 24
| (uint32_t)pack->gw485_Baud[1] << 16
| (uint32_t)pack->gw485_Baud[2] << 8
| (uint32_t)pack->gw485_Baud[3];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " gw485_Baud : 0x%x, %d \n", save_configInfo.gw485_Baud, save_configInfo.gw485_Baud);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.gw485_Baud != 9600 && save_configInfo.gw485_Baud != 115200) {
// if (save_configInfo.gw485_Baud != 0x2580 || save_configInfo.gw485_Baud != 115200) {
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " error : %d\n", save_configInfo.gw485_Baud);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
goto err;
}
save_configInfo.bat485_Baud = (uint32_t)pack->bat485_Baud[0] << 24
| (uint32_t)pack->bat485_Baud[1] << 16
| (uint32_t)pack->bat485_Baud[2] << 8
| (uint32_t)pack->bat485_Baud[3];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " bat485_Baud : 0x%x, %d \n", save_configInfo.bat485_Baud, save_configInfo.bat485_Baud);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.bat485_Baud != 9600 && save_configInfo.bat485_Baud!= 115200 && save_configInfo.bat485_Baud!= 0) {
goto err;
}
/* 判断协议类型是否正确 */
if (pack->protocolType != 0x01 && pack->protocolType != 0x02) {
goto err;
}
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " protocolType : 0x%x \n", pack->protocolType);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
/* 判断通信协议类型是否正确 */
if (pack->CommunicationProtocolType != 0x00 && pack->CommunicationProtocolType != 0x01) {
goto err;
}
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " CommunicationProtocolType : 0x%x \n", pack->CommunicationProtocolType);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
/* 判断电源盒类型是否正确 */
if (pack->onlyPower != 0x00 && pack->onlyPower != 0x01) {
goto err;
}
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " onlyPower : 0x%x \n", pack->onlyPower);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
/* 判断恒压充电阈值是否正确 */
save_configInfo.constantVoltageV =
(float_t)(pack->ConstantVoltageV[0] << 8 | pack->ConstantVoltageV[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " constantVoltageV : %d/100 \n", (int)(save_configInfo.constantVoltageV * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.constantVoltageV > 14.4 || save_configInfo.constantVoltageV < 13.5) {
goto err;
}
/* 判断浮充充电阈值是否正确 */
save_configInfo.floatI = (float_t)(pack->FloatI[0] << 8 | pack->FloatI[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " floatI : %d/100 \n", (int)(save_configInfo.floatI * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.floatI > 0.2 || save_configInfo.floatI < 0) {
goto err;
}
/* 判断太阳能板开路启动电压是否正确 */
save_configInfo.startSolarOpenCircuitV =
(float_t)(pack->startSolarOpenCircuitV[0] << 8 | pack->startSolarOpenCircuitV[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " startSolarOpenCircuitV : %d/100 \n", (int)(save_configInfo.startSolarOpenCircuitV * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.startSolarOpenCircuitV > 24 || save_configInfo.startSolarOpenCircuitV < 14) {
goto err;
}
/* 判断太阳能板关闭电压是否正确 */
save_configInfo.stopSolarOpenCircuitV =
(float_t)(pack->stopSolarOpenCircuitV[0] << 8 | pack->stopSolarOpenCircuitV[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " stopSolarOpenCircuitV : %d/100 \n", (int)(save_configInfo.stopSolarOpenCircuitV * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.stopSolarOpenCircuitV > 17 || save_configInfo.stopSolarOpenCircuitV < 13) {
goto err;
}
/* 判断恒压充电时的输出电压是否正确 */
save_configInfo.constantVoltageChargeV =
(float_t)(pack->constantVoltageChargeV[0] << 8 | pack->constantVoltageChargeV[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " constantVoltageChargeV : %d/100 \n", (int)(save_configInfo.constantVoltageChargeV * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.constantVoltageChargeV > 14.6 || save_configInfo.constantVoltageChargeV < 14) {
goto err;
}
/* 判断浮充充电时的输出电压是否正确 */
save_configInfo.FloatChargeV =
(float_t)(pack->FloatChargeV[0] << 8 | pack->FloatChargeV[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " FloatChargeV : %d/100 \n", (int)(save_configInfo.FloatChargeV * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.FloatChargeV > 14.4 || save_configInfo.FloatChargeV < 13.8) {
goto err;
}
/* 判断mos管停止工作温度是否正确 */
save_configInfo.HighSideMosTemperature_stop =
(float_t)(pack->HighSideMosTemperature_stop[0] << 8 | pack->HighSideMosTemperature_stop[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " HighSideMosTemperature_stop : %d/100 \n", (int)(save_configInfo.HighSideMosTemperature_stop * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.HighSideMosTemperature_stop < 60) {
goto err;
}
/* 判断mos管降低工作功率工作温度是否正确 */
save_configInfo.HighSideMosTemperature_end =
(float_t)(pack->HighSideMosTemperature_end[0] << 8 | pack->HighSideMosTemperature_end[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " HighSideMosTemperature_end : %d/100 \n", (int)(save_configInfo.HighSideMosTemperature_end * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.HighSideMosTemperature_end < 50) {
goto err;
}
/* 判断mos管完全恢复工作温度是否正确 */
save_configInfo.HighSideMosTemperature_start =
(float_t)(pack->HighSideMosTemperature_start[0] << 8 | pack->HighSideMosTemperature_start[1]) / enlargeScale;
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " HighSideMosTemperature_start : %d/100 \n", (int)(save_configInfo.HighSideMosTemperature_start * 100));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.HighSideMosTemperature_start < 40) {
goto err;
}
// /* 判断回路阻抗大小是否正确 */
// save_configInfo.loopImpedance =
// (float_t)(pack->loopImpedance[0] << 8 | pack->loopImpedance[1]) / enlargeScale / 10;
//// memset(buffer, 0, sizeof(buffer));
//// sprintf(buffer, " loopImpedance : %d/100 \n", (int)(save_configInfo.loopImpedance * 100));
//// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
// if (save_configInfo.loopImpedance > 1 || save_configInfo.loopImpedance < 0) {
// goto err;
// }
//
// /* 判断总电量消耗是否正确 */
// save_configInfo.totalElectricityConsumption =
// (float_t)(pack->totalElectricityConsumption[0] << 8 | pack->totalElectricityConsumption[1]) / enlargeScale;
//// memset(buffer, 0, sizeof(buffer));
//// sprintf(buffer, " totalElectricityConsumption : %d/100 \n", (int)(save_configInfo.totalElectricityConsumption * 100));
//// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
// if (save_configInfo.totalElectricityConsumption != 0) {
// goto err;
// }
//
// /* 判断总充电电量是否正确 */
// save_configInfo.totalChargCapacity =
// (float_t)(pack->totalChargCapacity[0] << 8 | pack->totalChargCapacity[1]) / enlargeScale;
//// memset(buffer, 0, sizeof(buffer));
//// sprintf(buffer, " totalChargCapacity : %d/100 \n", (int)(save_configInfo.totalChargCapacity * 100));
//// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
// if (save_configInfo.totalChargCapacity != 0) {
// goto err;
// }
/* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */
save_configInfo.checkSolarOpenCircuitVTime =
pack->checkSolarOpenCircuitVTime[0] << 8 | pack->checkSolarOpenCircuitVTime[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " checkSolarOpenCircuitVTime : %d \n", save_configInfo.checkSolarOpenCircuitVTime);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.checkSolarOpenCircuitVTime > 1800 || save_configInfo.checkSolarOpenCircuitVTime < 5) {
goto err;
}
/* 判断传感器运行再次注册的间隔是否正确 */
save_configInfo.sensorEnableBroadcastTime =
pack->sensorEnableBroadcastTime[0] << 8 | pack->sensorEnableBroadcastTime[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " sensorEnableBroadcastTime : %d \n", save_configInfo.sensorEnableBroadcastTime);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.sensorEnableBroadcastTime > 60 || save_configInfo.sensorEnableBroadcastTime < 10) {
goto err;
}
/* 判断出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出的间隔是否正确 */
save_configInfo.outputAgainFlagTime =
pack->outputAgainFlagTime[0] << 8 | pack->outputAgainFlagTime[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " outputAgainFlagTime : %d \n", save_configInfo.outputAgainFlagTime);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.sensorEnableBroadcastTime > 30 || save_configInfo.sensorEnableBroadcastTime < 5) {
goto err;
}
/* 判断出现过载后在该间隔时间中多次2次出现过载则关闭输出的间隔是否正确 */
save_configInfo.excessiveLoadFlagTime =
pack->excessiveLoadFlagTime[0] << 8 | pack->excessiveLoadFlagTime[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " excessiveLoadFlagTime : %d \n", save_configInfo.excessiveLoadFlagTime);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.excessiveLoadFlagTime > 90 || save_configInfo.excessiveLoadFlagTime < 30) {
goto err;
}
/* 判断出现过载过载保护后,在该间隔段时间后,再次尝试输出的间隔是否正确 */
save_configInfo.eLAgainTime = pack->eLAgainTime[0] << 8 | pack->eLAgainTime[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " eLAgainTime : %d \n", save_configInfo.eLAgainTime);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.eLAgainTime > 3000 || save_configInfo.eLAgainTime < 1000) {
goto err;
}
/* crc校验 */
save_configInfo.crc = pack->crc[0] << 8 | pack->crc[1];
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " crc : %x%x \n", pack->crc[0], pack->crc[1]);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (save_configInfo.crc != CheckFuncSL(config_buff, RECV_CONFIG_INFO - 3)) {
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " CheckFuncSL : %x \n", CheckFuncSL(config_buff, RECV_CONFIG_INFO));
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
goto err;
}
/* 结束标志 */
// memset(buffer, 0, sizeof(buffer));
// sprintf(buffer, " end_Flag : %x \n", pack->end_Flag);
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
if (pack->end_Flag != 0x16) {
goto err;
}
// printf("address : 0x %x %x %x %x %x %x %x\n", pack->address[0]
// , pack->address[1], pack->address[2], pack->address[3]
// , pack->address[4], pack->address[5], pack->address[6]);
config_info temp_configInfo;
read_config_info(&temp_configInfo);
if (pack->address[0] != 0xFF
|| pack->address[1] != 0xFF
|| pack->address[2] != 0xFF
|| pack->address[3] != 0xFF
|| pack->address[4] != 0xFF
|| pack->address[5] != 0xFF
|| pack->address[6] != 0xFF) {
save_configInfo.address[0] = pack->address[0];
save_configInfo.address[1] = pack->address[1];
save_configInfo.address[2] = pack->address[2];
save_configInfo.address[3] = pack->address[3];
save_configInfo.address[4] = pack->address[4];
save_configInfo.address[5] = pack->address[5];
save_configInfo.address[6] = pack->address[6];
// printf("address : 0x %x %x %x %x %x %x %x\n", save_configInfo.address[0]
// , save_configInfo.address[1], save_configInfo.address[2], save_configInfo.address[3]
// , save_configInfo.address[4], save_configInfo.address[5], save_configInfo.address[6]);
} else {
in_config_info->start_Flag[0] = defaultValue.start_Flag[0];
in_config_info->start_Flag[1] = defaultValue.start_Flag[1];
in_config_info->address[0] = defaultValue.address[0];
in_config_info->address[1] = defaultValue.address[1];
in_config_info->address[2] = defaultValue.address[2];
in_config_info->address[3] = defaultValue.address[3];
in_config_info->address[4] = defaultValue.address[4];
in_config_info->address[5] = defaultValue.address[5];
in_config_info->address[6] = defaultValue.address[6];
in_config_info->end_Flag = defaultValue.end_Flag;
save_configInfo.address[0] = temp_configInfo.address[0];
save_configInfo.address[1] = temp_configInfo.address[1];
save_configInfo.address[2] = temp_configInfo.address[2];
save_configInfo.address[3] = temp_configInfo.address[3];
save_configInfo.address[4] = temp_configInfo.address[4];
save_configInfo.address[5] = temp_configInfo.address[5];
save_configInfo.address[6] = temp_configInfo.address[6];
}
return 0;
if (pack->hardwareID[0] != 0xFF
|| pack->hardwareID[1] != 0xFF
|| pack->hardwareID[2] != 0xFF
|| pack->hardwareID[3] != 0xFF
|| pack->hardwareID[4] != 0xFF
|| pack->hardwareID[5] != 0xFF) {
save_configInfo.hardwareID[0] = pack->hardwareID[0];
save_configInfo.hardwareID[1] = pack->hardwareID[1];
save_configInfo.hardwareID[2] = pack->hardwareID[2];
save_configInfo.hardwareID[3] = pack->hardwareID[3];
save_configInfo.hardwareID[4] = pack->hardwareID[4];
save_configInfo.hardwareID[5] = pack->hardwareID[5];
} else {
save_configInfo.hardwareID[0] = temp_configInfo.hardwareID[0];
save_configInfo.hardwareID[1] = temp_configInfo.hardwareID[1];
save_configInfo.hardwareID[2] = temp_configInfo.hardwareID[2];
save_configInfo.hardwareID[3] = temp_configInfo.hardwareID[3];
save_configInfo.hardwareID[4] = temp_configInfo.hardwareID[4];
save_configInfo.hardwareID[5] = temp_configInfo.hardwareID[5];
}
if (pack->communicationID[0] != 0xFF
|| pack->communicationID[1] != 0xFF
|| pack->communicationID[2] != 0xFF
|| pack->communicationID[3] != 0xFF) {
save_configInfo.communicationID[0] = pack->communicationID[0];
save_configInfo.communicationID[1] = pack->communicationID[1];
save_configInfo.communicationID[2] = pack->communicationID[2];
save_configInfo.communicationID[3] = pack->communicationID[3];
} else {
save_configInfo.communicationID[0] = temp_configInfo.communicationID[0];
save_configInfo.communicationID[1] = temp_configInfo.communicationID[1];
save_configInfo.communicationID[2] = temp_configInfo.communicationID[2];
save_configInfo.communicationID[3] = temp_configInfo.communicationID[3];
}
save_configInfo.protocolType = pack->protocolType;
save_configInfo.CommunicationProtocolType = pack->CommunicationProtocolType;
save_configInfo.onlyPower = pack->onlyPower;
save_configInfo.crc = configCheckFunc((uint8_t *)&save_configInfo, CONFIG_INFO_SIZE - 2);
save_backups_config_info(&save_configInfo);
save_config_info(&save_configInfo);
memset(config_buff, 0, sizeof(config_buff));
/* 返回更改配置文件成功 */
SL_Mppt_SOther_pack SUpdateProfile_pack = {0};
SUpdateProfile_pack.start_Flag[0] = g_otherParameter.startFlagSL[0];
SUpdateProfile_pack.start_Flag[1] = g_otherParameter.startFlagSL[1];
SUpdateProfile_pack.address[0] = save_configInfo.address[0];
SUpdateProfile_pack.address[1] = save_configInfo.address[1];
SUpdateProfile_pack.address[2] = save_configInfo.address[2];
SUpdateProfile_pack.address[3] = save_configInfo.address[3];
SUpdateProfile_pack.address[4] = save_configInfo.address[4];
SUpdateProfile_pack.address[5] = save_configInfo.address[5];
SUpdateProfile_pack.address[6] = save_configInfo.address[6];
SUpdateProfile_pack.function_Code = SL_Function_Code_Update_Profile;
SUpdateProfile_pack.state = 0x01;
uint16_t crc = CheckFuncSL((uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE - 3);
SUpdateProfile_pack.check_Bit_H = crc >> 8;
SUpdateProfile_pack.check_Bit_L = crc;
SUpdateProfile_pack.end_Flag = g_otherParameter.endFlagSL;
while (1) {
if (!Check_485_bus_busy(g_gw485_uart4_handle)) {
uart_dev_write(g_gw485_uart4_handle, (uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
break;
}
Delay_Ms(randomDelay());
}
/* 复位 */
NVIC_SystemReset();
return;
err:
cfig_len--;
memcpy(config_buff, config_buff + 1, sizeof(config_buff) - 1);
}
}
/**
* @brief flash中
* @param
*/
void saveLoopImpedance(float_t *loopImpedance)
{
SPI_Flash_Write((uint8_t *)loopImpedance, LoopImpedance_SAVE_addr, sizeof(float_t));
}
/**
* @brief flash中的回路阻抗
* @param
*/
void readLoopImpedance(float_t *loopImpedance)
{
SPI_Flash_Read((uint8_t *)loopImpedance, LoopImpedance_SAVE_addr, sizeof(float_t));
}
/**
* @brief flash中
* @param
*/
void savetotalElectricityConsumption(float_t *totalElectricityConsumption)
{
SPI_Flash_Write((uint8_t *)totalElectricityConsumption, totalElectricityConsumption_SAVE_addr, sizeof(float_t));
}
/**
* @brief flash中的放电量
* @param
*/
void readtotalElectricityConsumption(float_t *totalElectricityConsumption)
{
SPI_Flash_Read((uint8_t *)totalElectricityConsumption, totalElectricityConsumption_SAVE_addr, sizeof(float_t));
}
/**
* @brief flash中
* @param
*/
void savetotalChargCapacity(float_t *totalChargCapacity)
{
SPI_Flash_Write((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float_t));
}
/**
* @brief flash中的充电量
* @param
*/
void readtotalChargCapacity(float_t *totalChargCapacity)
{
SPI_Flash_Read((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float_t));
}

File diff suppressed because it is too large Load Diff

11
App/src/parameter.c Normal file
View File

@ -0,0 +1,11 @@
/*
* parameter.c
*
* Created on: 20241012
* Author: psx
*/
#include "parameter.h"
Mppt_controlparameter g_controlParameter = {0};
Mppt_otherParameter g_otherParameter = {0};

View File

@ -13,14 +13,18 @@
#include <stdlib.h>
#include "task.h"
#include "tim.h"
#include "parameter.h"
default_Value defaultValue = {'S', 'L'\
, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11\
, POWERBOX\
, RS485
, 0x16};
SL_Mppt_para g_Mppt_Para = {0};
uint8_t rs485_buff[buffLen]={0x00};
uint8_t config_buff[configBuffLen] = {0x00};
uint32_t cfig_len = 0;
/* 用于解析串口包时的长度 */
#define analyzeStartFlag 2 //长度为2时解析起始标志
#define analyzeAddress 9 //长度为9时解析地址
#define analyzeFunctionCode 10 //长度为10时解析功能码
#define analyzeWritelen 14 //功能码为写入寄存器且buffer长度为14时可以解析出写入寄存器包的长度
/* 静态函数申明 */
static void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t MsgLen);
@ -30,44 +34,18 @@ static void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg
static void SL_MsgProcFunc_Update_Profile(device_handle device, void *pMsg, uint32_t MsgLen);
static void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t MsgLen);
//static uint16_t SL_ReadRegisterRegistrationStatus(void *pMsg);
//static uint16_t SL_ReadRegisteraddress(void *pMsg);
//static uint16_t SL_ReadRegisterAccessNodeType(void *pMsg);
//static uint16_t SL_ReadRegisterCommunicationMethods(void *pMsg);
static uint16_t SL_ReadRegisterSolarOpenCircuitVoltage(void *pMsg);
static uint16_t SL_ReadRegisterBatteryVoltage(void *pMsg);
static uint16_t SL_ReadRegisterChargCurrent(void *pMsg);
static uint16_t SL_ReadRegisterDischargCurrent(void *pMsg);
static uint16_t SL_ReadRegisterSolarOpenCircuitVoltage(void *pMsg);
static uint16_t SL_ReadRegisterHighSideMosTemperature(void *pMsg);
static uint16_t SL_ReadRegisterDischargMosState(void *pMsg);
static uint16_t SL_ReadRegisterMPPTMode(void *pMsg);
//static uint16_t SL_WriteRegisterRegistrationStatus(void *pMsg);
//static uint16_t SL_WriteRegisteraddress(void *pMsg);
//static uint16_t SL_WriteRegisterAccessNodeType(void *pMsg);
//static uint16_t SL_WriteRegisterCommunicationMethods(void *pMsg);
//static uint16_t SL_WriteRegisterBatteryVoltage(void *pMsg);
//static uint16_t SL_WriteRegisterBatterytemperature(void *pMsg);
//static uint16_t SL_WriteRegisterRemainingBatteryBower(void *pMsg);
//static uint16_t SL_WriteRegisterSolarOpenCircuitVoltage1(void *pMsg);
//static uint16_t SL_WriteRegisterSolarOpenCircuitVoltage2(void *pMsg);
/* 读取串口数据时用该数组解析 */
static uint8_t rs485_buff[50]={0x00};
/* 一次最多读写的寄存器个数,由设备决定 */
#define Register_Number_Max 5
/* 寄存器个数,由设备决定 */
#define MPPT_Register_Number 5
/* 读写的寄存器的最大起始位置,由设备决定 */
#define Register_Start_Address_Max 0x0200
/* 用于解析串口包时的长度 */
#define analyzeStartFlag 2 //长度为2时解析起始标志
#define analyzeAddress 9 //长度为9时解析地址
#define analyzeFunctionCode 10 //长度为10时解析功能码
#define analyzeWritelen 14 //功能码为写入寄存器且buffer长度为14时可以解析出写入寄存器包的长度
static uint16_t SL_ReadRegisterSOC(void *pMsg);
static uint16_t SL_ReadRegisterChargState(void *pMsg);
static uint16_t SL_ReadRegisterTotalChargCapacity(void *pMsg);
static uint16_t SL_ReadRegisterTotalElectricityConsumption(void *pMsg);
static uint16_t SL_ReadRegisterMPPT_Mode(void *pMsg);
static uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg);
/* 功能码处理表 */
SL_FuncionMsgProcTable g_MsgTbl[] =
@ -87,13 +65,16 @@ SL_RegProcTable g_RegTblR[] =
// {SL_Register_address, SL_ReadRegisteraddress},
// {SL_Register_Access_Node_Type, SL_ReadRegisterAccessNodeType},
// {SL_Register_Communication_Methods, SL_ReadRegisterCommunicationMethods},
{SL_Register_Solar_Open_Circuit_Voltage, SL_ReadRegisterSolarOpenCircuitVoltage},
{SL_Register_Battery_Voltage, SL_ReadRegisterBatteryVoltage},
{SL_Register_Charg_Current, SL_ReadRegisterChargCurrent},
{SL_Register_Discharg_Current, SL_ReadRegisterDischargCurrent},
{SL_Register_Solar_Open_Circuit_Voltage, SL_ReadRegisterSolarOpenCircuitVoltage},
{SL_Register_HighSideMos_Temperature, SL_ReadRegisterHighSideMosTemperature},
{SL_Register_DischargMos_State, SL_ReadRegisterDischargMosState},
{SL_Register_MPPT_Mode, SL_ReadRegisterMPPTMode},
{SL_Register_SOC, SL_ReadRegisterSOC},
{SL_Register_chargState, SL_ReadRegisterChargState},
{SL_Register_totalChargCapacity, SL_ReadRegisterTotalChargCapacity},
{SL_Register_totalElectricityConsumption, SL_ReadRegisterTotalElectricityConsumption},
{SL_Register_MPPT_Mode, SL_ReadRegisterMPPT_Mode},
};
/* 寄存器处理表 */
@ -108,18 +89,15 @@ SL_RegProcTable g_RegTblW[] =
// {SL_Register_Remaining_Battery_Bower, SL_WriteRegisterRemainingBatteryBower},
// {SL_Register_Solar_Open_Circuit_Voltage1, SL_WriteRegisterSolarOpenCircuitVoltage1},
// {SL_Register_Solar_Open_Circuit_Voltage2, SL_WriteRegisterSolarOpenCircuitVoltage2},
{SL_Register_eliminateStatistical, SL_WriteRegisterEliminateStatistical}
};
/**
* @brief
* @param
* @retval
*/
uint16_t CheckFunc(uint8_t *arr_buff, uint8_t len)
uint16_t CheckFuncSL(uint8_t *arr_buff, uint8_t len)
{
uint16_t crc = 0xFFFF;
uint16_t i, j;
@ -193,20 +171,20 @@ void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t Msg
SL_Mppt_Rorecv_pack *rpack = (SL_Mppt_Rorecv_pack *)pMsg;
uint16_t Register_Number_16 = chang_8_to_16(rpack->read_Register_Number_L,rpack->read_Register_Number_H);
if (Register_Number_16 > Register_Number_Max) {
if (Register_Number_16 > g_otherParameter.RegisterNumberMax) {
log_error(" Register_Number error:%x \r\n", Register_Number_16);
return;
}
uint16_t Start_Address_16 = chang_8_to_16(rpack->read_Register_Start_Address_L,rpack->read_Register_Start_Address_H);
if (Start_Address_16 > Register_Start_Address_Max) {
if (Start_Address_16 > g_otherParameter.RegisterStartAddressMax) {
log_error(" Register_Start_Address error : %x \r\n", Start_Address_16);
return;
}
/* 读取寄存器数据 */
// uint8_t reply_Data_Content[2 * 5] = {0};
uint16_t reply_Data_Content[Register_Number_Max] = {0};
uint16_t reply_Data_Content[10] = {0};
for ( uint16_t pos = 0; pos < Register_Number_16; pos++) {
for (uint16_t var = 0; var < sizeof(g_RegTblR) / sizeof(SL_RegProcTable); var++) {
if (g_RegTblR[var].regId == (Start_Address_16 + pos)) {
@ -220,18 +198,18 @@ void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t Msg
memset(rs485_buff, 0, sizeof(rs485_buff));
uint8_t *replay_pack = rs485_buff;
// strlcpy(replay_pack, g_slConfigInfo.start_Flag, 2);
*(replay_pack) = g_slConfigInfo.start_Flag[0];
*(replay_pack + 1) = g_slConfigInfo.start_Flag[1];
*(replay_pack) = g_otherParameter.startFlagSL[0];
*(replay_pack + 1) = g_otherParameter.startFlagSL[1];
replay_pack += 2;
// strlcpy(replay_pack, g_slConfigInfo.address, 7);
*(replay_pack) = g_slConfigInfo.address[0];
*(replay_pack + 1) = g_slConfigInfo.address[1];
*(replay_pack + 2) = g_slConfigInfo.address[2];
*(replay_pack + 3) = g_slConfigInfo.address[3];
*(replay_pack + 4) = g_slConfigInfo.address[4];
*(replay_pack + 5) = g_slConfigInfo.address[5];
*(replay_pack + 6) = g_slConfigInfo.address[6];
*(replay_pack) = g_otherParameter.address[0];
*(replay_pack + 1) = g_otherParameter.address[1];
*(replay_pack + 2) = g_otherParameter.address[2];
*(replay_pack + 3) = g_otherParameter.address[3];
*(replay_pack + 4) = g_otherParameter.address[4];
*(replay_pack + 5) = g_otherParameter.address[5];
*(replay_pack + 6) = g_otherParameter.address[6];
replay_pack += 7;
@ -252,14 +230,14 @@ void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t Msg
}
replay_pack += Register_Number_16 * 2;
uint16_t crc_temp = CheckFunc(rs485_buff, (2 + 7 + 1 + 2 + Register_Number_16 * 2));
// log_info("CheckFunc crc_temp: %x \r\n", crc_temp);
uint16_t crc_temp = CheckFuncSL(rs485_buff, (2 + 7 + 1 + 2 + Register_Number_16 * 2));
// log_info("CheckFuncSL crc_temp: %x \r\n", crc_temp);
*replay_pack = (uint8_t)(crc_temp >> 8);
replay_pack += 1;
*replay_pack = (uint8_t)crc_temp;
replay_pack += 1;
*replay_pack = g_slConfigInfo.end_Flag;
*replay_pack = g_otherParameter.endFlagSL;
while (1) {
Delay_Ms(randomDelay());
@ -280,7 +258,6 @@ void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t Msg
}
}
void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t MsgLen)
{
SL_Mppt_Worecv_pack *wpack = (SL_Mppt_Worecv_pack *)pMsg;
@ -288,21 +265,19 @@ void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t Ms
uint16_t Register_Number = \
chang_8_to_16(wpack->write_Register_Number_L, wpack->write_Register_Number_H);
if (Register_Number > Register_Number_Max) {
if (Register_Number > g_otherParameter.RegisterNumberMax) {
log_error(" Register_Number error:%x \r\n", Register_Number);
return;
}
uint16_t Register_Start_Address = \
chang_8_to_16(wpack->write_Register_Start_Address_L, wpack->write_Register_Start_Address_H);
if (Register_Start_Address > Register_Start_Address_Max) {
if (Register_Start_Address > g_otherParameter.RegisterStartAddressMax) {
log_error(" Register_Start_Address error : %x \r\n", Register_Start_Address);
return;
}
printf("in write register \n");
uint16_t content[Register_Number_Max] = {0};
uint16_t content[10] = {0};
for (uint16_t var = 0; var < Register_Number; var++) {
content[var] = buff[14 + 2 * var] << 8 | buff[14 + 2 * var + 1];
@ -320,56 +295,54 @@ void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t Ms
void SL_MsgProcFunc_Broadcast_Scan(device_handle device, void *pMsg, uint32_t MsgLen)
{
g_recvBroadcastDevice = device;
g_recvBroadcastRegisterNumber = MPPT_Register_Number;
RegistrationRequestFlag = 1;
g_otherParameter.RegistrationRequestFlag = 1;
/* 任务创立后,立即执行一次 */
TimeSliceOffset_Register(&m_recvbroadcast, Task_recvbroadcast \
TimeSliceOffset_Register(&g_recvbroadcast, Task_recvbroadcast \
, recvbroadcast_reloadVal, recvbroadcast_offset);
m_recvbroadcast.runFlag = 1;
g_recvbroadcast.runFlag = 1;
}
void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint32_t MsgLen)
{
log_info("Registration success \r\n");
recvbroadcast_flag = 1;
RegistrationRequestFlag = 0;
TimeSliceOffset_Unregister(&m_recvbroadcast);
m_recvbroadcast.runFlag = 0;
g_otherParameter.RegistrationRequestFlag = 0;
TimeSliceOffset_Unregister(&g_recvbroadcast);
g_recvbroadcast.runFlag = 0;
SL_Mppt_RegistrationReply_pack *rpack = (SL_Mppt_RegistrationReply_pack *)pMsg;
g_Mppt_Para.Registration_Status = chang_8_to_16(rpack->registration_Status_L, rpack->registration_Status_H);
g_otherParameter.Registration_Status = chang_8_to_16(rpack->registration_Status_L, rpack->registration_Status_H);
/* 20s内不再接收广播帧 */
TimeSliceOffset_Register(&m_sensorEnableBroadcast, Task_sensorEnableBroadcast
TimeSliceOffset_Register(&g_sensorEnableBroadcast, Task_sensorEnableBroadcast
, sensorEnableBroadcast_reloadVal, sensorEnableBroadcast_offset);
}
void SL_MsgProcFunc_Update_Profile(device_handle device, void *pMsg, uint32_t MsgLen)
{
SL_Mppt_SOther_pack SUpdateProfile_pack = {0};
SUpdateProfile_pack.start_Flag[0] = g_slConfigInfo.start_Flag[0];
SUpdateProfile_pack.start_Flag[1] = g_slConfigInfo.start_Flag[1];
SUpdateProfile_pack.start_Flag[0] = g_otherParameter.startFlagSL[0];
SUpdateProfile_pack.start_Flag[1] = g_otherParameter.startFlagSL[1];
SUpdateProfile_pack.address[0] = g_slConfigInfo.address[0];
SUpdateProfile_pack.address[1] = g_slConfigInfo.address[1];
SUpdateProfile_pack.address[2] = g_slConfigInfo.address[2];
SUpdateProfile_pack.address[3] = g_slConfigInfo.address[3];
SUpdateProfile_pack.address[4] = g_slConfigInfo.address[4];
SUpdateProfile_pack.address[5] = g_slConfigInfo.address[5];
SUpdateProfile_pack.address[6] = g_slConfigInfo.address[6];
SUpdateProfile_pack.address[0] = g_otherParameter.address[0];
SUpdateProfile_pack.address[1] = g_otherParameter.address[1];
SUpdateProfile_pack.address[2] = g_otherParameter.address[2];
SUpdateProfile_pack.address[3] = g_otherParameter.address[3];
SUpdateProfile_pack.address[4] = g_otherParameter.address[4];
SUpdateProfile_pack.address[5] = g_otherParameter.address[5];
SUpdateProfile_pack.address[6] = g_otherParameter.address[6];
SUpdateProfile_pack.function_Code = SL_Function_Code_Update_Profile;
SUpdateProfile_pack.state = 0x01;
uint16_t crc = CheckFunc((uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE - 3);
uint16_t crc = CheckFuncSL((uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE - 3);
SUpdateProfile_pack.check_Bit_H = crc >> 8;
SUpdateProfile_pack.check_Bit_L = crc;
SUpdateProfile_pack.end_Flag = g_slConfigInfo.end_Flag;
SUpdateProfile_pack.end_Flag = g_otherParameter.endFlagSL;
while (1) {
Delay_Ms(randomDelay());
@ -391,26 +364,26 @@ void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t Ms
{
SL_Mppt_SOther_pack SUpdateProfile_pack = {0};
SUpdateProfile_pack.start_Flag[0] = g_slConfigInfo.start_Flag[0];
SUpdateProfile_pack.start_Flag[1] = g_slConfigInfo.start_Flag[1];
SUpdateProfile_pack.start_Flag[0] = g_otherParameter.startFlagSL[0];
SUpdateProfile_pack.start_Flag[1] = g_otherParameter.startFlagSL[1];
SUpdateProfile_pack.address[0] = g_slConfigInfo.address[0];
SUpdateProfile_pack.address[1] = g_slConfigInfo.address[1];
SUpdateProfile_pack.address[2] = g_slConfigInfo.address[2];
SUpdateProfile_pack.address[3] = g_slConfigInfo.address[3];
SUpdateProfile_pack.address[4] = g_slConfigInfo.address[4];
SUpdateProfile_pack.address[5] = g_slConfigInfo.address[5];
SUpdateProfile_pack.address[6] = g_slConfigInfo.address[6];
SUpdateProfile_pack.address[0] = g_otherParameter.address[0];
SUpdateProfile_pack.address[1] = g_otherParameter.address[1];
SUpdateProfile_pack.address[2] = g_otherParameter.address[2];
SUpdateProfile_pack.address[3] = g_otherParameter.address[3];
SUpdateProfile_pack.address[4] = g_otherParameter.address[4];
SUpdateProfile_pack.address[5] = g_otherParameter.address[5];
SUpdateProfile_pack.address[6] = g_otherParameter.address[6];
SUpdateProfile_pack.function_Code = SL_Function_Code_Remote_Upgrade;
SUpdateProfile_pack.state = 0x01;
uint16_t crc = CheckFunc((uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE - 3);
uint16_t crc = CheckFuncSL((uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE - 3);
SUpdateProfile_pack.check_Bit_H = crc >> 8;
SUpdateProfile_pack.check_Bit_L = crc;
SUpdateProfile_pack.end_Flag = g_slConfigInfo.end_Flag;
SUpdateProfile_pack.end_Flag = g_otherParameter.endFlagSL;
while (1) {
Delay_Ms(randomDelay());
@ -429,53 +402,17 @@ void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t Ms
}
///**
// * @brief 读取注册状态寄存器
// * @param
// * @retval
// */
//uint16_t SL_ReadRegisterRegistrationStatus(void *pMsg)
//{
// log_info(" SL_ReadRegisterRegistrationStatus ");
// uint16_t value = g_Mppt_Para.Registration_Status;
// return value;
//}
//
///**
// * @brief 读取地址寄存器
// * @param
// * @retval
// */
//uint16_t SL_ReadRegisteraddress(void *pMsg)
//{
// log_info(" SL_ReadRegisteraddress ");
//
// return 0;
//}
//
///**
// * @brief 读取接入节点类型寄存器
// * @param
// * @retval
// */
//uint16_t SL_ReadRegisterAccessNodeType(void *pMsg)
//{
// log_info(" SL_ReadRegisterAccessNodeType ");
// uint16_t value = g_Mppt_Para.Access_Node_Type;
// return value;
//}
//
///**
// * @brief 读取通信方式寄存器
// * @param
// * @retval
// */
//uint16_t SL_ReadRegisterCommunicationMethods(void *pMsg)
//{
// log_info(" SL_ReadRegisterCommunicationMethods ");
// uint16_t value = g_Mppt_Para.Communication_Methods;
// return value;
//}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterSolarOpenCircuitVoltage(void *pMsg)
{
log_info(" SL_ReadRegisterSolarOpenCircuitVoltage ");
uint16_t value = (uint16_t)(g_otherParameter.Solar_Open_Circuit_Voltage * 10);
return value;
}
/**
* @brief
@ -485,7 +422,7 @@ void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t Ms
uint16_t SL_ReadRegisterBatteryVoltage(void *pMsg)
{
log_info(" SL_ReadRegisterBatteryVoltage ");
uint16_t value = (uint16_t)(g_Mppt_Para.Battery_Voltage * 10);
uint16_t value = (uint16_t)(g_otherParameter.Battery_Voltage * 10);
return value;
}
@ -497,7 +434,7 @@ uint16_t SL_ReadRegisterBatteryVoltage(void *pMsg)
uint16_t SL_ReadRegisterChargCurrent(void *pMsg)
{
log_info(" SL_ReadRegisterChargCurrent ");
uint16_t value = (uint16_t)(g_Mppt_Para.Charg_Current * 10);
uint16_t value = (uint16_t)(g_otherParameter.Charg_Current * 10);
return value;
}
@ -509,105 +446,111 @@ uint16_t SL_ReadRegisterChargCurrent(void *pMsg)
uint16_t SL_ReadRegisterDischargCurrent(void *pMsg)
{
log_info(" SL_ReadRegisterDischargCurrent ");
uint16_t value = (uint16_t)(g_Mppt_Para.Discharg_Current * 10);
uint16_t value = (uint16_t)(g_otherParameter.Discharg_Current * 10);
return value;
}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterSolarOpenCircuitVoltage(void *pMsg)
{
log_info(" SL_ReadRegisterSolarOpenCircuitVoltage ");
uint16_t value = (uint16_t)(g_Mppt_Para.Solar_Open_Circuit_Voltage * 10);
return value;
}
/**
* @brief mos管的温度寄存器
* @brief mos管的温度寄存器
* @param
* @retval
*/
uint16_t SL_ReadRegisterHighSideMosTemperature(void *pMsg)
{
log_info(" SL_ReadRegisterHighSideMosTemperature ");
uint16_t value = (uint16_t)(g_Mppt_Para.HighSideMos_Temperature * 10);
uint16_t value = (uint16_t)(g_otherParameter.HighSideMos_Temperature * 10);
return value;
}
/**
* @brief mos管状态寄存器
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterDischargMosState(void *pMsg)
uint16_t SL_ReadRegisterSOC(void *pMsg)
{
log_info(" SL_ReadRegisterDischargMosState ");
uint16_t value = (uint16_t)g_Mppt_Para.DischargMos_State;
log_info(" SL_ReadRegisterSOC ");
uint16_t value = (uint16_t)(1 * 10);
return value;
}
/**
* @brief mppt工作模式寄存器
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterMPPTMode(void *pMsg)
uint16_t SL_ReadRegisterChargState(void *pMsg)
{
log_info(" SL_ReadRegisterMPPTMode ");
uint16_t value = (uint16_t)g_Mppt_Para.MPPT_Mode;
log_info(" SL_ReadRegisterChargState ");
uint16_t value = 0;
if (g_controlParameter.dutyRatio > 0 && g_otherParameter.Charg_Current > 0.05) {
value |= 0xFF00;
} else {
value &= 0x00FF;
}
if (g_otherParameter.DischargMos_State == Bit_SET && g_otherParameter.Discharg_Current > 0.05) {
value |= 0x00FF;
} else {
value &= 0xFF00;
}
return value;
}
///**
// * @brief 写入注册状态寄存器
// * @param
// * @retval
// */
//uint16_t SL_WriteRegisterRegistrationStatus(void *pMsg)
//{
// log_info(" WriteRegisterRegistrationStatus %x", *(uint16_t *)pMsg);
//
// return 0;
//}
//
///**
// * @brief 写入地址寄存器
// * @param
// * @retval
// */
//uint16_t SL_WriteRegisteraddress(void *pMsg)
//{
// log_info(" WriteRegisteraddress %x", *(uint16_t *)pMsg);
//
// return 0;
//}
//
///**
// * @brief 写入接入节点类型寄存器
// * @param
// * @retval
// */
//uint16_t SL_WriteRegisterAccessNodeType(void *pMsg)
//{
// log_info(" WriteRegisterAccessNodeType %x", *(uint16_t *)pMsg);
//
// return 0;
//}
//
///**
// * @brief 写入通信方式寄存器
// * @param
// * @retval
// */
//uint16_t SL_WriteRegisterCommunicationMethods(void *pMsg)
//{
// log_info(" WriteRegisterCommunicationMethods %x", *(uint16_t *)pMsg);
//
// return 0;
//}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterTotalChargCapacity(void *pMsg)
{
log_info(" SL_ReadRegisterTotalChargCapacity ");
uint16_t value = (uint16_t)(g_otherParameter.totalChargCapacity * 1000);
return value;
}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterTotalElectricityConsumption(void *pMsg)
{
log_info(" SL_ReadRegisterTotalElectricityConsumption ");
uint16_t value = (uint16_t)(g_otherParameter.totalElectricityConsumption * 1000);
return value;
}
/**
* @brief MPPT工作模式
* @param
* @retval
*/
uint16_t SL_ReadRegisterMPPT_Mode(void *pMsg)
{
log_info(" SL_ReadRegisterMPPT_Mode ");
uint16_t value = (uint16_t)(g_otherParameter.MPPT_Mode);
return value;
}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg)
{
log_info(" SL_WriteRegisterEliminateStatistical ");
g_otherParameter.totalChargCapacity = 0;
g_otherParameter.totalElectricityConsumption = 0;
// saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
savetotalChargCapacity(&g_otherParameter.totalChargCapacity);
savetotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
return 1;
}
/**
* @brief "SL"
@ -621,8 +564,8 @@ static int Match_Startflag(uint8_t start_buff[2])
// log_info("Match_Startflag fail \r\n");
// return 1;
// }
if ((start_buff[0] == g_slConfigInfo.start_Flag[0]) && \
(start_buff[1] == g_slConfigInfo.start_Flag[1])) {
if ((start_buff[0] == g_otherParameter.startFlagSL[0]) && \
(start_buff[1] == g_otherParameter.startFlagSL[1])) {
log_info("Match_Startflag success \r\n");
return 1;
}
@ -641,13 +584,13 @@ static int Match_address(u_int8_t address[7])
// log_info("Match_address fail \r\n");
// return 1;
// }
if ((address[0] == g_slConfigInfo.address[0]) && \
(address[1] == g_slConfigInfo.address[1]) && \
(address[2] == g_slConfigInfo.address[2]) && \
(address[3] == g_slConfigInfo.address[3]) && \
(address[4] == g_slConfigInfo.address[4]) && \
(address[5] == g_slConfigInfo.address[5]) && \
(address[6] == g_slConfigInfo.address[6])) {
if ((address[0] == g_otherParameter.address[0]) && \
(address[1] == g_otherParameter.address[1]) && \
(address[2] == g_otherParameter.address[2]) && \
(address[3] == g_otherParameter.address[3]) && \
(address[4] == g_otherParameter.address[4]) && \
(address[5] == g_otherParameter.address[5]) && \
(address[6] == g_otherParameter.address[6])) {
log_info("Match_address success \r\n");
return 1;
}
@ -700,10 +643,12 @@ static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint3
c = uart_dev_in_char(uart_handle);
buff[offset++] = c;
config_buff[cfig_len++] = c;
/* 匹配起始标志位 */
if (offset == analyzeStartFlag || (flag_run > 0)) {
if (!Match_Startflag(pack->start_Flag)) {
log_info("Match_Startflag error \r\n");
memcpy(buff, buff+1, offset-1);
offset--;
continue;
@ -712,11 +657,16 @@ static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint3
/* 匹配地址 */
if (offset == analyzeAddress || (flag_run > 1)) {
if (!((((g_Mppt_Para.Registration_Status == 2) || RegistrationRequestFlag) && Match_address(pack->address))
|| (run_Broadcast && Match_Broadcastaddress(pack->address)))) {
if (!((((g_otherParameter.Registration_Status == 2) || g_otherParameter.RegistrationRequestFlag) && Match_address(pack->address))
|| (g_otherParameter.runBroadcast && Match_Broadcastaddress(pack->address)))) {
if (flag_run < 1) {
flag_run = 1;
}
// log_info("Startflag 0x%x 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
// log_info("Match address error 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\r\n", pack->address[0], pack->address[1], pack->address[2]
// , pack->address[3], pack->address[4], pack->address[5], pack->address[6]);
// log_info("Match address error 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\r\n", g_otherParameter.address[0], g_otherParameter.address[1], g_otherParameter.address[2]
// , g_otherParameter.address[3], g_otherParameter.address[4], g_otherParameter.address[5], g_otherParameter.address[6]);
memcpy(buff, buff+1, offset-1);
offset--;
continue;
@ -726,7 +676,7 @@ static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint3
/* 匹配功能码 */
if (offset == analyzeFunctionCode || (flag_run > 2)) {
/* 未注册时,不处理读写和其他帧 */
if (g_Mppt_Para.Registration_Status == 2) {
if (g_otherParameter.Registration_Status == 2) {
/* 读寄存器数据 */
if (pack->function_Code == SL_Function_Code_Read_Register) {
log_info("Read_Register\r\n");
@ -738,14 +688,20 @@ static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint3
log_info("Write_Register\r\n");
}
// /* 其他帧格式 */
// else if (pack->function_Code == SL_Function_Code_Update_Profile
// || pack->function_Code == SL_Function_Code_Remote_Upgrade) {
// len = SL_MPPT_ROTHER_PACK_SIZE;
// log_info("Other frames\r\n");
// }
/* 其他帧格式 */
else if (pack->function_Code == SL_Function_Code_Update_Profile
|| pack->function_Code == SL_Function_Code_Remote_Upgrade) {
else if (pack->function_Code == SL_Function_Code_Remote_Upgrade) {
len = SL_MPPT_ROTHER_PACK_SIZE;
log_info("Other frames\r\n");
}
else if (run_Broadcast) {
else if (g_otherParameter.runBroadcast) {
/* 广播扫描 */
if (pack->function_Code == SL_Function_Code_Broadcast_Scan) {
log_info("Broadcast_Scan\r\n");
@ -814,14 +770,20 @@ static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint3
if (offset == len) {
uint16_t crc_16 = chang_8_to_16(buff[offset - 2], buff[offset - 3]);
if ((CheckFunc(buff, offset - 3) != crc_16) || (buff[offset - 1] != 0x16)) {
if ((CheckFuncSL(buff, offset - 3) != crc_16) || (buff[offset - 1] != 0x16)) {
if (flag_run < 3) {
flag_run = 3;
}
// log_info(" crc : %x, %x", CheckFuncSL(buff, offset - 3), crc_16);
// log_info(" : %x, %x, %x", buff[offset - 3], buff[offset - 2], buff[offset - 1]);
memcpy(buff, buff+1, offset-1);
offset--;
} else {
memset(config_buff, 0, sizeof(config_buff));
cfig_len = 0;
return offset;
}
}
@ -845,26 +807,29 @@ void FRT_MsgHandler(device_handle device, uint8_t *pMsg, uint32_t MsgLen)
}
}
/**
* @brief
* @param
* @retval
*/
void read_and_process_uart_data(device_handle device)
{
// printf("ring_queue_length = %d \n", ring_queue_length(device));
// if (ring_queue_length(device) > 10) {uart_dev_char_present(device_handle device)
if (uart_dev_char_present(device)) {
Delay_Ms(20);
// printf("ring_queue_length = %d \n", ring_queue_length(device));
// if (uart_dev_char_present(device)) {
// Delay_Ms(20);
//// log_info("in read : %d", ring_queue_length(device));
//// char c;
//// while (uart_dev_char_present(device)) {
//// c = uart_dev_in_char(device);
//// log_info("%x ", (c & 0xff));
//// }
//// log_info("");
//
// memset(rs485_buff, 0, sizeof(rs485_buff));
// int ret = uart_read_climate_pack(device, rs485_buff, sizeof(rs485_buff));
// if(ret > 0){
// FRT_MsgHandler(device, rs485_buff, ret);
// }
// }
memset(rs485_buff, 0, sizeof(rs485_buff));
int ret = uart_read_climate_pack(device, rs485_buff, sizeof(rs485_buff));
if(ret > 0){
FRT_MsgHandler(device, rs485_buff, ret);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@
#include "uart_dev.h"
#include "inflash.h"
#include "parameter.h"
/* ʹÄÜ485·¢ËÍ */
#define rs485_send_enable 1
@ -18,9 +19,9 @@ device_handle g_bat485_uart3_handle;
device_handle g_gw485_uart4_handle;
static uint8_t bat485_in_buff[200];
static uint8_t gw485_in_buff[300];
static uint8_t gw485_in_buff[200];
uint8_t rs485_out_buff[100];
//uint8_t rs485_out_buff[100];
/**
@ -79,13 +80,15 @@ device_handle uart_dev_init(void)
// return (device_handle)(&uart_devices[i]);
// }
// }
if (g_otherParameter.bat485_Baud != 0) {
InitRingQueue(&uart_devices[0].uart_ring_queue, bat485_in_buff, sizeof(bat485_in_buff));
uart_init(BAT485_UART_INDEX, g_slConfigInfo.baud_485);
uart_init(BAT485_UART_INDEX, g_otherParameter.bat485_Baud);
uart_devices[0].init = 1;
g_bat485_uart3_handle = (device_handle)(&uart_devices[0]);
}
InitRingQueue(&uart_devices[1].uart_ring_queue, gw485_in_buff, sizeof(gw485_in_buff));
uart_init(GW485_UART_INDEX, g_slConfigInfo.baud_485);
uart_init(GW485_UART_INDEX, g_otherParameter.gw485_Baud);
uart_devices[1].init = 1;
g_gw485_uart4_handle = (device_handle)(&uart_devices[1]);
@ -103,9 +106,9 @@ void uart_init(uartIndex_e uart_index, int baud)
{
if (uart_index == BAT485_UART_INDEX) {
// BAT_485_Init(uart_devices[0].uart_baudrate);
BAT_485_Init(115200);
BAT_485_Init(baud);
} else if (uart_index == GW485_UART_INDEX) {
GW_485_Init(uart_devices[1].uart_baudrate);
GW_485_Init(baud);
}
}

285
App/src/uart_send.c Normal file
View File

@ -0,0 +1,285 @@
/*
* uart_send.c
*
* Created on: 20241119
* Author: psx
*/
#include "uart_send.h"
#include "parameter.h"
#include <string.h>
//static uint8_t dataLocation1[RS485_MAX_PACK_DATA_LEN];
//static uint8_t dataLocation2[RS485_MAX_PACK_DATA_LEN];
//static uint8_t dataLocation3[RS485_MAX_PACK_DATA_LEN];
static uint8_t dataLocation1[RS485_MAX_PACK_DATA_LEN];
static uint8_t dataLocation2[RS485_MAX_PACK_DATA_LEN];
static uint8_t dataLocation3[RS485_MAX_PACK_DATA_LEN];
uart_send_info uart_send;
/**
* @brief 线
* @param
* @retval
*
*/
void send_init(void)
{
uart_send.data1.data = dataLocation1;
uart_send.data2.data = dataLocation2;
uart_send.data3.data = dataLocation3;
uart_send.insertData = &uart_send.data1;
uart_send.sendDataGw = NULL;
uart_send.sendDataBat = NULL;
//有3个位置可以写入数据
uart_send.insertState = 3;
//没有数据能够发送
uart_send.sendStateGw = 0;
uart_send.sendStateBat = 0;
//发送完成
uart_send.sendOverStateBat = 1;
uart_send.sendOverStateGw = 1;
//485总线空闲
uart_send.GwState = 1;
uart_send.idleStateGw = 1;
uart_send.BatState = 1;
uart_send.idleStateBat = 1;
}
/**
* @brief 线
* @param
* @retval
*
*/
void check_sendState(void)
{
static uint8_t tempGwT = 0;
static uint8_t tempBatT = 0;
/* 进入空闲中断一段时间后仍然没有数据到来判断485总线空闲 */
if (!uart_send.GwState) {
if (uart_send.idleStateGw) {
tempGwT++;
if (tempGwT >= g_otherParameter.randomNumber) {
uart_send.GwState = 1;
}
}
} else {
tempGwT = 0;
}
/* 进入空闲中断一段时间后仍然没有数据到来判断485总线空闲 */
if (!uart_send.BatState) {
if (uart_send.idleStateBat) {
tempBatT++;
if (tempBatT >= g_otherParameter.randomNumber) {
uart_send.BatState = 1;
}
}
} else {
tempBatT = 0;
}
/* 向上通信总线空闲时,检测到有数据需要发送,同时上一次数据发送完成 */
// if (uart_send.GwState && uart_send.sendStateGw && uart_send.sendOverStateGw) {
if (uart_send.GwState && uart_send.sendStateGw && uart_send.sendOverStateGw) {
printf("Gw in Tx\n");
gw485_tx_enabla();
// USART_ITConfig(USART4, USART_IT_TXE, ENABLE);
uartDMA_Init(g_gw485_uart4_handle, uart_send.sendDataGw->data, uart_send.sendDataGw->dataLen);
USART_DMACmd(USART4, USART_DMAReq_Tx, ENABLE);
// uart_send.sendOverStateGw = 0;
uart_send.sendOverStateGw = 0;
}
/* 向下通信总线空闲时,检测到有数据需要发送,同时上一次数据发送完成 */
// if (uart_send.BatState && uart_send.sendStateBat && uart_send.sendOverStateBat) {
if (uart_send.BatState && uart_send.sendStateBat && uart_send.sendOverStateBat) {
printf("Bat in Tx\n");
bat485_tx_enabla();
// USART_ITConfig(USART3, USART_IT_TXE, ENABLE);
// uartDMA_Init(g_bat485_uart3_handle, uart_send.sendDataBat->data, uart_send.sendDataBat->dataLen);
USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE);
// uart_send.sendOverStateBat = 0;
uart_send.sendOverStateBat = 0;
}
/* 向上通信时,依次查看有无向上通信的数据 */
if (!uart_send.sendStateGw && (uart_send.insertState + uart_send.sendStateBat < 3)) {
if (uart_send.data1.dataState) {
if (uart_send.data1.device == g_gw485_uart4_handle) {
uart_send.sendStateGw = 1;
uart_send.sendDataGw = &uart_send.data1;
}
}
if (uart_send.data2.dataState) {
if (uart_send.data2.device == g_gw485_uart4_handle) {
uart_send.sendStateGw= 1;
uart_send.sendDataGw = &uart_send.data2;
}
}
if (uart_send.data3.dataState) {
if (uart_send.data3.device == g_gw485_uart4_handle) {
uart_send.sendStateGw = 1;
uart_send.sendDataGw = &uart_send.data3;
}
}
}
/* 向下通信时,依次查看有无向下通信的数据 */
if (!uart_send.sendStateBat && (uart_send.insertState + uart_send.sendStateGw < 3)) {
if (uart_send.data1.dataState) {
if (uart_send.data1.device == g_bat485_uart3_handle) {
uart_send.sendStateBat = 1;
uart_send.sendDataBat = &uart_send.data1;
}
}
if (uart_send.data2.dataState) {
if (uart_send.data2.device == g_bat485_uart3_handle) {
uart_send.sendStateBat = 1;
uart_send.sendDataBat = &uart_send.data2;
}
}
if (uart_send.data3.dataState) {
if (uart_send.data3.device == g_bat485_uart3_handle) {
uart_send.sendStateBat = 1;
uart_send.sendDataBat = &uart_send.data3;
}
}
}
}
/**
* @brief
* @param
* @retval
*
*/
void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len)
{
// printf("\n");
// printf("buff");
// for (int var = 0; var < len; ++var) {
// printf(" %x ", buff[var]);
// }
// printf("\n");
// printf("\n");
/* 拷贝数据到发送 */
do {
if (uart_send.insertState > 0 && uart_send.insertData != NULL) {
// memcpy(uart_send.insertData->data, buff, len);
for (int var = 0; var < len; ++var) {
uart_send.insertData->data[var] = buff[var];
// printf(" %x ", uart_send.insertData->data[var]);
}
uart_send.insertData->Counter = 0;
uart_send.insertData->dataLen = len;
uart_send.insertData->device = device;
// uart_send.insertData->dataState = 1;
// uart_send.insertState--;
break;
}
} while (1);
/* 可插入数据大于0时将插入指针指向空的储存位置,否则指向NULL */
if (uart_send.insertState > 0) {
if (!uart_send.data1.dataState) {
uart_send.insertData = &uart_send.data1;
}
else if (!uart_send.data2.dataState) {
uart_send.insertData = &uart_send.data2;
}
else if (!uart_send.data3.dataState) {
uart_send.insertData = &uart_send.data3;
}
} else {
uart_send.insertData = NULL;
}
printf("uart_send.insertData->data");
for (int var = 0; var < len; ++var) {
printf(" %x ", uart_send.insertData->data[var]);
}
printf("\n");
printf("uart_send.insertData->Counter : %d \n", uart_send.insertData->Counter);
printf("uart_send.insertData->dataLen : %d \n", uart_send.insertData->dataLen);
printf("uart_send.insertState : %d \n", uart_send.insertState);
uart_send.insertData->dataState = 1;
uart_send.insertState--;
}
void DMA1_Channel1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void uartDMA_Init(device_handle device, uint8_t buff[], uint8_t len)
{
DMA_InitTypeDef DMA_InitStructure = {0};
RCC_HBPeriphClockCmd(RCC_HBPeriph_DMA1, ENABLE);
DMA_DeInit(DMA1_Channel1);
DMA_ClearFlag(DMA1_FLAG_TC1);
if (device == g_bat485_uart3_handle) {
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&USART3->DATAR);
}
else if (device == g_gw485_uart4_handle) {
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&USART4->DATAR);
}
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)buff;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = len;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE); //使能传输完成中断
DMA_Cmd(DMA1_Channel1, ENABLE);
}
//中断处理函数
void DMA1_Channel1_IRQHandler(void)
{
if(DMA_GetITStatus(DMA1_IT_TC1) != RESET) {
//中断处理代码
Delay_Us(100);
gw485_tx_disenabla();
uart_send.sendStateGw = 0;
uart_send.insertState++;
// printf("\n\n bat uart_send.insertState : %d \n\n", uart_send.insertState);
/* 插入指针指向为空时 */
if (uart_send.insertData == NULL) {
if (!uart_send.data1.dataState) {
uart_send.insertData = &uart_send.data1;
}
if (!uart_send.data2.dataState) {
uart_send.insertData = &uart_send.data2;
}
if (!uart_send.data3.dataState) {
uart_send.insertData = &uart_send.data3;
}
}
uart_send.sendOverStateGw = 1;
DMA_ClearITPendingBit(DMA1_IT_TC1);
}
}

View File

@ -0,0 +1,91 @@
/*
* ring_queue.c
*
* Created on: 2024621
* Author: psx
*/
//循环队列
#include <stdio.h>
#include <stdlib.h>
#include "ring_queue2.h"
//#define RING_QUEUE_DEBUG
//#ifdef RING_QUEUE_DEBUG
//#define //rq_debug term_printf
//#else
//void rq_debug(const char *fmt, ...){};
//#endif
#define RQ_OK 1
#define RQ_ERROR 0
#define RQ_OVERFLOW -2
//初始化队列
int InitRingQueue2(RingQueue2 *q, RQ_ElementType2 *buff, int size)
{
q->elems = buff;
q->size = size;
q->front=q->rear=0;
return RQ_OK;
}
//遍历队列,
//消费者使用故对生产者可能修改的rear先读取缓存
int ShowRingQueue2(RingQueue2 *q)
{
//int i;
int rear = q->rear;
if(q->front == rear)
{
//rq_debug("队列为空\n");
return RQ_ERROR;
}
//rq_debug("队列中的元素为:\n");
//for(i=((q->front)%q->size); i != rear; i=((i+1)%q->size))
//rq_debug(" %c\n",q->elems[i]);
//rq_debug("\n");
//rq_debug("队首元素为%c\n",q->elems[q->front]);
//rq_debug("队尾元素为%c\n",q->elems[rear - 1]);
return RQ_OK;
}
//向队尾插入元素e
int InRingQueue2(RingQueue2 *q,RQ_ElementType2 e)
{
if(RingQueueFull2(q))
{
//rq_debug("空间不足\n");
return(RQ_OVERFLOW);
}
q->elems[q->rear] = e;
q->rear = (q->rear+1) % q->size;
//rq_debug("rear = %d\n",q->rear);
return RQ_OK;
}
//从队首取回并删除元素
int OutRingQueue2(RingQueue2 *q, RQ_ElementType2 *e)
{
if(RingQueueEmpty2(q))
{
//rq_debug("队列为空\n");
return RQ_ERROR;
}
*e = q->elems[q->front];
//rq_debug("被删除的队首元素为%c\n",q->elems[q->front]);
q->front = (q->front+1) % q->size;
return RQ_OK;
}
//队列中的元素个数
int RingQueueLength2(RingQueue2 *q)
{
return ((q->rear - q->front) + q->size) % q->size;
}

View File

@ -0,0 +1,45 @@
/*
* ring_queue.h
*
* Created on: 2024621
* Author: psx
*/
#ifndef DRIVERS_RINGQUEUE_RING_QUEUE2_H_
#define DRIVERS_RINGQUEUE_RING_QUEUE2_H_
//#define RING_QUEUE_DEBUG //定义本宏会打印RingQueue的调试信息
//typedef unsigned char RQ_ElementType2;//元素类型
typedef uint16_t RQ_ElementType2;//元素类型
typedef struct _ring_queue2
{
RQ_ElementType2 *elems;
int size;
volatile int front, rear;
}RingQueue2;
//初始化队列,需传入保存队列状态的结构q队列使用的buffer和buffer大小
int InitRingQueue2(RingQueue2 *q, RQ_ElementType2 *buff, int size);
#define RingQueueFull2(q) (((q)->rear+1) % (q)->size == (q)->front)
#define RingQueueEmpty2(q) ((q)->front == (q)->rear)
//遍历队列,
//消费者使用故对生产者可能修改的rear先读取缓存
int ShowRingQueue2(RingQueue2 *q);
//向队尾插入元素e
int InRingQueue2(RingQueue2 *q,RQ_ElementType2 e);
//从队首删除元素
int OutRingQueue2(RingQueue2 *q, RQ_ElementType2 *e);
//队列中的元素个数
int RingQueueLength2(RingQueue2 *q);
#endif /* DRIVERS_RINGQUEUE_RING_QUEUE_H_ */

View File

@ -70,6 +70,14 @@ void EnPowerSupply_Init(void);
/* WORK_VOLT_INT --> PA12 */
#define WORK_VOLT_INT_GPIO GPIOA
#define WORK_VOLT_INT_PIN GPIO_Pin_12
void WORK_VOLT_INT_open(void);
void WORK_VOLT_INT_close(void);
void WORK_VOLT_INT_Init(void);
/* 防反mos的控制 */
/* POW_FF_CON --> PA15 */
#define POW_FF_CON_GPIO GPIOA
#define POW_FF_CON_PIN GPIO_Pin_15
void POW_FF_CON_Init(void);
#endif /* HARDWARE_INC_GPIO_H_ */

View File

@ -29,4 +29,7 @@ void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data);
void USARTx_ITSendstr(USART_TypeDef* pUSARTx, char *str, int len);
//extern uint8_t USART_Rbuffer[100];
//extern uint8_t USART_RbufferLen;
#endif /* HARDWARE_INC_RS485_H_ */

View File

@ -9,10 +9,13 @@
#define HARDWARE_INC_TIM_H_
#include "debug.h"
#include "math.h"
void TIM3_Init(uint16_t delay_ms);
void TIM3_Int_Init(uint16_t arr,uint16_t psc);
extern float_t totalElectricityConsumption;
extern float_t totalChargCapacity;
void TIM2_Init(uint16_t delay_ms);
void TIM2_Int_Init(uint16_t arr,uint16_t psc);

View File

@ -7,7 +7,7 @@
#include "gpio.h"
#include "task.h"
#include "parameter.h"
void G_FFMOS_CON_Init(void)
{
@ -59,6 +59,7 @@ void BEEP_Init(void)
void POW_OUT_CON_Init(void)
{
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOB, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = POW_OUT_CON_PIN;
@ -100,23 +101,22 @@ void DSG_PROT_Init(void)
void EXTI2_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line2)==SET) { //EXTI_GetITStatus用来获取中断标志位状态如果EXTI线产生中断则返回SET否则返回RESET
// GPIO_WriteBit(DSG_PROT_GPIO, DSG_PROT_PIN, RESET);
EXTI_ClearITPendingBit(EXTI_Line2); //清除中断标志位
// printf("Run at EXTI 111\r\n");
if (outputAgainFlag == 0) {
outputAgainFlag = 1;
TimeSliceOffset_Register(&m_outputAgain, Task_outputAgain
if (0 == g_otherParameter.outputAgainFlag) {
g_otherParameter.outputAgainFlag++;
TimeSliceOffset_Register(&g_outputAgain, Task_outputAgain
, outputAgain_reloadVal, outputAgain_offset);
// m_outputAgain.runFlag = 1;
g_outputAgain.runFlag = 1;
return;
}
// if (outputAgainFlag == 1) {
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
// EXTI_ClearITPendingBit(EXTI_Line2); //清除中断标志位
// return;
// }
g_otherParameter.outputAgainFlag++;
if (2 == g_otherParameter.outputAgainFlag) {
TimeSliceOffset_Unregister(&g_outputAgain);
g_outputAgain.runFlag = 0;
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
}
}
}
@ -135,14 +135,8 @@ void EnPowerSupply_Init(void)
void EXTI15_10_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void WORK_VOLT_INT_Init(void)
void WORK_VOLT_INT_open(void)
{
RCC_PB2PeriphClockCmd(RCC_PB2Periph_AFIO | RCC_PB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = WORK_VOLT_INT_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //下拉输入
GPIO_Init(WORK_VOLT_INT_GPIO, &GPIO_InitStructure);
/* GPIOA ----> EXTI_Line12 */
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource12);//指定中断/事件线的输入源实际上是设定外部中断配置寄存器AFIO_EXTICRx的值此处为PA12
@ -151,6 +145,29 @@ void WORK_VOLT_INT_Init(void)
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //EXTI边沿触发事件此处选择为上升沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE; //使能EXTI线
EXTI_Init(&EXTI_InitStructure);
}
void WORK_VOLT_INT_close(void)
{
/* GPIOA ----> EXTI_Line12 */
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource12);//指定中断/事件线的输入源实际上是设定外部中断配置寄存器AFIO_EXTICRx的值此处为PA12
EXTI_InitStructure.EXTI_Line = EXTI_Line12; //EXTI中断/事件线选择此处选择EXTI_Line12
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //EXTI模式选择此处选择为产生中断模式
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //EXTI边沿触发事件此处选择为上升沿触发
EXTI_InitStructure.EXTI_LineCmd = DISABLE; //使能EXTI线
EXTI_Init(&EXTI_InitStructure);
}
void WORK_VOLT_INT_Init(void)
{
RCC_PB2PeriphClockCmd(RCC_PB2Periph_AFIO | RCC_PB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = WORK_VOLT_INT_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //下拉输入
GPIO_Init(WORK_VOLT_INT_GPIO, &GPIO_InitStructure);
WORK_VOLT_INT_open();
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; //使能EXTI12中断通道
@ -163,19 +180,36 @@ void WORK_VOLT_INT_Init(void)
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line12)==SET) { //EXTI_GetITStatus用来获取中断标志位状态如果EXTI线产生中断则返回SET否则返回RESET
// printf(" vout low 11V \n");
// WORK_VOLT_INT_close();
// TimeSliceOffset_Register(&g_overloadDelay, Task_overloadDelay
// , overloadDelay_reloadVal, overloadDelay_offset);
// Delay_Us(10);
// Delay_Ms(1);
// WORK_VOLT_INT_open();
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
EXTI_ClearITPendingBit(EXTI_Line12); //清除中断标志位
excessiveLoadFlag++;
TimeSliceOffset_Register(&m_excessiveLoad, Task_excessiveLoad
if (0 == g_otherParameter.excessiveLoadFlag) {
TimeSliceOffset_Register(&g_excessiveLoad, Task_excessiveLoad
, excessiveLoad_reloadVal, excessiveLoad_offset);
// uart_dev_write(g_bat485_uart3_handle, "\n\n\n\n\n in vout low 8V (Set)\n\n\n\n\n", sizeof("\n\n\n\n\n in vout low 8V (Set)\n\n\n\n\n"));
}
// uart_dev_write(g_bat485_uart3_handle, "\n\n\n\n\n in vout low 8V\n\n\n\n\n", sizeof("\n\n\n\n\n in vout low 8V\n\n\n\n\n"));
// if(EXTI_GetITStatus(EXTI_Line12)==SET) { //EXTI_GetITStatus用来获取中断标志位状态如果EXTI线产生中断则返回SET否则返回RESET
//// printf(" vout low 11V \n");
// uart_dev_write(g_bat485_uart3_handle, "\n\n\n\n\n in vout low 8V\n\n\n\n\n", sizeof("\n\n\n\n\n in vout low 8V\n\n\n\n\n"));
// }
g_otherParameter.excessiveLoadFlag++;
/* 多次过载则关闭输出 */
if (g_otherParameter.excessiveLoadFlag >= 2) {
return;
}
}
}
void POW_FF_CON_Init(void)
{
RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = POW_FF_CON_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(POW_FF_CON_GPIO, &GPIO_InitStructure);
// GPIO_WriteBit(POW_FF_CON_GPIO, POW_FF_CON_PIN, SET);
GPIO_WriteBit(POW_FF_CON_GPIO, POW_FF_CON_PIN, RESET);
}

View File

@ -8,7 +8,8 @@
#include "rs485.h"
#include "uart_dev.h"
#include "ring_queue.h"
#include "pdebug.h"
#include "uart_send.h"
void USART3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void USART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
@ -22,12 +23,18 @@ void USART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/* 接收缓冲区数组 */
uint8_t USART3_Rbuffer[1] = {0x00};
uint8_t USART4_Rbuffer[1] = {0x00};
//uint8_t USART_Rbuffer[100] = {0x00};
//uint8_t USART_RbufferLen = 0;
///* 发送 */
//uint8_t USART3_Tbuffer_Num = 0;
//uint8_t USART3_Tbuffer_Len = 0;
//uint8_t *USART3_Tbuffer;
uart_send_info *GwSendInfo;
uart_send_info *BatSendInfo;
/*
* @brief GW485
* @param
@ -60,6 +67,8 @@ void GW_485_Init(int baud)
GPIO_Init(GPIOB, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = baud;
// USART_InitStructure.USART_BaudRate = 9600;
// USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
@ -74,7 +83,7 @@ void GW_485_Init(int baud)
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
// USART_ITConfig(USART4, USART_IT_IDLE, ENABLE);
USART_ITConfig(USART4, USART_IT_IDLE, ENABLE);
USART_Cmd(USART4,ENABLE);
}
@ -125,7 +134,7 @@ void BAT_485_Init(int baud)
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
// USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
USART_Cmd(USART3,ENABLE);
}
@ -264,22 +273,46 @@ void USART3_IRQHandler(void)
{
// printf(" in usart3 \n");
// USART_ClearITPendingBit(USART3,USART_IT_RXNE); //清除中断标志
/* 有数据来时,总线不空闲 */
uart_send.idleStateBat = 0;
uart_send.BatState = 0;
USART3_Rbuffer[0] = USART_ReceiveData(USART3); //接收数据
uint8_t c = 0;
uart_device_info *dev = (uart_device_info *)g_bat485_uart3_handle;
c = USART3_Rbuffer[0];
if(!RingQueueFull(&dev->uart_ring_queue))
InRingQueue(&dev->uart_ring_queue, c);
InRingQueue(&dev->uart_ring_queue, USART3_Rbuffer[0]);
}
// if(USART_GetFlagStatus(USART3,USART_FLAG_TC) == SET) //中断发送
if(USART_GetITStatus(USART3, USART_IT_IDLE) != RESET) //中断产生
{
uart_send.idleStateGw = 1;
USART_ReceiveData(USART3);
}
// if(USART_GetITStatus(USART3, USART_FLAG_TXE) != RESET) //中断发送
// {
// USART_SendData(USART3, USART3_Tbuffer[USART3_Tbuffer_Num++]);
// if (USART3_Tbuffer_Len == USART3_Tbuffer_Num) {
// USART3_Tbuffer_Num = 0;
// USART_ITConfig(USART3, USART_IT_TC, DISABLE);
//// USART_ClearFlag(USART3,USART_FLAG_ORE); //清标志
//// USART_ReceiveData(USART3); //读DR
// USART_SendData(USART3, uart_send.sendDataBat->data[uart_send.sendDataBat->Counter++]);
// if (uart_send.sendDataBat->dataLen == uart_send.sendDataBat->Counter) {
// USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
// uart_send.sendOverStateBat = 1;
// uart_send.sendStateBat = 0;
// uart_send.insertState++;
//// printf("\n\n bat uart_send.insertState : %d \n\n", uart_send.insertState);
// /* 插入指针指向为空时 */
// if (uart_send.insertData == NULL) {
// if (!uart_send.data1.dataState) {
// uart_send.insertData = &uart_send.data1;
// }
// if (!uart_send.data2.dataState) {
// uart_send.insertData = &uart_send.data2;
// }
// if (!uart_send.data3.dataState) {
// uart_send.insertData = &uart_send.data3;
// }
// }
// Delay_Us(100);
// bat485_tx_disenabla();
// }
// }
}
@ -293,16 +326,55 @@ void USART4_IRQHandler(void)
{
if(USART_GetITStatus(USART4, USART_IT_RXNE) != RESET) //中断产生
{
// printf(" in usart4 \n");
// USART_ClearITPendingBit(USART4, USART_IT_RXNE); //清除中断标志
/* 有数据来时,总线不空闲 */
uart_send.GwState = 0;
uart_send.idleStateGw = 0;
USART4_Rbuffer[0] = USART_ReceiveData(USART4); //接收数据
uint8_t c = 0;
uart_device_info *dev = (uart_device_info *)g_gw485_uart4_handle;
c = USART4_Rbuffer[0];
if(!RingQueueFull(&dev->uart_ring_queue))
InRingQueue(&dev->uart_ring_queue, c);
InRingQueue(&dev->uart_ring_queue, USART4_Rbuffer[0]);
}
if(USART_GetITStatus(USART4, USART_IT_IDLE) != RESET) //中断产生
{
uart_send.idleStateGw = 1;
USART_ReceiveData(USART4);
}
// if(USART_GetITStatus(USART4, USART_FLAG_TXE) != RESET) //中断发送
// {
//// USART_SendData(USART4, uart_send.sendDataGw->data[uart_send.sendDataGw->Counter++]);
//
//// USART_SendData(USART4, USART_Tbuffer[count++]);
//// if (len == count) {
//// USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
//////// }
////// if (uart_send.sendDataGw->dataLen <= uart_send.sendDataGw->Counter) {
////// USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
////// uart_send.sendOverStateGw = 1;
////// uart_send.sendStateGw = 0;
////// uart_send.insertState++;
////// printf("\n\n Gw uart_send.insertState : %d \n\n", uart_send.insertState);
////// /* 插入指针指向为空时 */
////// if (uart_send.insertData == NULL) {
////// if (!uart_send.data1.dataState) {
////// uart_send.insertData = &uart_send.data1;
////// }
////// if (!uart_send.data2.dataState) {
////// uart_send.insertData = &uart_send.data2;
////// }
////// if (!uart_send.data3.dataState) {
////// uart_send.insertData = &uart_send.data3;
////// }
////// }
//// Delay_Us(100);
//// gw485_tx_disenabla();
//// }
// }
// if(USART_GetFlagStatus(USART4,USART_FLAG_TC) == SET) //中断发送
// {
// USART_SendData(USART4, USART4_Tbuffer[USART3_Tbuffer_Num++]);

View File

@ -10,6 +10,10 @@
#include "pwm.h"
#include "mppt_control.h"
#include "task.h"
#include "math.h"
#include "parameter.h"
#include "collect_Conversion.h"
#include "uart_send.h"
void TIM3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
@ -17,7 +21,7 @@ void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM1_UP_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/* delay_ms 为0.1ms */
void TIM3_Init(uint16_t delay_ms)
{
/* 分频系数 */
@ -59,7 +63,7 @@ void TIM3_IRQHandler(void)
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) { //检查TIM3中断是否发生。
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); //清除TIM3的中断挂起位。
// uart_dev_write(g_bat485_uart3_handle, "\n\n\n\n\nin tim3 irt\n\n\n\n\n", sizeof("\n\n\n\n\nin tim3 irt\n\n\n\n\n"));
test();
MpptContorl();
}
}
@ -98,14 +102,23 @@ void TIM2_Int_Init(uint16_t arr, uint16_t psc)
TIM_Cmd(TIM2, ENABLE); //TIM2使能
}
float_t totalElectricityConsumption = 0; /* 总电量消耗 */
float_t totalChargCapacity = 0; /* 总充电电量 */
void TIM2_IRQHandler(void)
{
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) { //检查TIM2中断是否发生。
TIM_ClearITPendingBit(TIM2, TIM_IT_Update); //清除TIM1的中断挂起位。
TimeSliceOffset_Produce();
// if (outputAgainFlag == 1) {
// outputAgainFlag = 0;
// }
g_otherParameter.Charg_Current = get_CHG_CURR();
g_otherParameter.Discharg_Current = get_DSG_CURR();
// totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
// totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
totalChargCapacity += g_otherParameter.Charg_Current;
totalElectricityConsumption += g_otherParameter.Discharg_Current;
check_sendState();
}
}

View File

@ -1 +1 @@
ENTRY( _start ) __stack_size = 2048; PROVIDE( _stack_size = __stack_size ); MEMORY { FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K } SECTIONS { .init : { _sinit = .; . = ALIGN(4); KEEP(*(SORT_NONE(.init))) . = ALIGN(4); _einit = .; } >FLASH AT>FLASH .vector : { *(.vector); . = ALIGN(64); } >FLASH AT>FLASH .text : { . = ALIGN(4); *(.text) *(.text.*) *(.rodata) *(.rodata*) *(.gnu.linkonce.t.*) . = ALIGN(4); } >FLASH AT>FLASH .fini : { KEEP(*(SORT_NONE(.fini))) . = ALIGN(4); } >FLASH AT>FLASH PROVIDE( _etext = . ); PROVIDE( _eitcm = . ); .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); } >FLASH AT>FLASH .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) PROVIDE_HIDDEN (__init_array_end = .); } >FLASH AT>FLASH .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) PROVIDE_HIDDEN (__fini_array_end = .); } >FLASH AT>FLASH .ctors : { /* gcc uses crtbegin.o to find the start of the constructors, so we make sure it is first. Because this is a wildcard, it doesn't matter if the user does not actually link against crtbegin.o; the linker won't look for a file to match a wildcard. The wildcard also means that it doesn't matter which directory crtbegin.o is in. */ KEEP (*crtbegin.o(.ctors)) KEEP (*crtbegin?.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) } >FLASH AT>FLASH .dtors : { KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin?.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) } >FLASH AT>FLASH .dalign : { . = ALIGN(4); PROVIDE(_data_vma = .); } >RAM AT>FLASH .dlalign : { . = ALIGN(4); PROVIDE(_data_lma = .); } >FLASH AT>FLASH .data : { *(.gnu.linkonce.r.*) *(.data .data.*) *(.gnu.linkonce.d.*) . = ALIGN(8); PROVIDE( __global_pointer$ = . + 0x800 ); *(.sdata .sdata.*) *(.sdata2.*) *(.gnu.linkonce.s.*) . = ALIGN(8); *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*) . = ALIGN(4); PROVIDE( _edata = .); } >RAM AT>FLASH .bss : { . = ALIGN(4); PROVIDE( _sbss = .); *(.sbss*) *(.gnu.linkonce.sb.*) *(.bss*) *(.gnu.linkonce.b.*) *(COMMON*) . = ALIGN(4); PROVIDE( _ebss = .); } >RAM AT>FLASH PROVIDE( _end = _ebss); PROVIDE( end = . ); .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size : { PROVIDE( _heap_end = . ); . = ALIGN(4); PROVIDE(_susrstack = . ); . = . + __stack_size; PROVIDE( _eusrstack = .); } >RAM }
ENTRY( _start ) __stack_size = 2048; PROVIDE( _stack_size = __stack_size ); MEMORY { FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K /* FLASH (rx) : ORIGIN = 0x00003750, LENGTH = 49K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K */ } SECTIONS { .init : { _sinit = .; . = ALIGN(4); KEEP(*(SORT_NONE(.init))) . = ALIGN(4); _einit = .; } >FLASH AT>FLASH .vector : { *(.vector); . = ALIGN(64); } >FLASH AT>FLASH .text : { . = ALIGN(4); *(.text) *(.text.*) *(.rodata) *(.rodata*) *(.gnu.linkonce.t.*) . = ALIGN(4); } >FLASH AT>FLASH .fini : { KEEP(*(SORT_NONE(.fini))) . = ALIGN(4); } >FLASH AT>FLASH PROVIDE( _etext = . ); PROVIDE( _eitcm = . ); .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); } >FLASH AT>FLASH .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) PROVIDE_HIDDEN (__init_array_end = .); } >FLASH AT>FLASH .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) PROVIDE_HIDDEN (__fini_array_end = .); } >FLASH AT>FLASH .ctors : { /* gcc uses crtbegin.o to find the start of the constructors, so we make sure it is first. Because this is a wildcard, it doesn't matter if the user does not actually link against crtbegin.o; the linker won't look for a file to match a wildcard. The wildcard also means that it doesn't matter which directory crtbegin.o is in. */ KEEP (*crtbegin.o(.ctors)) KEEP (*crtbegin?.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) } >FLASH AT>FLASH .dtors : { KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin?.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) } >FLASH AT>FLASH .dalign : { . = ALIGN(4); PROVIDE(_data_vma = .); } >RAM AT>FLASH .dlalign : { . = ALIGN(4); PROVIDE(_data_lma = .); } >FLASH AT>FLASH .data : { *(.gnu.linkonce.r.*) *(.data .data.*) *(.gnu.linkonce.d.*) . = ALIGN(8); PROVIDE( __global_pointer$ = . + 0x800 ); *(.sdata .sdata.*) *(.sdata2.*) *(.gnu.linkonce.s.*) . = ALIGN(8); *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*) . = ALIGN(4); PROVIDE( _edata = .); } >RAM AT>FLASH .bss : { . = ALIGN(4); PROVIDE( _sbss = .); *(.sbss*) *(.gnu.linkonce.sb.*) *(.bss*) *(.gnu.linkonce.b.*) *(COMMON*) . = ALIGN(4); PROVIDE( _ebss = .); } >RAM AT>FLASH PROVIDE( _end = _ebss); PROVIDE( end = . ); .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size : { PROVIDE( _heap_end = . ); . = ALIGN(4); PROVIDE(_susrstack = . ); . = . + __stack_size; PROVIDE( _eusrstack = .); } >RAM }

View File

@ -36,9 +36,12 @@ int main(void)
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
printf("SystemClk:%d\r\n", SystemCoreClock);
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID());
debug("SystemClk:%d\r\n", SystemCoreClock);
debug("ChipID:%08x\r\n", DBGMCU_GetCHIPID());
// printf("SystemClk:%d\r\n", SystemCoreClock);
// printf("ChipID:%08x\r\n", DBGMCU_GetCHIPID());
hardware_Init();
task_Init();
// Delay_Ms(10000);
Init();
}

View File

@ -20,7 +20,7 @@
#define SYSCLK_FREQ_48MHz_HSE 48000000
//#define SYSCLK_FREQ_56MHz_HSE 56000000
//#define SYSCLK_FREQ_72MHz_HSE 72000000
//#define SYSCLK_FREQ_96MHz_HSE 960000+
//#define SYSCLK_FREQ_96MHz_HSE 96000000
//#define SYSCLK_FREQ_48MHz_HSI 48000000
//#define SYSCLK_FREQ_56MHz_HSI 56000000
//#define SYSCLK_FREQ_72MHz_HSI 72000000

View File

@ -26,10 +26,12 @@ App/src/collect_Conversion.o: ../App/src/collect_Conversion.c \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\Hardware\inc/adc.h D:\psx\MPPT\git\Hardware\inc/gpio.h \
D:\psx\MPPT\git\Hardware\inc/adc.h \
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h \
D:\psx\MPPT\git\Hardware\inc/gpio.h D:\psx\MPPT\git\App\inc/parameter.h \
D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/uart_dev.h
D:\psx\MPPT\git\App\inc/collect_Conversion.h:
@ -91,10 +93,16 @@ D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h:
D:\psx\MPPT\git\Hardware\inc/adc.h:
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h:
D:\psx\MPPT\git\Hardware\inc/gpio.h:
D:\psx\MPPT\git\App\inc/parameter.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:

Binary file not shown.

121
obj/App/src/hy_protocol.d Normal file
View File

@ -0,0 +1,121 @@
App/src/hy_protocol.o: ../App/src/hy_protocol.c \
D:\psx\MPPT\git\App\inc/hy_protocol.h D:\psx\MPPT\git\Debug/debug.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h \
D:\psx\MPPT\git\Core/core_riscv.h D:\psx\MPPT\git\User/system_ch32l103.h \
D:\psx\MPPT\git\User/ch32l103_conf.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_adc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_bkp.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_can.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_crc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dbgmcu.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dma.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_exti.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_flash.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_gpio.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_i2c.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_iwdg.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_pwr.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rcc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rtc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_spi.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_tim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_usart.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_wwdg.h \
D:\psx\MPPT\git\User/ch32l103_it.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/inflash.h \
D:\psx\MPPT\git\App\inc/pdebug.h D:\psx\MPPT\git\App\inc/mppt_control.h \
D:\psx\MPPT\git\App\inc/task.h \
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h \
D:\psx\MPPT\git\App\inc/uart_dev.h D:\psx\MPPT\git\Hardware\inc/tim.h \
D:\psx\MPPT\git\App\inc/sl_protocol.h \
D:\psx\MPPT\git\App\inc/parameter.h D:\psx\MPPT\git\App\inc/uart_send.h
D:\psx\MPPT\git\App\inc/hy_protocol.h:
D:\psx\MPPT\git\Debug/debug.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h:
D:\psx\MPPT\git\Core/core_riscv.h:
D:\psx\MPPT\git\User/system_ch32l103.h:
D:\psx\MPPT\git\User/ch32l103_conf.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_adc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_bkp.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_can.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_crc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dbgmcu.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dma.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_exti.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_flash.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_gpio.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_i2c.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_iwdg.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_pwr.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rcc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rtc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_spi.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_tim.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_usart.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_wwdg.h:
D:\psx\MPPT\git\User/ch32l103_it.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:
D:\psx\MPPT\git\App\inc/inflash.h:
D:\psx\MPPT\git\App\inc/pdebug.h:
D:\psx\MPPT\git\App\inc/mppt_control.h:
D:\psx\MPPT\git\App\inc/task.h:
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Hardware\inc/tim.h:
D:\psx\MPPT\git\App\inc/sl_protocol.h:
D:\psx\MPPT\git\App\inc/parameter.h:
D:\psx\MPPT\git\App\inc/uart_send.h:

BIN
obj/App/src/hy_protocol.o Normal file

Binary file not shown.

View File

@ -28,7 +28,7 @@ App/src/inflash.o: ../App/src/inflash.c D:\psx\MPPT\git\App\inc/inflash.h \
D:\psx\MPPT\git\Hardware\inc/flash.h \
D:\psx\MPPT\git\App\inc/sl_protocol.h D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/parameter.h
D:\psx\MPPT\git\App\inc/inflash.h:
@ -97,3 +97,5 @@ D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:
D:\psx\MPPT\git\App\inc/parameter.h:

Binary file not shown.

View File

@ -27,13 +27,15 @@ App/src/mppt_control.o: ../App/src/mppt_control.c \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\App\inc/collect_Conversion.h \
D:\psx\MPPT\git\Hardware\inc/adc.h D:\psx\MPPT\git\Hardware\inc/pwm.h \
D:\psx\MPPT\git\App\inc/inflash.h D:\psx\MPPT\git\Hardware\inc/gpio.h \
D:\psx\MPPT\git\Hardware\inc/adc.h \
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h \
D:\psx\MPPT\git\Hardware\inc/pwm.h D:\psx\MPPT\git\App\inc/inflash.h \
D:\psx\MPPT\git\Hardware\inc/gpio.h \
D:\psx\MPPT\git\App\inc/sl_protocol.h D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/task.h \
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h \
D:\psx\MPPT\git\App\inc/uart_dev.h
D:\psx\MPPT\git\App\inc/uart_dev.h D:\psx\MPPT\git\App\inc/parameter.h
D:\psx\MPPT\git\App\inc/mppt_control.h:
@ -97,6 +99,8 @@ D:\psx\MPPT\git\App\inc/collect_Conversion.h:
D:\psx\MPPT\git\Hardware\inc/adc.h:
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h:
D:\psx\MPPT\git\Hardware\inc/pwm.h:
D:\psx\MPPT\git\App\inc/inflash.h:
@ -116,3 +120,5 @@ D:\psx\MPPT\git\App\inc/task.h:
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\App\inc/parameter.h:

Binary file not shown.

95
obj/App/src/parameter.d Normal file
View File

@ -0,0 +1,95 @@
App/src/parameter.o: ../App/src/parameter.c \
D:\psx\MPPT\git\App\inc/parameter.h D:\psx\MPPT\git\Debug/debug.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h \
D:\psx\MPPT\git\Core/core_riscv.h D:\psx\MPPT\git\User/system_ch32l103.h \
D:\psx\MPPT\git\User/ch32l103_conf.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_adc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_bkp.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_can.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_crc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dbgmcu.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dma.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_exti.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_flash.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_gpio.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_i2c.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_iwdg.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_pwr.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rcc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rtc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_spi.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_tim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_usart.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_wwdg.h \
D:\psx\MPPT\git\User/ch32l103_it.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h
D:\psx\MPPT\git\App\inc/parameter.h:
D:\psx\MPPT\git\Debug/debug.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h:
D:\psx\MPPT\git\Core/core_riscv.h:
D:\psx\MPPT\git\User/system_ch32l103.h:
D:\psx\MPPT\git\User/ch32l103_conf.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_adc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_bkp.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_can.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_crc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dbgmcu.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dma.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_exti.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_flash.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_gpio.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_i2c.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_iwdg.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_pwr.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rcc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rtc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_spi.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_tim.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_usart.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_wwdg.h:
D:\psx\MPPT\git\User/ch32l103_it.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:

BIN
obj/App/src/parameter.o Normal file

Binary file not shown.

View File

@ -32,7 +32,8 @@ App/src/sl_protocol.o: ../App/src/sl_protocol.c \
D:\psx\MPPT\git\App\inc/pdebug.h D:\psx\MPPT\git\App\inc/mppt_control.h \
D:\psx\MPPT\git\App\inc/task.h \
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h \
D:\psx\MPPT\git\App\inc/uart_dev.h D:\psx\MPPT\git\Hardware\inc/tim.h
D:\psx\MPPT\git\App\inc/uart_dev.h D:\psx\MPPT\git\Hardware\inc/tim.h \
D:\psx\MPPT\git\App\inc/parameter.h
D:\psx\MPPT\git\App\inc/sl_protocol.h:
@ -111,3 +112,5 @@ D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Hardware\inc/tim.h:
D:\psx\MPPT\git\App\inc/parameter.h:

Binary file not shown.

View File

@ -6,31 +6,40 @@
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../App/src/collect_Conversion.c \
../App/src/hy_protocol.c \
../App/src/inflash.c \
../App/src/mppt_control.c \
../App/src/parameter.c \
../App/src/sl_protocol.c \
../App/src/task.c \
../App/src/uart_dev.c
../App/src/uart_dev.c \
../App/src/uart_send.c
OBJS += \
./App/src/collect_Conversion.o \
./App/src/hy_protocol.o \
./App/src/inflash.o \
./App/src/mppt_control.o \
./App/src/parameter.o \
./App/src/sl_protocol.o \
./App/src/task.o \
./App/src/uart_dev.o
./App/src/uart_dev.o \
./App/src/uart_send.o
C_DEPS += \
./App/src/collect_Conversion.d \
./App/src/hy_protocol.d \
./App/src/inflash.d \
./App/src/mppt_control.d \
./App/src/parameter.d \
./App/src/sl_protocol.d \
./App/src/task.d \
./App/src/uart_dev.d
./App/src/uart_dev.d \
./App/src/uart_send.d
# Each subdirectory must supply rules for building sources it contributes
App/src/%.o: ../App/src/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -34,7 +34,11 @@ App/src/task.o: ../App/src/task.c D:\psx\MPPT\git\App\inc/task.h \
D:\psx\MPPT\git\Hardware\inc/flash.h \
D:\psx\MPPT\git\App\inc/sl_protocol.h \
D:\psx\MPPT\git\App\inc/mppt_control.h D:\psx\MPPT\git\App\inc/inflash.h \
D:\psx\MPPT\git\App\inc/collect_Conversion.h
D:\psx\MPPT\git\App\inc/collect_Conversion.h \
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h \
D:\psx\MPPT\git\App\inc/parameter.h \
D:\psx\MPPT\git\App\inc/hy_protocol.h \
D:\psx\MPPT\git\App\inc/uart_send.h
D:\psx\MPPT\git\App\inc/task.h:
@ -121,3 +125,11 @@ D:\psx\MPPT\git\App\inc/mppt_control.h:
D:\psx\MPPT\git\App\inc/inflash.h:
D:\psx\MPPT\git\App\inc/collect_Conversion.h:
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h:
D:\psx\MPPT\git\App\inc/parameter.h:
D:\psx\MPPT\git\App\inc/hy_protocol.h:
D:\psx\MPPT\git\App\inc/uart_send.h:

Binary file not shown.

View File

@ -27,7 +27,8 @@ App/src/uart_dev.o: ../App/src/uart_dev.c \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/inflash.h
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/inflash.h \
D:\psx\MPPT\git\App\inc/parameter.h D:\psx\MPPT\git\App\inc/uart_dev.h
D:\psx\MPPT\git\App\inc/uart_dev.h:
@ -92,3 +93,7 @@ D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:
D:\psx\MPPT\git\App\inc/inflash.h:
D:\psx\MPPT\git\App\inc/parameter.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:

Binary file not shown.

96
obj/App/src/uart_send.d Normal file
View File

@ -0,0 +1,96 @@
App/src/uart_send.o: ../App/src/uart_send.c \
D:\psx\MPPT\git\App\inc/uart_send.h D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Debug/debug.h D:\psx\MPPT\git\Peripheral\inc/ch32l103.h \
D:\psx\MPPT\git\Core/core_riscv.h D:\psx\MPPT\git\User/system_ch32l103.h \
D:\psx\MPPT\git\User/ch32l103_conf.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_adc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_bkp.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_can.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_crc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dbgmcu.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dma.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_exti.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_flash.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_gpio.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_i2c.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_iwdg.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_pwr.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rcc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rtc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_spi.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_tim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_usart.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_wwdg.h \
D:\psx\MPPT\git\User/ch32l103_it.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/parameter.h
D:\psx\MPPT\git\App\inc/uart_send.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Debug/debug.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h:
D:\psx\MPPT\git\Core/core_riscv.h:
D:\psx\MPPT\git\User/system_ch32l103.h:
D:\psx\MPPT\git\User/ch32l103_conf.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_adc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_bkp.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_can.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_crc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dbgmcu.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_dma.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_exti.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_flash.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_gpio.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_i2c.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_iwdg.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_pwr.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rcc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_rtc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_spi.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_tim.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_usart.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_wwdg.h:
D:\psx\MPPT\git\User/ch32l103_it.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_misc.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h:
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h:
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:
D:\psx\MPPT\git\App\inc/parameter.h:

BIN
obj/App/src/uart_send.o Normal file

Binary file not shown.

View File

@ -16,6 +16,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
Core/%.o: ../Core/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -16,6 +16,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
Debug/%.o: ../Debug/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -16,6 +16,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
Drivers/RingQueue/%.o: ../Drivers/RingQueue/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -0,0 +1,4 @@
Drivers/RingQueue2/ring_queue2.o: ../Drivers/RingQueue2/ring_queue2.c \
../Drivers/RingQueue2/ring_queue2.h
../Drivers/RingQueue2/ring_queue2.h:

Binary file not shown.

View File

@ -0,0 +1,21 @@
################################################################################
# MRS Version: 1.9.0
# 自动生成的文件。不要编辑!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../Drivers/RingQueue2/ring_queue2.c
OBJS += \
./Drivers/RingQueue2/ring_queue2.o
C_DEPS += \
./Drivers/RingQueue2/ring_queue2.d
# Each subdirectory must supply rules for building sources it contributes
Drivers/RingQueue2/%.o: ../Drivers/RingQueue2/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -16,6 +16,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
Drivers/TimeSliceOffset/%.o: ../Drivers/TimeSliceOffset/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -30,7 +30,8 @@ Hardware/src/gpio.o: ../Hardware/src/gpio.c \
D:\psx\MPPT\git\Drivers\TimeSliceOffset/timeSliceOffset.h \
D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/uart_dev.h
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\App\inc/parameter.h
D:\psx\MPPT\git\Hardware\inc/gpio.h:
@ -101,3 +102,5 @@ D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\Hardware\inc/rs485.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\App\inc/parameter.h:

Binary file not shown.

View File

@ -27,7 +27,9 @@ Hardware/src/rs485.o: ../Hardware/src/rs485.c \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_lptim.h \
D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h \
D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\App\inc/pdebug.h D:\psx\MPPT\git\App\inc/uart_dev.h \
D:\psx\MPPT\git\App\inc/uart_send.h
D:\psx\MPPT\git\Hardware\inc/rs485.h:
@ -90,3 +92,9 @@ D:\psx\MPPT\git\Peripheral\inc/ch32l103_opa.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h:
D:\psx\MPPT\git\App\inc/pdebug.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\App\inc/uart_send.h:

Binary file not shown.

View File

@ -31,6 +31,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
Hardware/src/%.o: ../Hardware/src/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -31,7 +31,11 @@ Hardware/src/tim.o: ../Hardware/src/tim.c \
D:\psx\MPPT\git\Drivers\RingQueue/ring_queue.h \
D:\psx\MPPT\git\Hardware\inc/rs485.h D:\psx\MPPT\git\Hardware\inc/pwm.h \
D:\psx\MPPT\git\App\inc/mppt_control.h D:\psx\MPPT\git\App\inc/task.h \
D:\psx\MPPT\git\App\inc/uart_dev.h
D:\psx\MPPT\git\App\inc/uart_dev.h D:\psx\MPPT\git\App\inc/parameter.h \
D:\psx\MPPT\git\App\inc/collect_Conversion.h \
D:\psx\MPPT\git\Hardware\inc/adc.h \
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h \
D:\psx\MPPT\git\App\inc/uart_send.h
D:\psx\MPPT\git\Hardware\inc/tim.h:
@ -106,3 +110,13 @@ D:\psx\MPPT\git\App\inc/mppt_control.h:
D:\psx\MPPT\git\App\inc/task.h:
D:\psx\MPPT\git\App\inc/uart_dev.h:
D:\psx\MPPT\git\App\inc/parameter.h:
D:\psx\MPPT\git\App\inc/collect_Conversion.h:
D:\psx\MPPT\git\Hardware\inc/adc.h:
D:\psx\MPPT\git\Drivers\RingQueue2/ring_queue2.h:
D:\psx\MPPT\git\App\inc/uart_send.h:

Binary file not shown.

View File

@ -76,6 +76,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
Peripheral/src/%.o: ../Peripheral/src/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

Binary file not shown.

View File

@ -22,6 +22,6 @@ C_DEPS += \
# Each subdirectory must supply rules for building sources it contributes
User/%.o: ../User/%.c
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"D:\psx\MPPT\git\Debug" -I"D:\psx\MPPT\git\Core" -I"D:\psx\MPPT\git\User" -I"D:\psx\MPPT\git\Peripheral\inc" -I"D:\psx\MPPT\git\App\inc" -I"D:\psx\MPPT\git\Hardware\inc" -I"D:\psx\MPPT\git\Drivers\TimeSliceOffset" -I"D:\psx\MPPT\git\Drivers\RingQueue" -I"D:\psx\MPPT\git\Drivers\RingQueue2" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@ @

View File

@ -14,6 +14,7 @@ RM := rm -rf
-include Peripheral/src/subdir.mk
-include Hardware/src/subdir.mk
-include Drivers/TimeSliceOffset/subdir.mk
-include Drivers/RingQueue2/subdir.mk
-include Drivers/RingQueue/subdir.mk
-include Debug/subdir.mk
-include Core/subdir.mk

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@ App/src \
Core \
Debug \
Drivers/RingQueue \
Drivers/RingQueue2 \
Drivers/TimeSliceOffset \
Hardware/src \
Peripheral/src \