diff options
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 6f8b6a9e8..d71aa61a4 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -910,6 +910,58 @@ mod eh1 { | |||
| 910 | } | 910 | } |
| 911 | } | 911 | } |
| 912 | 912 | ||
| 913 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | ||
| 914 | mod eio { | ||
| 915 | use embedded_io::asynch::Write; | ||
| 916 | use embedded_io::Io; | ||
| 917 | |||
| 918 | use super::*; | ||
| 919 | |||
| 920 | impl<T, TxDma, RxDma> Io for Uart<'_, T, TxDma, RxDma> | ||
| 921 | where | ||
| 922 | T: BasicInstance, | ||
| 923 | { | ||
| 924 | type Error = Error; | ||
| 925 | } | ||
| 926 | |||
| 927 | impl<T, TxDma, RxDma> Write for Uart<'_, T, TxDma, RxDma> | ||
| 928 | where | ||
| 929 | T: BasicInstance, | ||
| 930 | TxDma: super::TxDma<T>, | ||
| 931 | { | ||
| 932 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | ||
| 933 | self.write(buf).await?; | ||
| 934 | Ok(buf.len()) | ||
| 935 | } | ||
| 936 | |||
| 937 | async fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 938 | self.blocking_flush() | ||
| 939 | } | ||
| 940 | } | ||
| 941 | |||
| 942 | impl<T, TxDma> Io for UartTx<'_, T, TxDma> | ||
| 943 | where | ||
| 944 | T: BasicInstance, | ||
| 945 | { | ||
| 946 | type Error = Error; | ||
| 947 | } | ||
| 948 | |||
| 949 | impl<T, TxDma> Write for UartTx<'_, T, TxDma> | ||
| 950 | where | ||
| 951 | T: BasicInstance, | ||
| 952 | TxDma: super::TxDma<T>, | ||
| 953 | { | ||
| 954 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | ||
| 955 | self.write(buf).await?; | ||
| 956 | Ok(buf.len()) | ||
| 957 | } | ||
| 958 | |||
| 959 | async fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 960 | self.blocking_flush() | ||
| 961 | } | ||
| 962 | } | ||
| 963 | } | ||
| 964 | |||
| 913 | #[cfg(all( | 965 | #[cfg(all( |
| 914 | feature = "unstable-traits", | 966 | feature = "unstable-traits", |
| 915 | feature = "nightly", | 967 | feature = "nightly", |
