Skip to content

Commit

Permalink
Merge pull request #489 from nhpupu/fix-flash
Browse files Browse the repository at this point in the history
Fix flash error flag clearing
  • Loading branch information
burrbull authored Jul 16, 2024
2 parents 86b1686 + 10a2d02 commit d50ccba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit d50ccba

Please sign in to comment.