Compare commits

...

2 Commits

Author SHA1 Message Date
起床就犯困 20d2cfe02f 修改部分全局变量的存放,同时启用hy和sl协议(未更改完) 2024-10-18 16:55:39 +08:00
起床就犯困 a3d0cc2c68 增加一个环形buff 2024-10-14 10:50:02 +08:00
58 changed files with 18487 additions and 4701 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"/>
<storageModule moduleId="refreshScope"/>
</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="1033085767641952736" 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

@ -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_ */

View File

@ -52,19 +52,17 @@ typedef enum
}HY_AnalyzeDataLen;
/* 执行状态 */
typedef enum
{
HY_success = 0xFF, /* 成功 */
HY_fail = 0x00, /* 失败 */
}HY_state;
/* 指定对齐方式为1字节 */
#pragma pack(push,1)
/* 默认参数 */
typedef struct _HY_default_Value{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t end_Flag; /* 结束标志 */
}HY_default_Value;
extern HY_default_Value HY_defaultValue;
/* 默认参数 */
/* 通用参数 */
typedef struct _HY_Recv_pack{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
@ -116,6 +114,7 @@ typedef struct _HY_batteryStatusResponse{
uint8_t end_Flag; /* 结束标志 */
}HY_batteryStatusResponse;
#define HY_batteryStatusResponse_PACK_SIZE (sizeof(HY_batteryStatusResponse))
#define HY_batteryStatusResponse_dataLen 38
/* 电量统计数据报查询 */
typedef struct _HY_electricityStatisticsQuery{
@ -130,7 +129,7 @@ typedef struct _HY_electricityStatisticsQuery{
}HY_electricityStatisticsQuery;
#define HY_electricityStatisticsQuery_PACK_SIZE (sizeof(HY_electricityStatisticsQuery))
/* 电池状态数据报响应 */
/* 电量统计数据报响应 */
typedef struct _HY_electricityStatisticsResponse{
uint8_t start_Flag; /* 起始标志 */
uint8_t hardwareID[6]; /* 硬件ID高字节在前低字节在后 */
@ -145,6 +144,7 @@ typedef struct _HY_electricityStatisticsResponse{
uint8_t end_Flag; /* 结束标志 */
}HY_electricityStatisticsResponse;
#define HY_electricityStatisticsResponse_PACK_SIZE (sizeof(HY_electricityStatisticsResponse))
#define HY_electricityStatisticsResponse_dataLen 16
/* 传感器号码配置 */
typedef struct _HY_sensorNumberConfig{
@ -174,6 +174,7 @@ typedef struct _HY_sensorNumberConfigurationResponse{
uint8_t end_Flag; /* 结束标志 */
}HY_sensorNumberConfigurationResponse;
#define HY_sensorNumberConfigurationResponse_PACK_SIZE (sizeof(HY_sensorNumberConfigurationResponse))
#define HY_sensorNumberConfigurationResponse_dataLen 5
/* 传感器号码查询 */
typedef struct _HY_sensorNumberInquiryQuery{
@ -202,6 +203,7 @@ typedef struct _HY_sensorNumberInquiryResponse{
uint8_t end_Flag; /* 结束标志 */
}HY_sensorNumberInquiryResponse;
#define HY_sensorNumberInquiryResponse_PACK_SIZE (sizeof(HY_sensorNumberInquiryResponse))
#define HY_sensorNumberInquiryResponse_dataLen 14
/* 充电阈值电压配置 */
typedef struct _HY_chargingThresholdVoltageConfig{
@ -287,6 +289,7 @@ typedef struct _HY_resetInstructionResponse{
uint8_t end_Flag; /* 结束标志 */
}HY_resetInstructionResponse;
#define HY_resetInstructionResponse_PACK_SIZE (sizeof(HY_resetInstructionResponse))
#define HY_resetInstructionResponse_dataLen 5
/* 充电控制配置 */
typedef struct _HY_chargingControlConfig{
@ -316,6 +319,7 @@ typedef struct _HY_chargingControlConfigResponse{
uint8_t end_Flag; /* 结束标志 */
}HY_chargingControlConfigResponse;
#define HY_chargingControlConfigResponse_PACK_SIZE (sizeof(HY_chargingControlConfigResponse))
#define HY_chargingControlConfigResponse_dataLen 5
/* 充电控制查询 */
typedef struct _HY_QueryChargingControl{
@ -554,7 +558,6 @@ typedef struct _HY_checkMotherboardTemperatureResponse{
}HY_checkMotherboardTemperatureResponse;
#define HY_checkMotherboardTemperatureResponse_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureResponse))
/* 恢复默认的对齐设置 */
#pragma pack(pop)

View File

@ -9,6 +9,7 @@
#define APP_INC_INFLASH_H_
#include "debug.h"
#include "math.h"
#pragma pack(push,1)
@ -27,63 +28,93 @@ typedef struct _recv_config_info{
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_t stopSolarOpenCircuitV[2]; /* 太阳能板开路电压高于该电压停止充电 (V) */
uint8_t constantVoltageChargeV[2]; /* 恒压充电时的输出电压 (V) */
uint8_t FloatV[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]; /* 回路阻抗大小 (mΩ) */
uint8_t loopImpedance[2]; /* 回路阻抗大小 (Ω) */
uint8_t totalElectricityConsumption[2]; /* 总电量消耗 */
uint8_t totalChargCapacity[2]; /* 总充电电量 */
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{
/* SL */
uint8_t address[7]; /* 地址 */
uint8_t Access_Node_Type[2]; /* 接入节点类型 */
uint8_t Communication_Methods[2]; /* 通信方式 */
uint8_t gw485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
uint8_t bat485_Baud[4]; /* 串口波特率 */
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)*/
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 FloatV; /* 浮充电压 */
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
uint16_t registerRefreshTime; /* 寄存器数据刷新时间 */
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
uint16_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
uint16_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
uint16_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
uint16_t loopImpedance; /* 回路阻抗大小 (mΩ) */
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 sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 */
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该段时间中再次出现过载,则关闭输出 */
uint16_t eLAgainTime; /* 出现过载过载保护后,该段时间后,再次尝试输出 */
uint16_t crc; /* 校验 */
}config_info;
#define CONFIG_INFO_SIZE (sizeof(config_info))
#pragma pack(pop)
#define CONFIG_SAVE_ADDR_BEGIN (0x00)
#define CONFIG_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)
void save_config_info(config_info *save_config_info);
void save_backups_config_info(config_info *save_config_info);
void read_config_info(config_info *output_config_info);
void checkFlashContent(void);
void saveLoopImpedance(float_t *loopImpedance);
void saveTotalPower(float_t *totalElectricityConsumption, float_t *totalChargCapacity);
void config_info_start(void);
void read_and_process_config_data(void);
#endif /* APP_INC_INFLASH_H_ */

View File

@ -11,5 +11,7 @@
#include "debug.h"
#include <math.h>
extern void MpptContorl(void);
#endif /* APP_INC_MPPT_CONTROL_H_ */

View File

@ -25,14 +25,13 @@ typedef struct _Mppt_controlparameter{
float_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 (°C) */
float_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
float_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
float_t dutyRatio; /* 占空比 */
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
uint16_t excessiveLoadFlagTime; /* 出现过载后在该间隔时间中多次2次出现过载则关闭输出 (S) */
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
} Mppt_controlparameter;
extern Mppt_controlparameter g_controlParameter;
@ -42,27 +41,34 @@ typedef struct _Mppt_otherParameter{
uint16_t Access_Node_Type; /* 接入节点类型 */
uint16_t Communication_Methods; /* 通信方式 */
uint16_t Registration_Status; /* 注册状态 */
uint32_t gw485_Baud; /* 串口波特率 */
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
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 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; /* 总电量消耗 */
float_t totalChargCapacity; /* 总充电电量 */
float_t totalElectricityConsumption; /* 总电量消耗(W*H) */
float_t totalChargCapacity; /* 总充电电量(W*H) */
float_t SOC; /* 剩余电量 */
uint16_t chargMos_State; /* 充电开关状态 */
@ -71,7 +77,15 @@ typedef struct _Mppt_otherParameter{
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; /* 读写的寄存器的最大起始位置,由设备决定 */
}Mppt_otherParameter;
extern Mppt_otherParameter g_otherParameter;

View File

@ -12,6 +12,12 @@
#include "uart_dev.h"
#include "math.h"
#define buffLen 100
#define configBuffLen 100
extern uint8_t rs485_buff[buffLen];
extern uint8_t config_buff[configBuffLen];
/* 功能码 */
typedef enum
{
@ -74,11 +80,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))
@ -223,7 +227,7 @@ extern default_Value defaultValue;
#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,9 +13,77 @@
#include "uart_dev.h"
#include "math.h"
void Init();
/* 控制运行指示灯和喂狗 */
#define WdiRunled_reloadVal 1000 /* 任务执行间隔 */
#define WdiRunled_offset 0 /* 任务执行偏移量 */
#define wdi_RESET (60 * 60 * 24) /* 一天复位一次 */
extern STR_TimeSliceOffset m_WdiRunled;
extern void Task_WdiRunled(void);
/* 刷新寄存器中的数据 */
#define refreshRegister_reloadVal 1000 /* 任务执行间隔 */
#define refreshRegister_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_refreshRegister;
extern void Task_refreshRegister(void);
/* 回路阻抗检测 */
#define impedanceCalculation_reloadVal 200 /* 任务执行间隔 */
#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 startMpptControl_reloadVal 1000 /* 任务执行间隔 */
#define startMpptControl_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_startMpptControl;
extern void Task_startMpptControl(void);
/* 根据寄存器数据完成一些判断 */
#define dataJudgment_reloadVal 1000 /* 任务执行间隔 */
#define dataJudgment_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_dataJudgment;
extern void Task_dataJudgment(void);
/* 串口数据解析和处理 */
#define usartSL_reloadVal 100 /* 任务执行间隔 */
#define usartSL_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_usart;
extern void Task_usartSL(void);
extern void Task_usartHY(void);
/* 广播回应 */
#define recvbroadcast_reloadVal 3000 /* 任务执行间隔 */
#define recvbroadcast_offset 0 /* 任务执行偏移量 */
extern uint8_t recvbroadcast_flag; /* 是否需要再次发送标志 */
extern device_handle g_recvBroadcastDevice; /* 串口句柄 */
extern STR_TimeSliceOffset g_recvbroadcast;
extern void Task_recvbroadcast(void);
/* 再次注册延时 */
#define sensorEnableBroadcast_reloadVal 1000 /* 任务执行间隔 */
#define sensorEnableBroadcast_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_sensorEnableBroadcast;
extern void Task_sensorEnableBroadcast(void);
#endif /* APP_INC_TASK_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,63 @@ 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));
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
//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 * 0.005 / 2));
///* 光伏1开路输出电压比例 */
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;
/* 系统电源电压比例 */
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 +415,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;
//}

View File

@ -13,16 +13,8 @@
#include <stdlib.h>
#include "task.h"
#include "tim.h"
HY_default_Value HY_defaultValue = {0x68\
, 0x48, 0x59, 0x30, 0x30, 0x30, 0x31\
, 0x00, 0x00, 0x00, 0x01\
, 0x16};
/* 读取串口数据时用该数组解析 */
static uint8_t rs485_buff[100]={0x00};
#include "sl_protocol.h"
#include "parameter.h"
/* 电池状态数据报 */
static void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t MsgLen);
@ -139,46 +131,76 @@ uint8_t HY_CheckFunc(uint8_t *arr_buff, uint8_t len)
}
/**
* @brief
* @brief ID
* @param address
* @retval 1
* 0
*/
static int HY_matchhardwareID(u_int8_t hardwareID[6])
static int HY_matchHardwareID(u_int8_t hardwareID[6])
{
//// if (!strcmp(address, g_slConfigInfo.address)) {
//// log_info("Match_address fail \r\n");
//// return 1;
//// }
// if ((hardwareID[0] == g_slConfigInfo.address[0]) && \
// (hardwareID[1] == g_slConfigInfo.address[1]) && \
// (hardwareID[2] == g_slConfigInfo.address[2]) && \
// (hardwareID[3] == g_slConfigInfo.address[3]) && \
// (hardwareID[4] == g_slConfigInfo.address[4]) && \
// (hardwareID[5] == g_slConfigInfo.address[5]) && \
// (hardwareID[6] == g_slConfigInfo.address[6])) {
// log_info("Match_address success \r\n");
// return 1;
// }
if ((hardwareID[0] == g_otherParameter.hardwareID[0]) && \
(hardwareID[1] == g_otherParameter.hardwareID[1]) && \
(hardwareID[2] == g_otherParameter.hardwareID[2]) && \
(hardwareID[3] == g_otherParameter.hardwareID[3]) && \
(hardwareID[4] == g_otherParameter.hardwareID[4]) && \
(hardwareID[5] == g_otherParameter.hardwareID[5])) {
log_info("Match_hardwareIDHY success \r\n");
return 1;
}
return 0;
}
/**
* @brief 广
* @brief 广ID
* @param address
* @retval 1
* 0
*/
static int Match_Broadcastaddress(u_int8_t address[6])
static int Match_BroadcastHardwareID(u_int8_t hardwareID[6])
{
if (address[0] == 0xFF && \
address[1] == 0xFF && \
address[2] == 0xFF && \
address[3] == 0xFF && \
address[4] == 0xFF && \
address[5] == 0xFF && \
address[6] == 0xFF) {
log_info("Match_Broadcastaddress success\r\n");
if (hardwareID[0] == 0xFF && \
hardwareID[1] == 0xFF && \
hardwareID[2] == 0xFF && \
hardwareID[3] == 0xFF && \
hardwareID[4] == 0xFF && \
hardwareID[5] == 0xFF) {
log_info("Match_BroadcastHardwareID success\r\n");
return 1;
}
return 0;
}
/**
* @brief ID
* @param address
* @retval 1
* 0
*/
static int HY_matchCommunicationID(u_int8_t communicationID[4])
{
if ((communicationID[0] == g_otherParameter.communicationID[0]) && \
(communicationID[1] == g_otherParameter.communicationID[1]) && \
(communicationID[2] == g_otherParameter.communicationID[2]) && \
(communicationID[3] == g_otherParameter.communicationID[3])) {
log_info("Match_hardwareIDHY success \r\n");
return 1;
}
return 0;
}
/**
* @brief 广ID
* @param address
* @retval 1
* 0
*/
static int Match_BroadcastCommunicationID(u_int8_t communicationID[4])
{
if (communicationID[0] == 0xFF && \
communicationID[1] == 0xFF && \
communicationID[2] == 0xFF && \
communicationID[3] == 0xFF) {
log_info("Match_BroadcastHardwareID success\r\n");
return 1;
}
return 0;
@ -196,6 +218,12 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
uint32_t offset = 0;
uint32_t len = 0;
uint8_t flag_run = 0;
/* 接收到的硬件ID种类
* 0x01 广ID
* 0x02 ID
**/
uint8_t hardwordIDType = 0;
char c = 0;
HY_Recv_pack *pack = (HY_Recv_pack *)buff;
@ -212,7 +240,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
/* 匹配起始标志位 */
if (offset == HY_analyzeStartFlag || (flag_run > 0)) {
if (pack->start_Flag != HY_defaultValue.start_Flag) {
if (pack->start_Flag != g_otherParameter.startFlagHY) {
memcpy(buff, buff+1, offset-1);
offset--;
continue;
@ -221,7 +249,16 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
/* 匹配硬件ID */
if (offset == HY_analyzeHardwareID || (flag_run > 1)) {
if (HY_matchhardwareID(pack->hardwareID) || Match_Broadcastaddress(pack->hardwareID)) {
if (HY_matchHardwareID(pack->hardwareID)) {
hardwordIDType = 0x02;
}
else if (Match_BroadcastHardwareID(pack->hardwareID)) {
hardwordIDType = 0x01;
}
else {
hardwordIDType = 0x00;
if (flag_run < 1) {
flag_run = 1;
}
@ -231,11 +268,121 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
}
}
/* 匹配通信ID */
if (offset == HY_analyzeCommunicationID || (flag_run > 2)) {
if (HY_matchCommunicationID(pack->hardwareID) || Match_BroadcastCommunicationID(pack->hardwareID)) {
if (flag_run < 2) {
flag_run = 2;
}
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
/* 匹配 */
if (offset == HY_analyzeControlWord || (flag_run > 3)) {
if (pack->controlWord == HY_batteryStatus && hardwordIDType == 0x02) {
len = HY_batteryStatusQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_electricityStatistics && hardwordIDType == 0x02) {
len = HY_electricityStatisticsQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_sensorNumberConfiguration && hardwordIDType == 0x02) {
len = HY_sensorNumberConfiguration_PACK_SIZE;
}
else if (pack->controlWord == HY_sensorNumberInquiry && hardwordIDType == 0x01) {
len = HY_sensorNumberInquiryQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_chargingThresholdVoltageConfiguration && hardwordIDType == 0x02) {
len = HY_chargingThresholdVoltageConfig_PACK_SIZE;
}
else if (pack->controlWord == HY_chargingRangeVoltageQuery && hardwordIDType == 0x02) {
len = HY_chargRangeVoltageQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_resetInstruction && hardwordIDType == 0x02) {
len = HY_resetInstructionQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_chargingControlConfiguration && hardwordIDType == 0x02) {
len = HY_chargingControlConfig_PACK_SIZE;
}
else if (pack->controlWord == HY_chargingControlQuery && hardwordIDType == 0x02) {
len = HY_QueryChargingControl_PACK_SIZE;
}
else if (pack->controlWord == HY_configureProtocolType && hardwordIDType == 0x02) {
len = HY_configProtocolType_PACK_SIZE;
}
else if (pack->controlWord == HY_queryControlBoxConfiguration && hardwordIDType == 0x02) {
len = HY_queryControlBoxConfigurationQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_querySoftwareVersion && hardwordIDType == 0x02) {
len = HY_SoftwareVersionQuery_PACK_SIZE;
}
else if (pack->controlWord == HY_enterConfigurationMode && hardwordIDType == 0x02) {
len = HY_enterConfigMode_PACK_SIZE;
}
else if (pack->controlWord == HY_configureHardwareID && hardwordIDType == 0x02) {
len = HY_configHardwareID_PACK_SIZE;
}
// else if (pack->controlWord == HY_hardwareID_communicationIDQuery) {
// len = HY_modifyCommunicationIDChange_PACK_SIZE;
// }
else if (pack->controlWord == HY_modifyCommunicationID && hardwordIDType == 0x02) {
len = HY_modifyCommunicationIDChange_PACK_SIZE;
}
else if (pack->controlWord == HY_checkMotherboardTemperature && hardwordIDType == 0x02) {
len = HY_checkMotherboardTemperatureQuery_PACK_SIZE;
}
else {
if (flag_run < 3) {
flag_run = 3;
}
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
/* 匹配通信ID */
if (offset == HY_analyzeDataLen || (flag_run > 4)) {
if (len != ((pack->dataLen[0] << 8 + pack->dataLen[1]) + 16)) {
if (flag_run < 4) {
flag_run = 4;
}
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
if (offset == len) {
if (buff[len - 2] != HY_CheckFunc(buff, len - 2)
&& buff[len - 1] != g_otherParameter.endFlagHY) {
if (flag_run < 5) {
flag_run = 5;
}
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
return len;
}
}
return 0;
}
@ -263,11 +410,9 @@ static void HY_FRT_MsgHandler(device_handle device, uint8_t *pMsg, uint32_t MsgL
*/
void HY_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));
memset(rs485_buff, 0, sizeof(rs485_buff));
int ret = HY_uart_read_climate_pack(device, rs485_buff, sizeof(rs485_buff));
if(ret > 0){
@ -276,39 +421,236 @@ void HY_read_and_process_uart_data(device_handle device)
}
}
/* 电池状态数据报 */
void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t MsgLen)
{
HY_batteryStatusResponse pack;
pack.start_Flag = g_otherParameter.startFlagHY;
pack.hardwareID[0] = g_otherParameter.hardwareID[0];
pack.hardwareID[1] = g_otherParameter.hardwareID[1];
pack.hardwareID[2] = g_otherParameter.hardwareID[2];
pack.hardwareID[3] = g_otherParameter.hardwareID[3];
pack.hardwareID[4] = g_otherParameter.hardwareID[4];
pack.hardwareID[5] = g_otherParameter.hardwareID[5];
pack.communicationID[0] = g_otherParameter.communicationID[0];
pack.communicationID[1] = g_otherParameter.communicationID[1];
pack.communicationID[2] = g_otherParameter.communicationID[2];
pack.communicationID[3] = g_otherParameter.communicationID[3];
pack.controlWord = HY_batteryStatus;
pack.dataLen[0] = HY_batteryStatusResponse_dataLen >> 8;
pack.dataLen[1] = HY_batteryStatusResponse_dataLen;
pack.batteryVoltage = g_otherParameter.Battery_Voltage;
pack.dischargCurrent = g_otherParameter.Discharg_Current;
pack.chargCurrent1 = g_otherParameter.Charg_Current;
pack.SOC = g_otherParameter.SOC;
pack.openCircuitVoltage1 = g_otherParameter.Solar_In_Circuit_Voltage;
if (g_controlParameter.dutyRatio) {
pack.chargSwitchStatus1 = 1;
} else {
pack.chargSwitchStatus1 = 0;
}
pack.chargCurrent2 = g_otherParameter.Charg_Current;
pack.openCircuitVoltage1 = g_otherParameter.Solar_In_Circuit_Voltage;
if (g_controlParameter.dutyRatio) {
pack.chargSwitchStatus2 = 1;
} else {
pack.chargSwitchStatus2 = 0;
}
pack.Mos_Temperature = g_otherParameter.HighSideMos_Temperature;
HY_batteryStatusQuery *Tpack = (HY_batteryStatusQuery *)pMsg;
pack.frameNumber = Tpack->frameNumber;
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_batteryStatusResponse_PACK_SIZE - 2);
pack.end_Flag = g_otherParameter.endFlagHY;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/* 电量统计数据报 */
void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint32_t MsgLen)
{
HY_electricityStatisticsResponse pack;
pack.start_Flag = g_otherParameter.startFlagHY;
pack.hardwareID[0] = g_otherParameter.hardwareID[0];
pack.hardwareID[1] = g_otherParameter.hardwareID[1];
pack.hardwareID[2] = g_otherParameter.hardwareID[2];
pack.hardwareID[3] = g_otherParameter.hardwareID[3];
pack.hardwareID[4] = g_otherParameter.hardwareID[4];
pack.hardwareID[5] = g_otherParameter.hardwareID[5];
pack.communicationID[0] = g_otherParameter.communicationID[0];
pack.communicationID[1] = g_otherParameter.communicationID[1];
pack.communicationID[2] = g_otherParameter.communicationID[2];
pack.communicationID[3] = g_otherParameter.communicationID[3];
pack.controlWord = HY_electricityStatistics;
pack.dataLen[0] = HY_electricityStatisticsResponse_dataLen >> 8;
pack.dataLen[1] = HY_electricityStatisticsResponse_dataLen;
pack.statisticalDuration = 0;
pack.totalChargCapacity = g_otherParameter.totalChargCapacity;
pack.totalElectricityConsumption = g_otherParameter.totalElectricityConsumption;
HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg;
pack.frameNumber = Tpack->frameNumber;
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_electricityStatisticsResponse_PACK_SIZE - 2);
pack.end_Flag = g_otherParameter.endFlagHY;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/* 传感器号码配置 */
void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg, uint32_t MsgLen)
{
HY_sensorNumberConfigurationResponse pack;
HY_sensorNumberConfig *Tpack = (HY_sensorNumberConfig *)pMsg;
if (HY_matchHardwareID(Tpack->newHardwareID)) {
g_otherParameter.communicationID[0] = Tpack->newCommunicationID[0];
g_otherParameter.communicationID[1] = Tpack->newCommunicationID[1];
g_otherParameter.communicationID[2] = Tpack->newCommunicationID[2];
g_otherParameter.communicationID[3] = Tpack->newCommunicationID[3];
pack.state = HY_success;
}
else {
pack.state = HY_fail;
}
pack.start_Flag = g_otherParameter.startFlagHY;
pack.hardwareID[0] = g_otherParameter.hardwareID[0];
pack.hardwareID[1] = g_otherParameter.hardwareID[1];
pack.hardwareID[2] = g_otherParameter.hardwareID[2];
pack.hardwareID[3] = g_otherParameter.hardwareID[3];
pack.hardwareID[4] = g_otherParameter.hardwareID[4];
pack.hardwareID[5] = g_otherParameter.hardwareID[5];
pack.communicationID[0] = g_otherParameter.communicationID[0];
pack.communicationID[1] = g_otherParameter.communicationID[1];
pack.communicationID[2] = g_otherParameter.communicationID[2];
pack.communicationID[3] = g_otherParameter.communicationID[3];
pack.controlWord = Tpack->controlWord;
pack.dataLen[0] = HY_sensorNumberConfigurationResponse_dataLen >> 8;
pack.dataLen[1] = HY_sensorNumberConfigurationResponse_dataLen;
pack.frameNumber = Tpack->frameNumber;
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfiguration_PACK_SIZE - 2);
pack.end_Flag = g_otherParameter.endFlagHY;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/* 传感器号码查询 */
void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32_t MsgLen)
{
HY_sensorNumberInquiryQuery *Tpack = (HY_sensorNumberInquiryQuery *)pMsg;
HY_sensorNumberInquiryResponse pack;
pack.start_Flag = g_otherParameter.startFlagHY;
pack.hardwareID[0] = g_otherParameter.hardwareID[0];
pack.hardwareID[1] = g_otherParameter.hardwareID[1];
pack.hardwareID[2] = g_otherParameter.hardwareID[2];
pack.hardwareID[3] = g_otherParameter.hardwareID[3];
pack.hardwareID[4] = g_otherParameter.hardwareID[4];
pack.hardwareID[5] = g_otherParameter.hardwareID[5];
pack.communicationID[0] = g_otherParameter.communicationID[0];
pack.communicationID[1] = g_otherParameter.communicationID[1];
pack.communicationID[2] = g_otherParameter.communicationID[2];
pack.communicationID[3] = g_otherParameter.communicationID[3];
pack.controlWord = Tpack->controlWord;
pack.dataLen[0] = HY_sensorNumberInquiryResponse_dataLen >> 8;
pack.dataLen[1] = HY_sensorNumberInquiryResponse_dataLen;
pack.hardwareIDR[0] = g_otherParameter.hardwareID[0];
pack.hardwareIDR[1] = g_otherParameter.hardwareID[1];
pack.hardwareIDR[2] = g_otherParameter.hardwareID[2];
pack.hardwareIDR[3] = g_otherParameter.hardwareID[3];
pack.hardwareIDR[4] = g_otherParameter.hardwareID[4];
pack.hardwareIDR[5] = g_otherParameter.hardwareID[5];
pack.communicationIDR[0] = g_otherParameter.communicationID[0];
pack.communicationIDR[1] = g_otherParameter.communicationID[1];
pack.communicationIDR[2] = g_otherParameter.communicationID[2];
pack.communicationIDR[3] = g_otherParameter.communicationID[3];
pack.frameNumber = Tpack->frameNumber;
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfiguration_PACK_SIZE - 2);
pack.end_Flag = g_otherParameter.endFlagHY;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/* 充电阈值电压配置 */
@ -326,14 +668,98 @@ void HY_MsgProcFunc_chargingRangeVoltageQuery(device_handle device, void *pMsg,
/* 复位指令 */
void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t MsgLen)
{
HY_resetInstructionQuery *Tpack = (HY_resetInstructionQuery *)pMsg;
HY_resetInstructionResponse pack;
pack.start_Flag = g_otherParameter.startFlagHY;
pack.hardwareID[0] = g_otherParameter.hardwareID[0];
pack.hardwareID[1] = g_otherParameter.hardwareID[1];
pack.hardwareID[2] = g_otherParameter.hardwareID[2];
pack.hardwareID[3] = g_otherParameter.hardwareID[3];
pack.hardwareID[4] = g_otherParameter.hardwareID[4];
pack.hardwareID[5] = g_otherParameter.hardwareID[5];
pack.communicationID[0] = g_otherParameter.communicationID[0];
pack.communicationID[1] = g_otherParameter.communicationID[1];
pack.communicationID[2] = g_otherParameter.communicationID[2];
pack.communicationID[3] = g_otherParameter.communicationID[3];
pack.controlWord = Tpack->controlWord;
pack.dataLen[0] = HY_resetInstructionResponse_dataLen >> 8;
pack.dataLen[1] = HY_resetInstructionResponse_dataLen;
pack.state = HY_success;
pack.frameNumber = Tpack->frameNumber;
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_resetInstructionResponse_PACK_SIZE - 2);
pack.end_Flag = g_otherParameter.endFlagHY;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/* 充电控制配置 */
void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMsg, uint32_t MsgLen)
{
// HY_chargingControlConfig *Tpack = (HY_chargingControlConfig *)pMsg;
//
// HY_chargingControlConfigResponse pack;
//
// pack.start_Flag = g_otherParameter.startFlagHY;
//
// pack.hardwareID[0] = g_otherParameter.hardwareID[0];
// pack.hardwareID[1] = g_otherParameter.hardwareID[1];
// pack.hardwareID[2] = g_otherParameter.hardwareID[2];
// pack.hardwareID[3] = g_otherParameter.hardwareID[3];
// pack.hardwareID[4] = g_otherParameter.hardwareID[4];
// pack.hardwareID[5] = g_otherParameter.hardwareID[5];
//
// pack.communicationID[0] = g_otherParameter.communicationID[0];
// pack.communicationID[1] = g_otherParameter.communicationID[1];
// pack.communicationID[2] = g_otherParameter.communicationID[2];
// pack.communicationID[3] = g_otherParameter.communicationID[3];
//
// pack.controlWord = Tpack->controlWord;
//
// pack.dataLen[0] = HY_chargingControlConfigResponse_dataLen >> 8;
// pack.dataLen[1] = HY_chargingControlConfigResponse_dataLen;
//
// pack.state = HY_success;
//
// pack.frameNumber = Tpack->frameNumber;
//
// pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_chargingControlConfigResponse_PACK_SIZE - 2);
// pack.end_Flag = g_otherParameter.endFlagHY;
//
// while (1) {
// Delay_Ms(randomDelay());
// if (!Check_485_bus_busy(device)) {
// uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
//
// if (device == g_bat485_uart3_handle) {
// USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
// } else {
// USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
// }
// break;
// }
// }
}
/* 充电控制查询 */

View File

@ -8,6 +8,335 @@
#include "inflash.h"
#include "flash.h"
#include "sl_protocol.h"
#include "parameter.h"
#include <string.h>
/**
* @brief
* @param
* @retval
*/
static 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
* @param save_config_info
* @retval
*/
void save_config_info(config_info *save_config_info)
{
SPI_Flash_Write((uint8_t *)save_config_info, CONFIG_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
}
/**
* @brief
* @param save_config_info
* @retval
*/
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 output_config_info中
*/
void read_config_info(config_info *output_config_info)
{
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);
if (temp_configInfo.crc == configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2)) {
return;
}
read_backups_config_info(&temp_configInfo);
if (temp_configInfo.crc == configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2)) {
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 = 115200,
.bat485_Baud = 115200,
.hardwareID = {0x48, 0x59, 0x30, 0x30, 0x30, 0x31},
.communicationID = {0x00, 0x00, 0x00, 0x01},
.protocolType = 0x01,
.CommunicationProtocolType = 0x00,
.onlyPower = 0x01,
.constantVoltageV = 14.2,
.floatI = 0.02,
.startSolarOpenCircuitV = 17,
.stopSolarOpenCircuitV = 15,
.constantVoltageChargeV = 14.4,
.FloatChargeV = 14.2,
.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.stopSolarOpenCircuitV = 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;
strlcpy(g_otherParameter.address, temp_configInfo.address, 7);
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);
strlcpy(g_otherParameter.communicationID, temp_configInfo.communicationID, 4);
g_otherParameter.CommunicationProtocolType = temp_configInfo.CommunicationProtocolType;
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, "SV01_24101501", 13);
strlcpy(g_otherParameter.startFlagSL, "SL", 2);
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 = 5;
g_otherParameter.RegisterStartAddressMax = 0x150;
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 (temp_configInfo.protocolType == 0x01) {
g_otherParameter.gw485_Baud = 9600;
} else if (temp_configInfo.protocolType == 0x02) {
g_otherParameter.gw485_Baud = 115200;
}
}
}
/**
* @brief flash中
* @param
* @retval
*
*/
void read_and_process_config_data(void)
{
while (strlen(config_buff) > RECV_CONFIG_INFO) {
recv_config_info *pack = (recv_config_info *)config_buff;
if (pack->start_Flag[0] != g_otherParameter.startFlagSL[0]
|| pack->start_Flag[1] != g_otherParameter.startFlagSL[1]) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
// 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;
// }
uint16_t temp_u16;
temp_u16 = (uint16_t)pack->Access_Node_Type[0] << 8
| (uint16_t)pack->Access_Node_Type[1];
// if (temp_u16 != POWERBOX || temp_u16 != MICROMETEOROLOGY) {
if (temp_u16 != POWERBOX) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
temp_u16 = (uint16_t)pack->Communication_Methods[0] << 8
| (uint16_t)pack->Communication_Methods[1];
// if (temp_u16 != RS485 || temp_u16 != RJ45) {
if (temp_u16 != RS485) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
uint32_t temp_u32;
temp_u32 = (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];
if (temp_u32 != 9600 || temp_u32!= 115200) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
temp_u32 = (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];
if (temp_u32 != 9600 || temp_u32!= 115200 || temp_u32!= 0) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
if (pack->protocolType != 0x01 || pack->protocolType != 0x02) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
if (pack->CommunicationProtocolType != 0x00 || pack->CommunicationProtocolType != 0x01) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
if (pack->onlyPower != 0x00 || pack->onlyPower != 0x01) {
memcpy(config_buff, config_buff + 1, RECV_CONFIG_INFO - 1);
continue;
}
float_t temp_float;
}
}

View File

@ -14,3 +14,222 @@
#include "task.h"
#include "uart_dev.h"
#include "parameter.h"
static void ConstantCurrentCharge(void);
static void ConstantVoltageCharge(void);
static void FloatingCharge(void);
/**
* @brief
* @param
* @retval
*
*/
void mppt_constantVoltage(float InVoltage)
{
static float_t kp = 0.005;
static float_t ki = 0.00001;
float_t pv1Volt = g_otherParameter.Input_Voltage;
float_t error = pv1Volt - InVoltage;
float_t stepPwm = kp * error + ki * pv1Volt;
g_controlParameter.dutyRatio += stepPwm;
Set_duty_ratio(&g_controlParameter.dutyRatio);
}
/**
* @brief ()
* @param
* @retval
*
*/
void mppt_constantVoltageB(float OutVoltage)
{
static float_t kp = 0.005;
static float_t ki = 0.00001;
float_t outVolt = g_otherParameter.Battery_Voltage;
float_t error = OutVoltage - outVolt;
float_t stepPwm = kp * error + ki * outVolt;
g_controlParameter.dutyRatio += stepPwm;
Set_duty_ratio(&g_controlParameter.dutyRatio);
}
/**
* @brief
* @param
* @retval
*
*/
void mppt_constantVoltageO(float OutVoltage)
{
static float_t kp = 0.005;
static float_t ki = 0.00001;
float_t outVolt = g_otherParameter.Output_Voltage;
float_t error = OutVoltage - outVolt;
float_t stepPwm = kp * error + ki * outVolt;
g_controlParameter.dutyRatio += stepPwm;
Set_duty_ratio(&g_controlParameter.dutyRatio);
}
/**
* @brief mppt最大功率充电
* @param
* @retval
*
*/
void ConstantCurrentCharge(void)
{
mppt_constantVoltage(18);
}
/**
* @brief
* @param
* @retval
*
*/
void ConstantVoltageCharge(void)
{
mppt_constantVoltageO(g_controlParameter.constantVoltageChargeV);
}
/**
* @brief
* @param
* @retval
*
*/
void FloatingCharge(void)
{
mppt_constantVoltageO(g_controlParameter.FloatV);
}
/**
* @brief mppt控制模式的确定
* @param
* @retval
*
*/
void MpptContorlChoice(void)
{
switch(g_otherParameter.MPPT_Mode) {
case CONSTANTCURRENT:
ConstantCurrentCharge();
break;
case CONSTANTVOLTAGE:
ConstantVoltageCharge();
break;
case FLOAT:
FloatingCharge();
break;
default:
break;
}
}
/**
* @brief mppt模式的确定
* @param
* @retval
*
*/
void MpptModeChoice(void)
{
/* 太阳能板输出电压小于一定值且充电电流也小于一定值时mppt停止工作 */
if ((g_otherParameter.Input_Voltage < g_controlParameter.stopSolarOpenCircuitV
&& g_otherParameter.Charg_Current < 0.05) ){
// && g_otherParameter.MPPT_Mode != NoWork) {
g_otherParameter.MPPT_Mode = NoWork;
TIM_Cmd(TIM3, DISABLE);
TIM_SetCompare4(TIM4, 0);
g_controlParameter.dutyRatio = 0;
TimeSliceOffset_Register(&g_startMpptControl, Task_startMpptControl
, startMpptControl_reloadVal, startMpptControl_offset);
return;
}
/* 流向电池的电流小于一定值或者电压过大或者过小采用浮充输出 */
if ((g_otherParameter.Charg_BatteryCurrent < 0.05 && g_otherParameter.Charg_BatteryCurrent > -0.05)
|| g_otherParameter.Battery_Voltage > 16 || g_otherParameter.Battery_Voltage < 8) {
g_otherParameter.MPPT_Mode = FLOAT;
g_otherParameter.batteryState = 0;
return;
}
/* */
if ((g_controlParameter.constantVoltageV - 0.2) >= g_otherParameter.Battery_Voltage
// && g_otherParameter.Charg_BatteryCurrent > 0.1) {
&& g_otherParameter.Charg_Current > 0.1) {
g_otherParameter.MPPT_Mode = CONSTANTCURRENT;
return;
}
if (((g_controlParameter.constantVoltageV < g_otherParameter.Battery_Voltage)
&& (g_controlParameter.floatI + 0.1 <= g_otherParameter.Charg_Current))) {
g_otherParameter.MPPT_Mode = CONSTANTVOLTAGE;
return;
}
if ((((g_controlParameter.constantVoltageV < g_otherParameter.Battery_Voltage)
&& (g_controlParameter.floatI > g_otherParameter.Charg_Current))
&& (g_controlParameter.floatI > g_otherParameter.Discharg_Current))) {
// || g_Mppt_Para.MPPT_Mode == FLOAT) {
g_otherParameter.MPPT_Mode = FLOAT;
return;
}
}
/**
* @brief mppt的控制
* @param
* @retval
*
*/
void MpptContorl(void)
{
g_otherParameter.Output_Voltage = get_PV_VOLT_OUT();
g_otherParameter.Input_Voltage = get_PV1_VOLT_IN();
/* 出现adc采集出错全为0,退出本次中断 */
if (g_otherParameter.Discharg_Current == 0 && g_otherParameter.Charg_Current == 0) {
return;
}
g_otherParameter.Charg_BatteryCurrent = g_otherParameter.Charg_Current - g_otherParameter.Discharg_Current;
/* 判断有无电池 */
if (g_otherParameter.batteryState == 0 && (g_otherParameter.Charg_BatteryCurrent > 0.1 || g_otherParameter.Charg_BatteryCurrent < -0.1)
&& g_otherParameter.Output_Voltage < 14.2) {
g_otherParameter.batteryState = 1;
}
if (!g_otherParameter.overTemperature) {
MpptModeChoice();
MpptContorlChoice();
}
}

View File

@ -15,8 +15,729 @@
#include "tim.h"
#include "parameter.h"
default_Value defaultValue = {'S', 'L'\
, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11\
, POWERBOX\
, RS485
, 0x16};
uint8_t rs485_buff[buffLen]={0x00};
uint8_t config_buff[configBuffLen] = {0x00};
/* 用于解析串口包时的长度 */
#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);
static void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t MsgLen);
static void SL_MsgProcFunc_Broadcast_Scan(device_handle device, void *pMsg, uint32_t MsgLen);
static void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint32_t MsgLen);
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_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);
/* 功能码处理表 */
SL_FuncionMsgProcTable g_MsgTbl[] =
{
{SL_Function_Code_Read_Register, SL_MsgProcFunc_Read_Register},
{SL_Function_Code_Write_Register, SL_MsgProcFunc_Write_Register},
{SL_Function_Code_Broadcast_Scan, SL_MsgProcFunc_Broadcast_Scan},
{SL_Function_Code_Registration_request, SL_MsgProcFunc_Registration_request},
{SL_Function_Code_Update_Profile, SL_MsgProcFunc_Update_Profile},
{SL_Function_Code_Remote_Upgrade, SL_MsgProcFunc_Remote_Upgrade},
};
/* 寄存器处理表 */
SL_RegProcTable g_RegTblR[] =
{
// {SL_Register_Registration_Status, SL_ReadRegisterRegistrationStatus},
// {SL_Register_address, SL_ReadRegisteraddress},
// {SL_Register_Access_Node_Type, SL_ReadRegisterAccessNodeType},
// {SL_Register_Communication_Methods, SL_ReadRegisterCommunicationMethods},
{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_RegProcTable g_RegTblW[] =
{
// {SL_Register_Registration_Status, SL_WriteRegisterRegistrationStatus},
// {SL_Register_address, SL_WriteRegisteraddress},
// {SL_Register_Access_Node_Type, SL_WriteRegisterAccessNodeType},
// {SL_Register_Communication_Methods, SL_WriteRegisterCommunicationMethods},
// {SL_Register_Battery_Voltage, SL_WriteRegisterBatteryVoltage},
// {SL_Register_Battery_temperature, SL_WriteRegisterBatterytemperature},
// {SL_Register_Remaining_Battery_Bower, SL_WriteRegisterRemainingBatteryBower},
// {SL_Register_Solar_Open_Circuit_Voltage1, SL_WriteRegisterSolarOpenCircuitVoltage1},
// {SL_Register_Solar_Open_Circuit_Voltage2, SL_WriteRegisterSolarOpenCircuitVoltage2},
};
/**
* @brief
* @param
* @retval
*/
uint16_t CheckFuncSL(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 ,100-2500ms10ms  
* @param
* @retval
*/
int randomDelay()
{
int minSeconds = 10;
int maxSeconds = 250;
// srand(SystemCoreClock);//time(NULL)替换为对应操作系统时钟
srand(TIM_GetCounter(TIM4));
int delaySeconds = minSeconds + rand() % (maxSeconds - minSeconds + 1);
return delaySeconds * 10;
}
/**
* @brief 485线
* @param
* @retval 1
* 0
*/
uint8_t Check_485_bus_busy(device_handle device)
{
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
uint16_t num_ago = ring_queue_length(device);
Delay_Ms(2);
uint16_t num_now = ring_queue_length(device);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, DISABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, DISABLE);
}
if (num_now == num_ago) {
return 0;
}
return 1;
}
/**
* @brief
* @param
* @retval
*/
void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t MsgLen)
{
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 > 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 > 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[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)) {
// *(uint16_t *)&reply_Data_Content[pos * 2] = g_RegTblR[var].pRegProc(NULL);
reply_Data_Content[pos] = g_RegTblR[var].pRegProc(NULL);
}
}
}
/* 打包 */
memset(rs485_buff, 0, sizeof(rs485_buff));
uint8_t *replay_pack = rs485_buff;
// strlcpy(replay_pack, g_slConfigInfo.start_Flag, 2);
*(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_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;
*replay_pack = SL_Function_Code_Read_Register;
replay_pack += 1;
// *(uint16_t *)&replay_pack = rpack->read_Register_Number;
*replay_pack = (Register_Number_16 >> 8);
*(replay_pack + 1) = (Register_Number_16);
replay_pack += 2;
for (uint8_t var = 0; var < Register_Number_16 * 2; var++) {
if (0 == (var & 0x01)) {
*(replay_pack + var) = (reply_Data_Content[var / 2] >> 8);
} else {
*(replay_pack + var) = (reply_Data_Content[var / 2]);
}
}
replay_pack += Register_Number_16 * 2;
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_otherParameter.endFlagSL;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
// log_info("pack : %s", (uint8_t *)&replay_pack);
// uart_dev_write(device, (uint8_t *)&replay_pack, 16 + Register_Number_16 * 2 + 1);
uart_dev_write(device, rs485_buff, 16 + Register_Number_16 * 2);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t MsgLen)
{
SL_Mppt_Worecv_pack *wpack = (SL_Mppt_Worecv_pack *)pMsg;
uint8_t *buff = (uint8_t *)pMsg;
uint16_t Register_Number = \
chang_8_to_16(wpack->write_Register_Number_L, wpack->write_Register_Number_H);
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 > g_otherParameter.RegisterStartAddressMax) {
log_error(" Register_Start_Address error : %x \r\n", Register_Start_Address);
return;
}
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];
}
for ( uint16_t pos = 0; pos < Register_Number; pos++) {
for (uint16_t i = 0; i < sizeof(g_RegTblW) / sizeof(SL_RegProcTable); i++) {
if (g_RegTblW[i].regId == (Register_Start_Address + pos)) {
g_RegTblW[i].pRegProc(&content[pos]);
}
}
}
}
void SL_MsgProcFunc_Broadcast_Scan(device_handle device, void *pMsg, uint32_t MsgLen)
{
g_recvBroadcastDevice = device;
g_otherParameter.RegistrationRequestFlag = 1;
/* 任务创立后,立即执行一次 */
TimeSliceOffset_Register(&g_recvbroadcast, Task_recvbroadcast \
, recvbroadcast_reloadVal, recvbroadcast_offset);
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;
g_otherParameter.RegistrationRequestFlag = 0;
TimeSliceOffset_Unregister(&g_recvbroadcast);
g_recvbroadcast.runFlag = 0;
SL_Mppt_RegistrationReply_pack *rpack = (SL_Mppt_RegistrationReply_pack *)pMsg;
g_otherParameter.Registration_Status = chang_8_to_16(rpack->registration_Status_L, rpack->registration_Status_H);
/* 20s内不再接收广播帧 */
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_otherParameter.startFlagSL[0];
SUpdateProfile_pack.start_Flag[1] = g_otherParameter.startFlagSL[1];
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 = 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) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, (uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE + 1);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t MsgLen)
{
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] = 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 = 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) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(device)) {
uart_dev_write(device, (uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE + 1);
if (device == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterBatteryVoltage(void *pMsg)
{
log_info(" SL_ReadRegisterBatteryVoltage ");
uint16_t value = (uint16_t)(g_otherParameter.Battery_Voltage * 10);
return value;
}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterChargCurrent(void *pMsg)
{
log_info(" SL_ReadRegisterChargCurrent ");
uint16_t value = (uint16_t)(g_otherParameter.Charg_Current * 10);
return value;
}
/**
* @brief
* @param
* @retval
*/
uint16_t SL_ReadRegisterDischargCurrent(void *pMsg)
{
log_info(" SL_ReadRegisterDischargCurrent ");
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_otherParameter.Solar_Open_Circuit_Voltage * 10);
return value;
}
/**
* @brief mos管的温度寄存器
* @param
* @retval
*/
uint16_t SL_ReadRegisterHighSideMosTemperature(void *pMsg)
{
log_info(" SL_ReadRegisterHighSideMosTemperature ");
uint16_t value = (uint16_t)(g_otherParameter.HighSideMos_Temperature * 10);
return value;
}
/**
* @brief mos管状态寄存器
* @param
* @retval
*/
uint16_t SL_ReadRegisterDischargMosState(void *pMsg)
{
log_info(" SL_ReadRegisterDischargMosState ");
uint16_t value = (uint16_t)g_otherParameter.DischargMos_State;
return value;
}
/**
* @brief mppt工作模式寄存器
* @param
* @retval
*/
uint16_t SL_ReadRegisterMPPTMode(void *pMsg)
{
log_info(" SL_ReadRegisterMPPTMode ");
uint16_t value = (uint16_t)g_otherParameter.MPPT_Mode;
return value;
}
/**
* @brief "SL"
* @param start_buff
* @retval 1
* 0
*/
static int Match_Startflag(uint8_t start_buff[2])
{
// if (!strcmp(start_buff, g_slConfigInfo.start_Flag)) {
// log_info("Match_Startflag fail \r\n");
// return 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;
}
return 0;
}
/**
* @brief
* @param address
* @retval 1
* 0
*/
static int Match_address(u_int8_t address[7])
{
// if (!strcmp(address, g_slConfigInfo.address)) {
// log_info("Match_address fail \r\n");
// return 1;
// }
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;
}
return 0;
}
/**
* @brief 广
* @param address
* @retval 1
* 0
*/
static int Match_Broadcastaddress(u_int8_t address[7])
{
if (address[0] == 0xFF && \
address[1] == 0xFF && \
address[2] == 0xFF && \
address[3] == 0xFF && \
address[4] == 0xFF && \
address[5] == 0xFF && \
address[6] == 0xFF) {
log_info("Match_Broadcastaddress success\r\n");
return 1;
}
return 0;
}
/**
* @brief
* @param uart_handle
* @param buff
* @param buff_size
* @retval
*/
static int uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint32_t buff_size)
{
uint32_t offset = 0;
uint32_t len = 0;
uint8_t flag_run = 0;
char c = 0;
SL_Mppt_Recv_pack *pack = (SL_Mppt_Recv_pack *)buff;
buff_size--; //预留一个'\0'位置
for (; offset < buff_size;){
if (ring_queue_length(uart_handle) == 0) {
break;
}
c = uart_dev_in_char(uart_handle);
buff[offset++] = c;
/* 匹配起始标志位 */
if (offset == analyzeStartFlag || (flag_run > 0)) {
if (!Match_Startflag(pack->start_Flag)) {
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
/* 匹配地址 */
if (offset == analyzeAddress || (flag_run > 1)) {
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;
}
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
/* 匹配功能码 */
if (offset == analyzeFunctionCode || (flag_run > 2)) {
/* 未注册时,不处理读写和其他帧 */
if (g_otherParameter.Registration_Status == 2) {
/* 读寄存器数据 */
if (pack->function_Code == SL_Function_Code_Read_Register) {
log_info("Read_Register\r\n");
len = SL_MPPT_RORECV_PACK_SIZE;
}
/* 写寄存器数据 */
else if (pack->function_Code == SL_Function_Code_Write_Register) {
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 (g_otherParameter.runBroadcast) {
/* 广播扫描 */
if (pack->function_Code == SL_Function_Code_Broadcast_Scan) {
log_info("Broadcast_Scan\r\n");
len = SL_MPPT_SCAN_BROADCAST_PACK_SIZE;
}
/* 注册请求 */
else if (pack->function_Code == SL_Function_Code_Registration_request) {
log_info("Registration_request\r\n");
len = SL_MPPT_REGISTRATIONREPLY_PACK_SIZE;
}
else {
if (flag_run < 2) {
flag_run = 2;
}
log_info("funcode error %x\r\n", pack->function_Code);
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
else {
if (flag_run < 2) {
flag_run = 2;
}
log_info("funcode error %x\r\n", pack->function_Code);
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
/* 广播扫描 */
else if (pack->function_Code == SL_Function_Code_Broadcast_Scan) {
log_info("Broadcast_Scan\r\n");
len = SL_MPPT_SCAN_BROADCAST_PACK_SIZE;
}
/* 注册请求 */
else if (pack->function_Code == SL_Function_Code_Registration_request) {
log_info("Registration_request\r\n");
len = SL_MPPT_REGISTRATIONREPLY_PACK_SIZE;
}
else {
if (flag_run < 2) {
flag_run = 2;
}
log_info("funcode error %x\r\n", pack->function_Code);
memcpy(buff, buff+1, offset-1);
offset--;
continue;
}
}
if ((pack->function_Code == SL_Function_Code_Write_Register) && (offset >= 14)) {
SL_Mppt_Worecv_pack *wpack = (SL_Mppt_Worecv_pack *)buff;
uint8_t Register_Number = (wpack->write_Register_Number_H << 8) | wpack->write_Register_Number_L;
len = Register_Number * 2 + SL_MPPT_WORECV_PACK_SIZE - 4;
continue;
}
if (offset == len) {
uint16_t crc_16 = chang_8_to_16(buff[offset - 2], buff[offset - 3]);
if ((CheckFuncSL(buff, offset - 3) != crc_16) || (buff[offset - 1] != 0x16)) {
if (flag_run < 3) {
flag_run = 3;
}
memcpy(buff, buff+1, offset-1);
offset--;
} else {
return offset;
}
}
}
return 0;
}
/**
* @brief
* @param
* @retval
*/
void FRT_MsgHandler(device_handle device, uint8_t *pMsg, uint32_t MsgLen)
{
SL_Mppt_Recv_pack *pack = (SL_Mppt_Recv_pack *)pMsg;
for (u_int16_t i = 0; i < sizeof(g_MsgTbl) / sizeof(SL_FuncionMsgProcTable); i++){
if (pack->function_Code == g_MsgTbl[i].msgId){
g_MsgTbl[i].pMsgProc(device, pMsg, MsgLen);
}
}
}
void read_and_process_uart_data(device_handle device)
{
if (uart_dev_char_present(device)) {
Delay_Ms(20);
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);
}
}
}

View File

@ -23,5 +23,499 @@
#include <stdlib.h>
#include "collect_Conversion.h"
#include "parameter.h"
#include "hy_protocol.h"
/**
* @brief
* @param
* @retval
*
*/
void Init()
{
SPI_Flash_Init();
currBuffInit();
config_info_start();
adcChangeProportionalInit();
uart_dev_init();
PWM_TIM_Configuration();
ADC_all_Init();
RUN_LED_Init();
WDI_INPUT_Init();
POW_OUT_CON_Init();
DSG_PROT_Init();
WORK_VOLT_INT_Init();
TIM3_Init(1);
TimeSliceOffset_Register(&m_WdiRunled, Task_WdiRunled, WdiRunled_reloadVal, WdiRunled_offset);
TimeSliceOffset_Register(&m_refreshRegister, Task_refreshRegister,
refreshRegister_reloadVal, refreshRegister_offset);
TimeSliceOffset_Register(&g_startMpptControl, Task_startMpptControl,
startMpptControl_reloadVal, startMpptControl_offset);
TimeSliceOffset_Register(&g_dataJudgment, Task_dataJudgment,
dataJudgment_reloadVal, dataJudgment_offset);
if (g_otherParameter.CommunicationProtocolType == 0x00) {
TimeSliceOffset_Register(&m_usart, Task_usartSL, usartSL_reloadVal, usartSL_offset);
} else if (g_otherParameter.CommunicationProtocolType == 0x01) {
TimeSliceOffset_Register(&m_usart, Task_usartHY, usartSL_reloadVal, usartSL_offset);
}
TIM2_Init(1);
TimeSliceOffset_Start(); /* 启动时间片轮询 */
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset m_WdiRunled;
void Task_WdiRunled(void)
{
static uint8_t flag = RESET;
flag = !flag;
GPIO_WriteBit(RUN_LED_GPIO, RUN_LED_PIN, flag);
static uint32_t temp = wdi_RESET;
if (!(--temp)) {
temp = 0;
NVIC_SystemReset();
}
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, SET);
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, RESET);
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset m_refreshRegister;
void Task_refreshRegister(void)
{
g_otherParameter.Output_Voltage = get_PV_VOLT_OUT();
g_otherParameter.Input_Voltage = get_PV_VOLT_IN1();
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
g_otherParameter.HighSideMos_Temperature = get_MOSFET_Temper();
g_otherParameter.Charg_BatteryCurrent = g_otherParameter.Charg_Current
- g_otherParameter.Discharg_Current;
g_otherParameter.totalChargCapacity += totalChargCapacity / 3600000;
g_otherParameter.totalElectricityConsumption += totalElectricityConsumption / 3600000;
saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
totalChargCapacity = 0;
totalElectricityConsumption = 0;
g_otherParameter.SOC = 0;
g_otherParameter.Battery_Voltage = g_otherParameter.Output_Voltage
- g_otherParameter.Charg_BatteryCurrent * g_controlParameter.loopImpedance;
if (g_otherParameter.onlyPower) {
g_otherParameter.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN)
&& GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN);
} else {
g_otherParameter.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN);
}
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset m_impedanceCalculation;
void Task_impedanceCalculation(void)
{
static uint8_t num = 0;
static float_t currOne = 0;
static float_t voltOne = 0;
static float_t currTwo = 0;
static float_t voltTwo = 0;
num++;
if (num == 1) {
TIM_Cmd(TIM3, DISABLE);
TIM_SetCompare4(TIM4, 300);
return;
}
if (num == 11) {
currOne = get_CHG_CURR() - get_DSG_CURR();
voltOne = get_PV_VOLT_OUT();
TIM_SetCompare4(TIM4, 420);
return;
}
if (num == 11) {
currOne = get_CHG_CURR() - get_DSG_CURR();
voltOne = get_PV_VOLT_OUT();
TIM_SetCompare4(TIM4, 420);
return;
}
if (num == 21) {
TimeSliceOffset_Unregister(&m_impedanceCalculation);
m_impedanceCalculation.runFlag = 0;
currTwo = get_CHG_CURR() - get_DSG_CURR();
voltTwo = get_PV_VOLT_OUT();
float_t tempLoopImpedance = 0;
tempLoopImpedance = (voltOne - voltTwo) / (currOne - currTwo);
/* 判断回路阻抗是否合理 */
if (tempLoopImpedance < 1.0 && tempLoopImpedance > 0.05) {
g_controlParameter.loopImpedance = tempLoopImpedance;
saveLoopImpedance(&g_controlParameter.loopImpedance);
}
g_otherParameter.impedanceStart = 0;
num = 0;
g_otherParameter.MPPT_Mode = CONSTANTCURRENT;
TIM_Cmd(TIM3, ENABLE);
return;
}
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset g_outputAgain;
void Task_outputAgain(void)
{
static uint8_t num = 0;
num++;
if (num == g_controlParameter.outputAgainFlagTime) {
num = 0;
g_otherParameter.outputAgainFlag = 0;
TimeSliceOffset_Unregister(&g_outputAgain);
g_outputAgain.runFlag = 0;
if (!(GPIO_ReadInputDataBit(DSG_PROT_GPIO, DSG_PROT_PIN))) {
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
}
}
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset g_excessiveLoad;
void Task_excessiveLoad(void)
{
static uint8_t num = 0;
static uint16_t numLong = 0;
/* 短路保护了则退出过载保护 */
if (g_otherParameter.outputAgainFlag == 1) {
num = 0;
numLong = 0;
g_otherParameter.excessiveLoadFlag = 0;
TimeSliceOffset_Unregister(&g_excessiveLoad);
g_excessiveLoad.runFlag = 0;
}
/* 过载一次 */
if (g_otherParameter.excessiveLoadFlag == 1) {
num++;
}
/* 多次过载则关闭输出 */
if (g_otherParameter.excessiveLoadFlag >= 2) {
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
num = 0;
}
/* 仅过载一次,达到时间后关闭该任务 */
if (num == g_controlParameter.excessiveLoadFlagTime) {
num = 0;
g_otherParameter.excessiveLoadFlag = 0;
TimeSliceOffset_Unregister(&g_excessiveLoad);
g_excessiveLoad.runFlag = 0;
return;
}
/* 关闭输出后开始计时 */
if (!(GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN))) {
numLong++;
}
/* 达到时间就重新尝试输出 */
if (numLong == g_controlParameter.eLAgainTime) {
numLong = 0;
TimeSliceOffset_Unregister(&g_excessiveLoad);
g_excessiveLoad.runFlag = 0;
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
g_otherParameter.excessiveLoadFlag = 0;
}
return;
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset m_softStart;
void Task_softStart(void)
{
static uint16_t num = 0;
static float_t dutyRatio = 0;
num++;
if (num < 5) {
TIM_SetCompare4(TIM4, 100);
}
else if (num > 70 || dutyRatio > 0.75) {
TimeSliceOffset_Unregister(&m_softStart);
m_softStart.runFlag = 0;
dutyRatio = 0;
num = 0;
g_controlParameter.dutyRatio = 0.75;
Set_duty_ratio(&g_controlParameter.dutyRatio);
if (g_otherParameter.batteryState == 1) {
g_otherParameter.MPPT_Mode = CONSTANTCURRENT;
TIM_Cmd(TIM3, ENABLE);
return;
} else {
g_otherParameter.Charg_BatteryCurrent = g_otherParameter.Charg_Current
- g_otherParameter.Discharg_Current;
//软起动后bms保护板开启电池充电
if (g_otherParameter.Charg_BatteryCurrent > 0.1
|| g_otherParameter.Charg_BatteryCurrent < -0.1) {
g_otherParameter.MPPT_Mode = CONSTANTCURRENT;
TIM_Cmd(TIM3, ENABLE);
return;
}
g_otherParameter.MPPT_Mode = FLOAT;
TIM_Cmd(TIM3, ENABLE);
return;
}
}
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset g_startMpptControl;
void Task_startMpptControl(void)
{
static uint8_t num = 0;
if (g_controlParameter.checkSolarOpenCircuitVTime == ++num) {
num = 0;
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
if (g_otherParameter.Solar_Open_Circuit_Voltage > g_controlParameter.startSolarOpenCircuitV) {
TimeSliceOffset_Unregister(&g_startMpptControl);
g_startMpptControl.runFlag = 0;
if (g_otherParameter.Output_Voltage > 11) {
g_otherParameter.batteryState = 1;
} else {
g_otherParameter.batteryState = 0;
}
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
}
}
return;
}
/**
* @brief
*
* MOS管温度对于进入什么模式
* @param
* @retval
*
*/
STR_TimeSliceOffset g_dataJudgment;
void Task_dataJudgment(void)
{
/* 有电池,太阳能输出功率大,同时回路阻抗未测试或需要重新测试 */
if ((g_otherParameter.impedanceStart == 1 || g_controlParameter.loopImpedance == 0.0)
&& g_otherParameter.batteryState == 1 && (g_otherParameter.Charg_Current > 3.0)) {
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
}
if (g_otherParameter.overTemperature != 0
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_start + 3) {
if (g_otherParameter.overTemperature == 2) {
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
}
g_otherParameter.overTemperature = 0;
return;
}
if (g_otherParameter.overTemperature == 0
&& g_otherParameter.HighSideMos_Temperature < g_controlParameter.HighSideMosTemperature_stop
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_end + 3) {
g_controlParameter.dutyRatio -= 0.15;
Set_duty_ratio(&g_controlParameter.dutyRatio);
g_otherParameter.overTemperature = 1;
}
if (g_otherParameter.overTemperature != 2
&& g_otherParameter.HighSideMos_Temperature > g_controlParameter.HighSideMosTemperature_stop + 3) {
g_otherParameter.overTemperature = 2;
TIM_Cmd(TIM3, DISABLE);
TIM_SetCompare4(TIM4, 0);
g_controlParameter.dutyRatio = 0;
}
}
/**
* @brief
* Task_usartSLsl协议
* Task_usartHYhy协议
* @param
* @retval
*
*/
STR_TimeSliceOffset m_usart;
void Task_usartSL(void)
{
read_and_process_uart_data(g_gw485_uart4_handle);
}
void Task_usartHY(void)
{
HY_read_and_process_uart_data(g_gw485_uart4_handle);
}
/**
* @brief 广,3s
* @param
* @retval
*
*/
uint8_t recvbroadcast_flag; /* 是否需要再次发送标志 */
device_handle g_recvBroadcastDevice; /* 串口句柄 */
STR_TimeSliceOffset g_recvbroadcast;
void Task_recvbroadcast(void)
{
static uint8_t run_number = 0;
/* 超过三次,不再发送 */
if (run_number++ == 3 || run_number > 3) {
g_otherParameter.RegistrationRequestFlag = 0;
run_number = 0;
TimeSliceOffset_Unregister(&g_recvbroadcast);
g_recvbroadcast.runFlag = 0;
return;
}
SL_Mppt_RegistrationRequest_pack recvpack = {0};
/* 起始标志 */
recvpack.start_Flag[0] = g_otherParameter.startFlagSL[0];
recvpack.start_Flag[1] = g_otherParameter.startFlagSL[1];
/* ID */
recvpack.address[0] = 0xFF;
recvpack.address[1] = 0xFF;
recvpack.address[2] = 0xFF;
recvpack.address[3] = 0xFF;
recvpack.address[4] = 0xFF;
recvpack.address[5] = 0xFF;
recvpack.address[6] = 0xFF;
/* 功能码 */
recvpack.function_Code = SL_Function_Code_Registration_request;
/* 寄存器长度 */
// recvpack.register_Length_H = (g_otherParameter.RegisterNumberMax + 5) >> 8;
// recvpack.register_Length_L = g_otherParameter.RegisterNumberMax + 5;
recvpack.register_Length_H = g_otherParameter.RegisterNumberMax >> 8;
recvpack.register_Length_L = g_otherParameter.RegisterNumberMax;
/* 注册状态 */
recvpack.registration_Status_H = g_otherParameter.Registration_Status >> 8;
recvpack.registration_Status_L = g_otherParameter.Registration_Status;
/* 接入节点ID */
recvpack.access_Node_ID[0] = g_otherParameter.address[0];
recvpack.access_Node_ID[1] = g_otherParameter.address[1];
recvpack.access_Node_ID[2] = g_otherParameter.address[2];
recvpack.access_Node_ID[3] = g_otherParameter.address[3];
recvpack.access_Node_ID[4] = g_otherParameter.address[4];
recvpack.access_Node_ID[5] = g_otherParameter.address[5];
recvpack.access_Node_ID[6] = g_otherParameter.address[6];
/* 接入节点类型 */
recvpack.access_Node_Type_H = g_otherParameter.Access_Node_Type >> 8;
recvpack.access_Node_Type_L = g_otherParameter.Access_Node_Type;
/* 校验位 */
// uint8_t *rpack_buf = (uint8_t *)&recvpack;
uint16_t crc = CheckFuncSL((uint8_t *)&recvpack, SL_MPPT_REGISTRATIONREQUEST_PACK_SIZE - 3);
recvpack.check_Bit_H = crc >> 8;
recvpack.check_Bit_L = crc;
/* 结束标志 */
recvpack.end_Flag = g_otherParameter.endFlagSL;
/* 校验位 */
for (uint8_t var = 0; var < 10; ++var) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(g_recvBroadcastDevice)) {
if (recvbroadcast_flag == 1) {
recvbroadcast_flag = 0;
run_number = 0;
return;
}
uart_dev_write(g_recvBroadcastDevice, (uint8_t *)&recvpack, SL_MPPT_REGISTRATIONREQUEST_PACK_SIZE + 1);
if (g_recvBroadcastDevice == g_bat485_uart3_handle) {
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
} else {
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
}
break;
}
}
}
/**
* @brief
* @param
* @retval
*
*/
STR_TimeSliceOffset g_sensorEnableBroadcast;
void Task_sensorEnableBroadcast(void)
{
static uint32_t enabBroadcastTimeFlag = 0;
enabBroadcastTimeFlag++;
g_otherParameter.runBroadcast = 0;
if (enabBroadcastTimeFlag == g_controlParameter.sensorEnableBroadcastTime) {
TimeSliceOffset_Unregister(&g_sensorEnableBroadcast);
g_sensorEnableBroadcast.runFlag = 0;
enabBroadcastTimeFlag = 0;
g_otherParameter.runBroadcast = 1;
}
return;
}

View File

@ -80,10 +80,12 @@ 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_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_otherParameter.gw485_Baud);

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

@ -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,17 +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
// , outputAgain_reloadVal, outputAgain_offset);
// m_outputAgain.runFlag = 1;
// return;
// }
if (0 == g_otherParameter.outputAgainFlag) {
g_otherParameter.outputAgainFlag++;
TimeSliceOffset_Register(&g_outputAgain, Task_outputAgain
, outputAgain_reloadVal, outputAgain_offset);
g_outputAgain.runFlag = 1;
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);
}
}
}
@ -157,13 +163,12 @@ void WORK_VOLT_INT_Init(void)
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line12)==SET) { //EXTI_GetITStatus用来获取中断标志位状态如果EXTI线产生中断则返回SET否则返回RESET
// EXTI_ClearITPendingBit(EXTI_Line12); //Çå³ýÖжϱê־λ
// excessiveLoadFlag++;
// TimeSliceOffset_Register(&m_excessiveLoad, Task_excessiveLoad
// , excessiveLoad_reloadVal, excessiveLoad_offset);
EXTI_ClearITPendingBit(EXTI_Line12); //Çå³ýÖжϱê־λ
if (0 == g_otherParameter.excessiveLoadFlag) {
TimeSliceOffset_Register(&g_excessiveLoad, Task_excessiveLoad
, excessiveLoad_reloadVal, excessiveLoad_offset);
}
g_otherParameter.excessiveLoadFlag++;
}
}

