From 2b618b466f5ba3df4bb97afb732d10469c5da3c0 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sun, 7 Jul 2019 09:57:33 +0200 Subject: [PATCH] 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. --- src/bootloader/bootloader.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 } } -- 2.30.2