aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-02-23 22:23:01 +0100
committerDario Nieuwenhuis <[email protected]>2023-03-05 02:08:29 +0100
commit9eb65b11cb29ec85224c129660d8ae2e01e06119 (patch)
tree3af1d54f0de05c7308accad5ac4a9de48fb899a9
parentbef559307c2b63540e73539e3ba906f4c370a131 (diff)
nrf/qspi: remove cfg_if hack
-rw-r--r--embassy-nrf/src/qspi.rs61
1 files changed, 31 insertions, 30 deletions
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index d434327fc..5b68aa4d4 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -525,42 +525,43 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> NorFlash for Qspi<'d, T, FLASH_SI
525 } 525 }
526} 526}
527 527
528cfg_if::cfg_if! { 528#[cfg(feature = "nightly")]
529 if #[cfg(feature = "nightly")] 529mod _eh1 {
530 { 530 use core::future::Future;
531 use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash}; 531
532 use core::future::Future; 532 use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash};
533 533
534 impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncNorFlash for Qspi<'d, T, FLASH_SIZE> { 534 use super::*;
535 const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE; 535
536 const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE; 536 impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncNorFlash for Qspi<'d, T, FLASH_SIZE> {
537 537 const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE;
538 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 538 const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE;
539 fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> {
540 async move { self.write(offset as usize, data).await }
541 }
542 539
543 type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 540 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
544 fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { 541 fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> {
545 async move { 542 async move { self.write(offset as usize, data).await }
546 for address in (from as usize..to as usize).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) { 543 }
547 self.erase(address).await? 544
548 } 545 type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
549 Ok(()) 546 fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> {
547 async move {
548 for address in (from as usize..to as usize).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) {
549 self.erase(address).await?
550 } 550 }
551 Ok(())
551 } 552 }
552 } 553 }
554 }
553 555
554 impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncReadNorFlash for Qspi<'d, T, FLASH_SIZE> { 556 impl<'d, T: Instance, const FLASH_SIZE: usize> AsyncReadNorFlash for Qspi<'d, T, FLASH_SIZE> {
555 const READ_SIZE: usize = 4; 557 const READ_SIZE: usize = 4;
556 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 558 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
557 fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> { 559 fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> {
558 async move { self.read(address as usize, data).await } 560 async move { self.read(address as usize, data).await }
559 } 561 }
560 562
561 fn capacity(&self) -> usize { 563 fn capacity(&self) -> usize {
562 FLASH_SIZE 564 FLASH_SIZE
563 }
564 } 565 }
565 } 566 }
566} 567}