View File

@ -10,6 +10,9 @@
#include "pwm.h"
#include "mppt_control.h"
#include "task.h"
#include "math.h"
#include "parameter.h"
#include "collect_Conversion.h"
void TIM3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
@ -59,7 +62,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 +101,20 @@ 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();
totalElectricityConsumption += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
totalChargCapacity += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
}
}

View File

@ -39,6 +39,5 @@ int main(void)
printf("SystemClk:%d\r\n", SystemCoreClock);
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID());
// hardware_Init();
// task_Init();
Init();
}

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.

View File

@ -32,7 +32,9 @@ App/src/hy_protocol.o: ../App/src/hy_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/sl_protocol.h \
D:\psx\MPPT\git\App\inc/parameter.h
D:\psx\MPPT\git\App\inc/hy_protocol.h:
@ -111,3 +113,7 @@ 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:

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,8 +27,10 @@ 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 \
@ -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:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -37,6 +37,6 @@ C_DEPS += \
# 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

@ -35,7 +35,9 @@ App/src/task.o: ../App/src/task.c D:\psx\MPPT\git\App\inc/task.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/parameter.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/task.h:
@ -123,4 +125,8 @@ 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:

Binary file not shown.

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

@ -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,10 @@ 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\Hardware\inc/tim.h:
@ -106,3 +109,11 @@ 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:

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 \