X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fbootloader%2Fflash.rs;h=7d0d294f0d92b62c4d2c256873481366f173cf85;hb=d6daa720f563825f35bf347dfd6948109e40bc5f;hp=f6c00d956622a9068216d87a128c89b858e0c78f;hpb=ba2d74b93676c335eb41cdb6d75978cf20a9340a;p=gps-watch.git diff --git a/src/bootloader/flash.rs b/src/bootloader/flash.rs index f6c00d9..7d0d294 100644 --- a/src/bootloader/flash.rs +++ b/src/bootloader/flash.rs @@ -41,7 +41,6 @@ const FTFA_FSTAT_MGSTAT0 : u8 = 1 << 0; const FTFA_FSTAT_FPVIOL : u8 = 1 << 4; const FTFA_FSTAT_ACCERR : u8 = 1 << 5; const FTFA_FSTAT_RDCOLERR: u8 = 1 << 6; -const FTFA_FSTAT_CCIF : u8 = 1 << 7; const FCMD_RD1SEC : u8 = 0x01; const FCMD_PGM4 : u8 = 0x06; @@ -49,6 +48,10 @@ const FCMD_ERSSCR : u8 = 0x09; pub const SECTOR_SIZE : usize = 1024; +extern { + fn flash_run_command() -> u8; +} + // The hardware refuses to run another command (or even take the new command's // parameters) until the errors reported by a previous command have been // acknowledged (see KL26P121M48SF4RM.pdf p. 445). @@ -59,19 +62,7 @@ fn prepare_command() { } fn run_command() -> u8 { - let mut fstat = Reg8::new(FTFA_FSTAT); - - // Start command. - fstat.write(FTFA_FSTAT_CCIF); - - // Wait for it to finish. - loop { - let v = fstat.read(); - - if (v & FTFA_FSTAT_CCIF) != 0 { - return v; - } - } + unsafe { flash_run_command() } } fn erase_check(sector: u32) -> bool {