Commit e414aefc authored by 陈家乐's avatar 陈家乐

🐞 fix:读写EE整理

parent 2f798ebc
...@@ -9,6 +9,8 @@ Mileage_t g_ReadMileage; ...@@ -9,6 +9,8 @@ Mileage_t g_ReadMileage;
uint8_t odo_writeState; uint8_t odo_writeState;
uint8_t odoclr_writeState; uint8_t odoclr_writeState;
uint8_t trip_writeState; uint8_t trip_writeState;
uint8_t trip_readState;
uint8_t odo_readState;
uint8_t odo_readState; uint8_t odo_readState;
uint32_t Milleage_InitFlag = 0U; uint32_t Milleage_InitFlag = 0U;
/****************************************************************************** /******************************************************************************
...@@ -147,6 +149,7 @@ uint32_t Get_MileageInit_Status(void) ...@@ -147,6 +149,7 @@ uint32_t Get_MileageInit_Status(void)
uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t u16Len) uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t u16Len)
{ {
uint16_t timeout = 0;
switch (u16BlockID) switch (u16BlockID)
{ {
case EM_MILEAGE_BLOCK: case EM_MILEAGE_BLOCK:
...@@ -155,12 +158,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -155,12 +158,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
break; break;
case EM_ODO_BLOCK: case EM_ODO_BLOCK:
timeout = 0;
eeprom_ReadRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4); odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
while(odo_readState != WRITE_COMPLETE)
{
//eeprom_comm_DelayUs(5000);
odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
timeout++;
if(odo_readState == WRITE_COMPLETE)
{
break;
}
if(timeout >= 3)
{
break;
}
}
break; break;
case EM_TRIP_BLOCK: case EM_TRIP_BLOCK:
eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4); timeout = 0;
odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
while(odo_readState != WRITE_COMPLETE)
{
//eeprom_comm_DelayUs(5000);
odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
timeout++;
if(odo_readState == WRITE_COMPLETE)
{
break;
}
if(timeout >= 3)
{
break;
}
}
break; break;
// case EM_Maintenance_BLOCK: // case EM_Maintenance_BLOCK:
...@@ -207,12 +239,12 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -207,12 +239,12 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
case EM_ODO_BLOCK: case EM_ODO_BLOCK:
timeout = 0; timeout = 0;
odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4); odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
while(odoclr_writeState == WRITE_FAIL) while(odoclr_writeState != WRITE_COMPLETE)
{ {
//eeprom_comm_DelayUs(5000); //eeprom_comm_DelayUs(5000);
odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4); odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
timeout++; timeout++;
if(odoclr_writeState != WRITE_FAIL) if(odoclr_writeState == WRITE_COMPLETE)
{ {
break; break;
} }
...@@ -221,27 +253,17 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -221,27 +253,17 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
return; return;
} }
} }
timeout = 0;
while(odoclr_writeState == WRITING)
{
odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
if(timeout++ > 20)
{
timeout = 0;
break;
}
}
break; break;
case EM_TRIP_BLOCK: case EM_TRIP_BLOCK:
timeout = 0; timeout = 0;
trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4); trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
while(trip_writeState == WRITE_FAIL) while(trip_writeState != WRITE_COMPLETE)
{ {
//eeprom_comm_DelayUs(5000); //eeprom_comm_DelayUs(5000);
trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4); trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
timeout++; timeout++;
if(trip_writeState != WRITE_FAIL) if(trip_writeState == WRITE_COMPLETE)
{ {
break; break;
} }
...@@ -250,17 +272,6 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -250,17 +272,6 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
return; return;
} }
} }
timeout = 0;
//eeprom_comm_DelayUs(5000);
while(trip_writeState == WRITING)
{
trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
if(timeout++ > 20)
{
timeout = 0;
break;
}
}
break; break;
// case EM_Maintenance_BLOCK: // case EM_Maintenance_BLOCK:
......
...@@ -54,12 +54,12 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len) ...@@ -54,12 +54,12 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len)
ee_uint16_t Cnt = 0; ee_uint16_t Cnt = 0;
ee_uint16_t TimeOut = 0; ee_uint16_t TimeOut = 0;
tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
while(tmpWritestatus == WRITE_FAIL) while(tmpWritestatus != WRITE_COMPLETE)
{ {
//eeprom_comm_DelayUs(5000); //eeprom_comm_DelayUs(5000);
tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
TimeOut++; TimeOut++;
if(tmpWritestatus != WRITE_FAIL) if(tmpWritestatus == WRITE_COMPLETE)
{ {
break; break;
} }
...@@ -68,31 +68,26 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len) ...@@ -68,31 +68,26 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len)
return; return;
} }
} }
//eeprom_comm_DelayUs(5000);
while(tmpWritestatus == WRITING)
{
tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
Cnt++;
if(Cnt >= 1000)
{
break;
}
}
} }
static void Service_Interval_Read_EEProm(uint32_t u32Data [], uint16_t u16Len) static void Service_Interval_Read_EEProm(uint32_t u32Data [], uint16_t u16Len)
{ {
ee_uint16_t tmpReadstatus = 0; ee_uint16_t tmpReadstatus = 0;
ee_uint16_t Cnt = 0; ee_uint16_t TimeOut = 0;
tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
while(tmpReadstatus == READING) while(tmpReadstatus != WRITE_COMPLETE)
{ {
//eeprom_comm_DelayUs(5000);
tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
Cnt++; TimeOut++;
if(Cnt >= 1000) if(tmpReadstatus == WRITE_COMPLETE)
{ {
break; break;
} }
if(TimeOut >= 3)
{
return;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment