aboutsummaryrefslogtreecommitdiff
path: root/embassy-embedded-hal/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-embedded-hal/src')
-rw-r--r--embassy-embedded-hal/src/adapter.rs42
1 files changed, 0 insertions, 42 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")]
135impl<T, E> embedded_hal_async::serial::Read for BlockingAsync<T>
136where
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")]
160impl<T, E> embedded_hal_async::serial::Write for BlockingAsync<T>
161where
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
177use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; 135use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
178use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; 136use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};