1
- use embedded_storage:: nor_flash:: { MultiwriteNorFlash , NorFlash , ReadNorFlash } ;
1
+ use embedded_storage:: nor_flash:: {
2
+ ErrorType , MultiwriteNorFlash , NorFlash , NorFlashError , NorFlashErrorKind , ReadNorFlash ,
3
+ } ;
2
4
3
5
use crate :: pac:: FLASH ;
4
6
use crate :: signature:: FlashSize ;
@@ -357,9 +359,24 @@ pub fn flash_sectors(flash_size: usize, dual_bank: bool) -> impl Iterator<Item =
357
359
}
358
360
}
359
361
360
- impl ReadNorFlash for LockedFlash {
362
+ impl NorFlashError for Error {
363
+ fn kind ( & self ) -> NorFlashErrorKind {
364
+ match self {
365
+ Error :: ProgrammingAlignment => NorFlashErrorKind :: NotAligned ,
366
+ _ => NorFlashErrorKind :: Other ,
367
+ }
368
+ }
369
+ }
370
+
371
+ impl ErrorType for LockedFlash {
372
+ type Error = Error ;
373
+ }
374
+
375
+ impl ErrorType for UnlockedFlash < ' _ > {
361
376
type Error = Error ;
377
+ }
362
378
379
+ impl ReadNorFlash for LockedFlash {
363
380
const READ_SIZE : usize = 1 ;
364
381
365
382
fn read ( & mut self , offset : u32 , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
@@ -374,8 +391,6 @@ impl ReadNorFlash for LockedFlash {
374
391
}
375
392
376
393
impl < ' a > ReadNorFlash for UnlockedFlash < ' a > {
377
- type Error = Error ;
378
-
379
394
const READ_SIZE : usize = 1 ;
380
395
381
396
fn read ( & mut self , offset : u32 , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
0 commit comments