Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
ffdbc1f4
Commit
ffdbc1f4
authored
6 years ago
by
Alexander Amelkin
Committed by
Scott Lahteine
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
STM32F1: Fix SD card persistent store API (#11090)
parent
8d8f2573
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp
+13
-10
13 additions, 10 deletions
Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp
with
13 additions
and
10 deletions
Marlin/src/HAL/HAL_STM32F1/persistent_store_flash.cpp
+
13
−
10
View file @
ffdbc1f4
...
...
@@ -42,10 +42,12 @@
namespace
HAL
{
namespace
PersistentStore
{
namespace
{
// Store settings in the last two pages
// Flash pages must be erased before writing, so keep track.
bool
firstWrite
=
false
;
uint32_t
pageBase
=
EEPROM_START_ADDRESS
;
}
bool
access_start
()
{
firstWrite
=
true
;
...
...
@@ -64,9 +66,9 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
if
(
firstWrite
)
{
FLASH_Unlock
();
status
=
FLASH_ErasePage
(
EEPROM_PAGE0_BASE
);
if
(
status
!=
FLASH_COMPLETE
)
return
fals
e
;
if
(
status
!=
FLASH_COMPLETE
)
return
tru
e
;
status
=
FLASH_ErasePage
(
EEPROM_PAGE1_BASE
);
if
(
status
!=
FLASH_COMPLETE
)
return
fals
e
;
if
(
status
!=
FLASH_COMPLETE
)
return
tru
e
;
firstWrite
=
false
;
}
...
...
@@ -76,7 +78,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
uint16_t
*
wordBuffer
=
(
uint16_t
*
)
value
;
while
(
wordsToWrite
)
{
status
=
FLASH_ProgramHalfWord
(
pageBase
+
pos
+
(
i
*
2
),
wordBuffer
[
i
]);
if
(
status
!=
FLASH_COMPLETE
)
return
fals
e
;
if
(
status
!=
FLASH_COMPLETE
)
return
tru
e
;
wordsToWrite
--
;
i
++
;
}
...
...
@@ -85,15 +87,15 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
if
(
size
&
1
)
{
uint16_t
temp
=
value
[
size
-
1
];
status
=
FLASH_ProgramHalfWord
(
pageBase
+
pos
+
i
,
temp
);
if
(
status
!=
FLASH_COMPLETE
)
return
fals
e
;
if
(
status
!=
FLASH_COMPLETE
)
return
tru
e
;
}
crc16
(
crc
,
value
,
size
);
pos
+=
((
size
+
1
)
&
~
1
);
return
tru
e
;
return
fals
e
;
}
void
read_data
(
int
&
pos
,
uint8_t
*
value
,
uint16_t
size
,
uint16_t
*
crc
,
const
bool
writing
/*=true*/
)
{
bool
read_data
(
int
&
pos
,
uint8_t
*
value
,
uint16_t
size
,
uint16_t
*
crc
,
const
bool
writing
/*=true*/
)
{
for
(
uint16_t
i
=
0
;
i
<
size
;
i
++
)
{
byte
*
accessPoint
=
(
byte
*
)(
pageBase
+
pos
+
i
);
uint8_t
c
=
*
accessPoint
;
...
...
@@ -101,6 +103,7 @@ void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const boo
crc16
(
crc
,
&
c
,
1
);
}
pos
+=
((
size
+
1
)
&
~
1
);
return
false
;
}
}
// PersistentStore
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment