aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/Cargo.toml2
-rw-r--r--embassy-nrf/src/nvmc.rs17
-rw-r--r--examples/nrf/Cargo.toml2
3 files changed, 17 insertions, 4 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index f64e2a950..4ed922ba9 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -63,7 +63,7 @@ futures = { version = "0.3.17", default-features = false }
63critical-section = "0.2.5" 63critical-section = "0.2.5"
64rand_core = "0.6.3" 64rand_core = "0.6.3"
65fixed = "1.10.0" 65fixed = "1.10.0"
66embedded-storage = "0.2.0" 66embedded-storage = "0.3.0"
67cfg-if = "1.0.0" 67cfg-if = "1.0.0"
68nrf-usbd = {version = "0.1.1"} 68nrf-usbd = {version = "0.1.1"}
69usb-device = "0.2.8" 69usb-device = "0.2.8"
diff --git a/embassy-nrf/src/nvmc.rs b/embassy-nrf/src/nvmc.rs
index 722e49d6c..7d7b56841 100644
--- a/embassy-nrf/src/nvmc.rs
+++ b/embassy-nrf/src/nvmc.rs
@@ -8,7 +8,9 @@ use core::ptr;
8use core::slice; 8use core::slice;
9use embassy::util::Unborrow; 9use embassy::util::Unborrow;
10use embassy_hal_common::unborrow; 10use embassy_hal_common::unborrow;
11use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash}; 11use embedded_storage::nor_flash::{
12 ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash,
13};
12 14
13pub const PAGE_SIZE: usize = 4096; 15pub const PAGE_SIZE: usize = 4096;
14pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE; 16pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE;
@@ -20,6 +22,15 @@ pub enum Error {
20 Unaligned, 22 Unaligned,
21} 23}
22 24
25impl NorFlashError for Error {
26 fn kind(&self) -> NorFlashErrorKind {
27 match self {
28 Self::OutOfBounds => NorFlashErrorKind::OutOfBounds,
29 Self::Unaligned => NorFlashErrorKind::NotAligned,
30 }
31 }
32}
33
23pub struct Nvmc<'d> { 34pub struct Nvmc<'d> {
24 _p: PhantomData<&'d NVMC>, 35 _p: PhantomData<&'d NVMC>,
25} 36}
@@ -43,9 +54,11 @@ impl<'d> Nvmc<'d> {
43 54
44impl<'d> MultiwriteNorFlash for Nvmc<'d> {} 55impl<'d> MultiwriteNorFlash for Nvmc<'d> {}
45 56
46impl<'d> ReadNorFlash for Nvmc<'d> { 57impl<'d> ErrorType for Nvmc<'d> {
47 type Error = Error; 58 type Error = Error;
59}
48 60
61impl<'d> ReadNorFlash for Nvmc<'d> {
49 const READ_SIZE: usize = 1; 62 const READ_SIZE: usize = 1;
50 63
51 fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { 64 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 eb1872d45..da16bcbaf 100644
--- a/examples/nrf/Cargo.toml
+++ b/examples/nrf/Cargo.toml
@@ -17,7 +17,7 @@ cortex-m-rt = "0.7.0"
17panic-probe = { version = "0.3", features = ["print-defmt"] } 17panic-probe = { version = "0.3", features = ["print-defmt"] }
18futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 18futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
19rand = { version = "0.8.4", default-features = false } 19rand = { version = "0.8.4", default-features = false }
20embedded-storage = "0.2.0" 20embedded-storage = "0.3.0"
21 21
22usb-device = "0.2" 22usb-device = "0.2"
23usbd-serial = "0.1.1" 23usbd-serial = "0.1.1"