aboutsummaryrefslogtreecommitdiff
path: root/embassy-embedded-hal/src
diff options
context:
space:
mode:
authorMehmet Ali Anil <[email protected]>2023-03-06 22:08:47 +0100
committerMehmet Ali Anil <[email protected]>2023-03-06 22:16:36 +0100
commitbc0cb43307c2a46330ce253505203dbc607bcc6c (patch)
treefa0ddab9184b802efa9e6313c90847ad167184c5 /embassy-embedded-hal/src
parent2209bef4f22bf77d9d52cda0a0ea40485cc2747a (diff)
Bump embedded-storage-async to 0.4
Diffstat (limited to 'embassy-embedded-hal/src')
-rw-r--r--embassy-embedded-hal/src/adapter.rs19
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
3use core::future::Future;
4
5use embedded_hal_02::{blocking, serial}; 3use 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
184use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; 182use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash};
185use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash}; 183use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
186 184
187impl<T> ErrorType for BlockingAsync<T> 185impl<T> ErrorType for BlockingAsync<T>
188where 186where
@@ -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 {