Skip to content

Commit c36535d

Browse files
committed
scb: add static version of system_reset as system_reset2
1 parent 8fd4547 commit c36535d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/peripheral/scb.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,27 @@ impl SCB {
619619
::asm::nop(); // avoid rust-lang/rust#28728
620620
}
621621
}
622+
623+
/// Initiate a system reset request to reset the MCU
624+
///
625+
/// Static version of [`SCB::system_reset`].
626+
pub fn system_reset2() -> ! {
627+
::asm::dsb();
628+
unsafe {
629+
(*Self::ptr()).aircr.modify(
630+
|r| {
631+
SCB_AIRCR_VECTKEY | // otherwise the write is ignored
632+
r & SCB_AIRCR_PRIGROUP_MASK | // keep priority group unchanged
633+
SCB_AIRCR_SYSRESETREQ
634+
}, // set the bit
635+
)
636+
};
637+
::asm::dsb();
638+
loop {
639+
// wait for the reset
640+
::asm::nop(); // avoid rust-lang/rust#28728
641+
}
642+
}
622643
}
623644

624645
const SCB_ICSR_PENDSVSET: u32 = 1 << 28;

0 commit comments

Comments
 (0)