1- use embedded_storage:: nor_flash:: { MultiwriteNorFlash , NorFlash , ReadNorFlash } ;
1+ use embedded_storage:: nor_flash:: {
2+ ErrorType , MultiwriteNorFlash , NorFlash , NorFlashError , NorFlashErrorKind , ReadNorFlash ,
3+ } ;
24
35use crate :: pac:: FLASH ;
46use crate :: signature:: FlashSize ;
@@ -357,9 +359,24 @@ pub fn flash_sectors(flash_size: usize, dual_bank: bool) -> impl Iterator<Item =
357359 }
358360}
359361
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 < ' _ > {
361376 type Error = Error ;
377+ }
362378
379+ impl ReadNorFlash for LockedFlash {
363380 const READ_SIZE : usize = 1 ;
364381
365382 fn read ( & mut self , offset : u32 , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
@@ -374,8 +391,6 @@ impl ReadNorFlash for LockedFlash {
374391}
375392
376393impl < ' a > ReadNorFlash for UnlockedFlash < ' a > {
377- type Error = Error ;
378-
379394 const READ_SIZE : usize = 1 ;
380395
381396 fn read ( & mut self , offset : u32 , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
0 commit comments