Skip to content

Commit a742ef4

Browse files
committed
Add a NOR trait to encode that word clearing is supported
This is to encode MCU flashes that have ECC, where it is common that only a complete clear of the word is allowed. This is a more restrictive version of `MultiwriteNorFlash` as it cannot encode flashes with ECC support.
1 parent 95861f8 commit a742ef4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/nor_flash.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ impl<T: NorFlash> NorFlash for &mut T {
178178
}
179179
}
180180

181+
/// Marker trait for NorFlash relaxing the restrictions on `write`.
182+
///
183+
/// Writes to the same word twice are now allowed as long as the second write is all 0s.
184+
/// This is common for flashes that have ECC, where after the first write only a complete clear of
185+
/// the word is allowed after initial write.
186+
pub trait WordclearNorFlash: NorFlash {}
187+
188+
impl<T> WordclearNorFlash for T where T: MultiwriteNorFlash {}
189+
181190
/// Marker trait for NorFlash relaxing the restrictions on `write`.
182191
///
183192
/// Writes to the same word twice are now allowed. The result is the logical AND of the

0 commit comments

Comments
 (0)