@@ -2,7 +2,7 @@ use atomic_polyfill::{fence, Ordering};
2
2
use embassy_hal_common:: drop:: OnDrop ;
3
3
use embassy_hal_common:: { into_ref, PeripheralRef } ;
4
4
5
- use super :: { family, Error , FlashLayout , FlashRegion , FlashSector , FLASH_BASE , FLASH_SIZE , WRITE_SIZE } ;
5
+ use super :: { family, Error , FlashLayout , FlashRegion , FlashSector , FLASH_BASE , FLASH_SIZE , MAX_ERASE_SIZE , WRITE_SIZE } ;
6
6
use crate :: flash:: FlashBank ;
7
7
use crate :: Peripheral ;
8
8
@@ -162,6 +162,35 @@ impl FlashRegion {
162
162
}
163
163
}
164
164
165
+ impl embedded_storage:: nor_flash:: ErrorType for Flash < ' _ > {
166
+ type Error = Error ;
167
+ }
168
+
169
+ impl embedded_storage:: nor_flash:: ReadNorFlash for Flash < ' _ > {
170
+ const READ_SIZE : usize = 1 ;
171
+
172
+ fn read ( & mut self , offset : u32 , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
173
+ self . blocking_read ( offset, bytes)
174
+ }
175
+
176
+ fn capacity ( & self ) -> usize {
177
+ FLASH_SIZE
178
+ }
179
+ }
180
+
181
+ impl embedded_storage:: nor_flash:: NorFlash for Flash < ' _ > {
182
+ const WRITE_SIZE : usize = WRITE_SIZE ;
183
+ const ERASE_SIZE : usize = MAX_ERASE_SIZE ;
184
+
185
+ fn write ( & mut self , offset : u32 , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
186
+ self . blocking_write ( offset, bytes)
187
+ }
188
+
189
+ fn erase ( & mut self , from : u32 , to : u32 ) -> Result < ( ) , Self :: Error > {
190
+ self . blocking_erase ( from, to)
191
+ }
192
+ }
193
+
165
194
foreach_flash_region ! {
166
195
( $type_name: ident, $write_size: literal, $erase_size: literal) => {
167
196
impl crate :: _generated:: flash_regions:: $type_name<' _> {
0 commit comments