diff options
| author | Mehmet Ali Anil <[email protected]> | 2023-03-06 22:08:47 +0100 |
|---|---|---|
| committer | Mehmet Ali Anil <[email protected]> | 2023-03-06 22:16:36 +0100 |
| commit | bc0cb43307c2a46330ce253505203dbc607bcc6c (patch) | |
| tree | fa0ddab9184b802efa9e6313c90847ad167184c5 /embassy-nrf | |
| parent | 2209bef4f22bf77d9d52cda0a0ea40485cc2747a (diff) | |
Bump embedded-storage-async to 0.4
Diffstat (limited to 'embassy-nrf')
| -rw-r--r-- | embassy-nrf/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/qspi.rs | 24 |
2 files changed, 10 insertions, 16 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index c31ce199b..4e62ca89e 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -100,7 +100,7 @@ critical-section = "1.1" | |||
| 100 | rand_core = "0.6.3" | 100 | rand_core = "0.6.3" |
| 101 | fixed = "1.10.0" | 101 | fixed = "1.10.0" |
| 102 | embedded-storage = "0.3.0" | 102 | embedded-storage = "0.3.0" |
| 103 | embedded-storage-async = { version = "0.3.0", optional = true } | 103 | embedded-storage-async = { version = "0.4.0", optional = true } |
| 104 | cfg-if = "1.0.0" | 104 | cfg-if = "1.0.0" |
| 105 | 105 | ||
| 106 | nrf52805-pac = { version = "0.12.0", optional = true, features = [ "rt" ] } | 106 | nrf52805-pac = { version = "0.12.0", optional = true, features = [ "rt" ] } |
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index d434327fc..1b379002b 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs | |||
| @@ -528,34 +528,28 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> NorFlash for Qspi<'d, T, FLASH_SI | |||
| 528 | cfg_if::cfg_if! { | 528 | cfg_if::cfg_if! { |
| 529 | if #[cfg(feature = "nightly")] | 529 | if #[cfg(feature = "nightly")] |
| 530 | { | 530 | { |
| 531 | use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash}; | 531 | use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; |
| 532 | use core::future::Future; | ||
| 533 | 532 | ||
| 534 | impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncNorFlash for Qspi<'d, T, FLASH_SIZE> { | 533 | impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncNorFlash for Qspi<'d, T, FLASH_SIZE> { |
| 535 | const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE; | 534 | const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE; |
| 536 | const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE; | 535 | const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE; |
| 537 | 536 | ||
| 538 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 537 | async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> { |
| 539 | fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> { | 538 | self.write(offset as usize, data).await |
| 540 | async move { self.write(offset as usize, data).await } | ||
| 541 | } | 539 | } |
| 542 | 540 | ||
| 543 | type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 541 | async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { |
| 544 | fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { | 542 | for address in (from as usize..to as usize).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) { |
| 545 | async move { | 543 | self.erase(address).await? |
| 546 | for address in (from as usize..to as usize).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) { | ||
| 547 | self.erase(address).await? | ||
| 548 | } | ||
| 549 | Ok(()) | ||
| 550 | } | 544 | } |
| 545 | Ok(()) | ||
| 551 | } | 546 | } |
| 552 | } | 547 | } |
| 553 | 548 | ||
| 554 | impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncReadNorFlash for Qspi<'d, T, FLASH_SIZE> { | 549 | impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncReadNorFlash for Qspi<'d, T, FLASH_SIZE> { |
| 555 | const READ_SIZE: usize = 4; | 550 | const READ_SIZE: usize = 4; |
| 556 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 551 | async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> { |
| 557 | fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> { | 552 | self.read(address as usize, data).await |
| 558 | async move { self.read(address as usize, data).await } | ||
| 559 | } | 553 | } |
| 560 | 554 | ||
| 561 | fn capacity(&self) -> usize { | 555 | fn capacity(&self) -> usize { |
