diff --git a/APP/application/Src/start.c b/APP/application/Src/start.c
index a7e0b76..23ad8f6 100644
--- a/APP/application/Src/start.c
+++ b/APP/application/Src/start.c
@@ -76,8 +76,10 @@ void start(void)
// HAL_Delay(1000);
// }
/* 启动事件 */
+ // HAL_Delay(8000);
insertEventsOrderRecord(startEvent);
+ // log_info(" CSR = %x\n", RCC->CSR);
+
TimeSliceOffset_Start();
}
-
diff --git a/APP/businessLogic/Inc/task.h b/APP/businessLogic/Inc/task.h
index bbd4f11..d3e67d9 100644
--- a/APP/businessLogic/Inc/task.h
+++ b/APP/businessLogic/Inc/task.h
@@ -4,6 +4,10 @@
#include "timeSliceOffset.h"
+// extern STR_TimeSliceOffset g_SOE_flag;
+// extern void Task_SOE_flag(void);
+
+
void task_Init(void);
diff --git a/APP/businessLogic/Src/SOE.c b/APP/businessLogic/Src/SOE.c
index aafb09e..7421e46 100644
--- a/APP/businessLogic/Src/SOE.c
+++ b/APP/businessLogic/Src/SOE.c
@@ -5,9 +5,13 @@
#include "FM_RTC.h"
#include "flash.h"
#include "capture.h"
+#include "task.h"
#define eventsOrderRecordStartAddr 4096
+// /* 用于标记SOE擦除 */
+// static uint8_t soeFlag = 0;
+
typedef struct _soeDataInfo {
uint16_t mode; //故障类型 2byte
timeInfo time; //时间 6byte
@@ -28,13 +32,14 @@ typedef struct _soeSaveInfo {
typedef struct _soeStorageParameters {
uint16_t len; //soe下次记录距离0的偏移量
uint16_t pos; //下次soe记录的位置
+ uint32_t dataLen; //soe数据总个数
} soeStorageParameters;
static soeSaveInfo soeInfo = {0};
static soeStorageParameters soeParameters = {0};
/**
- * @brief 得到一次时间记录的长度
+ * @brief 得到一次事件记录的长度
* @param
*/
uint16_t getSoeDataInfoSize(void)
@@ -53,6 +58,7 @@ void eventsOrderRecordStartInit(void)
if (soeParameters.len == 0xFFFF && soeParameters.pos == 0xFFFF) {
soeParameters.len = 0;
soeParameters.pos = eventsOrderRecordStartAddr + sizeof(soeParameters);
+ soeParameters.dataLen = 0;
write_Flash((uint8_t *)(&soeParameters), eventsOrderRecordStartAddr, sizeof(soeParameters));
}
@@ -60,6 +66,7 @@ void eventsOrderRecordStartInit(void)
|| soeParameters.pos != eventsOrderRecordStartAddr + sizeof(soeParameters) + soeParameters.len * soeDataInfoSize) {
soeParameters.len = 0;
soeParameters.pos = eventsOrderRecordStartAddr + sizeof(soeParameters);
+ soeParameters.dataLen = 0;
write_Flash((uint8_t *)(&soeParameters), eventsOrderRecordStartAddr, sizeof(soeParameters));
}
@@ -68,6 +75,8 @@ void eventsOrderRecordStartInit(void)
soeInfo.outPos = 0;
soeInfo.outData = NULL;
soeInfo.insertData = &soeInfo.data[soeInfo.insertPos];
+
+ // soeFlag = 1;
}
/**
@@ -169,7 +178,7 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode)
} else {
soeInfo.insertData = &soeInfo.data[soeInfo.insertPos];
}
-
+
soeInfo.outData = &soeInfo.data[soeInfo.outPos];
}
@@ -181,9 +190,15 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode)
void setEventsOrderRecord(void)
{
if (soeInfo.outData == NULL || soeInfo.count >= 5) {
+ soeInfo.outData = NULL;
+ soeInfo.count = 5;
return;
}
+ // if (soeFlag == 0) {
+ // return;
+ // }
+
write_Flash((uint8_t *)(soeInfo.outData), soeParameters.pos, soeDataInfoSize);
// read_Flash((uint8_t *)(soeInfo.outData), eventsOrderRecordStartAddr, sizeof(soeStorageParameters));
@@ -198,8 +213,11 @@ void setEventsOrderRecord(void)
soeParameters.len++;
if (soeParameters.len >= 100) {
soeParameters.len = 0;
- }
- soeParameters.pos += soeDataInfoSize;
+ soeParameters.pos = eventsOrderRecordStartAddr + sizeof(soeParameters);
+ } else {
+ soeParameters.pos += soeDataInfoSize;
+ }
+ soeParameters.dataLen++;
write_Flash((uint8_t *)(&soeParameters), eventsOrderRecordStartAddr, sizeof(soeStorageParameters));
soeInfo.outPos++;
@@ -227,8 +245,20 @@ void setEventsOrderRecord(void)
void readEventsOrderRecord(uint16_t offset, uint8_t *data)
{
+ // if (soeFlag == 0) {
+ // return;
+ // }
+
uint16_t addr;
+ if (offset > soeParameters.dataLen) {
+ for (size_t i = 0; i < soeDataInfoSize; i++) {
+ data[i] = 0;
+ }
+
+ return;
+ }
+
if (soeParameters.len - offset < 0) {
addr = eventsOrderRecordStartAddr + sizeof(soeStorageParameters)
+ (100 + soeParameters.len - offset) * soeDataInfoSize;
@@ -236,7 +266,7 @@ void readEventsOrderRecord(uint16_t offset, uint8_t *data)
addr = eventsOrderRecordStartAddr + sizeof(soeStorageParameters)
+ (soeParameters.len - offset) * soeDataInfoSize;
}
-
+
read_Flash(data, addr, soeDataInfoSize);
}
@@ -247,8 +277,25 @@ void readEventsOrderRecord(uint16_t offset, uint8_t *data)
*/
void cleanEventsOrderRecord(void)
{
- erase_Sector_Flash((eventsOrderRecordStartAddr / 4096));
+ // soeFlag = 0;
+ // erase_Sector_Flash((eventsOrderRecordStartAddr / 4096));
+
soeParameters.len = 0;
+ soeParameters.dataLen = 0;
soeParameters.pos = eventsOrderRecordStartAddr + sizeof(soeParameters);
write_Flash((uint8_t *)(&soeParameters), eventsOrderRecordStartAddr, sizeof(soeParameters));
+
+ // TimeSliceOffset_Register(&g_SOE_flag, Task_SOE_flag, uart_reloadVal, uart_offset);
}
+
+// extern STR_TimeSliceOffset g_SOE_flag;
+// void Task_SOE_flag(void)
+// {
+// soeParameters.len = 0;
+// soeParameters.pos = eventsOrderRecordStartAddr + sizeof(soeParameters);
+// write_Flash((uint8_t *)(&soeParameters), eventsOrderRecordStartAddr, sizeof(soeParameters));
+
+// soeFlag = 1;
+
+
+// }
\ No newline at end of file
diff --git a/APP/businessLogic/Src/bl_usart.c b/APP/businessLogic/Src/bl_usart.c
index 587c2c4..d009776 100644
--- a/APP/businessLogic/Src/bl_usart.c
+++ b/APP/businessLogic/Src/bl_usart.c
@@ -21,7 +21,7 @@
#define HY_communicationIDStartAddr (HY_hardWordIDStartAddr + HY_hardWordIDSize)
#define HY_communicationIDSize 4
static uint8_t HY_hardWordID[HY_hardWordIDSize] = {0x48, 0x59, 0x30, 0x30, 0x30, 0x31};
-static uint8_t HY_communicationID[HY_communicationIDSize] = {0x00, 0x00, 0x00, 0x02};
+static uint8_t HY_communicationID[HY_communicationIDSize] = {0x00, 0x00, 0x00, 0x01};
static uint8_t HY_startFlag = 0x68;
static uint8_t HY_endFlag = 0x16;
@@ -1023,6 +1023,9 @@ BOOL analysisCrcCheckBitSL(void)
return TRUE;
}
}
+ else if (gw485RxBufferIndex < frameLength) {
+ return FALSE;
+ }
log_error("analysisCrcCheckBitSL \n");
state = wait;
@@ -3060,7 +3063,7 @@ BOOL analysisStartFlagHY(void)
state = hardWordIDHY;
return TRUE;
}
-
+
else if (gw485RxBuffer[1] == 0xFF
&& gw485RxBuffer[2] == 0xFF
&& gw485RxBuffer[3] == 0xFF
@@ -3076,6 +3079,7 @@ BOOL analysisStartFlagHY(void)
return FALSE;
}
+ log_error("analysisStartFlagHY \n");
state = wait;
gw485RxBufferIndex--;
memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex);
@@ -3117,6 +3121,7 @@ BOOL analysisHardWordIDHY(void)
return FALSE;
}
+ log_error("analysisHardWordIDHY \n");
state = wait;
gw485RxBufferIndex--;
memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex);
@@ -3170,7 +3175,11 @@ BOOL analysisCommunicationIDHY(void)
return TRUE;
}
}
+ if (gw485RxBufferIndex < 12) {
+ return FALSE;
+ }
+ log_error("analysisCommunicationIDHY \n");
state = wait;
gw485RxBufferIndex--;
memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex);
@@ -3202,6 +3211,7 @@ BOOL analysisControlWordHY(void)
return FALSE;
}
+ log_error("analysisControlWordHY \n");
state = wait;
gw485RxBufferIndex--;
memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex);
@@ -3215,6 +3225,10 @@ BOOL analysisControlWordHY(void)
*/
BOOL analysisDataLengthHY(void)
{
+ if (gw485RxBufferIndex < 15) {
+ return FALSE;
+ }
+
if (gw485RxBuffer[11] == HY_batteryStatus) {
state = batteryStatusHY;
}
@@ -4142,7 +4156,7 @@ BOOL analysisQueryTimeHY(void)
{
/* 解析帧 */
if (gw485RxBufferIndex >= frameLength) {
- log_info("analysisQueryTimeHY \n");
+ log_info("analysisQueryTimeHY \n");
/* 比较校验位和结束标志 */
if (gw485RxBuffer[frameLength - 2] != HY_CheckFunc(gw485RxBuffer, frameLength - 2)
@@ -4831,7 +4845,7 @@ BOOL analysisModifyCommunicationIDHY(void)
{
/* 解析帧 */
if (gw485RxBufferIndex >= frameLength) {
- // log_info("analysisSensorNumberConfigurationHY \n");
+ log_info("analysisSensorNumberConfigurationHY \n");
/* 比较校验位和结束标志 */
if (gw485RxBuffer[frameLength - 2] != HY_CheckFunc(gw485RxBuffer, frameLength - 2)
@@ -5075,7 +5089,7 @@ void HY_readHardWordID_Flash(void)
for (; i < HY_hardWordIDSize; i++) {
if (temp[0] != 0xFF) {
break;
- }
+ }
}
if (i != HY_hardWordIDSize) {
diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c
index e4fb56f..df71f0f 100644
--- a/APP/businessLogic/Src/inFlash.c
+++ b/APP/businessLogic/Src/inFlash.c
@@ -314,8 +314,6 @@ void config_info_start(void)
// setLastTime(time);
}
-
-
/**
* @brief 保存回路阻抗在flash中
* @param
diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c
index 28d32e8..3bafcb6 100644
--- a/APP/businessLogic/Src/task.c
+++ b/APP/businessLogic/Src/task.c
@@ -144,6 +144,9 @@ void Task_uart(void);
STR_TimeSliceOffset m_SOE;
void Task_SOE(void);
+// /* 将flag中的soe记录擦除延时 */
+// STR_TimeSliceOffset g_SOE_flag;
+// void Task_SOE_flag(void);
/**
diff --git a/APP/hardwareDriver/Src/w25qxx.c b/APP/hardwareDriver/Src/w25qxx.c
index 7bdb33e..b11c476 100644
--- a/APP/hardwareDriver/Src/w25qxx.c
+++ b/APP/hardwareDriver/Src/w25qxx.c
@@ -161,6 +161,8 @@ void W25QXX_ReadUniqueID(uint8_t UID[8])
//NumByteToRead:要读取的字节数(最大65535)
void W25QXX_Read(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead)
{
+ // volatile static int timeReadTemp1, timeReadTemp2, timeReadTemp3, timeReadTemp4, timeReadTemp5;
+ // timeReadTemp1 = HAL_GetTick();
volatile static int timeReadTemp1, timeReadTemp2, timeReadTemp3, timeReadTemp4, timeReadTemp5;
timeReadTemp1 = HAL_GetTick();
diff --git a/Core/Src/main.c b/Core/Src/main.c
index f4dc0bc..7d18c24 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -95,20 +95,20 @@ int main(void)
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
-// MX_GPIO_Init();
-// MX_DMA_Init();
-// MX_ADC1_Init();
-// MX_ADC2_Init();
-// MX_TIM3_Init();
-// MX_TIM6_Init();
-// MX_UART4_Init();
-// MX_USART2_UART_Init();
-// MX_USART3_UART_Init();
-// MX_TIM7_Init();
-// MX_TIM16_Init();
-// MX_TIM15_Init();
-// MX_RTC_Init();
-// MX_SPI1_Init();
+// MX_GPIO_Init();
+// MX_DMA_Init();
+// MX_ADC1_Init();
+// MX_ADC2_Init();
+// MX_TIM3_Init();
+// MX_TIM6_Init();
+// MX_UART4_Init();
+// MX_USART2_UART_Init();
+// MX_USART3_UART_Init();
+// MX_TIM7_Init();
+// MX_TIM16_Init();
+// MX_TIM15_Init();
+// MX_RTC_Init();
+// MX_SPI1_Init();
/* USER CODE BEGIN 2 */
// while (1) {
@@ -137,38 +137,6 @@ int main(void)
*/
void SystemClock_Config(void)
{
-// RCC_OscInitTypeDef RCC_OscInitStruct = {0};
-// RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
-
-// /** Configure the main internal regulator output voltage
-// */
-// HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
-
-// /** Initializes the RCC Oscillators according to the specified parameters
-// * in the RCC_OscInitTypeDef structure.
-// */
-// RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
-// RCC_OscInitStruct.HSIState = RCC_HSI_ON;
-// RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
-// RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
-// if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
-// {
-// Error_Handler();
-// }
-
-// /** Initializes the CPU, AHB and APB buses clocks
-// */
-// RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
-// |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
-// RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
-// RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
-// RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
-// RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
-
-// if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
-// {
-// Error_Handler();
-// }
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
diff --git a/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c b/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
index a280c3e..563b90d 100644
--- a/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
+++ b/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
@@ -147,43 +147,6 @@ uint32_t uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
*/
HAL_StatusTypeDef HAL_Init(void)
{
-
-// HAL_StatusTypeDef status = HAL_OK;
-// /* Configure Flash prefetch, Instruction cache, Data cache */
-// /* Default configuration at reset is: */
-// /* - Prefetch disabled */
-// /* - Instruction cache enabled */
-// /* - Data cache enabled */
-// #if (INSTRUCTION_CACHE_ENABLE == 0U)
-// __HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
-// #endif /* INSTRUCTION_CACHE_ENABLE */
-
-// #if (DATA_CACHE_ENABLE == 0U)
-// __HAL_FLASH_DATA_CACHE_DISABLE();
-// #endif /* DATA_CACHE_ENABLE */
-
-// #if (PREFETCH_ENABLE != 0U)
-// __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
-// #endif /* PREFETCH_ENABLE */
-
-// /* Set Interrupt Group Priority */
-// HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
-
-// /* Use SysTick as time base source and configure 1ms tick (default clock after Reset is HSI) */
-// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
-// {
-// status = HAL_ERROR;
-// }
-// else
-// {
-// /* Init the low level hardware */
-// HAL_MspInit();
-// }
-
-// /* Return function status */
-// return status;
-
-
HAL_StatusTypeDef status = HAL_OK;
/* Configure Flash prefetch, Instruction cache, Data cache */
/* Default configuration at reset is: */
diff --git a/EWARM/chargeController.ewd b/EWARM/chargeController.ewd
index fd4c67f..7965952 100644
--- a/EWARM/chargeController.ewd
+++ b/EWARM/chargeController.ewd
@@ -36,7 +36,7 @@
@@ -294,7 +294,7 @@
@@ -1905,7 +1905,7 @@