From 8748b5cc97b83649f94ffd0f329da843a49e8bad Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 16 Nov 2023 14:30:58 +0100 Subject: [PATCH 1/2] Updating to embedded-storage 0.3 --- Cargo.toml | 2 +- src/flash.rs | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a364d25d..62e34a6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ fugit-timer = "0.1.3" rtic-monotonic = { version = "1.0", optional = true } systick-monotonic = { version = "1.0", optional = true } bitflags = "2.2" -embedded-storage = "0.2" +embedded-storage = "0.3" vcell = "0.1.3" [dependencies.time] diff --git a/src/flash.rs b/src/flash.rs index 60d051d2..a18c6925 100644 --- a/src/flash.rs +++ b/src/flash.rs @@ -1,4 +1,6 @@ -use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash}; +use embedded_storage::nor_flash::{ + ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash, +}; use crate::pac::FLASH; use crate::signature::FlashSize; @@ -357,9 +359,24 @@ pub fn flash_sectors(flash_size: usize, dual_bank: bool) -> impl Iterator NorFlashErrorKind { + match self { + Error::ProgrammingAlignment => NorFlashErrorKind::NotAligned, + _ => NorFlashErrorKind::Other, + } + } +} + +impl ErrorType for LockedFlash { + type Error = Error; +} + +impl ErrorType for UnlockedFlash<'_> { type Error = Error; +} +impl ReadNorFlash for LockedFlash { const READ_SIZE: usize = 1; fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { @@ -374,8 +391,6 @@ impl ReadNorFlash for LockedFlash { } impl<'a> ReadNorFlash for UnlockedFlash<'a> { - type Error = Error; - const READ_SIZE: usize = 1; fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { From 0b6fa712ca5d79792ab85135e9f2ec7c12c96d22 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 16 Nov 2023 14:31:52 +0100 Subject: [PATCH 2/2] Updating CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d091a3fe..f6b6b93d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - complete and rework Dma Stream API [#666] - SPI bidi takes 2 pins [#526] - `Fast Read Quad I/O (EBh)` in `qspi-w25q` example now matches W25QXX datasheet. [#682] + - `embedded-storage` version bumped to 0.3 ### Fixed