application: Perform system reset from panic handler if requested.
[gps-watch.git] / src / application / main.rs
index b11950366e6bbd826081c548b3d25b6ff0fc4547..92429e5d4a404d05ed0a4ef9bba4a544cabe60ff 100644 (file)
@@ -75,6 +75,16 @@ impl Timer {
     }
 }
 
+#[inline(never)]
+#[panic_handler]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+    loop {
+        if (gpio::get(gpio::GPIOA) & (1 << 12)) == 0 {
+            nvic::system_reset();
+        }
+    }
+}
+
 #[no_mangle]
 pub unsafe extern "C" fn _start() -> ! {
     clock::configure();