From 69936c9509fa6f12b8441f02473ade7f14603a61 Mon Sep 17 00:00:00 2001 From: Dion Dokter Date: Thu, 28 Mar 2024 14:17:55 +0100 Subject: [PATCH 1/2] Add erase all function --- src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2093ec5..ed56665 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,23 @@ pub mod mock_flash; /// Many flashes have 4-byte or 1-byte words. const MAX_WORD_SIZE: usize = 32; +/// Resets the flash in the entire given flash range. +/// +/// This is just a helper function as it just calls the flashes erase function. +pub async fn erase_all( + flash: &mut S, + flash_range: Range, +) -> Result<(), Error> { + flash + .erase(flash_range.start, flash_range.end) + .await + .map_err(|e| Error::Storage { + value: e, + #[cfg(feature = "_test")] + backtrace: std::backtrace::Backtrace::capture(), + }) +} + // Type representing buffer aligned to 4 byte boundary. #[repr(align(4))] pub(crate) struct AlignedBuf(pub(crate) [u8; SIZE]); From 3e75445575a48f1796bb188e16a6e4d341084192 Mon Sep 17 00:00:00 2001 From: Dion Dokter Date: Thu, 28 Mar 2024 14:20:24 +0100 Subject: [PATCH 2/2] Type --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ed56665..07a0ff2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ const MAX_WORD_SIZE: usize = 32; /// Resets the flash in the entire given flash range. /// -/// This is just a helper function as it just calls the flashes erase function. +/// This is just a thin helper function as it just calls the flash's erase function. pub async fn erase_all( flash: &mut S, flash_range: Range,