diff options
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 91 | ||||
| -rw-r--r-- | embassy-nrf/src/spim.rs | 58 | ||||
| -rw-r--r-- | embassy-nrf/src/twim.rs | 60 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 99 | ||||
| -rw-r--r-- | embassy-rp/src/uart.rs | 71 | ||||
| -rw-r--r-- | embassy-stm32/src/exti.rs | 49 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 67 | ||||
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 68 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 95 | ||||
| -rw-r--r-- | embassy-time/src/delay.rs | 32 |
10 files changed, 346 insertions, 344 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index b52035705..d99f592b0 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -469,72 +469,73 @@ mod eh1 { | |||
| 469 | } | 469 | } |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | cfg_if::cfg_if! { | 472 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 473 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 473 | mod eha { |
| 474 | use futures::FutureExt; | 474 | use futures::FutureExt; |
| 475 | 475 | ||
| 476 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { | 476 | use super::*; |
| 477 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 478 | 477 | ||
| 479 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { | 478 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { |
| 480 | self.wait_for_high().map(Ok) | 479 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 481 | } | ||
| 482 | 480 | ||
| 483 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 481 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { |
| 482 | self.wait_for_high().map(Ok) | ||
| 483 | } | ||
| 484 | 484 | ||
| 485 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { | 485 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 486 | self.wait_for_low().map(Ok) | ||
| 487 | } | ||
| 488 | 486 | ||
| 489 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 487 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { |
| 488 | self.wait_for_low().map(Ok) | ||
| 489 | } | ||
| 490 | 490 | ||
| 491 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { | 491 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 492 | self.wait_for_rising_edge().map(Ok) | ||
| 493 | } | ||
| 494 | 492 | ||
| 495 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 493 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { |
| 494 | self.wait_for_rising_edge().map(Ok) | ||
| 495 | } | ||
| 496 | 496 | ||
| 497 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { | 497 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 498 | self.wait_for_falling_edge().map(Ok) | ||
| 499 | } | ||
| 500 | 498 | ||
| 501 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 499 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { |
| 500 | self.wait_for_falling_edge().map(Ok) | ||
| 501 | } | ||
| 502 | 502 | ||
| 503 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { | 503 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 504 | self.wait_for_any_edge().map(Ok) | 504 | |
| 505 | } | 505 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { |
| 506 | self.wait_for_any_edge().map(Ok) | ||
| 506 | } | 507 | } |
| 508 | } | ||
| 507 | 509 | ||
| 508 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { | 510 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { |
| 509 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 511 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 510 | 512 | ||
| 511 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { | 513 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { |
| 512 | self.wait_for_high().map(Ok) | 514 | self.wait_for_high().map(Ok) |
| 513 | } | 515 | } |
| 514 | 516 | ||
| 515 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 517 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 516 | 518 | ||
| 517 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { | 519 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { |
| 518 | self.wait_for_low().map(Ok) | 520 | self.wait_for_low().map(Ok) |
| 519 | } | 521 | } |
| 520 | 522 | ||
| 521 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 523 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 522 | 524 | ||
| 523 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { | 525 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { |
| 524 | self.wait_for_rising_edge().map(Ok) | 526 | self.wait_for_rising_edge().map(Ok) |
| 525 | } | 527 | } |
| 526 | 528 | ||
| 527 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 529 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 528 | 530 | ||
| 529 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { | 531 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { |
| 530 | self.wait_for_falling_edge().map(Ok) | 532 | self.wait_for_falling_edge().map(Ok) |
| 531 | } | 533 | } |
| 532 | 534 | ||
| 533 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 535 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 534 | 536 | ||
| 535 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { | 537 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { |
| 536 | self.wait_for_any_edge().map(Ok) | 538 | self.wait_for_any_edge().map(Ok) |
| 537 | } | ||
| 538 | } | 539 | } |
| 539 | } | 540 | } |
| 540 | } | 541 | } |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index be2fc02fc..2955182e4 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -475,49 +475,47 @@ mod eh1 { | |||
| 475 | } | 475 | } |
| 476 | } | 476 | } |
| 477 | 477 | ||
| 478 | cfg_if::cfg_if! { | 478 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 479 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 479 | mod eha { |
| 480 | use core::future::Future; | 480 | use core::future::Future; |
| 481 | 481 | ||
| 482 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spim<'d, T> { | 482 | use super::*; |
| 483 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 484 | 483 | ||
| 485 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 484 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spim<'d, T> { |
| 486 | async move { Ok(()) } | 485 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 487 | } | 486 | |
| 487 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 488 | async move { Ok(()) } | ||
| 488 | } | 489 | } |
| 490 | } | ||
| 489 | 491 | ||
| 490 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead<u8> for Spim<'d, T> { | 492 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead<u8> for Spim<'d, T> { |
| 491 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 493 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 492 | 494 | ||
| 493 | fn read<'a>(&'a mut self, words: &'a mut [u8]) -> Self::ReadFuture<'a> { | 495 | fn read<'a>(&'a mut self, words: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 494 | self.read(words) | 496 | self.read(words) |
| 495 | } | ||
| 496 | } | 497 | } |
| 498 | } | ||
| 497 | 499 | ||
| 498 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite<u8> for Spim<'d, T> { | 500 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite<u8> for Spim<'d, T> { |
| 499 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 501 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 500 | 502 | ||
| 501 | fn write<'a>(&'a mut self, data: &'a [u8]) -> Self::WriteFuture<'a> { | 503 | fn write<'a>(&'a mut self, data: &'a [u8]) -> Self::WriteFuture<'a> { |
| 502 | self.write(data) | 504 | self.write(data) |
| 503 | } | ||
| 504 | } | 505 | } |
| 506 | } | ||
| 505 | 507 | ||
| 506 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> { | 508 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spim<'d, T> { |
| 507 | type TransferFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 509 | type TransferFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 508 | 510 | ||
| 509 | fn transfer<'a>(&'a mut self, rx: &'a mut [u8], tx: &'a [u8]) -> Self::TransferFuture<'a> { | 511 | fn transfer<'a>(&'a mut self, rx: &'a mut [u8], tx: &'a [u8]) -> Self::TransferFuture<'a> { |
| 510 | self.transfer(rx, tx) | 512 | self.transfer(rx, tx) |
| 511 | } | 513 | } |
| 512 | 514 | ||
| 513 | type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 515 | type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 514 | 516 | ||
| 515 | fn transfer_in_place<'a>( | 517 | fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Self::TransferInPlaceFuture<'a> { |
| 516 | &'a mut self, | 518 | self.transfer_in_place(words) |
| 517 | words: &'a mut [u8], | ||
| 518 | ) -> Self::TransferInPlaceFuture<'a> { | ||
| 519 | self.transfer_in_place(words) | ||
| 520 | } | ||
| 521 | } | 519 | } |
| 522 | } | 520 | } |
| 523 | } | 521 | } |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 850f6d0fa..3d4af753a 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -838,43 +838,43 @@ mod eh1 { | |||
| 838 | } | 838 | } |
| 839 | } | 839 | } |
| 840 | 840 | ||
| 841 | cfg_if::cfg_if! { | 841 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 842 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 842 | mod eha { |
| 843 | impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { | 843 | use super::*; |
| 844 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 844 | impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { |
| 845 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 845 | 846 | ||
| 846 | fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 847 | fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 847 | self.read(address, buffer) | 848 | self.read(address, buffer) |
| 848 | } | 849 | } |
| 849 | 850 | ||
| 850 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 851 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 851 | 852 | ||
| 852 | fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { | 853 | fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { |
| 853 | self.write(address, bytes) | 854 | self.write(address, bytes) |
| 854 | } | 855 | } |
| 855 | 856 | ||
| 856 | type WriteReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 857 | type WriteReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 857 | 858 | ||
| 858 | fn write_read<'a>( | 859 | fn write_read<'a>( |
| 859 | &'a mut self, | 860 | &'a mut self, |
| 860 | address: u8, | 861 | address: u8, |
| 861 | wr_buffer: &'a [u8], | 862 | wr_buffer: &'a [u8], |
| 862 | rd_buffer: &'a mut [u8], | 863 | rd_buffer: &'a mut [u8], |
| 863 | ) -> Self::WriteReadFuture<'a> { | 864 | ) -> Self::WriteReadFuture<'a> { |
| 864 | self.write_read(address, wr_buffer, rd_buffer) | 865 | self.write_read(address, wr_buffer, rd_buffer) |
| 865 | } | 866 | } |
| 866 | 867 | ||
| 867 | type TransactionFuture<'a, 'b> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a, 'b: 'a; | 868 | type TransactionFuture<'a, 'b> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a, 'b: 'a; |
| 868 | 869 | ||
| 869 | fn transaction<'a, 'b>( | 870 | fn transaction<'a, 'b>( |
| 870 | &'a mut self, | 871 | &'a mut self, |
| 871 | address: u8, | 872 | address: u8, |
| 872 | operations: &'a mut [embedded_hal_async::i2c::Operation<'b>], | 873 | operations: &'a mut [embedded_hal_async::i2c::Operation<'b>], |
| 873 | ) -> Self::TransactionFuture<'a, 'b> { | 874 | ) -> Self::TransactionFuture<'a, 'b> { |
| 874 | let _ = address; | 875 | let _ = address; |
| 875 | let _ = operations; | 876 | let _ = operations; |
| 876 | async move { todo!() } | 877 | async move { todo!() } |
| 877 | } | ||
| 878 | } | 878 | } |
| 879 | } | 879 | } |
| 880 | } | 880 | } |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 4347ea558..c250e24ca 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -1073,78 +1073,79 @@ mod eh1 { | |||
| 1073 | } | 1073 | } |
| 1074 | } | 1074 | } |
| 1075 | 1075 | ||
| 1076 | cfg_if::cfg_if! { | 1076 | #[cfg(all( |
| 1077 | if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { | 1077 | feature = "unstable-traits", |
| 1078 | use core::future::Future; | 1078 | feature = "nightly", |
| 1079 | feature = "_todo_embedded_hal_serial" | ||
| 1080 | ))] | ||
| 1081 | mod eha { | ||
| 1082 | use core::future::Future; | ||
| 1079 | 1083 | ||
| 1080 | impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { | 1084 | use super::*; |
| 1081 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1082 | 1085 | ||
| 1083 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 1086 | impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { |
| 1084 | self.read(buffer) | 1087 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1085 | } | 1088 | |
| 1089 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 1090 | self.read(buffer) | ||
| 1086 | } | 1091 | } |
| 1092 | } | ||
| 1087 | 1093 | ||
| 1088 | impl<'d, T: Instance> embedded_hal_async::serial::Write for Uarte<'d, T> { | 1094 | impl<'d, T: Instance> embedded_hal_async::serial::Write for Uarte<'d, T> { |
| 1089 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 1095 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1090 | 1096 | ||
| 1091 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { | 1097 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { |
| 1092 | self.write(buffer) | 1098 | self.write(buffer) |
| 1093 | } | 1099 | } |
| 1094 | 1100 | ||
| 1095 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 1101 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1096 | 1102 | ||
| 1097 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 1103 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 1098 | async move { Ok(()) } | 1104 | async move { Ok(()) } |
| 1099 | } | ||
| 1100 | } | 1105 | } |
| 1106 | } | ||
| 1101 | 1107 | ||
| 1102 | impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { | 1108 | impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { |
| 1103 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 1109 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1104 | 1110 | ||
| 1105 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { | 1111 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { |
| 1106 | self.write(buffer) | 1112 | self.write(buffer) |
| 1107 | } | 1113 | } |
| 1108 | 1114 | ||
| 1109 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 1115 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1110 | 1116 | ||
| 1111 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 1117 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 1112 | async move { Ok(()) } | 1118 | async move { Ok(()) } |
| 1113 | } | ||
| 1114 | } | 1119 | } |
| 1120 | } | ||
| 1115 | 1121 | ||
| 1116 | impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { | 1122 | impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { |
| 1117 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 1123 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1118 | 1124 | ||
| 1119 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 1125 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 1120 | self.read(buffer) | 1126 | self.read(buffer) |
| 1121 | } | ||
| 1122 | } | 1127 | } |
| 1128 | } | ||
| 1123 | 1129 | ||
| 1124 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read | 1130 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read for UarteWithIdle<'d, U, T> { |
| 1125 | for UarteWithIdle<'d, U, T> | 1131 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1126 | { | ||
| 1127 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1128 | 1132 | ||
| 1129 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 1133 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 1130 | self.read(buffer) | 1134 | self.read(buffer) |
| 1131 | } | ||
| 1132 | } | 1135 | } |
| 1136 | } | ||
| 1133 | 1137 | ||
| 1134 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Write | 1138 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Write for UarteWithIdle<'d, U, T> { |
| 1135 | for UarteWithIdle<'d, U, T> | 1139 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1136 | { | ||
| 1137 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1138 | 1140 | ||
| 1139 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { | 1141 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { |
| 1140 | self.write(buffer) | 1142 | self.write(buffer) |
| 1141 | } | 1143 | } |
| 1142 | 1144 | ||
| 1143 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 1145 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 1144 | 1146 | ||
| 1145 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 1147 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 1146 | async move { Ok(()) } | 1148 | async move { Ok(()) } |
| 1147 | } | ||
| 1148 | } | 1149 | } |
| 1149 | } | 1150 | } |
| 1150 | } | 1151 | } |
diff --git a/embassy-rp/src/uart.rs b/embassy-rp/src/uart.rs index 4a3c7a0ce..987b716b4 100644 --- a/embassy-rp/src/uart.rs +++ b/embassy-rp/src/uart.rs | |||
| @@ -477,56 +477,57 @@ mod eh1 { | |||
| 477 | } | 477 | } |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | cfg_if::cfg_if! { | 480 | #[cfg(all( |
| 481 | if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { | 481 | feature = "unstable-traits", |
| 482 | use core::future::Future; | 482 | feature = "nightly", |
| 483 | feature = "_todo_embedded_hal_serial" | ||
| 484 | ))] | ||
| 485 | mod eha { | ||
| 486 | use core::future::Future; | ||
| 483 | 487 | ||
| 484 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for UartTx<'d, T, M> | 488 | use super::*; |
| 485 | { | ||
| 486 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 487 | 489 | ||
| 488 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | 490 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for UartTx<'d, T, M> { |
| 489 | self.write(buf) | 491 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 490 | } | ||
| 491 | 492 | ||
| 492 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 493 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { |
| 494 | self.write(buf) | ||
| 495 | } | ||
| 493 | 496 | ||
| 494 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 497 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 495 | async move { Ok(()) } | 498 | |
| 496 | } | 499 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 500 | async move { Ok(()) } | ||
| 497 | } | 501 | } |
| 502 | } | ||
| 498 | 503 | ||
| 499 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for UartRx<'d, T, M> | 504 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for UartRx<'d, T, M> { |
| 500 | { | 505 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 501 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 502 | 506 | ||
| 503 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | 507 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 504 | self.read(buf) | 508 | self.read(buf) |
| 505 | } | ||
| 506 | } | 509 | } |
| 510 | } | ||
| 507 | 511 | ||
| 508 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for Uart<'d, T, M> | 512 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for Uart<'d, T, M> { |
| 509 | { | 513 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 510 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 511 | 514 | ||
| 512 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | 515 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { |
| 513 | self.write(buf) | 516 | self.write(buf) |
| 514 | } | 517 | } |
| 515 | 518 | ||
| 516 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 519 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 517 | 520 | ||
| 518 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 521 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 519 | async move { Ok(()) } | 522 | async move { Ok(()) } |
| 520 | } | ||
| 521 | } | 523 | } |
| 524 | } | ||
| 522 | 525 | ||
| 523 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for Uart<'d, T, M> | 526 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for Uart<'d, T, M> { |
| 524 | { | 527 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 525 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 526 | 528 | ||
| 527 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | 529 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 528 | self.read(buf) | 530 | self.read(buf) |
| 529 | } | ||
| 530 | } | 531 | } |
| 531 | } | 532 | } |
| 532 | } | 533 | } |
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 935149b13..07c96ead0 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -165,40 +165,41 @@ mod eh1 { | |||
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | cfg_if::cfg_if! { | 168 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 169 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 169 | mod eha { |
| 170 | use futures::FutureExt; | 170 | use futures::FutureExt; |
| 171 | 171 | ||
| 172 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { | 172 | use super::*; |
| 173 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 174 | 173 | ||
| 175 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { | 174 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { |
| 176 | self.wait_for_high().map(Ok) | 175 | type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 177 | } | ||
| 178 | 176 | ||
| 179 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 177 | fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> { |
| 178 | self.wait_for_high().map(Ok) | ||
| 179 | } | ||
| 180 | 180 | ||
| 181 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { | 181 | type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 182 | self.wait_for_low().map(Ok) | ||
| 183 | } | ||
| 184 | 182 | ||
| 185 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 183 | fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> { |
| 184 | self.wait_for_low().map(Ok) | ||
| 185 | } | ||
| 186 | 186 | ||
| 187 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { | 187 | type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 188 | self.wait_for_rising_edge().map(Ok) | ||
| 189 | } | ||
| 190 | 188 | ||
| 191 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 189 | fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> { |
| 190 | self.wait_for_rising_edge().map(Ok) | ||
| 191 | } | ||
| 192 | 192 | ||
| 193 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { | 193 | type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 194 | self.wait_for_falling_edge().map(Ok) | ||
| 195 | } | ||
| 196 | 194 | ||
| 197 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 195 | fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> { |
| 196 | self.wait_for_falling_edge().map(Ok) | ||
| 197 | } | ||
| 198 | 198 | ||
| 199 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { | 199 | type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 200 | self.wait_for_any_edge().map(Ok) | 200 | |
| 201 | } | 201 | fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> { |
| 202 | self.wait_for_any_edge().map(Ok) | ||
| 202 | } | 203 | } |
| 203 | } | 204 | } |
| 204 | } | 205 | } |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 07a3105da..db4924461 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -927,46 +927,45 @@ mod eh1 { | |||
| 927 | } | 927 | } |
| 928 | } | 928 | } |
| 929 | 929 | ||
| 930 | cfg_if::cfg_if! { | 930 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 931 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 931 | mod eha { |
| 932 | use super::{RxDma, TxDma}; | 932 | use core::future::Future; |
| 933 | use core::future::Future; | ||
| 934 | 933 | ||
| 935 | impl<'d, T: Instance, TXDMA: TxDma<T>, RXDMA: RxDma<T>> embedded_hal_async::i2c::I2c | 934 | use super::super::{RxDma, TxDma}; |
| 936 | for I2c<'d, T, TXDMA, RXDMA> | 935 | use super::*; |
| 937 | { | ||
| 938 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 939 | 936 | ||
| 940 | fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 937 | impl<'d, T: Instance, TXDMA: TxDma<T>, RXDMA: RxDma<T>> embedded_hal_async::i2c::I2c for I2c<'d, T, TXDMA, RXDMA> { |
| 941 | self.read(address, buffer) | 938 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 942 | } | ||
| 943 | 939 | ||
| 944 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 940 | fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 945 | fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { | 941 | self.read(address, buffer) |
| 946 | self.write(address, bytes) | 942 | } |
| 947 | } | ||
| 948 | 943 | ||
| 949 | type WriteReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 944 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 950 | fn write_read<'a>( | 945 | fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { |
| 951 | &'a mut self, | 946 | self.write(address, bytes) |
| 952 | address: u8, | 947 | } |
| 953 | bytes: &'a [u8], | ||
| 954 | buffer: &'a mut [u8], | ||
| 955 | ) -> Self::WriteReadFuture<'a> { | ||
| 956 | self.write_read(address, bytes, buffer) | ||
| 957 | } | ||
| 958 | 948 | ||
| 959 | type TransactionFuture<'a, 'b> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a, 'b: 'a; | 949 | type WriteReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 950 | fn write_read<'a>( | ||
| 951 | &'a mut self, | ||
| 952 | address: u8, | ||
| 953 | bytes: &'a [u8], | ||
| 954 | buffer: &'a mut [u8], | ||
| 955 | ) -> Self::WriteReadFuture<'a> { | ||
| 956 | self.write_read(address, bytes, buffer) | ||
| 957 | } | ||
| 960 | 958 | ||
| 961 | fn transaction<'a, 'b>( | 959 | type TransactionFuture<'a, 'b> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a, 'b: 'a; |
| 962 | &'a mut self, | 960 | |
| 963 | address: u8, | 961 | fn transaction<'a, 'b>( |
| 964 | operations: &'a mut [embedded_hal_async::i2c::Operation<'b>], | 962 | &'a mut self, |
| 965 | ) -> Self::TransactionFuture<'a, 'b> { | 963 | address: u8, |
| 966 | let _ = address; | 964 | operations: &'a mut [embedded_hal_async::i2c::Operation<'b>], |
| 967 | let _ = operations; | 965 | ) -> Self::TransactionFuture<'a, 'b> { |
| 968 | async move { todo!() } | 966 | let _ = address; |
| 969 | } | 967 | let _ = operations; |
| 968 | async move { todo!() } | ||
| 970 | } | 969 | } |
| 971 | } | 970 | } |
| 972 | } | 971 | } |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 26fb392ef..acc29d87e 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -870,54 +870,48 @@ mod eh1 { | |||
| 870 | } | 870 | } |
| 871 | } | 871 | } |
| 872 | 872 | ||
| 873 | cfg_if::cfg_if! { | 873 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 874 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 874 | mod eha { |
| 875 | use core::future::Future; | 875 | use core::future::Future; |
| 876 | impl<'d, T: Instance, Tx, Rx> embedded_hal_async::spi::SpiBusFlush for Spi<'d, T, Tx, Rx> { | 876 | |
| 877 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 877 | use super::*; |
| 878 | 878 | impl<'d, T: Instance, Tx, Rx> embedded_hal_async::spi::SpiBusFlush for Spi<'d, T, Tx, Rx> { | |
| 879 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 879 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 880 | async { Ok(()) } | 880 | |
| 881 | } | 881 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 882 | async { Ok(()) } | ||
| 882 | } | 883 | } |
| 884 | } | ||
| 883 | 885 | ||
| 884 | impl<'d, T: Instance, Tx: TxDma<T>, Rx, W: Word> embedded_hal_async::spi::SpiBusWrite<W> | 886 | impl<'d, T: Instance, Tx: TxDma<T>, Rx, W: Word> embedded_hal_async::spi::SpiBusWrite<W> for Spi<'d, T, Tx, Rx> { |
| 885 | for Spi<'d, T, Tx, Rx> | 887 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 886 | { | ||
| 887 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 888 | 888 | ||
| 889 | fn write<'a>(&'a mut self, data: &'a [W]) -> Self::WriteFuture<'a> { | 889 | fn write<'a>(&'a mut self, data: &'a [W]) -> Self::WriteFuture<'a> { |
| 890 | self.write(data) | 890 | self.write(data) |
| 891 | } | ||
| 892 | } | 891 | } |
| 892 | } | ||
| 893 | 893 | ||
| 894 | impl<'d, T: Instance, Tx: TxDma<T>, Rx: RxDma<T>, W: Word> embedded_hal_async::spi::SpiBusRead<W> | 894 | impl<'d, T: Instance, Tx: TxDma<T>, Rx: RxDma<T>, W: Word> embedded_hal_async::spi::SpiBusRead<W> |
| 895 | for Spi<'d, T, Tx, Rx> | 895 | for Spi<'d, T, Tx, Rx> |
| 896 | { | 896 | { |
| 897 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 897 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 898 | 898 | ||
| 899 | fn read<'a>(&'a mut self, data: &'a mut [W]) -> Self::ReadFuture<'a> { | 899 | fn read<'a>(&'a mut self, data: &'a mut [W]) -> Self::ReadFuture<'a> { |
| 900 | self.read(data) | 900 | self.read(data) |
| 901 | } | ||
| 902 | } | 901 | } |
| 902 | } | ||
| 903 | 903 | ||
| 904 | impl<'d, T: Instance, Tx: TxDma<T>, Rx: RxDma<T>, W: Word> embedded_hal_async::spi::SpiBus<W> | 904 | impl<'d, T: Instance, Tx: TxDma<T>, Rx: RxDma<T>, W: Word> embedded_hal_async::spi::SpiBus<W> for Spi<'d, T, Tx, Rx> { |
| 905 | for Spi<'d, T, Tx, Rx> | 905 | type TransferFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 906 | { | ||
| 907 | type TransferFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 908 | 906 | ||
| 909 | fn transfer<'a>(&'a mut self, rx: &'a mut [W], tx: &'a [W]) -> Self::TransferFuture<'a> { | 907 | fn transfer<'a>(&'a mut self, rx: &'a mut [W], tx: &'a [W]) -> Self::TransferFuture<'a> { |
| 910 | self.transfer(rx, tx) | 908 | self.transfer(rx, tx) |
| 911 | } | 909 | } |
| 912 | 910 | ||
| 913 | type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 911 | type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 914 | 912 | ||
| 915 | fn transfer_in_place<'a>( | 913 | fn transfer_in_place<'a>(&'a mut self, words: &'a mut [W]) -> Self::TransferInPlaceFuture<'a> { |
| 916 | &'a mut self, | 914 | self.transfer_in_place(words) |
| 917 | words: &'a mut [W], | ||
| 918 | ) -> Self::TransferInPlaceFuture<'a> { | ||
| 919 | self.transfer_in_place(words) | ||
| 920 | } | ||
| 921 | } | 915 | } |
| 922 | } | 916 | } |
| 923 | } | 917 | } |
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 2ad85c675..6c2668748 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -361,64 +361,69 @@ mod eh1 { | |||
| 361 | } | 361 | } |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | cfg_if::cfg_if! { | 364 | #[cfg(all( |
| 365 | if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { | 365 | feature = "unstable-traits", |
| 366 | use core::future::Future; | 366 | feature = "nightly", |
| 367 | 367 | feature = "_todo_embedded_hal_serial" | |
| 368 | impl<'d, T: BasicInstance, TxDma> embedded_hal_async::serial::Write for UartTx<'d, T, TxDma> | 368 | ))] |
| 369 | where | 369 | mod eha { |
| 370 | TxDma: crate::usart::TxDma<T>, | 370 | use core::future::Future; |
| 371 | { | ||
| 372 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 373 | |||
| 374 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 375 | self.write(buf) | ||
| 376 | } | ||
| 377 | 371 | ||
| 378 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 372 | use super::*; |
| 379 | 373 | ||
| 380 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 374 | impl<'d, T: BasicInstance, TxDma> embedded_hal_async::serial::Write for UartTx<'d, T, TxDma> |
| 381 | async move { Ok(()) } | 375 | where |
| 382 | } | 376 | TxDma: crate::usart::TxDma<T>, |
| 377 | { | ||
| 378 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 379 | |||
| 380 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 381 | self.write(buf) | ||
| 383 | } | 382 | } |
| 384 | 383 | ||
| 385 | impl<'d, T: BasicInstance, RxDma> embedded_hal_async::serial::Read for UartRx<'d, T, RxDma> | 384 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 386 | where | ||
| 387 | RxDma: crate::usart::RxDma<T>, | ||
| 388 | { | ||
| 389 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 390 | 385 | ||
| 391 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | 386 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 392 | self.read(buf) | 387 | async move { Ok(()) } |
| 393 | } | ||
| 394 | } | 388 | } |
| 389 | } | ||
| 395 | 390 | ||
| 396 | impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_async::serial::Write for Uart<'d, T, TxDma, RxDma> | 391 | impl<'d, T: BasicInstance, RxDma> embedded_hal_async::serial::Read for UartRx<'d, T, RxDma> |
| 397 | where | 392 | where |
| 398 | TxDma: crate::usart::TxDma<T>, | 393 | RxDma: crate::usart::RxDma<T>, |
| 399 | { | 394 | { |
| 400 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 395 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 401 | 396 | ||
| 402 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | 397 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 403 | self.write(buf) | 398 | self.read(buf) |
| 404 | } | 399 | } |
| 400 | } | ||
| 405 | 401 | ||
| 406 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 402 | impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_async::serial::Write for Uart<'d, T, TxDma, RxDma> |
| 403 | where | ||
| 404 | TxDma: crate::usart::TxDma<T>, | ||
| 405 | { | ||
| 406 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 407 | 407 | ||
| 408 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | 408 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { |
| 409 | async move { Ok(()) } | 409 | self.write(buf) |
| 410 | } | ||
| 411 | } | 410 | } |
| 412 | 411 | ||
| 413 | impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_async::serial::Read for Uart<'d, T, TxDma, RxDma> | 412 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 414 | where | ||
| 415 | RxDma: crate::usart::RxDma<T>, | ||
| 416 | { | ||
| 417 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 418 | 413 | ||
| 419 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | 414 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { |
| 420 | self.read(buf) | 415 | async move { Ok(()) } |
| 421 | } | 416 | } |
| 417 | } | ||
| 418 | |||
| 419 | impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_async::serial::Read for Uart<'d, T, TxDma, RxDma> | ||
| 420 | where | ||
| 421 | RxDma: crate::usart::RxDma<T>, | ||
| 422 | { | ||
| 423 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 424 | |||
| 425 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 426 | self.read(buf) | ||
| 422 | } | 427 | } |
| 423 | } | 428 | } |
| 424 | } | 429 | } |
diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs index d010fff98..0a7982963 100644 --- a/embassy-time/src/delay.rs +++ b/embassy-time/src/delay.rs | |||
| @@ -31,26 +31,28 @@ mod eh1 { | |||
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | cfg_if::cfg_if! { | 34 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 35 | if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { | 35 | mod eha { |
| 36 | use crate::Timer; | 36 | use core::future::Future; |
| 37 | use core::future::Future; | ||
| 38 | use futures_util::FutureExt; | ||
| 39 | 37 | ||
| 40 | impl embedded_hal_async::delay::DelayUs for Delay { | 38 | use futures_util::FutureExt; |
| 41 | type Error = core::convert::Infallible; | ||
| 42 | 39 | ||
| 43 | type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 40 | use super::*; |
| 41 | use crate::Timer; | ||
| 42 | |||
| 43 | impl embedded_hal_async::delay::DelayUs for Delay { | ||
| 44 | type Error = core::convert::Infallible; | ||
| 44 | 45 | ||
| 45 | fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> { | 46 | type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 46 | Timer::after(Duration::from_micros(micros as _)).map(Ok) | 47 | |
| 47 | } | 48 | fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> { |
| 49 | Timer::after(Duration::from_micros(micros as _)).map(Ok) | ||
| 50 | } | ||
| 48 | 51 | ||
| 49 | type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 52 | type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; |
| 50 | 53 | ||
| 51 | fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> { | 54 | fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> { |
| 52 | Timer::after(Duration::from_millis(millis as _)).map(Ok) | 55 | Timer::after(Duration::from_millis(millis as _)).map(Ok) |
| 53 | } | ||
| 54 | } | 56 | } |
| 55 | } | 57 | } |
| 56 | } | 58 | } |
