Compare commits
No commits in common. "daec605235a2b0b916d2863d60bd251bac5b8a1e" and "a83d788afbc971fe5d11a49c2009c47c2eb61dc1" have entirely different histories.
daec605235
...
a83d788afb
|
@ -151,5 +151,5 @@
|
|||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Address=0x08000000
|
||||
Target Path=obj\mppt_Nos_V0.4.hex
|
||||
Erase All=false
|
||||
Erase All=true
|
||||
Program=true
|
||||
Verify=true
|
||||
Reset=true
|
||||
|
|
|
@ -55,17 +55,8 @@ typedef enum
|
|||
/* 执行状态 */
|
||||
typedef enum
|
||||
{
|
||||
/* 返回状态 */
|
||||
HY_success = 0xFF, /* 成功 */
|
||||
HY_fail = 0x00, /* 失败 */
|
||||
|
||||
/* 返回状态 */
|
||||
HY_success1 = 0x01, /* 成功 */
|
||||
|
||||
/* 充电开关状态 */
|
||||
HY_switchON = 0x00, /* 打开 */
|
||||
HY_switchOFF = 0x01, /* 关闭 */
|
||||
|
||||
}HY_state;
|
||||
|
||||
/* 指定对齐方式为1字节 */
|
||||
|
@ -350,14 +341,13 @@ typedef struct _HY_QueryChargingControlResponse{
|
|||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
uint8_t controlWord; /* 控制字 */
|
||||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
uint8_t chargInterface1; /* 充电接口1状态 */
|
||||
uint8_t chargInterface2; /* 充电接口2状态 */
|
||||
uint8_t chargInterface; /* 充电接口状态 */
|
||||
uint8_t chargInterfaceControl; /* 充电接口状态 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
uint8_t check_Bit; /* 校验码 */
|
||||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_QueryChargingControlResponse;
|
||||
#define HY_QueryChargingControlResponse_PACK_SIZE (sizeof(HY_QueryChargingControlResponse))
|
||||
#define HY_QueryChargingControlResponse_dataLen 6
|
||||
|
||||
/* 配置协议类型 */
|
||||
typedef struct _HY_configProtocolType{
|
||||
|
@ -386,7 +376,6 @@ typedef struct _HY_configProtocolTypeResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_configProtocolTypeResponse;
|
||||
#define HY_configProtocolTypeResponse_PACK_SIZE (sizeof(HY_configProtocolTypeResponse))
|
||||
#define HY_configProtocolTypeResponse_dataLen 5
|
||||
|
||||
/* 查询电池控制盒当前配置 */
|
||||
typedef struct _HY_queryControlBoxConfigurationQuery{
|
||||
|
@ -417,7 +406,6 @@ typedef struct _HY_queryControlBoxConfigurationResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_queryControlBoxConfigurationResponse;
|
||||
#define HY_queryControlBoxConfigurationResponse_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationResponse))
|
||||
#define HY_queryControlBoxConfigurationResponse_dataLen 8
|
||||
|
||||
/* 查询电池控制盒软件版本 */
|
||||
typedef struct _HY_SoftwareVersionQuery{
|
||||
|
@ -432,7 +420,7 @@ typedef struct _HY_SoftwareVersionQuery{
|
|||
}HY_SoftwareVersionQuery;
|
||||
#define HY_SoftwareVersionQuery_PACK_SIZE (sizeof(HY_SoftwareVersionQuery))
|
||||
|
||||
/* 查询电池控制盒软件版本响应 */
|
||||
/* 查询电池控制盒软件版本 */
|
||||
typedef struct _HY_SoftwareVersionQueryResponse{
|
||||
uint8_t start_Flag; /* 起始标志 */
|
||||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
|
@ -445,7 +433,6 @@ typedef struct _HY_SoftwareVersionQueryResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_SoftwareVersionQueryResponse;
|
||||
#define HY_SoftwareVersionQueryResponse_PACK_SIZE (sizeof(HY_SoftwareVersionQueryResponse))
|
||||
#define HY_SoftwareVersionQueryResponse_dataLen 17
|
||||
|
||||
/* 进入配置模式 */
|
||||
typedef struct _HY_enterConfigMode{
|
||||
|
@ -473,7 +460,6 @@ typedef struct _HY_enterConfigModeResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_enterConfigModeResponse;
|
||||
#define HY_enterConfigModeResponse_PACK_SIZE (sizeof(HY_enterConfigModeResponse))
|
||||
#define HY_enterConfigModeResponse_dataLen 5
|
||||
|
||||
/* 配置控制盒硬件ID号 */
|
||||
typedef struct _HY_configHardwareID{
|
||||
|
@ -502,36 +488,19 @@ typedef struct _HY_configHardwareIDResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_configHardwareIDResponse;
|
||||
#define HY_configHardwareIDResponse_PACK_SIZE (sizeof(HY_configHardwareIDResponse))
|
||||
#define HY_configHardwareIDResponse_dataLen 5
|
||||
|
||||
/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */
|
||||
typedef struct _HY_QueryhardwareID_communicationID{
|
||||
uint8_t start_Flag; /* 起始标志 */
|
||||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
uint8_t controlWord; /* 控制字 */
|
||||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
uint8_t check_Bit; /* 校验码 */
|
||||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_QueryhardwareID_communicationID;
|
||||
#define HY_QueryhardwareID_communicationID_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationID))
|
||||
|
||||
/* 控制盒硬件ID号及通信ID号(原传感器号)查询响应 */
|
||||
typedef struct _HY_QueryhardwareID_communicationIDResponse{
|
||||
uint8_t start_Flag; /* 起始标志 */
|
||||
uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
uint8_t controlWord; /* 控制字 */
|
||||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
uint8_t hardwareIDR[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
uint8_t communicationIDR[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
uint8_t check_Bit; /* 校验码 */
|
||||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_QueryhardwareID_communicationIDResponse;
|
||||
#define HY_QueryhardwareID_communicationIDResponse_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationIDResponse))
|
||||
#define HY_QueryhardwareID_dataLen 14
|
||||
///* 控制盒硬件ID号及通信ID号(原传感器号)查询 */
|
||||
//typedef struct _HY_QueryhardwareID_communicationID{
|
||||
// uint8_t start_Flag; /* 起始标志 */
|
||||
// uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
// uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */
|
||||
// uint8_t controlWord; /* 控制字 */
|
||||
// uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
// uint32_t frameNumber; /* 帧序号 */
|
||||
// uint8_t check_Bit; /* 校验码 */
|
||||
// uint8_t end_Flag; /* 结束标志 */
|
||||
//}HY_QueryhardwareID_communicationID;
|
||||
//#define HY_QueryhardwareID_communicationID_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationID))
|
||||
|
||||
/* 修改通信ID号(原传感器号) */
|
||||
typedef struct _HY_modifyCommunicationIDChange{
|
||||
|
@ -541,8 +510,8 @@ typedef struct _HY_modifyCommunicationIDChange{
|
|||
uint8_t controlWord; /* 控制字 */
|
||||
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
|
||||
uint32_t frameNumber; /* 帧序号 */
|
||||
uint8_t newHardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
uint8_t newCommunicationID[4]; /* 新通信ID;高字节在前,低字节在后 */
|
||||
uint8_t nowHardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */
|
||||
uint8_t newcommunicationID[4]; /* 新通信ID;高字节在前,低字节在后 */
|
||||
uint8_t check_Bit; /* 校验码 */
|
||||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_modifyCommunicationIDChange;
|
||||
|
@ -561,7 +530,6 @@ typedef struct _HY_modifyCommunicationIDChangeResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_modifyCommunicationIDChangeResponse;
|
||||
#define HY_modifyCommunicationIDChangeResponse_PACK_SIZE (sizeof(HY_modifyCommunicationIDChangeResponse))
|
||||
#define HY_modifyCommunicationIDChangeResponse_dataLen 5
|
||||
|
||||
/* 查询主板温度值 */
|
||||
typedef struct _HY_checkMotherboardTemperatureQuery{
|
||||
|
@ -589,7 +557,6 @@ typedef struct _HY_checkMotherboardTemperatureResponse{
|
|||
uint8_t end_Flag; /* 结束标志 */
|
||||
}HY_checkMotherboardTemperatureResponse;
|
||||
#define HY_checkMotherboardTemperatureResponse_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureResponse))
|
||||
#define HY_checkMotherboardTemperatureResponse_dataLen 8
|
||||
|
||||
/* 恢复默认的对齐设置 */
|
||||
#pragma pack(pop)
|
||||
|
|
|
@ -46,9 +46,9 @@ typedef struct _recv_config_info{
|
|||
uint8_t HighSideMosTemperature_stop[2]; /* 当上桥温度达到该值时,停止输出 (°C) */
|
||||
uint8_t HighSideMosTemperature_end[2]; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
|
||||
uint8_t HighSideMosTemperature_start[2];/* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||
// uint8_t loopImpedance[2]; /* 回路阻抗大小 (Ω) */
|
||||
// uint8_t totalElectricityConsumption[2]; /* 总电量消耗 */
|
||||
// uint8_t totalChargCapacity[2]; /* 总充电电量 */
|
||||
uint8_t loopImpedance[2]; /* 回路阻抗大小 (Ω) */
|
||||
uint8_t totalElectricityConsumption[2]; /* 总电量消耗 */
|
||||
uint8_t totalChargCapacity[2]; /* 总充电电量 */
|
||||
|
||||
uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
// uint8_t registerRefreshTime[2]; /* 寄存器数据刷新时间 (S) */
|
||||
|
@ -88,9 +88,9 @@ typedef struct _config_info{
|
|||
float_t HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
|
||||
float_t HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
|
||||
float_t HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
|
||||
// float_t loopImpedance; /* 回路阻抗大小 (Ω) */
|
||||
// float_t totalElectricityConsumption; /* 总电量消耗 */
|
||||
// float_t totalChargCapacity; /* 总充电电量 */
|
||||
float_t loopImpedance; /* 回路阻抗大小 (Ω) */
|
||||
float_t totalElectricityConsumption; /* 总电量消耗 */
|
||||
float_t totalChargCapacity; /* 总充电电量 */
|
||||
|
||||
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
||||
// uint16_t registerRefreshTime; /* 寄存器数据刷新时间 */
|
||||
|
@ -106,27 +106,18 @@ typedef struct _config_info{
|
|||
#pragma pack(pop)
|
||||
|
||||
|
||||
#define CONFIG_SAVE_addr (0)
|
||||
#define CONFIG_SAVE_ADDR_BEGIN (CONFIG_INFO_SIZE)
|
||||
#define CONFIG_SAVE_ADDR_END (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE)
|
||||
#define LoopImpedance_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 10)
|
||||
#define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20)
|
||||
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
|
||||
#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 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);
|
||||
|
||||
void saveLoopImpedance(float_t *loopImpedance);
|
||||
void readLoopImpedance(float_t *loopImpedance);
|
||||
void savetotalElectricityConsumption(float_t *totalElectricityConsumption);
|
||||
void readtotalElectricityConsumption(float_t *totalElectricityConsumption);
|
||||
void savetotalChargCapacity(float_t *totalChargCapacity);
|
||||
void readtotalChargCapacity(float_t *totalChargCapacity);
|
||||
|
||||
|
||||
extern uint16_t configCheckFunc(uint8_t *arr_buff, uint8_t len);
|
||||
|
||||
#endif /* APP_INC_INFLASH_H_ */
|
||||
|
|
|
@ -32,7 +32,6 @@ typedef struct _Mppt_controlparameter{
|
|||
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
|
||||
} Mppt_controlparameter;
|
||||
extern Mppt_controlparameter g_controlParameter;
|
||||
|
||||
|
@ -48,7 +47,6 @@ typedef struct _Mppt_otherParameter{
|
|||
/* HY */
|
||||
uint8_t hardwareID[6]; /* 硬件ID */
|
||||
uint8_t communicationID[4]; /* 通信ID */
|
||||
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||
uint8_t startFlagHY; /* 起始码 */
|
||||
uint8_t endFlagHY; /* 结束码 */
|
||||
|
||||
|
@ -88,10 +86,6 @@ typedef struct _Mppt_otherParameter{
|
|||
uint8_t runBroadcast; /* 是否接收广播帧标志位 */
|
||||
uint16_t RegisterNumberMax; /* 寄存器个数 */
|
||||
uint16_t RegisterStartAddressMax; /* 读写的寄存器的最大起始位置,由设备决定 */
|
||||
uint32_t collectOpenCircuitVoltageNUM; /* 距离上次开路电压采集,运行次数 */
|
||||
|
||||
uint8_t HYconfigModeState; /* HY通信协议是否进入了配置模式,0x00未进入,0xFF进入 */
|
||||
uint8_t HYconfigModeT; /* HY通信协议进入配置模式后的延时时间 */
|
||||
}Mppt_otherParameter;
|
||||
extern Mppt_otherParameter g_otherParameter;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
/* Comment out this define to include debug messages */
|
||||
//#define NDEBUG
|
||||
|
||||
#define log_info_enable 1
|
||||
#define log_info_enable 0
|
||||
#define log_warn_enable 0
|
||||
#define log_error_enable 0
|
||||
|
||||
|
|
|
@ -36,18 +36,14 @@ typedef enum
|
|||
SL_Register_address = 0x0001, /* 地址 */
|
||||
SL_Register_Access_Node_Type = 0x0002, /* 接入节点类型 */
|
||||
SL_Register_Communication_Methods = 0x0003, /* 通信方式 */
|
||||
|
||||
SL_Register_Solar_Open_Circuit_Voltage = 0x0100, /* 太阳能开路电压 */
|
||||
SL_Register_Output_Voltage = 0x0100, /* 输出电压 */
|
||||
SL_Register_Battery_Voltage = 0x0101, /* 电池电压 */
|
||||
SL_Register_Charg_Current = 0x0102, /* 充电电流(流向电池+负载) */
|
||||
SL_Register_Discharg_Current = 0x0103, /* 放电电流(流向负载) */
|
||||
SL_Register_HighSideMos_Temperature = 0x0104, /* 高端mos的温度 */
|
||||
SL_Register_SOC = 0x0105, /* 剩余电量 */
|
||||
SL_Register_chargState = 0x0106, /* 充电状态 */
|
||||
SL_Register_totalChargCapacity = 0x0107, /* 总充电量 */
|
||||
SL_Register_totalElectricityConsumption = 0x0108, /* 总放电量 */
|
||||
SL_Register_MPPT_Mode = 0x0109, /* 工作模式 */
|
||||
SL_Register_eliminateStatistical = 0x0110, /* 消除统计 */
|
||||
SL_Register_Solar_Open_Circuit_Voltage = 0x0104, /* 太阳能开路电压 */
|
||||
SL_Register_HighSideMos_Temperature = 0x0105, /* 高端mos的温度 */
|
||||
SL_Register_DischargMos_State = 0x0106, /* 放电mos的状态 */
|
||||
SL_Register_MPPT_Mode = 0x0107, /* 工作模式 */
|
||||
}SL_Mppt_MsgRegister;
|
||||
|
||||
/* 注册状态 */
|
||||
|
|
|
@ -17,7 +17,7 @@ void Init();
|
|||
|
||||
/* 控制运行指示灯和喂狗 */
|
||||
#define WdiRunled_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define WdiRunled_offset 100 /* 任务执行偏移量 */
|
||||
#define WdiRunled_offset 700 /* 任务执行偏移量 */
|
||||
#define wdi_RESET (60 * 60 * 24) /* 一天复位一次 */
|
||||
extern STR_TimeSliceOffset m_WdiRunled;
|
||||
extern void Task_WdiRunled(void);
|
||||
|
@ -96,24 +96,10 @@ extern void Task_sensorEnableBroadcast(void);
|
|||
extern STR_TimeSliceOffset m_uartConfigFile;
|
||||
extern void Task_uartConfigFile(void);
|
||||
|
||||
///* 过载延时 */
|
||||
//#define overloadDelay_reloadVal 10 /* 任务执行间隔 */
|
||||
//#define overloadDelay_offset 0 /* 任务执行偏移量 */
|
||||
//extern STR_TimeSliceOffset g_overloadDelay;
|
||||
//extern void Task_overloadDelay(void);
|
||||
|
||||
/* 开路电压采集 */
|
||||
#define collectOpenCircuitVoltage_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define collectOpenCircuitVoltage_offset 0 /* 任务执行偏移量 */
|
||||
extern STR_TimeSliceOffset g_collectOpenCircuitVoltage;
|
||||
extern void Task_collectOpenCircuitVoltage(void);
|
||||
|
||||
|
||||
/* HY进入配置模式延迟后退出 */
|
||||
#define configurationModeDelayedExit_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define configurationModeDelayedExit_offset 0 /* 任务执行偏移量 */
|
||||
extern STR_TimeSliceOffset g_configurationModeDelayedExit;
|
||||
extern void Task_configurationModeDelayedExit(void);
|
||||
|
||||
/* 过载保护 */
|
||||
#define overloadDelay_reloadVal 10 /* 任务执行间隔 */
|
||||
#define overloadDelay_offset 0 /* 任务执行偏移量 */
|
||||
extern STR_TimeSliceOffset g_overloadDelay;
|
||||
extern void Task_overloadDelay(void);
|
||||
|
||||
#endif /* APP_INC_TASK_H_ */
|
||||
|
|
|
@ -182,7 +182,7 @@ static int HY_matchCommunicationID(u_int8_t communicationID[4])
|
|||
(communicationID[1] == g_otherParameter.communicationID[1]) && \
|
||||
(communicationID[2] == g_otherParameter.communicationID[2]) && \
|
||||
(communicationID[3] == g_otherParameter.communicationID[3])) {
|
||||
log_info("Match_CommunicationIDHY success \r\n");
|
||||
log_info("Match_hardwareIDHY success \r\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -200,7 +200,7 @@ static int Match_BroadcastCommunicationID(u_int8_t communicationID[4])
|
|||
communicationID[1] == 0xFF && \
|
||||
communicationID[2] == 0xFF && \
|
||||
communicationID[3] == 0xFF) {
|
||||
log_info("Match_BroadcastCommunicationID success\r\n");
|
||||
log_info("Match_BroadcastHardwareID success\r\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -242,14 +242,11 @@ 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 != g_otherParameter.startFlagHY) {
|
||||
log_info(" Match_start_Flag error %x ", pack->start_Flag);
|
||||
// printf("1 : %x \n", pack->start_Flag);
|
||||
log_info("Match_start_Flag error");
|
||||
memcpy(buff, buff+1, offset-1);
|
||||
offset--;
|
||||
continue;
|
||||
}
|
||||
// log_info(" Match_start_Flag success ");
|
||||
// printf("%x\n", pack->start_Flag);
|
||||
}
|
||||
|
||||
/* 匹配硬件ID */
|
||||
|
@ -276,7 +273,7 @@ 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->communicationID) || Match_BroadcastCommunicationID(pack->communicationID))) {
|
||||
if (HY_matchCommunicationID(pack->hardwareID) || Match_BroadcastCommunicationID(pack->hardwareID)) {
|
||||
if (flag_run < 2) {
|
||||
flag_run = 2;
|
||||
}
|
||||
|
@ -344,9 +341,9 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
else if (pack->controlWord == HY_configureHardwareID && hardwordIDType == 0x02) {
|
||||
len = HY_configHardwareID_PACK_SIZE;
|
||||
}
|
||||
else if (pack->controlWord == HY_hardwareID_communicationIDQuery && hardwordIDType == 0x01) {
|
||||
len = HY_QueryhardwareID_communicationID_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;
|
||||
}
|
||||
|
@ -372,7 +369,6 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
|
|||
if (flag_run < 4) {
|
||||
flag_run = 4;
|
||||
}
|
||||
log_info("Match_dataLen error: %x", len);
|
||||
log_info("Match_dataLen error: %x", (pack->dataLen[0] << 8 | pack->dataLen[1]) + 16);
|
||||
log_info("Match_dataLen error: %x", pack->dataLen[0]);
|
||||
log_info("Match_dataLen error: %x", pack->dataLen[1]);
|
||||
|
@ -461,24 +457,26 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
|
|||
pack.dataLen[0] = HY_batteryStatusResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_batteryStatusResponse_dataLen;
|
||||
|
||||
// pack.batteryVoltage = g_otherParameter.Battery_Voltage;
|
||||
|
||||
pack.batteryVoltage = 6.66;
|
||||
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 && g_otherParameter.Charg_Current > 0.05) {
|
||||
pack.chargSwitchStatus1 = HY_switchON;
|
||||
if (g_controlParameter.dutyRatio) {
|
||||
pack.chargSwitchStatus1 = 1;
|
||||
} else {
|
||||
pack.chargSwitchStatus1 = HY_switchOFF;
|
||||
pack.chargSwitchStatus1 = 0;
|
||||
}
|
||||
|
||||
pack.chargCurrent2 = pack.chargCurrent1;
|
||||
pack.openCircuitVoltage2 = pack.openCircuitVoltage1;
|
||||
pack.chargCurrent2 = g_otherParameter.Charg_Current;
|
||||
pack.openCircuitVoltage1 = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
|
||||
pack.chargSwitchStatus2 = pack.chargSwitchStatus1;
|
||||
if (g_controlParameter.dutyRatio) {
|
||||
pack.chargSwitchStatus2 = 1;
|
||||
} else {
|
||||
pack.chargSwitchStatus2 = 0;
|
||||
}
|
||||
|
||||
pack.Mos_Temperature = g_otherParameter.HighSideMos_Temperature;
|
||||
|
||||
|
@ -490,6 +488,7 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
|
|||
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);
|
||||
|
||||
|
@ -501,8 +500,8 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
|
|||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* 电量统计数据报 */
|
||||
|
@ -531,14 +530,6 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
pack.statisticalDuration = 0;
|
||||
pack.totalChargCapacity = g_otherParameter.totalChargCapacity;
|
||||
pack.totalElectricityConsumption = g_otherParameter.totalElectricityConsumption;
|
||||
|
||||
/* ²éѯºóÇå¿Õ */
|
||||
g_otherParameter.totalChargCapacity = 0;
|
||||
g_otherParameter.totalElectricityConsumption = 0;
|
||||
// saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
|
||||
savetotalChargCapacity(&g_otherParameter.totalChargCapacity);
|
||||
savetotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
|
||||
|
||||
HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg;
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
|
@ -546,8 +537,9 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
Delay_Ms(randomDelay());
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_electricityStatisticsResponse_PACK_SIZE);
|
||||
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
|
@ -557,7 +549,6 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
|
|||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,12 +601,13 @@ void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg,
|
|||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfigurationResponse_PACK_SIZE - 2);
|
||||
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_sensorNumberConfigurationResponse_PACK_SIZE);
|
||||
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
|
@ -625,7 +617,6 @@ void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg,
|
|||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,12 +660,13 @@ void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32
|
|||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberInquiryResponse_PACK_SIZE - 2);
|
||||
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_sensorNumberInquiryResponse_PACK_SIZE);
|
||||
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
|
@ -684,7 +676,6 @@ void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32
|
|||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,8 +725,9 @@ void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t
|
|||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
Delay_Ms(randomDelay());
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_resetInstructionResponse_PACK_SIZE);
|
||||
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
|
@ -744,7 +736,6 @@ void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t
|
|||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
|
||||
/* 复位 */
|
||||
|
@ -755,593 +746,107 @@ void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t
|
|||
/* 充电控制配置 */
|
||||
void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_chargingControlConfig *Tpack = (HY_chargingControlConfig *)pMsg;
|
||||
|
||||
if (Tpack->chargInterfaceControl == HY_switchON) {
|
||||
if (g_controlParameter.dutyRatio == 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (Tpack->chargInterfaceControl == HY_switchOFF) {
|
||||
if (g_controlParameter.dutyRatio != 0) {
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
TIM_SetCompare4(TIM4, 0);
|
||||
g_controlParameter.dutyRatio = 0;
|
||||
|
||||
TimeSliceOffset_Unregister(&g_collectOpenCircuitVoltage);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_chargingControlConfigResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/* 充电控制查询 */
|
||||
static void HY_MsgProcFunc_chargingControlQuery(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_QueryChargingControl *Tpack = (HY_QueryChargingControl *)pMsg;
|
||||
|
||||
HY_QueryChargingControlResponse 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_QueryChargingControlResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_QueryChargingControlResponse_dataLen;
|
||||
|
||||
if (g_controlParameter.dutyRatio > 0 && g_otherParameter.Charg_Current > 0.05) {
|
||||
pack.chargInterface1 = HY_switchON;
|
||||
} else {
|
||||
pack.chargInterface1 = HY_switchOFF;
|
||||
}
|
||||
|
||||
pack.chargInterface2 = pack.chargInterface1;
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryChargingControlResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_QueryChargingControlResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* 配置协议类型 */
|
||||
void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_configProtocolType *Tpack = (HY_configProtocolType *)pMsg;
|
||||
|
||||
g_otherParameter.protocolType = Tpack->protocolType;
|
||||
|
||||
config_info temp_configInfo;
|
||||
read_config_info(&temp_configInfo);
|
||||
temp_configInfo.protocolType = Tpack->protocolType;
|
||||
|
||||
temp_configInfo.crc = configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
|
||||
if (g_otherParameter.protocolType == 0x01) {
|
||||
g_otherParameter.gw485_Baud = 9600;
|
||||
} else if (g_otherParameter.protocolType == 0x02) {
|
||||
g_otherParameter.gw485_Baud = 115200;
|
||||
}
|
||||
|
||||
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 = HY_responseConfigureProtocolType;
|
||||
|
||||
pack.dataLen[0] = HY_configProtocolTypeResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_configProtocolTypeResponse_dataLen;
|
||||
|
||||
pack.state = HY_success;
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configProtocolTypeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_configProtocolTypeResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
|
||||
uart_dev_init();
|
||||
}
|
||||
|
||||
///* ÏìÓ¦ÅäÖÃÐÒéÀàÐÍ */
|
||||
//static void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t MsgLen);
|
||||
|
||||
/* 查询电池控制盒当前配置 */
|
||||
void HY_MsgProcFunc_queryControlBoxConfiguration(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_queryControlBoxConfigurationQuery *Tpack = (HY_queryControlBoxConfigurationQuery *)pMsg;
|
||||
|
||||
HY_queryControlBoxConfigurationResponse 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_queryControlBoxConfigurationResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_queryControlBoxConfigurationResponse_dataLen;
|
||||
|
||||
// pack.state = HY_success;
|
||||
pack.protocolType = g_otherParameter.protocolType;
|
||||
pack.voltageLevel = 0x00; //12V
|
||||
pack.mainBoardTemperatureSensorType = 0xFF;
|
||||
pack.batteryTemperatureSensorType = 0xFF;
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryControlBoxConfigurationResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
/* 查询电池控制盒软件版本 */
|
||||
void HY_MsgProcFunc_querySoftwareVersion(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_SoftwareVersionQuery *Tpack = (HY_SoftwareVersionQuery *)pMsg;
|
||||
|
||||
HY_SoftwareVersionQueryResponse 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_SoftwareVersionQueryResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_SoftwareVersionQueryResponse_dataLen;
|
||||
|
||||
strlcpy(pack.versionInformation, g_otherParameter.versionInformation, 13);
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_SoftwareVersionQueryResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_SoftwareVersionQueryResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
/* 进入配置模式 */
|
||||
void HY_MsgProcFunc_enterConfigurationMode(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_enterConfigMode *Tpack = (HY_enterConfigMode *)pMsg;
|
||||
|
||||
HY_enterConfigModeResponse 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_enterConfigModeResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_enterConfigModeResponse_dataLen;
|
||||
|
||||
pack.state = HY_success;
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_enterConfigModeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_enterConfigModeResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
|
||||
|
||||
TimeSliceOffset_Register(&g_configurationModeDelayedExit, Task_configurationModeDelayedExit
|
||||
, configurationModeDelayedExit_reloadVal, configurationModeDelayedExit_offset);
|
||||
g_otherParameter.HYconfigModeState = 0xFF;
|
||||
|
||||
}
|
||||
|
||||
/* 配置控制盒硬件ID号 */
|
||||
void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_configHardwareIDResponse pack;
|
||||
|
||||
HY_configHardwareID *Tpack = (HY_configHardwareID *)pMsg;
|
||||
if (g_otherParameter.HYconfigModeState == 0xFF) {
|
||||
g_otherParameter.hardwareID[0] = Tpack->hardwareID[0];
|
||||
g_otherParameter.hardwareID[1] = Tpack->hardwareID[1];
|
||||
g_otherParameter.hardwareID[2] = Tpack->hardwareID[2];
|
||||
g_otherParameter.hardwareID[3] = Tpack->hardwareID[3];
|
||||
g_otherParameter.hardwareID[4] = Tpack->hardwareID[4];
|
||||
g_otherParameter.hardwareID[5] = Tpack->hardwareID[5];
|
||||
|
||||
config_info temp_configInfo;
|
||||
read_config_info(&temp_configInfo);
|
||||
temp_configInfo.hardwareID[0] = Tpack->hardwareID[0];
|
||||
temp_configInfo.hardwareID[1] = Tpack->hardwareID[1];
|
||||
temp_configInfo.hardwareID[2] = Tpack->hardwareID[2];
|
||||
temp_configInfo.hardwareID[3] = Tpack->hardwareID[3];
|
||||
temp_configInfo.hardwareID[4] = Tpack->hardwareID[4];
|
||||
temp_configInfo.hardwareID[5] = Tpack->hardwareID[5];
|
||||
|
||||
temp_configInfo.crc = configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
|
||||
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_configHardwareIDResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_configHardwareIDResponse_dataLen;
|
||||
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configHardwareIDResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_configHardwareIDResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */
|
||||
void HY_MsgProcFunc_hardwareID_communicationIDQuery(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_QueryhardwareID_communicationID *Tpack = (HY_QueryhardwareID_communicationID *)pMsg;
|
||||
|
||||
HY_QueryhardwareID_communicationIDResponse 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_QueryhardwareID_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_QueryhardwareID_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_QueryhardwareID_communicationIDResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
/* 修改通信ID号(原传感器号) */
|
||||
void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_modifyCommunicationIDChangeResponse pack;
|
||||
|
||||
HY_modifyCommunicationIDChange *Tpack = (HY_modifyCommunicationIDChange *)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];
|
||||
|
||||
config_info temp_configInfo;
|
||||
read_config_info(&temp_configInfo);
|
||||
temp_configInfo.communicationID[0] = Tpack->newCommunicationID[0];
|
||||
temp_configInfo.communicationID[1] = Tpack->newCommunicationID[1];
|
||||
temp_configInfo.communicationID[2] = Tpack->newCommunicationID[2];
|
||||
temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3];
|
||||
|
||||
temp_configInfo.crc = configCheckFunc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2);
|
||||
save_config_info(&temp_configInfo);
|
||||
|
||||
pack.state = HY_success1;
|
||||
}
|
||||
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_modifyCommunicationIDChangeResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_modifyCommunicationIDChangeResponse_dataLen;
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_modifyCommunicationIDChangeResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
/* 查询主板温度值 */
|
||||
void HY_MsgProcFunc_checkMotherboardTemperature(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
HY_checkMotherboardTemperatureQuery *Tpack = (HY_checkMotherboardTemperatureQuery *)pMsg;
|
||||
|
||||
HY_checkMotherboardTemperatureResponse 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_checkMotherboardTemperatureResponse_dataLen >> 8;
|
||||
pack.dataLen[1] = HY_checkMotherboardTemperatureResponse_dataLen;
|
||||
|
||||
pack.MotherboardTemperature = g_otherParameter.HighSideMos_Temperature;
|
||||
|
||||
pack.frameNumber = Tpack->frameNumber;
|
||||
|
||||
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_checkMotherboardTemperatureResponse_PACK_SIZE - 2);
|
||||
pack.end_Flag = g_otherParameter.endFlagHY;
|
||||
|
||||
while (1) {
|
||||
if (!Check_485_bus_busy(device)) {
|
||||
uart_dev_write(device, &pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE);
|
||||
|
||||
if (device == g_bat485_uart3_handle) {
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
} else {
|
||||
USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
Delay_Ms(randomDelay());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -121,9 +121,9 @@ void checkFlashContent(void)
|
|||
.HighSideMosTemperature_stop = 100,
|
||||
.HighSideMosTemperature_end = 90,
|
||||
.HighSideMosTemperature_start = 50,
|
||||
// .loopImpedance = 0.0,
|
||||
// .totalElectricityConsumption = 0.0,
|
||||
// .totalChargCapacity = 0.0,
|
||||
.loopImpedance = 0.0,
|
||||
.totalElectricityConsumption = 0.0,
|
||||
.totalChargCapacity = 0.0,
|
||||
|
||||
.checkSolarOpenCircuitVTime = 10,
|
||||
// .registerRefreshTime = 1,
|
||||
|
@ -138,41 +138,41 @@ void checkFlashContent(void)
|
|||
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 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 读取配置文件初始化各参数
|
||||
|
@ -193,7 +193,7 @@ void config_info_start(void)
|
|||
g_controlParameter.stopSolarOpenCircuitV = temp_configInfo.stopSolarOpenCircuitV;
|
||||
g_controlParameter.constantVoltageChargeV = temp_configInfo.constantVoltageChargeV;
|
||||
g_controlParameter.FloatV = temp_configInfo.FloatChargeV;
|
||||
// g_controlParameter.loopImpedance = temp_configInfo.loopImpedance;
|
||||
g_controlParameter.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;
|
||||
|
@ -202,7 +202,6 @@ void config_info_start(void)
|
|||
g_controlParameter.outputAgainFlagTime = temp_configInfo.outputAgainFlagTime;
|
||||
g_controlParameter.excessiveLoadFlagTime = temp_configInfo.excessiveLoadFlagTime;
|
||||
g_controlParameter.eLAgainTime = temp_configInfo.eLAgainTime;
|
||||
g_controlParameter.collectOpenCircuitVoltageTime= 3600;
|
||||
|
||||
// strlcpy(g_otherParameter.address, temp_configInfo.address, 7);
|
||||
g_otherParameter.address[0] = temp_configInfo.address[0];
|
||||
|
@ -229,7 +228,6 @@ void config_info_start(void)
|
|||
g_otherParameter.communicationID[1] = temp_configInfo.communicationID[1];
|
||||
g_otherParameter.communicationID[2] = temp_configInfo.communicationID[2];
|
||||
g_otherParameter.communicationID[3] = temp_configInfo.communicationID[3];
|
||||
g_otherParameter.protocolType = temp_configInfo.protocolType;
|
||||
g_otherParameter.CommunicationProtocolType = temp_configInfo.CommunicationProtocolType;
|
||||
// g_otherParameter.CommunicationProtocolType = 0x01;
|
||||
g_otherParameter.onlyPower = temp_configInfo.onlyPower;
|
||||
|
@ -242,8 +240,8 @@ void config_info_start(void)
|
|||
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.totalElectricityConsumption = temp_configInfo.totalElectricityConsumption;
|
||||
g_otherParameter.totalChargCapacity = temp_configInfo.totalChargCapacity;
|
||||
g_otherParameter.SOC = 0;
|
||||
g_otherParameter.chargMos_State = 0;
|
||||
g_otherParameter.DischargMos_State = 0;
|
||||
|
@ -265,31 +263,23 @@ void config_info_start(void)
|
|||
g_otherParameter.overTemperature = 0;
|
||||
g_otherParameter.RegistrationRequestFlag = 0;
|
||||
g_otherParameter.runBroadcast = 1;
|
||||
g_otherParameter.RegisterNumberMax = 10;
|
||||
g_otherParameter.RegisterNumberMax = 5;
|
||||
g_otherParameter.RegisterStartAddressMax = 0x150;
|
||||
|
||||
g_otherParameter.HYconfigModeState = 0;
|
||||
g_otherParameter.HYconfigModeT = 0;
|
||||
|
||||
if (g_otherParameter.CommunicationProtocolType == 0x00) {
|
||||
g_otherParameter.gw485_Baud = temp_configInfo.gw485_Baud;
|
||||
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
|
||||
} else if (g_otherParameter.CommunicationProtocolType == 0x01) {
|
||||
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
|
||||
if (g_otherParameter.protocolType == 0x01) {
|
||||
if (temp_configInfo.protocolType == 0x01) {
|
||||
g_otherParameter.gw485_Baud = 9600;
|
||||
} else if (g_otherParameter.protocolType == 0x02) {
|
||||
} else if (temp_configInfo.protocolType == 0x02) {
|
||||
g_otherParameter.gw485_Baud = 115200;
|
||||
}
|
||||
}
|
||||
|
||||
readLoopImpedance(&g_controlParameter.loopImpedance);
|
||||
readtotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
|
||||
readtotalChargCapacity(&g_otherParameter.totalChargCapacity);
|
||||
|
||||
// printf("");
|
||||
|
||||
printf("%s\n", g_otherParameter.versionInformation);
|
||||
printf("address : 0x %x %x %x %x %x %x %x\n", g_otherParameter.address[0]
|
||||
, g_otherParameter.address[1], g_otherParameter.address[2], g_otherParameter.address[3]
|
||||
, g_otherParameter.address[4], g_otherParameter.address[5], g_otherParameter.address[6]);
|
||||
|
@ -522,35 +512,35 @@ void read_and_process_config_data(void)
|
|||
goto err;
|
||||
}
|
||||
|
||||
// /* 判断回路阻抗大小是否正确 */
|
||||
// save_configInfo.loopImpedance =
|
||||
// (float_t)(pack->loopImpedance[0] << 8 | pack->loopImpedance[1]) / enlargeScale / 10;
|
||||
//// memset(buffer, 0, sizeof(buffer));
|
||||
//// sprintf(buffer, " loopImpedance : %d/100 \n", (int)(save_configInfo.loopImpedance * 100));
|
||||
//// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
|
||||
// if (save_configInfo.loopImpedance > 1 || save_configInfo.loopImpedance < 0) {
|
||||
// goto err;
|
||||
// }
|
||||
//
|
||||
// /* 判断总电量消耗是否正确 */
|
||||
// save_configInfo.totalElectricityConsumption =
|
||||
// (float_t)(pack->totalElectricityConsumption[0] << 8 | pack->totalElectricityConsumption[1]) / enlargeScale;
|
||||
//// memset(buffer, 0, sizeof(buffer));
|
||||
//// sprintf(buffer, " totalElectricityConsumption : %d/100 \n", (int)(save_configInfo.totalElectricityConsumption * 100));
|
||||
//// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
|
||||
// if (save_configInfo.totalElectricityConsumption != 0) {
|
||||
// goto err;
|
||||
// }
|
||||
//
|
||||
// /* 判断总充电电量是否正确 */
|
||||
// save_configInfo.totalChargCapacity =
|
||||
// (float_t)(pack->totalChargCapacity[0] << 8 | pack->totalChargCapacity[1]) / enlargeScale;
|
||||
//// memset(buffer, 0, sizeof(buffer));
|
||||
//// sprintf(buffer, " totalChargCapacity : %d/100 \n", (int)(save_configInfo.totalChargCapacity * 100));
|
||||
//// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
|
||||
// if (save_configInfo.totalChargCapacity != 0) {
|
||||
// goto err;
|
||||
// }
|
||||
/* 判断回路阻抗大小是否正确 */
|
||||
save_configInfo.loopImpedance =
|
||||
(float_t)(pack->loopImpedance[0] << 8 | pack->loopImpedance[1]) / enlargeScale / 10;
|
||||
// memset(buffer, 0, sizeof(buffer));
|
||||
// sprintf(buffer, " loopImpedance : %d/100 \n", (int)(save_configInfo.loopImpedance * 100));
|
||||
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
|
||||
if (save_configInfo.loopImpedance > 1 || save_configInfo.loopImpedance < 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断总电量消耗是否正确 */
|
||||
save_configInfo.totalElectricityConsumption =
|
||||
(float_t)(pack->totalElectricityConsumption[0] << 8 | pack->totalElectricityConsumption[1]) / enlargeScale;
|
||||
// memset(buffer, 0, sizeof(buffer));
|
||||
// sprintf(buffer, " totalElectricityConsumption : %d/100 \n", (int)(save_configInfo.totalElectricityConsumption * 100));
|
||||
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
|
||||
if (save_configInfo.totalElectricityConsumption != 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断总充电电量是否正确 */
|
||||
save_configInfo.totalChargCapacity =
|
||||
(float_t)(pack->totalChargCapacity[0] << 8 | pack->totalChargCapacity[1]) / enlargeScale;
|
||||
// memset(buffer, 0, sizeof(buffer));
|
||||
// sprintf(buffer, " totalChargCapacity : %d/100 \n", (int)(save_configInfo.totalChargCapacity * 100));
|
||||
// uart_dev_write(g_gw485_uart4_handle, buffer, sizeof(buffer));
|
||||
if (save_configInfo.totalChargCapacity != 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */
|
||||
save_configInfo.checkSolarOpenCircuitVTime =
|
||||
|
@ -748,58 +738,6 @@ void read_and_process_config_data(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 保存回路阻抗在flash中
|
||||
* @param
|
||||
*/
|
||||
void saveLoopImpedance(float_t *loopImpedance)
|
||||
{
|
||||
SPI_Flash_Write((uint8_t *)loopImpedance, LoopImpedance_SAVE_addr, sizeof(float_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取flash中的回路阻抗
|
||||
* @param
|
||||
*/
|
||||
void readLoopImpedance(float_t *loopImpedance)
|
||||
{
|
||||
SPI_Flash_Read((uint8_t *)loopImpedance, LoopImpedance_SAVE_addr, sizeof(float_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 保存放电量在flash中
|
||||
* @param
|
||||
*/
|
||||
void savetotalElectricityConsumption(float_t *totalElectricityConsumption)
|
||||
{
|
||||
SPI_Flash_Write((uint8_t *)totalElectricityConsumption, totalElectricityConsumption_SAVE_addr, sizeof(float_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取flash中的放电量
|
||||
* @param
|
||||
*/
|
||||
void readtotalElectricityConsumption(float_t *totalElectricityConsumption)
|
||||
{
|
||||
SPI_Flash_Read((uint8_t *)totalElectricityConsumption, totalElectricityConsumption_SAVE_addr, sizeof(float_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 保存充电量在flash中
|
||||
* @param
|
||||
*/
|
||||
void savetotalChargCapacity(float_t *totalChargCapacity)
|
||||
{
|
||||
SPI_Flash_Write((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取flash中的充电量
|
||||
* @param
|
||||
*/
|
||||
void readtotalChargCapacity(float_t *totalChargCapacity)
|
||||
{
|
||||
SPI_Flash_Read((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float_t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -160,7 +160,6 @@ void MpptModeChoice(void)
|
|||
|
||||
TimeSliceOffset_Register(&g_startMpptControl, Task_startMpptControl
|
||||
, startMpptControl_reloadVal, startMpptControl_offset);
|
||||
TimeSliceOffset_Unregister(&g_collectOpenCircuitVoltage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -180,8 +179,7 @@ void MpptModeChoice(void)
|
|||
}
|
||||
|
||||
if ((g_controlParameter.constantVoltageV < g_otherParameter.Battery_Voltage)
|
||||
// && (g_controlParameter.floatI + 0.1 <= g_otherParameter.Charg_Current)) {
|
||||
&& ((g_controlParameter.floatI + 0.1 <= g_otherParameter.Charg_BatteryCurrent) || (g_controlParameter.floatI + 0.1 <= -g_otherParameter.Charg_Current))) {
|
||||
&& (g_controlParameter.floatI + 0.1 <= g_otherParameter.Charg_Current)) {
|
||||
g_otherParameter.MPPT_Mode = CONSTANTVOLTAGE;
|
||||
return;
|
||||
}
|
||||
|
@ -213,6 +211,11 @@ void MpptContorl(void)
|
|||
|
||||
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();
|
||||
|
|
|
@ -34,18 +34,13 @@ static void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg
|
|||
static void SL_MsgProcFunc_Update_Profile(device_handle device, void *pMsg, uint32_t MsgLen);
|
||||
static void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t MsgLen);
|
||||
|
||||
static uint16_t SL_ReadRegisterSolarOpenCircuitVoltage(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterBatteryVoltage(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterChargCurrent(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterDischargCurrent(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterSolarOpenCircuitVoltage(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterHighSideMosTemperature(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterSOC(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterChargState(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterTotalChargCapacity(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterTotalElectricityConsumption(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterMPPT_Mode(void *pMsg);
|
||||
|
||||
static uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterDischargMosState(void *pMsg);
|
||||
static uint16_t SL_ReadRegisterMPPTMode(void *pMsg);
|
||||
|
||||
/* 功能码处理表 */
|
||||
SL_FuncionMsgProcTable g_MsgTbl[] =
|
||||
|
@ -65,16 +60,13 @@ SL_RegProcTable g_RegTblR[] =
|
|||
// {SL_Register_address, SL_ReadRegisteraddress},
|
||||
// {SL_Register_Access_Node_Type, SL_ReadRegisterAccessNodeType},
|
||||
// {SL_Register_Communication_Methods, SL_ReadRegisterCommunicationMethods},
|
||||
{SL_Register_Solar_Open_Circuit_Voltage, SL_ReadRegisterSolarOpenCircuitVoltage},
|
||||
{SL_Register_Battery_Voltage, SL_ReadRegisterBatteryVoltage},
|
||||
{SL_Register_Charg_Current, SL_ReadRegisterChargCurrent},
|
||||
{SL_Register_Discharg_Current, SL_ReadRegisterDischargCurrent},
|
||||
{SL_Register_Solar_Open_Circuit_Voltage, SL_ReadRegisterSolarOpenCircuitVoltage},
|
||||
{SL_Register_HighSideMos_Temperature, SL_ReadRegisterHighSideMosTemperature},
|
||||
{SL_Register_SOC, SL_ReadRegisterSOC},
|
||||
{SL_Register_chargState, SL_ReadRegisterChargState},
|
||||
{SL_Register_totalChargCapacity, SL_ReadRegisterTotalChargCapacity},
|
||||
{SL_Register_totalElectricityConsumption, SL_ReadRegisterTotalElectricityConsumption},
|
||||
{SL_Register_MPPT_Mode, SL_ReadRegisterMPPT_Mode},
|
||||
{SL_Register_DischargMos_State, SL_ReadRegisterDischargMosState},
|
||||
{SL_Register_MPPT_Mode, SL_ReadRegisterMPPTMode},
|
||||
};
|
||||
|
||||
/* 寄存器处理表 */
|
||||
|
@ -89,7 +81,6 @@ SL_RegProcTable g_RegTblW[] =
|
|||
// {SL_Register_Remaining_Battery_Bower, SL_WriteRegisterRemainingBatteryBower},
|
||||
// {SL_Register_Solar_Open_Circuit_Voltage1, SL_WriteRegisterSolarOpenCircuitVoltage1},
|
||||
// {SL_Register_Solar_Open_Circuit_Voltage2, SL_WriteRegisterSolarOpenCircuitVoltage2},
|
||||
{SL_Register_eliminateStatistical, SL_WriteRegisterEliminateStatistical}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -401,19 +392,6 @@ void SL_MsgProcFunc_Remote_Upgrade(device_handle device, void *pMsg, uint32_t Ms
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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 读取电池电压寄存器
|
||||
* @param
|
||||
|
@ -451,7 +429,19 @@ uint16_t SL_ReadRegisterDischargCurrent(void *pMsg)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 读取mos管的温度寄存器
|
||||
* @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
|
||||
*/
|
||||
|
@ -463,95 +453,29 @@ uint16_t SL_ReadRegisterHighSideMosTemperature(void *pMsg)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 读取电池剩余电量
|
||||
* @brief 读取放电mos管状态寄存器
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_ReadRegisterSOC(void *pMsg)
|
||||
uint16_t SL_ReadRegisterDischargMosState(void *pMsg)
|
||||
{
|
||||
log_info(" SL_ReadRegisterSOC ");
|
||||
uint16_t value = (uint16_t)(1 * 10);
|
||||
log_info(" SL_ReadRegisterDischargMosState ");
|
||||
uint16_t value = (uint16_t)g_otherParameter.DischargMos_State;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取充放电状态
|
||||
* @brief 读取mppt工作模式寄存器
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_ReadRegisterChargState(void *pMsg)
|
||||
uint16_t SL_ReadRegisterMPPTMode(void *pMsg)
|
||||
{
|
||||
log_info(" SL_ReadRegisterChargState ");
|
||||
uint16_t value = 0;
|
||||
if (g_controlParameter.dutyRatio > 0 && g_otherParameter.Charg_Current > 0.05) {
|
||||
value |= 0xFF00;
|
||||
} else {
|
||||
value &= 0x00FF;
|
||||
}
|
||||
|
||||
if (g_otherParameter.DischargMos_State == Bit_SET && g_otherParameter.Discharg_Current > 0.05) {
|
||||
value |= 0x00FF;
|
||||
} else {
|
||||
value &= 0xFF00;
|
||||
}
|
||||
|
||||
log_info(" SL_ReadRegisterMPPTMode ");
|
||||
uint16_t value = (uint16_t)g_otherParameter.MPPT_Mode;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取总充电电量
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_ReadRegisterTotalChargCapacity(void *pMsg)
|
||||
{
|
||||
log_info(" SL_ReadRegisterTotalChargCapacity ");
|
||||
uint16_t value = (uint16_t)(g_otherParameter.totalChargCapacity * 1000);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取总消耗电量
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_ReadRegisterTotalElectricityConsumption(void *pMsg)
|
||||
{
|
||||
log_info(" SL_ReadRegisterTotalElectricityConsumption ");
|
||||
uint16_t value = (uint16_t)(g_otherParameter.totalElectricityConsumption * 1000);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取MPPT工作模式
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_ReadRegisterMPPT_Mode(void *pMsg)
|
||||
{
|
||||
log_info(" SL_ReadRegisterMPPT_Mode ");
|
||||
uint16_t value = (uint16_t)(g_otherParameter.MPPT_Mode);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清除总充电量和总消耗量
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg)
|
||||
{
|
||||
log_info(" SL_WriteRegisterEliminateStatistical ");
|
||||
g_otherParameter.totalChargCapacity = 0;
|
||||
g_otherParameter.totalElectricityConsumption = 0;
|
||||
// saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
|
||||
savetotalChargCapacity(&g_otherParameter.totalChargCapacity);
|
||||
savetotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 匹配起始标志"SL"
|
||||
* @param start_buff 起始标志
|
||||
|
@ -833,3 +757,21 @@ void read_and_process_uart_data(device_handle device)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
void Init()
|
||||
{
|
||||
SPI_Flash_Init();
|
||||
// SPI_Flash_Erase_Sector(0);
|
||||
currBuffInit();
|
||||
config_info_start();
|
||||
adcChangeProportionalInit();
|
||||
|
@ -47,8 +48,6 @@ void Init()
|
|||
POW_FF_CON_Init();
|
||||
DSG_PROT_Init();
|
||||
WORK_VOLT_INT_Init();
|
||||
|
||||
/* 1ms */
|
||||
TIM3_Init(10);
|
||||
|
||||
TimeSliceOffset_Register(&m_WdiRunled, Task_WdiRunled, WdiRunled_reloadVal, WdiRunled_offset);
|
||||
|
@ -88,8 +87,6 @@ void Task_WdiRunled(void)
|
|||
static uint32_t temp = wdi_RESET;
|
||||
if (!(--temp)) {
|
||||
temp = 0;
|
||||
savetotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
|
||||
savetotalChargCapacity(&g_otherParameter.totalChargCapacity);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
@ -105,8 +102,6 @@ void Task_WdiRunled(void)
|
|||
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, SET);
|
||||
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, RESET);
|
||||
|
||||
// printf(" vBattery : %d/100 \n", (int)(g_otherParameter.Battery_Voltage * 100));
|
||||
|
||||
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
|
||||
|
||||
char buffer[80];
|
||||
|
@ -192,16 +187,11 @@ void Task_refreshRegister(void)
|
|||
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
g_otherParameter.HighSideMos_Temperature = get_MOSFET_Temper();
|
||||
|
||||
if (g_controlParameter.dutyRatio == 0) {
|
||||
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
saveTotalPower(&g_otherParameter.totalElectricityConsumption, &g_otherParameter.totalChargCapacity);
|
||||
totalChargCapacity = 0;
|
||||
totalElectricityConsumption = 0;
|
||||
|
||||
|
@ -248,12 +238,12 @@ void Task_impedanceCalculation(void)
|
|||
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);
|
||||
|
@ -389,7 +379,8 @@ void Task_softStart(void)
|
|||
|
||||
if (g_otherParameter.batteryState == 1) {
|
||||
g_otherParameter.MPPT_Mode = CONSTANTCURRENT;
|
||||
goto start;
|
||||
TIM_Cmd(TIM3, ENABLE);
|
||||
return;
|
||||
} else {
|
||||
g_otherParameter.Charg_BatteryCurrent = g_otherParameter.Charg_Current
|
||||
- g_otherParameter.Discharg_Current;
|
||||
|
@ -397,14 +388,14 @@ void Task_softStart(void)
|
|||
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);
|
||||
|
||||
start:
|
||||
TIM_Cmd(TIM3, ENABLE);
|
||||
TimeSliceOffset_Register(&g_collectOpenCircuitVoltage, Task_collectOpenCircuitVoltage
|
||||
, collectOpenCircuitVoltage_reloadVal, collectOpenCircuitVoltage_offset);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -448,12 +439,6 @@ void Task_startMpptControl(void)
|
|||
STR_TimeSliceOffset g_dataJudgment;
|
||||
void Task_dataJudgment(void)
|
||||
{
|
||||
/* 判断有无电池 */
|
||||
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.impedanceStart == 1 || g_controlParameter.loopImpedance == 0.0)
|
||||
&& g_otherParameter.batteryState == 1 && (g_otherParameter.Charg_Current > 3.0)) {
|
||||
|
@ -638,55 +623,18 @@ void Task_uartConfigFile(void)
|
|||
read_and_process_config_data();
|
||||
}
|
||||
|
||||
///**
|
||||
// * @brief 过载延时
|
||||
// * @param
|
||||
// * @retval
|
||||
// *
|
||||
// */
|
||||
//STR_TimeSliceOffset g_overloadDelay;
|
||||
//void Task_overloadDelay(void)
|
||||
//{
|
||||
// TimeSliceOffset_Unregister(&g_overloadDelay);
|
||||
// g_overloadDelay.runFlag = 0;
|
||||
// WORK_VOLT_INT_open();
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief 系统启动后,通过该任务采集开路电压
|
||||
* @brief ¹ýÔØÑÓʱ
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
STR_TimeSliceOffset g_collectOpenCircuitVoltage;
|
||||
void Task_collectOpenCircuitVoltage(void)
|
||||
STR_TimeSliceOffset g_overloadDelay;
|
||||
void Task_overloadDelay(void)
|
||||
{
|
||||
static uint8_t flag = 0;
|
||||
g_otherParameter.collectOpenCircuitVoltageNUM++;
|
||||
if (g_otherParameter.collectOpenCircuitVoltageNUM == g_controlParameter.collectOpenCircuitVoltageTime) {
|
||||
if (g_otherParameter.batteryState) {
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
TIM_SetCompare4(TIM4, 0);
|
||||
g_controlParameter.dutyRatio = 0;
|
||||
flag = 1;
|
||||
g_collectOpenCircuitVoltage.count = 500;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
flag = 0;
|
||||
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
}
|
||||
TimeSliceOffset_Unregister(&g_overloadDelay);
|
||||
g_overloadDelay.runFlag = 0;
|
||||
WORK_VOLT_INT_open();
|
||||
}
|
||||
|
||||
STR_TimeSliceOffset g_configurationModeDelayedExit;
|
||||
void Task_configurationModeDelayedExit(void)
|
||||
{
|
||||
if (120 == ++g_otherParameter.HYconfigModeT) {
|
||||
g_otherParameter.HYconfigModeState = 0;
|
||||
g_otherParameter.HYconfigModeT = 0;
|
||||
TimeSliceOffset_Unregister(&g_configurationModeDelayedExit);
|
||||
g_configurationModeDelayedExit.runFlag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
|||
|
||||
void TIM1_UP_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
|
||||
/* delay_ms Ϊ0.1ms */
|
||||
|
||||
void TIM3_Init(uint16_t delay_ms)
|
||||
{
|
||||
/* 分频系数 */
|
||||
|
|
|
@ -1 +1 @@
|
|||
ENTRY( _start )
__stack_size = 2048;
PROVIDE( _stack_size = __stack_size );
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
/*
FLASH (rx) : ORIGIN = 0x00003750, LENGTH = 49K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
*/
}
SECTIONS
{
.init :
{
_sinit = .;
. = ALIGN(4);
KEEP(*(SORT_NONE(.init)))
. = ALIGN(4);
_einit = .;
} >FLASH AT>FLASH
.vector :
{
*(.vector);
. = ALIGN(64);
} >FLASH AT>FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text.*)
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.t.*)
. = ALIGN(4);
} >FLASH AT>FLASH
.fini :
{
KEEP(*(SORT_NONE(.fini)))
. = ALIGN(4);
} >FLASH AT>FLASH
PROVIDE( _etext = . );
PROVIDE( _eitcm = . );
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH AT>FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH AT>FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH AT>FLASH
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} >FLASH AT>FLASH
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} >FLASH AT>FLASH
.dalign :
{
. = ALIGN(4);
PROVIDE(_data_vma = .);
} >RAM AT>FLASH
.dlalign :
{
. = ALIGN(4);
PROVIDE(_data_lma = .);
} >FLASH AT>FLASH
.data :
{
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.sdata2.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
. = ALIGN(4);
PROVIDE( _edata = .);
} >RAM AT>FLASH
.bss :
{
. = ALIGN(4);
PROVIDE( _sbss = .);
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss*)
*(.gnu.linkonce.b.*)
*(COMMON*)
. = ALIGN(4);
PROVIDE( _ebss = .);
} >RAM AT>FLASH
PROVIDE( _end = _ebss);
PROVIDE( end = . );
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
{
PROVIDE( _heap_end = . );
. = ALIGN(4);
PROVIDE(_susrstack = . );
. = . + __stack_size;
PROVIDE( _eusrstack = .);
} >RAM
}
|
||||
ENTRY( _start )
__stack_size = 2048;
PROVIDE( _stack_size = __stack_size );
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
}
SECTIONS
{
.init :
{
_sinit = .;
. = ALIGN(4);
KEEP(*(SORT_NONE(.init)))
. = ALIGN(4);
_einit = .;
} >FLASH AT>FLASH
.vector :
{
*(.vector);
. = ALIGN(64);
} >FLASH AT>FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text.*)
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.t.*)
. = ALIGN(4);
} >FLASH AT>FLASH
.fini :
{
KEEP(*(SORT_NONE(.fini)))
. = ALIGN(4);
} >FLASH AT>FLASH
PROVIDE( _etext = . );
PROVIDE( _eitcm = . );
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH AT>FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH AT>FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH AT>FLASH
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} >FLASH AT>FLASH
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} >FLASH AT>FLASH
.dalign :
{
. = ALIGN(4);
PROVIDE(_data_vma = .);
} >RAM AT>FLASH
.dlalign :
{
. = ALIGN(4);
PROVIDE(_data_lma = .);
} >FLASH AT>FLASH
.data :
{
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.sdata2.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
. = ALIGN(4);
PROVIDE( _edata = .);
} >RAM AT>FLASH
.bss :
{
. = ALIGN(4);
PROVIDE( _sbss = .);
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss*)
*(.gnu.linkonce.b.*)
*(COMMON*)
. = ALIGN(4);
PROVIDE( _ebss = .);
} >RAM AT>FLASH
PROVIDE( _end = _ebss);
PROVIDE( end = . );
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
{
PROVIDE( _heap_end = . );
. = ALIGN(4);
PROVIDE(_susrstack = . );
. = . + __stack_size;
PROVIDE( _eusrstack = .);
} >RAM
}
|
|
@ -39,7 +39,5 @@ int main(void)
|
|||
printf("SystemClk:%d\r\n", SystemCoreClock);
|
||||
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID());
|
||||
|
||||
// Delay_Ms(10000);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
obj/User/main.o
BIN
obj/User/main.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
28310
obj/mppt_Nos_V0.4.lst
28310
obj/mppt_Nos_V0.4.lst
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue