aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/spim.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-11-21 23:31:31 +0100
committerDario Nieuwenhuis <[email protected]>2022-11-25 21:02:06 +0100
commit1e2fb0459d8546ba658bb9fe150be5f1f537b48e (patch)
treeeb40a5027581896c7b78db58f509431ed6b11892 /embassy-nrf/src/spim.rs
parent758f5d7ea29f1df14d5ef59c82e4b7f22545d775 (diff)
Switch to async-fn-in-trait
Diffstat (limited to 'embassy-nrf/src/spim.rs')
-rw-r--r--embassy-nrf/src/spim.rs31
1 files changed, 10 insertions, 21 deletions
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs
index d821d2353..7bb4e39f7 100644
--- a/embassy-nrf/src/spim.rs
+++ b/embassy-nrf/src/spim.rs
@@ -477,45 +477,34 @@ mod eh1 {
477 477
478#[cfg(all(feature = "unstable-traits", feature = "nightly"))] 478#[cfg(all(feature = "unstable-traits", feature = "nightly"))]
479mod eha { 479mod eha {
480 use core::future::Future;
481 480
482 use super::*; 481 use super::*;
483 482
484 impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spim<'d, T> { 483 impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spim<'d, T> {
485 type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 484 async fn flush(&mut self) -> Result<(), Error> {
486 485 Ok(())
487 fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
488 async move { Ok(()) }
489 } 486 }
490 } 487 }
491 488
492 impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead<u8> for Spim<'d, T> { 489 impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead<u8> for Spim<'d, T> {
493 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 490 async fn read(&mut self, words: &mut [u8]) -> Result<(), Error> {
494 491 self.read(words).await
495 fn read<'a>(&'a mut self, words: &'a mut [u8]) -> Self::ReadFuture<'a> {
496 self.read(words)
497 } 492 }
498 } 493 }
499 494
500 impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite<u8> for Spim<'d, T> { 495 impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite<u8> for Spim<'d, T> {
501 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 496 async fn write(&mut self, data: &[u8]) -> Result<(), Error> {
502 497 self.write(data).await
503 fn write<'a>(&'a mut self, data: &'a [u8]) -> Self::WriteFuture<'a> {
504 self.write(data)
505 } 498 }
506 } 499 }
507 500
508 impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> { 501 impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> {
509 type TransferFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 502 async fn transfer(&mut self, rx: &mut [u8], tx: &[u8]) -> Result<(), Error> {
510 503 self.transfer(rx, tx).await
511 fn transfer<'a>(&'a mut self, rx: &'a mut [u8], tx: &'a [u8]) -> Self::TransferFuture<'a> {
512 self.transfer(rx, tx)
513 } 504 }
514 505
515 type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 506 async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error> {
516 507 self.transfer_in_place(words).await
517 fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Self::TransferInPlaceFuture<'a> {
518 self.transfer_in_place(words)
519 } 508 }
520 } 509 }
521} 510}