mppt/App/inc/inflash.h

133 lines
6.4 KiB
C
Raw Permalink Normal View History

2024-07-11 06:58:55 +00:00
/*
* inflash.h
*
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>24<EFBFBD><EFBFBD>
* Author: psx
*/
#ifndef APP_INC_INFLASH_H_
#define APP_INC_INFLASH_H_
#include "debug.h"
#include "math.h"
2024-07-11 06:58:55 +00:00
2024-10-26 01:07:30 +00:00
#define softVer "SV01_24101501"
2024-07-11 06:58:55 +00:00
#pragma pack(push,1)
/* <20><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD>ں<EFBFBD> */
typedef struct _recv_config_info{
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
/* SL */
uint8_t address[7]; /* <20><>ַ */
uint8_t Access_Node_Type[2]; /* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> */
uint8_t Communication_Methods[2]; /* ͨ<>ŷ<EFBFBD>ʽ */
2024-10-26 01:07:30 +00:00
uint8_t gw485_Baud[4]; /* <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD> */
uint8_t bat485_Baud[4]; /* <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>,Ϊ0<CEAA><30><EFBFBD><EFBFBD>bms<6D><73>֧<EFBFBD><D6A7>ͨ<EFBFBD><CDA8> */
/* HY */
uint8_t hardwareID[6]; /* Ӳ<><D3B2>ID */
uint8_t communicationID[4]; /* ͨ<><CDA8>ID */
uint8_t protocolType; /* Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; 0x01<30><31>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ԴЭ<D4B4><D0AD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>9600) 0x02<30><32>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>115200)*/
uint8_t CommunicationProtocolType; /* 0x00:SL
0x01:HY*/
uint8_t onlyPower; /* <20>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD><E4B5B1>Դ<EFBFBD>壺0x00:<3A><><EFBFBD><EFBFBD>
0x01<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
uint8_t ConstantVoltageV[2]; /* <20><><EFBFBD>ڸ<EFBFBD>(<28><>ѹ / 100)<29>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FloatI * 100<30><30><EFBFBD>к<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> */
uint8_t FloatI[2]; /* <20><><EFBFBD>ڸ<EFBFBD>(<28><>ѹ / 100)<29>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FloatI * 100<30><30><EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
uint8_t startSolarOpenCircuitV[2]; /* <20><><EFBFBD>ڸ<EFBFBD>(<28><>ѹ / 100)<29><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> */
uint8_t stopSolarOpenCircuitV[2]; /* ̫<><CCAB><EFBFBD>ܰ忪·<E5BFAA><C2B7>ѹ<EFBFBD><D1B9><EFBFBD>ڸõ<DAB8>ѹֹͣ<CDA3><D6B9><EFBFBD><EFBFBD> (V) */
uint8_t constantVoltageChargeV[2]; /* <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ (V) */
uint8_t FloatChargeV[2]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ (V) */
uint8_t HighSideMosTemperature_stop[2]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȴﵽ<C8B4><EFB5BD>ֵʱ<D6B5><CAB1>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD> (<28><>C) */
uint8_t HighSideMosTemperature_end[2]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD><EFBFBD>͹<EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><>C) */
uint8_t HighSideMosTemperature_start[2];/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶Ƚ<C2B6><C8BD>͵<EFBFBD><CDB5><EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><>C) */
2024-11-08 08:51:14 +00:00
// uint8_t loopImpedance[2]; /* <20><>·<EFBFBD><EFBFBD><E8BFB9>С (<28><>) */
// uint8_t totalElectricityConsumption[2]; /* <20>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
// uint8_t totalChargCapacity[2]; /* <20>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
uint8_t checkSolarOpenCircuitVTime[2]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB><EFBFBD>ܰ忪·<E5BFAA><C2B7>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> (S) */
// uint8_t registerRefreshTime[2]; /* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>ʱ<EFBFBD><CAB1> (S) */
uint8_t sensorEnableBroadcastTime[2]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> (S) */
uint8_t outputAgainFlagTime[2]; /* <20><><EFBFBD>ֶ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ٴμ<D9B4><CEBC><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>·<EFBFBD><C2B7><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD> (S) */
uint8_t excessiveLoadFlagTime[2]; /* <20><><EFBFBD>ֹ<EFBFBD><D6B9>غ<EFBFBD><D8BA><EFBFBD><EFBFBD>ڸü<DAB8><C3BC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD><D0B6>Σ<EFBFBD>2<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>أ<EFBFBD><D8A3><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD> (S) */
uint8_t eLAgainTime[2]; /* <20><><EFBFBD>ֹ<EFBFBD><D6B9>ع<EFBFBD><D8B9>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸü<DAB8><C3BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴγ<D9B4><CEB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (S) */
uint8_t crc[2]; /* У<><D0A3> */
uint8_t end_Flag; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
}recv_config_info;
#define RECV_CONFIG_INFO sizeof(recv_config_info)
2024-08-29 02:50:22 +00:00
2024-07-11 06:58:55 +00:00
typedef struct _config_info{
/* SL */
uint8_t address[7]; /* <20><>ַ */
uint16_t Access_Node_Type; /* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> */
uint16_t Communication_Methods; /* ͨ<>ŷ<EFBFBD>ʽ */
uint32_t gw485_Baud; /* <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>,Ϊ0<CEAA><30><EFBFBD><EFBFBD>bms<6D><73>֧<EFBFBD><D6A7>ͨ<EFBFBD><CDA8> */
uint32_t bat485_Baud; /* <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD> */
/* HY */
uint8_t hardwareID[6]; /* Ӳ<><D3B2>ID */
uint8_t communicationID[4]; /* ͨ<><CDA8>ID */
uint8_t protocolType; /* Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; 0x01<30><31>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ԴЭ<D4B4><D0AD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>9600) 0x02<30><32>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>115200)*/
uint8_t CommunicationProtocolType; /* 0x00:SL
0x01:HY*/
uint8_t onlyPower; /* <20>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD><E4B5B1>Դ<EFBFBD>壺0x00:<3A><><EFBFBD><EFBFBD>
0x01<EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
float_t constantVoltageV; /* <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ConstantVoltageV<65>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FloatI + 0.1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
float_t floatI; /* <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ConstantVoltageV<65>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FloatI<74><49><EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
float_t startSolarOpenCircuitV; /* ̫<><CCAB><EFBFBD>ܰ忪·<E5BFAA><C2B7>ѹ<EFBFBD><D1B9><EFBFBD>ڸõ<DAB8>ѹ<EFBFBD><D1B9>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> */
float_t stopSolarOpenCircuitV; /* ̫<><CCAB><EFBFBD>ܰ忪·<E5BFAA><C2B7>ѹ<EFBFBD><D1B9><EFBFBD>ڸõ<DAB8>ѹ ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD> */
float_t constantVoltageChargeV; /* <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ */
float_t FloatChargeV; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ */
float_t HighSideMosTemperature_stop; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶ȴﵽ<C8B4><EFB5BD>ֵʱ<D6B5><CAB1>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD> */
float_t HighSideMosTemperature_end; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD><EFBFBD>͹<EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
float_t HighSideMosTemperature_start; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶Ƚ<C2B6><C8BD>͵<EFBFBD><CDB5><EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2024-11-08 08:51:14 +00:00
// float_t loopImpedance; /* <20><>·<EFBFBD><EFBFBD><E8BFB9>С (<28><>) */
// float_t totalElectricityConsumption; /* <20>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
// float_t totalChargCapacity; /* <20>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2024-08-29 02:50:22 +00:00
uint16_t checkSolarOpenCircuitVTime; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB><EFBFBD>ܰ忪·<E5BFAA><C2B7>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> */
// uint16_t registerRefreshTime; /* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>ʱ<EFBFBD><CAB1> */
2024-08-29 02:50:22 +00:00
uint16_t sensorEnableBroadcastTime; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> */
uint16_t outputAgainFlagTime; /* <20><><EFBFBD>ֶ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ٴμ<D9B4><CEBC><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>·<EFBFBD><C2B7><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD> */
uint16_t excessiveLoadFlagTime; /* <20><><EFBFBD>ֹ<EFBFBD><D6B9>غ<EFBFBD><D8BA><EFBFBD><EFBFBD>ڸö<DAB8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ٴγ<D9B4><CEB3>ֹ<EFBFBD><D6B9>أ<EFBFBD><D8A3><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD> */
uint16_t eLAgainTime; /* <20><><EFBFBD>ֹ<EFBFBD><D6B9>ع<EFBFBD><D8B9>ر<EFBFBD><D8B1><EFBFBD><EFBFBD>󣬸ö<F3A3ACB8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴγ<D9B4><CEB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
uint16_t crc; /* У<><D0A3> */
2024-07-11 06:58:55 +00:00
}config_info;
2024-07-11 06:58:55 +00:00
#define CONFIG_INFO_SIZE (sizeof(config_info))
#pragma pack(pop)
2024-11-08 08:51:14 +00:00
#define CONFIG_SAVE_addr (0)
#define CONFIG_SAVE_ADDR_BEGIN (CONFIG_INFO_SIZE)
#define CONFIG_SAVE_ADDR_END (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE)
#define LoopImpedance_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 10)
#define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20)
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
void save_config_info(config_info *save_config_info);
void read_config_info(config_info *output_config_info);
void checkFlashContent(void);
void config_info_start(void);
void read_and_process_config_data(void);
2024-07-11 06:58:55 +00:00
2024-11-08 08:51:14 +00:00
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);
2024-10-26 01:07:30 +00:00
extern uint16_t configCheckFunc(uint8_t *arr_buff, uint8_t len);
2024-07-11 06:58:55 +00:00
#endif /* APP_INC_INFLASH_H_ */