Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
TianYing_ty100
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TY
TianYing_ty100
Commits
e414aefc
Commit
e414aefc
authored
Sep 28, 2024
by
陈家乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix:读写EE整理
parent
2f798ebc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
44 deletions
+50
-44
Services_Mileage_User.c
Firmware/Source/Component/Mileage/Services_Mileage_User.c
+39
-28
Service_Interval_User.c
...Source/Component/Service_Interval/Service_Interval_User.c
+11
-16
No files found.
Firmware/Source/Component/Mileage/Services_Mileage_User.c
View file @
e414aefc
...
@@ -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:
...
...
Firmware/Source/Component/Service_Interval/Service_Interval_User.c
View file @
e414aefc
...
@@ -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
Cn
t
=
0
;
ee_uint16_t
TimeOu
t
=
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
);
Cn
t
++
;
TimeOu
t
++
;
if
(
Cnt
>=
1000
)
if
(
tmpReadstatus
==
WRITE_COMPLETE
)
{
{
break
;
break
;
}
}
if
(
TimeOut
>=
3
)
{
return
;
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment