From: Tilman Sauerbeck Date: Sun, 7 Jul 2019 07:57:33 +0000 (+0200) Subject: bootloader: Make run() function return a bool. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=2b618b466f5ba3df4bb97afb732d10469c5da3c0;p=gps-watch.git bootloader: Make run() function return a bool. The return value indicates if the caller should continue to call the function. It only returns false once COMMAND_START_APP is seen. The idea is that after run() returns false, the we can jump to the application code. --- diff --git a/src/bootloader/bootloader.rs b/src/bootloader/bootloader.rs index cf4bca2..311b1a6 100644 --- a/src/bootloader/bootloader.rs +++ b/src/bootloader/bootloader.rs @@ -121,7 +121,7 @@ impl Bootloader { } } - pub fn run(&mut self) { + pub fn run(&mut self) -> bool { if self.command_bytes < 4 { if let Some(b) = try_read_u8() { self.command >>= 8; @@ -131,10 +131,14 @@ impl Bootloader { } } - if self.command_bytes == 4 { + if self.command_bytes != 4 { + true + } else { self.command_bytes = 0; self.process_command(); + + self.command != COMMAND_START_APP } }