diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-12-15 11:01:16 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-15 11:01:16 +0000 |
| commit | 1e37cc5498d30404ce0daf59748bce22ac4815cf (patch) | |
| tree | 5a30ce8cf50854f0a699a421486a87f11e472c24 /embassy-nrf | |
| parent | c84996df8a8f56404f5b57264383e1f53a912510 (diff) | |
| parent | f5ead85377ab78d8f463df4f1e358770ff3eca5b (diff) | |
Merge pull request #3646 from wackazong/embedded_io_async_uarte
Add trait embedded_io_async to uarte
Diffstat (limited to 'embassy-nrf')
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 2a59d029d..ebb4dd941 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -1047,3 +1047,42 @@ mod eh02 { | |||
| 1047 | } | 1047 | } |
| 1048 | } | 1048 | } |
| 1049 | } | 1049 | } |
| 1050 | |||
| 1051 | mod _embedded_io { | ||
| 1052 | use super::*; | ||
| 1053 | |||
| 1054 | impl embedded_io_async::Error for Error { | ||
| 1055 | fn kind(&self) -> embedded_io_async::ErrorKind { | ||
| 1056 | match *self { | ||
| 1057 | Error::BufferTooLong => embedded_io_async::ErrorKind::InvalidInput, | ||
| 1058 | Error::BufferNotInRAM => embedded_io_async::ErrorKind::Unsupported, | ||
| 1059 | Error::Framing => embedded_io_async::ErrorKind::InvalidData, | ||
| 1060 | Error::Parity => embedded_io_async::ErrorKind::InvalidData, | ||
| 1061 | Error::Overrun => embedded_io_async::ErrorKind::OutOfMemory, | ||
| 1062 | Error::Break => embedded_io_async::ErrorKind::ConnectionAborted, | ||
| 1063 | } | ||
| 1064 | } | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | impl<'d, U: Instance> embedded_io_async::ErrorType for Uarte<'d, U> { | ||
| 1068 | type Error = Error; | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | impl<'d, U: Instance> embedded_io_async::ErrorType for UarteTx<'d, U> { | ||
| 1072 | type Error = Error; | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | impl<'d, U: Instance> embedded_io_async::Write for Uarte<'d, U> { | ||
| 1076 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | ||
| 1077 | self.write(buf).await?; | ||
| 1078 | Ok(buf.len()) | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | impl<'d: 'd, U: Instance> embedded_io_async::Write for UarteTx<'d, U> { | ||
| 1083 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | ||
| 1084 | self.write(buf).await?; | ||
| 1085 | Ok(buf.len()) | ||
| 1086 | } | ||
| 1087 | } | ||
| 1088 | } | ||
