2024-07-11 06:58:55 +00:00
|
|
|
|
/*
|
|
|
|
|
* inflash.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>24<EFBFBD><EFBFBD>
|
|
|
|
|
* Author: psx
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "inflash.h"
|
|
|
|
|
#include "flash.h"
|
2024-08-29 02:50:22 +00:00
|
|
|
|
#include "sl_protocol.h"
|
2024-07-11 06:58:55 +00:00
|
|
|
|
|
|
|
|
|
config_info g_slConfigInfo = {
|
2024-08-29 02:50:22 +00:00
|
|
|
|
.constantCurrentV = 1000,
|
2024-09-21 03:00:09 +00:00
|
|
|
|
.constantVoltageV = 1400,
|
2024-09-20 07:04:41 +00:00
|
|
|
|
.floatI = 20,
|
2024-08-29 02:50:22 +00:00
|
|
|
|
.startSolarOpenCircuitV = 1700,
|
|
|
|
|
.stopSolarOpenCircuitV = 1500,
|
2024-09-18 01:47:44 +00:00
|
|
|
|
.constantVoltageChargeV = 1440,
|
|
|
|
|
.trickleChargeC = 100,
|
2024-09-20 07:04:41 +00:00
|
|
|
|
// .FloatTime = 10,
|
|
|
|
|
.FloatV = 1420,
|
2024-08-29 02:50:22 +00:00
|
|
|
|
.checkSolarOpenCircuitVTime = 10,
|
|
|
|
|
.registerRefreshTime = 1,
|
2024-09-20 07:04:41 +00:00
|
|
|
|
.loopImpedance = 20,
|
|
|
|
|
// .resRefreshTime = 1,
|
2024-08-29 02:50:22 +00:00
|
|
|
|
.sensorEnableBroadcastTime = 20,
|
2024-08-29 09:24:57 +00:00
|
|
|
|
.HighSideMosTemperature_stop = 70,
|
|
|
|
|
.HighSideMosTemperature_end = 50,
|
|
|
|
|
.HighSideMosTemperature_start = 40,
|
2024-07-11 06:58:55 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param save_config_info <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void save_config_info(config_info save_config_info)
|
|
|
|
|
{
|
|
|
|
|
SPI_Flash_Write((uint8_t *)&save_config_info, FLASH_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param read_config_info <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @retval 0 flash<EFBFBD>ж<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
|
|
|
|
|
* 1 flash<EFBFBD>ж<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>óɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
uint8_t read_config_info(void)
|
|
|
|
|
{
|
|
|
|
|
config_info temp_config_info;
|
|
|
|
|
SPI_Flash_Read((uint8_t *)&temp_config_info, FLASH_SAVE_ADDR_BEGIN, CONFIG_INFO_SIZE);
|
2024-08-29 02:50:22 +00:00
|
|
|
|
if (temp_config_info.start_Flag[0] == 'S'
|
|
|
|
|
&& temp_config_info.start_Flag[1] == 'L'
|
|
|
|
|
&& temp_config_info.end_Flag == 0x16) {
|
2024-07-11 06:58:55 +00:00
|
|
|
|
g_slConfigInfo = temp_config_info;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2024-08-29 02:50:22 +00:00
|
|
|
|
else {
|
|
|
|
|
g_slConfigInfo.start_Flag[0] = defaultValue.start_Flag[0];
|
|
|
|
|
g_slConfigInfo.start_Flag[1] = defaultValue.start_Flag[1];
|
|
|
|
|
g_slConfigInfo.address[0] = defaultValue.address[0];
|
|
|
|
|
g_slConfigInfo.address[1] = defaultValue.address[1];
|
|
|
|
|
g_slConfigInfo.address[2] = defaultValue.address[2];
|
|
|
|
|
g_slConfigInfo.address[3] = defaultValue.address[3];
|
|
|
|
|
g_slConfigInfo.address[4] = defaultValue.address[4];
|
|
|
|
|
g_slConfigInfo.address[5] = defaultValue.address[5];
|
|
|
|
|
g_slConfigInfo.address[6] = defaultValue.address[6];
|
|
|
|
|
g_slConfigInfo.end_Flag = defaultValue.end_Flag;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 06:58:55 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|