diff options
| author | Mehmet Ali Anil <[email protected]> | 2023-03-06 22:08:47 +0100 |
|---|---|---|
| committer | Mehmet Ali Anil <[email protected]> | 2023-03-06 22:16:36 +0100 |
| commit | bc0cb43307c2a46330ce253505203dbc607bcc6c (patch) | |
| tree | fa0ddab9184b802efa9e6313c90847ad167184c5 /embassy-embedded-hal/src/adapter.rs | |
| parent | 2209bef4f22bf77d9d52cda0a0ea40485cc2747a (diff) | |
Bump embedded-storage-async to 0.4
Diffstat (limited to 'embassy-embedded-hal/src/adapter.rs')
| -rw-r--r-- | embassy-embedded-hal/src/adapter.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/embassy-embedded-hal/src/adapter.rs b/embassy-embedded-hal/src/adapter.rs index 3680984f1..a49f8df4b 100644 --- a/embassy-embedded-hal/src/adapter.rs +++ b/embassy-embedded-hal/src/adapter.rs | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | //! Adapters between embedded-hal traits. | 1 | //! Adapters between embedded-hal traits. |
| 2 | 2 | ||
| 3 | use core::future::Future; | ||
| 4 | |||
| 5 | use embedded_hal_02::{blocking, serial}; | 3 | use embedded_hal_02::{blocking, serial}; |
| 6 | 4 | ||
| 7 | /// Wrapper that implements async traits using blocking implementations. | 5 | /// Wrapper that implements async traits using blocking implementations. |
| @@ -182,7 +180,7 @@ where | |||
| 182 | 180 | ||
| 183 | /// NOR flash wrapper | 181 | /// NOR flash wrapper |
| 184 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; | 182 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; |
| 185 | use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash}; | 183 | use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; |
| 186 | 184 | ||
| 187 | impl<T> ErrorType for BlockingAsync<T> | 185 | impl<T> ErrorType for BlockingAsync<T> |
| 188 | where | 186 | where |
| @@ -198,14 +196,12 @@ where | |||
| 198 | const WRITE_SIZE: usize = <T as NorFlash>::WRITE_SIZE; | 196 | const WRITE_SIZE: usize = <T as NorFlash>::WRITE_SIZE; |
| 199 | const ERASE_SIZE: usize = <T as NorFlash>::ERASE_SIZE; | 197 | const ERASE_SIZE: usize = <T as NorFlash>::ERASE_SIZE; |
| 200 | 198 | ||
| 201 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 199 | async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> { |
| 202 | fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> { | 200 | self.wrapped.write(offset, data) |
| 203 | async move { self.wrapped.write(offset, data) } | ||
| 204 | } | 201 | } |
| 205 | 202 | ||
| 206 | type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 203 | async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { |
| 207 | fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { | 204 | self.wrapped.erase(from, to) |
| 208 | async move { self.wrapped.erase(from, to) } | ||
| 209 | } | 205 | } |
| 210 | } | 206 | } |
| 211 | 207 | ||
| @@ -214,9 +210,8 @@ where | |||
| 214 | T: ReadNorFlash, | 210 | T: ReadNorFlash, |
| 215 | { | 211 | { |
| 216 | const READ_SIZE: usize = <T as ReadNorFlash>::READ_SIZE; | 212 | const READ_SIZE: usize = <T as ReadNorFlash>::READ_SIZE; |
| 217 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 213 | async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> { |
| 218 | fn read<'a>(&'a mut self, address: u32, data: &'a mut [u8]) -> Self::ReadFuture<'a> { | 214 | self.wrapped.read(address, data) |
| 219 | async move { self.wrapped.read(address, data) } | ||
| 220 | } | 215 | } |
| 221 | 216 | ||
| 222 | fn capacity(&self) -> usize { | 217 | fn capacity(&self) -> usize { |
