diff options
| author | Ulf Lilleengen <[email protected]> | 2022-02-07 12:35:58 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-02-07 12:35:58 +0100 |
| commit | f79624c3e64565b57eb18f7fae152fdb50c8bded (patch) | |
| tree | 02b4b9fc2ff4697d7c149dbf07cd9e9277e60694 | |
| parent | d06b0628e06bdf2ff32de26ea041ecf2f082d00a (diff) | |
Upgrade to embedded-storage 0.3.0
| -rw-r--r-- | embassy-nrf/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/nvmc.rs | 17 | ||||
| -rw-r--r-- | examples/nrf/Cargo.toml | 2 |
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 } | |||
| 63 | critical-section = "0.2.5" | 63 | critical-section = "0.2.5" |
| 64 | rand_core = "0.6.3" | 64 | rand_core = "0.6.3" |
| 65 | fixed = "1.10.0" | 65 | fixed = "1.10.0" |
| 66 | embedded-storage = "0.2.0" | 66 | embedded-storage = "0.3.0" |
| 67 | cfg-if = "1.0.0" | 67 | cfg-if = "1.0.0" |
| 68 | nrf-usbd = {version = "0.1.1"} | 68 | nrf-usbd = {version = "0.1.1"} |
| 69 | usb-device = "0.2.8" | 69 | usb-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; | |||
| 8 | use core::slice; | 8 | use core::slice; |
| 9 | use embassy::util::Unborrow; | 9 | use embassy::util::Unborrow; |
| 10 | use embassy_hal_common::unborrow; | 10 | use embassy_hal_common::unborrow; |
| 11 | use embedded_storage::nor_flash::{MultiwriteNorFlash, NorFlash, ReadNorFlash}; | 11 | use embedded_storage::nor_flash::{ |
| 12 | ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash, | ||
| 13 | }; | ||
| 12 | 14 | ||
| 13 | pub const PAGE_SIZE: usize = 4096; | 15 | pub const PAGE_SIZE: usize = 4096; |
| 14 | pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE; | 16 | pub const FLASH_SIZE: usize = crate::chip::FLASH_SIZE; |
| @@ -20,6 +22,15 @@ pub enum Error { | |||
| 20 | Unaligned, | 22 | Unaligned, |
| 21 | } | 23 | } |
| 22 | 24 | ||
| 25 | impl 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 | |||
| 23 | pub struct Nvmc<'d> { | 34 | pub 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 | ||
| 44 | impl<'d> MultiwriteNorFlash for Nvmc<'d> {} | 55 | impl<'d> MultiwriteNorFlash for Nvmc<'d> {} |
| 45 | 56 | ||
| 46 | impl<'d> ReadNorFlash for Nvmc<'d> { | 57 | impl<'d> ErrorType for Nvmc<'d> { |
| 47 | type Error = Error; | 58 | type Error = Error; |
| 59 | } | ||
| 48 | 60 | ||
| 61 | impl<'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" | |||
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 18 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 18 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 19 | rand = { version = "0.8.4", default-features = false } | 19 | rand = { version = "0.8.4", default-features = false } |
| 20 | embedded-storage = "0.2.0" | 20 | embedded-storage = "0.3.0" |
| 21 | 21 | ||
| 22 | usb-device = "0.2" | 22 | usb-device = "0.2" |
| 23 | usbd-serial = "0.1.1" | 23 | usbd-serial = "0.1.1" |
