Skip to content

Commit dc3f15e

Browse files
committed
Some changes in flash mostly for rm0455
1 parent 368a0a7 commit dc3f15e

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

src/flash/operations.rs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ impl NorFlashError for Error {
5353
impl Error {
5454
fn read(flash_bank: &BANK) -> Option<Self> {
5555
let sr = flash_bank.sr().read();
56+
57+
#[cfg(not(feature = "rm0455"))]
58+
if sr.operr().bit() {
59+
return Some(Error::Operation);
60+
}
61+
5662
if sr.pgserr().bit() {
5763
Some(Error::ProgrammingSequence)
5864
} else if sr.wrperr().bit() {
@@ -61,8 +67,6 @@ impl Error {
6167
Some(Error::Strobe)
6268
} else if sr.incerr().bit() {
6369
Some(Error::Inconsistency)
64-
} else if sr.operr().bit() {
65-
Some(Error::Operation)
6670
} else if sr.rdperr().bit() {
6771
Some(Error::ReadProtection)
6872
} else if sr.rdserr().bit() {
@@ -75,22 +79,26 @@ impl Error {
7579
}
7680
}
7781
fn clear_error_flags(regs: &BANK) {
78-
regs.sr().modify(|_, w| {
79-
w.pgserr()
80-
.set_bit()
81-
.wrperr()
82+
regs.ccr().write(|w| {
83+
let w = w.clr_pgserr()
8284
.set_bit()
83-
.strberr()
85+
.clr_wrperr()
8486
.set_bit()
85-
.incerr()
87+
.clr_strberr()
8688
.set_bit()
87-
.operr()
89+
.clr_incerr();
90+
91+
#[cfg(not(feature = "rm0455"))]
92+
let w = w
8893
.set_bit()
89-
.rdperr()
94+
.clr_operr();
95+
96+
w.set_bit()
97+
.clr_rdperr()
9098
.set_bit()
91-
.rdserr()
99+
.clr_rdserr()
92100
.set_bit()
93-
.dbeccerr()
101+
.clr_dbeccerr()
94102
.set_bit()
95103
});
96104
}
@@ -214,11 +222,13 @@ impl UnlockedFlashBank<'_> {
214222
#[rustfmt::skip]
215223
#[allow(unused_unsafe)]
216224
self.bank.cr().modify(|_, w| unsafe {
217-
w
225+
#[cfg(not(feature = "rm0455"))]
226+
let w = w
218227
// double-word parallelism
219-
.psize().bits(0b11)
220-
// not sector erase
221-
.ser().clear_bit()
228+
.psize().bits(0b11);
229+
230+
// not sector erase
231+
w.ser().clear_bit()
222232
// programming
223233
.pg().set_bit()
224234
});

0 commit comments

Comments
 (0)