From 14c7cb2a5f0ef80d167bb6aefc6187b7b601d3e9 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sun, 4 Aug 2024 11:16:51 +0200 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + src/nor_flash.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9225845..29863dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +- Add `WordclearNorFlash` to encode relaxed `write` requirements similar to `MultiwriteNorFlash` but that allows for flashes with ECC. - Add `start()` and `end()` method to the `Region` trait. - Much faster `OverlapIterator`. diff --git a/src/nor_flash.rs b/src/nor_flash.rs index c20ddba..08f45b9 100644 --- a/src/nor_flash.rs +++ b/src/nor_flash.rs @@ -178,6 +178,15 @@ impl NorFlash for &mut T { } } +/// Marker trait for NorFlash relaxing the restrictions on `write`. +/// +/// Writes to the same word twice are now allowed as long as the second write is all 0s. +/// This is common for flashes that have ECC, where after the first write only a complete clear of +/// the word is allowed after initial write. +pub trait WordclearNorFlash: NorFlash {} + +impl WordclearNorFlash for T where T: MultiwriteNorFlash {} + /// Marker trait for NorFlash relaxing the restrictions on `write`. /// /// Writes to the same word twice are now allowed. The result is the logical AND of the