diff options
| -rw-r--r-- | embassy-embedded-hal/src/adapter.rs | 42 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 77 | ||||
| -rw-r--r-- | embassy-rp/src/uart/buffered.rs | 55 | ||||
| -rw-r--r-- | embassy-rp/src/uart/mod.rs | 55 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 67 |
5 files changed, 0 insertions, 296 deletions
diff --git a/embassy-embedded-hal/src/adapter.rs b/embassy-embedded-hal/src/adapter.rs index ee919bd84..171ff6c9f 100644 --- a/embassy-embedded-hal/src/adapter.rs +++ b/embassy-embedded-hal/src/adapter.rs | |||
| @@ -131,48 +131,6 @@ where | |||
| 131 | type Error = E; | 131 | type Error = E; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | #[cfg(feature = "_todo_embedded_hal_serial")] | ||
| 135 | impl<T, E> embedded_hal_async::serial::Read for BlockingAsync<T> | ||
| 136 | where | ||
| 137 | T: serial::Read<u8, Error = E>, | ||
| 138 | E: embedded_hal_1::serial::Error + 'static, | ||
| 139 | { | ||
| 140 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where T: 'a; | ||
| 141 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 142 | async move { | ||
| 143 | let mut pos = 0; | ||
| 144 | while pos < buf.len() { | ||
| 145 | match self.wrapped.read() { | ||
| 146 | Err(nb::Error::WouldBlock) => {} | ||
| 147 | Err(nb::Error::Other(e)) => return Err(e), | ||
| 148 | Ok(b) => { | ||
| 149 | buf[pos] = b; | ||
| 150 | pos += 1; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | } | ||
| 154 | Ok(()) | ||
| 155 | } | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | #[cfg(feature = "_todo_embedded_hal_serial")] | ||
| 160 | impl<T, E> embedded_hal_async::serial::Write for BlockingAsync<T> | ||
| 161 | where | ||
| 162 | T: blocking::serial::Write<u8, Error = E> + serial::Read<u8, Error = E>, | ||
| 163 | E: embedded_hal_1::serial::Error + 'static, | ||
| 164 | { | ||
| 165 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where T: 'a; | ||
| 166 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 167 | async move { self.wrapped.bwrite_all(buf) } | ||
| 168 | } | ||
| 169 | |||
| 170 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where T: 'a; | ||
| 171 | fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 172 | async move { self.wrapped.bflush() } | ||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 176 | /// NOR flash wrapper | 134 | /// NOR flash wrapper |
| 177 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; | 135 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; |
| 178 | use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; | 136 | use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index e59b2332a..586c88b2d 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -992,80 +992,3 @@ mod eh1 { | |||
| 992 | type Error = Error; | 992 | type Error = Error; |
| 993 | } | 993 | } |
| 994 | } | 994 | } |
| 995 | |||
| 996 | #[cfg(all( | ||
| 997 | feature = "unstable-traits", | ||
| 998 | feature = "nightly", | ||
| 999 | feature = "_todo_embedded_hal_serial" | ||
| 1000 | ))] | ||
| 1001 | mod eha { | ||
| 1002 | use core::future::Future; | ||
| 1003 | |||
| 1004 | use super::*; | ||
| 1005 | |||
| 1006 | impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { | ||
| 1007 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1008 | |||
| 1009 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 1010 | self.read(buffer) | ||
| 1011 | } | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | impl<'d, T: Instance> embedded_hal_async::serial::Write for Uarte<'d, T> { | ||
| 1015 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1016 | |||
| 1017 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 1018 | self.write(buffer) | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1022 | |||
| 1023 | fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 1024 | async move { Ok(()) } | ||
| 1025 | } | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { | ||
| 1029 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1030 | |||
| 1031 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 1032 | self.write(buffer) | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1036 | |||
| 1037 | fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 1038 | async move { Ok(()) } | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { | ||
| 1043 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1044 | |||
| 1045 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 1046 | self.read(buffer) | ||
| 1047 | } | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read for UarteWithIdle<'d, U, T> { | ||
| 1051 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1052 | |||
| 1053 | fn read<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 1054 | self.read(buffer) | ||
| 1055 | } | ||
| 1056 | } | ||
| 1057 | |||
| 1058 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Write for UarteWithIdle<'d, U, T> { | ||
| 1059 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1060 | |||
| 1061 | fn write<'a>(&'a mut self, buffer: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 1062 | self.write(buffer) | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1066 | |||
| 1067 | fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 1068 | async move { Ok(()) } | ||
| 1069 | } | ||
| 1070 | } | ||
| 1071 | } | ||
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index c620ed08c..cb0461930 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs | |||
| @@ -726,58 +726,3 @@ mod eh1 { | |||
| 726 | } | 726 | } |
| 727 | } | 727 | } |
| 728 | } | 728 | } |
| 729 | |||
| 730 | #[cfg(all( | ||
| 731 | feature = "unstable-traits", | ||
| 732 | feature = "nightly", | ||
| 733 | feature = "_todo_embedded_hal_serial" | ||
| 734 | ))] | ||
| 735 | mod eha { | ||
| 736 | use core::future::Future; | ||
| 737 | |||
| 738 | use super::*; | ||
| 739 | |||
| 740 | impl<'d, T: Instance> embedded_hal_async::serial::Write for BufferedUartTx<'d, T> { | ||
| 741 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 742 | |||
| 743 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 744 | Self::write(buf) | ||
| 745 | } | ||
| 746 | |||
| 747 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 748 | |||
| 749 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 750 | Self::flush() | ||
| 751 | } | ||
| 752 | } | ||
| 753 | |||
| 754 | impl<'d, T: Instance> embedded_hal_async::serial::Read for BufferedUartRx<'d, T> { | ||
| 755 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 756 | |||
| 757 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 758 | Self::read(buf) | ||
| 759 | } | ||
| 760 | } | ||
| 761 | |||
| 762 | impl<'d, T: Instance> embedded_hal_async::serial::Write for BufferedUart<'d, T> { | ||
| 763 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 764 | |||
| 765 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 766 | BufferedUartTx::<'d, T>::write(buf) | ||
| 767 | } | ||
| 768 | |||
| 769 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 770 | |||
| 771 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 772 | BufferedUartTx::<'d, T>::flush() | ||
| 773 | } | ||
| 774 | } | ||
| 775 | |||
| 776 | impl<'d, T: Instance> embedded_hal_async::serial::Read for BufferedUart<'d, T> { | ||
| 777 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 778 | |||
| 779 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 780 | BufferedUartRx::<'d, T>::read(buf) | ||
| 781 | } | ||
| 782 | } | ||
| 783 | } | ||
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index a945f2295..7122930f5 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -651,61 +651,6 @@ mod eh1 { | |||
| 651 | } | 651 | } |
| 652 | } | 652 | } |
| 653 | 653 | ||
| 654 | #[cfg(all( | ||
| 655 | feature = "unstable-traits", | ||
| 656 | feature = "nightly", | ||
| 657 | feature = "_todo_embedded_hal_serial" | ||
| 658 | ))] | ||
| 659 | mod eha { | ||
| 660 | use core::future::Future; | ||
| 661 | |||
| 662 | use super::*; | ||
| 663 | |||
| 664 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for UartTx<'d, T, M> { | ||
| 665 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 666 | |||
| 667 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 668 | self.write(buf) | ||
| 669 | } | ||
| 670 | |||
| 671 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 672 | |||
| 673 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 674 | async move { Ok(()) } | ||
| 675 | } | ||
| 676 | } | ||
| 677 | |||
| 678 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for UartRx<'d, T, M> { | ||
| 679 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 680 | |||
| 681 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 682 | self.read(buf) | ||
| 683 | } | ||
| 684 | } | ||
| 685 | |||
| 686 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for Uart<'d, T, M> { | ||
| 687 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 688 | |||
| 689 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 690 | self.write(buf) | ||
| 691 | } | ||
| 692 | |||
| 693 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 694 | |||
| 695 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 696 | async move { Ok(()) } | ||
| 697 | } | ||
| 698 | } | ||
| 699 | |||
| 700 | impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for Uart<'d, T, M> { | ||
| 701 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 702 | |||
| 703 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 704 | self.read(buf) | ||
| 705 | } | ||
| 706 | } | ||
| 707 | } | ||
| 708 | |||
| 709 | mod sealed { | 654 | mod sealed { |
| 710 | use super::*; | 655 | use super::*; |
| 711 | 656 | ||
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index a42eede18..8bbba305b 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -973,73 +973,6 @@ mod eio { | |||
| 973 | } | 973 | } |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | #[cfg(all( | ||
| 977 | feature = "unstable-traits", | ||
| 978 | feature = "nightly", | ||
| 979 | feature = "_todo_embedded_hal_serial" | ||
| 980 | ))] | ||
| 981 | mod eha { | ||
| 982 | use core::future::Future; | ||
| 983 | |||
| 984 | use super::*; | ||
| 985 | |||
| 986 | impl<'d, T: BasicInstance, TxDma> embedded_hal_async::serial::Write for UartTx<'d, T, TxDma> | ||
| 987 | where | ||
| 988 | TxDma: crate::usart::TxDma<T>, | ||
| 989 | { | ||
| 990 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 991 | |||
| 992 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 993 | self.write(buf) | ||
| 994 | } | ||
| 995 | |||
| 996 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 997 | |||
| 998 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 999 | async move { Ok(()) } | ||
| 1000 | } | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | impl<'d, T: BasicInstance, RxDma> embedded_hal_async::serial::Read for UartRx<'d, T, RxDma> | ||
| 1004 | where | ||
| 1005 | RxDma: crate::usart::RxDma<T>, | ||
| 1006 | { | ||
| 1007 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1008 | |||
| 1009 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 1010 | self.read(buf) | ||
| 1011 | } | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_async::serial::Write for Uart<'d, T, TxDma, RxDma> | ||
| 1015 | where | ||
| 1016 | TxDma: crate::usart::TxDma<T>, | ||
| 1017 | { | ||
| 1018 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1019 | |||
| 1020 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 1021 | self.write(buf) | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1025 | |||
| 1026 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 1027 | async move { Ok(()) } | ||
| 1028 | } | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_async::serial::Read for Uart<'d, T, TxDma, RxDma> | ||
| 1032 | where | ||
| 1033 | RxDma: crate::usart::RxDma<T>, | ||
| 1034 | { | ||
| 1035 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | ||
| 1036 | |||
| 1037 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 1038 | self.read(buf) | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | #[cfg(feature = "nightly")] | 976 | #[cfg(feature = "nightly")] |
| 1044 | pub use buffered::*; | 977 | pub use buffered::*; |
| 1045 | #[cfg(feature = "nightly")] | 978 | #[cfg(feature = "nightly")] |
