spi读写过慢
This commit is contained in:
parent
d6f0e84c3f
commit
55811f0946
|
@ -64,12 +64,10 @@ void start(void)
|
||||||
startInfo();
|
startInfo();
|
||||||
|
|
||||||
// HAL_Delay(5000);
|
// HAL_Delay(5000);
|
||||||
// while (1) {
|
while (1) {
|
||||||
// cfgTest();
|
cfgTest();
|
||||||
// HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TimeSliceOffset_Start();
|
TimeSliceOffset_Start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,15 @@ typedef struct _config_info{
|
||||||
|
|
||||||
uint16_t crc; /* 校验 */
|
uint16_t crc; /* 校验 */
|
||||||
}config_info;
|
}config_info;
|
||||||
|
|
||||||
#define CONFIG_INFO_SIZE (sizeof(config_info))
|
#define CONFIG_INFO_SIZE (sizeof(config_info))
|
||||||
|
// typedef struct _other_info {
|
||||||
|
// float loopImpedance;
|
||||||
|
// float totalElectricityConsumption;
|
||||||
|
// float totalChargCapacity;
|
||||||
|
// float lastTime;
|
||||||
|
// }other_info;
|
||||||
|
// #define OTHER_INFO_SIZE (sizeof(other_info))
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#define CONFIG_SAVE_addr (0)
|
#define CONFIG_SAVE_addr (0)
|
||||||
|
@ -128,6 +135,12 @@ typedef struct _config_info{
|
||||||
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
|
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
|
||||||
#define time_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 40)
|
#define time_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 40)
|
||||||
|
|
||||||
|
// #define LoopImpedance_SAVE_addr (4096)
|
||||||
|
// #define totalElectricityConsumption_SAVE_addr (LoopImpedance_SAVE_addr + 4)
|
||||||
|
// #define totalChargCapacity_SAVE_addr (LoopImpedance_SAVE_addr + 8)
|
||||||
|
// #define time_SAVE_addr (LoopImpedance_SAVE_addr + 12)
|
||||||
|
|
||||||
|
|
||||||
// void save_config_info(config_info *save_config_info);
|
// void save_config_info(config_info *save_config_info);
|
||||||
void read_config_info(config_info *output_config_info);
|
void read_config_info(config_info *output_config_info);
|
||||||
void saveConfigInfo(config_info *config_info);
|
void saveConfigInfo(config_info *config_info);
|
||||||
|
@ -143,6 +156,8 @@ void savetotalChargCapacity(float *totalChargCapacity);
|
||||||
void readtotalChargCapacity(float *totalChargCapacity);
|
void readtotalChargCapacity(float *totalChargCapacity);
|
||||||
void saveTime(timeInfo *time);
|
void saveTime(timeInfo *time);
|
||||||
void readTime(timeInfo *time);
|
void readTime(timeInfo *time);
|
||||||
|
// void saveOtherInfo(other_info *otherInfo);
|
||||||
|
// void readOtherInfo(other_info *otherInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -268,11 +268,11 @@ BOOL getExcessiveLoadFlag(void)
|
||||||
// temp_PV_VOLT_OUT = get_PV_VOLT_OUT();
|
// temp_PV_VOLT_OUT = get_PV_VOLT_OUT();
|
||||||
// temp_OUT_VOLT_IN = get_OUT_VOLT_IN();
|
// temp_OUT_VOLT_IN = get_OUT_VOLT_IN();
|
||||||
if (state == TRUE) {
|
if (state == TRUE) {
|
||||||
if (get_OUT_VOLT_IN() < (get_PV_VOLT_OUT() - 0.1f)) {
|
// if (get_OUT_VOLT_IN() < (get_PV_VOLT_OUT() - 0.1f)) {
|
||||||
// if (temp_OUT_VOLT_IN < (temp_PV_VOLT_OUT - 0.5f)) {
|
// if (temp_OUT_VOLT_IN < (temp_PV_VOLT_OUT - 0.5f)) {
|
||||||
POW_FF_PCON_Open();
|
POW_FF_PCON_Open();
|
||||||
POW_OUT_PCON_Open();
|
POW_OUT_PCON_Open();
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
POW_FF_PCON_Close();
|
POW_FF_PCON_Close();
|
||||||
POW_OUT_PCON_Close();
|
POW_OUT_PCON_Close();
|
||||||
|
|
|
@ -55,19 +55,19 @@ void saveConfigInfo(config_info *configInfo)
|
||||||
|
|
||||||
void cfgTest(void)
|
void cfgTest(void)
|
||||||
{
|
{
|
||||||
uint32_t tempTime = HAL_GetTick();
|
// uint32_t tempTime = HAL_GetTick();
|
||||||
config_info temp_configInfo;
|
// config_info temp_configInfo;
|
||||||
read_config_info(&temp_configInfo);
|
// read_config_info(&temp_configInfo);
|
||||||
log_info("1 read time : %d \n", HAL_GetTick() - tempTime);
|
// log_info("1 read time : %d \n", HAL_GetTick() - tempTime);
|
||||||
tempTime = HAL_GetTick();
|
// tempTime = HAL_GetTick();
|
||||||
saveConfigInfo(&temp_configInfo);
|
// saveConfigInfo(&temp_configInfo);
|
||||||
log_info("1 write time : %d \n", HAL_GetTick() - tempTime);
|
// log_info("1 write time : %d \n", HAL_GetTick() - tempTime);
|
||||||
tempTime = HAL_GetTick();
|
// tempTime = HAL_GetTick();
|
||||||
for (int i = 0; i < 10; i++) {
|
// for (int i = 0; i < 10; i++) {
|
||||||
read_config_info(&temp_configInfo);
|
// read_config_info(&temp_configInfo);
|
||||||
saveConfigInfo(&temp_configInfo);
|
// saveConfigInfo(&temp_configInfo);
|
||||||
}
|
// }
|
||||||
log_info("10 time : %d \n", HAL_GetTick() - tempTime);
|
// log_info("10 time : %d \n", HAL_GetTick() - tempTime);
|
||||||
|
|
||||||
// uint32_t tempTime = HAL_GetTick();
|
// uint32_t tempTime = HAL_GetTick();
|
||||||
// float tempF;
|
// float tempF;
|
||||||
|
@ -97,20 +97,20 @@ void cfgTest(void)
|
||||||
// }
|
// }
|
||||||
// log_info("10 time : %d \n", HAL_GetTick() - tempTime);
|
// log_info("10 time : %d \n", HAL_GetTick() - tempTime);
|
||||||
|
|
||||||
// uint32_t tempTime = HAL_GetTick();
|
uint32_t tempTime = HAL_GetTick();
|
||||||
// uint8_t tempBuf[30];
|
uint8_t tempBuf[30];
|
||||||
// write_Flash((uint8_t *)"hello 12345\n", 2048, sizeof("hello 12345\n"));
|
write_Flash((uint8_t *)"hello 12345\n", 2048, sizeof("hello 12345\n"));
|
||||||
// log_info("1 write time : %d \n", HAL_GetTick() - tempTime);
|
log_info("1 write time : %d \n", HAL_GetTick() - tempTime);
|
||||||
// tempTime = HAL_GetTick();
|
tempTime = HAL_GetTick();
|
||||||
// read_Flash(tempBuf, 2048, sizeof("hello world\n"));
|
read_Flash(tempBuf, 2048, sizeof("hello 12345\n"));
|
||||||
// log_info("1 read time : %d \n", HAL_GetTick() - tempTime);
|
log_info("1 read time : %d \n", HAL_GetTick() - tempTime);
|
||||||
// log_info("%s\n", tempBuf);
|
log_info("%s\n", tempBuf);
|
||||||
// tempTime = HAL_GetTick();
|
tempTime = HAL_GetTick();
|
||||||
// for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
// read_Flash(tempBuf, 2048, sizeof("hello world\n"));
|
read_Flash(tempBuf, 2048, sizeof("hello world\n"));
|
||||||
// write_Flash((uint8_t *)"hello world\n", 2048, sizeof("hello world\n"));
|
write_Flash((uint8_t *)"hello world\n", 2048, sizeof("hello world\n"));
|
||||||
// }
|
}
|
||||||
// log_info("10 time : %d \n", HAL_GetTick() - tempTime);
|
log_info("10 time : %d \n", HAL_GetTick() - tempTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -365,5 +365,13 @@ void readTime(timeInfo *time)
|
||||||
read_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
|
read_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void saveOtherInfo(other_info *otherInfo)
|
||||||
|
// {
|
||||||
|
// write_Flash((uint8_t *)otherInfo, LoopImpedance_SAVE_addr, sizeof(OTHER_INFO_SIZE));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void readOtherInfo(other_info *otherInfo)
|
||||||
|
// {
|
||||||
|
// read_Flash((uint8_t *)otherInfo, LoopImpedance_SAVE_addr, sizeof(OTHER_INFO_SIZE));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
|
@ -469,6 +469,9 @@ float get_OUT_VOLT_IN(void)
|
||||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
||||||
{
|
{
|
||||||
if (hdma->Instance == ADC1) {
|
if (hdma->Instance == ADC1) {
|
||||||
|
// HAL_GPIO_TogglePin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
|
||||||
|
HAL_GPIO_WritePin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin,GPIO_PIN_SET);
|
||||||
|
|
||||||
setSoftShortCircuit(adcBuff[DSG_CURR_NUM]);
|
setSoftShortCircuit(adcBuff[DSG_CURR_NUM]);
|
||||||
|
|
||||||
WORK_VOLT_capture.totalInData -= WORK_VOLT_capture.inData16[pointer];
|
WORK_VOLT_capture.totalInData -= WORK_VOLT_capture.inData16[pointer];
|
||||||
|
@ -500,6 +503,9 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
||||||
DSG_CURR_capture.IODataF[3] = (float32_t)DSG_CURR_capture.totalInData / indata16_size;
|
DSG_CURR_capture.IODataF[3] = (float32_t)DSG_CURR_capture.totalInData / indata16_size;
|
||||||
PV_VOLT_IN_capture.IODataF[3] = (float32_t)PV_VOLT_IN_capture.totalInData / indata16_size;
|
PV_VOLT_IN_capture.IODataF[3] = (float32_t)PV_VOLT_IN_capture.totalInData / indata16_size;
|
||||||
CHG_CURR_capture.IODataF[3] = (float32_t)CHG_CURR_capture.totalInData / indata16_size;
|
CHG_CURR_capture.IODataF[3] = (float32_t)CHG_CURR_capture.totalInData / indata16_size;
|
||||||
|
|
||||||
|
// HAL_GPIO_TogglePin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
|
||||||
|
HAL_GPIO_WritePin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin,GPIO_PIN_RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ static void Flash_WriteOneByte(uint8_t DataBuffer)
|
||||||
}
|
}
|
||||||
FLASH_CLK_LOW;
|
FLASH_CLK_LOW;
|
||||||
FLASH_MOSI_HIGH; //一字节数据传送完毕,MOSI数据线置高表示空闲状态
|
FLASH_MOSI_HIGH; //一字节数据传送完毕,MOSI数据线置高表示空闲状态
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///@brief 写指令
|
///@brief 写指令
|
||||||
|
|
Loading…
Reference in New Issue