diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index f64e2a95..4ed922ba 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -63,7 +63,7 @@ futures = { version = "0.3.17", default-features = false } critical-section = "0.2.5" rand_core = "0.6.3" fixed = "1.10.0" -embedded-storage = "0.2.0" +embedded-storage = "0.3.0" cfg-if = "1.0.0" nrf-usbd = {version = "0.1.1"} usb-device = "0.2.8" diff --git a/embassy-nrf/src/nvmc.rs b/embassy-nrf/src/nvmc.rs index 722e49d6..7d7b5684 100644 --- a/embassy-nrf/src/nvmc.rs +++ b/embassy-nrf/src/nvmc.rs @@ -8,7 +8,9 @@ use core::ptr; use core::slice; use embassy::util::Unborrow; use embassy_hal_common::unborrow; -use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash}; +use embedded_storage::nor_flash::{ + ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash, +}; pub const PAGE_SIZE: usize = 4096; pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE; @@ -20,6 +22,15 @@ pub enum Error { Unaligned, } +impl NorFlashError for Error { + fn kind(&self) -> NorFlashErrorKind { + match self { + Self::OutOfBounds => NorFlashErrorKind::OutOfBounds, + Self::Unaligned => NorFlashErrorKind::NotAligned, + } + } +} + pub struct Nvmc<'d> { _p: PhantomData<&'d NVMC>, } @@ -43,9 +54,11 @@ impl<'d> Nvmc<'d> { impl<'d> MultiwriteNorFlash for Nvmc<'d> {} -impl<'d> ReadNorFlash for Nvmc<'d> { +impl<'d> ErrorType for Nvmc<'d> { type Error = Error; +} +impl<'d> ReadNorFlash for Nvmc<'d> { const READ_SIZE: usize = 1; fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index eb1872d4..da16bcba 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -17,7 +17,7 @@ cortex-m-rt = "0.7.0" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand = { version = "0.8.4", default-features = false } -embedded-storage = "0.2.0" +embedded-storage = "0.3.0" usb-device = "0.2" usbd-serial = "0.1.1"