Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flash error flag clearing #489

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Replace UB code by a legitimate pointer access
- Reexport `Direction` from `qei`
- Add dac
- Fix flash error flag clearing

## [v0.10.0] - 2022-12-12

Expand Down
9 changes: 6 additions & 3 deletions src/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl<'a> FlashWriter<'a> {
self.lock()?;

if sr.wrprterr().bit_is_set() {
self.flash.sr.sr().modify(|_, w| w.wrprterr().clear_bit());
// reset by writing 1
self.flash.sr.sr().modify(|_, w| w.wrprterr().bit(true));
Err(Error::EraseError)
} else {
if self.verify {
Expand Down Expand Up @@ -257,12 +258,14 @@ impl<'a> FlashWriter<'a> {

// Check for errors
if self.flash.sr.sr().read().pgerr().bit_is_set() {
self.flash.sr.sr().modify(|_, w| w.pgerr().clear_bit());
// reset by writing 1
self.flash.sr.sr().modify(|_, w| w.pgerr().bit(true));

self.lock()?;
return Err(Error::ProgrammingError);
} else if self.flash.sr.sr().read().wrprterr().bit_is_set() {
self.flash.sr.sr().modify(|_, w| w.wrprterr().clear_bit());
// reset by writing 1
self.flash.sr.sr().modify(|_, w| w.wrprterr().bit(true));

self.lock()?;
return Err(Error::WriteError);
Expand Down
Loading