Remove BootFlash borrow

Compiler will infer a different lifetime for BootFlash than for the
borrowed flash, which makes it require more type annotations than if it
was just owning the type. Since it doesn't really matter if it owns or
borrows in practical use, change it to own so that it simplifies usage.
This commit is contained in:
Ulf Lilleengen
2022-09-20 09:42:40 +02:00
parent 6663390224
commit d0fe654c82
3 changed files with 16 additions and 17 deletions

View File

@ -21,7 +21,7 @@ fn main() -> ! {
let mut bl = BootLoader::default();
let start = bl.prepare(&mut SingleFlashConfig::new(&mut BootFlash::<_, 4096>::new(
&mut WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, 5),
WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, 5),
)));
unsafe { bl.load(start) }
}

View File

@ -20,10 +20,9 @@ fn main() -> ! {
*/
let mut bl: BootLoader<ERASE_SIZE, WRITE_SIZE> = BootLoader::default();
let mut flash = Flash::unlock(p.FLASH);
let start = bl.prepare(&mut SingleFlashConfig::new(
&mut BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(&mut flash),
));
let flash = Flash::unlock(p.FLASH);
let mut flash = BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(flash);
let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash));
core::mem::drop(flash);
unsafe { bl.load(start) }
}