diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/peripheral/scb.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/peripheral/scb.rs b/src/peripheral/scb.rs index c82e098..59eedba 100644 --- a/src/peripheral/scb.rs +++ b/src/peripheral/scb.rs @@ -620,6 +620,7 @@ const SCB_AIRCR_SYSRESETREQ: u32 = 1 << 2; impl SCB { /// Initiate a system reset request to reset the MCU + #[deprecated(since = "0.6.1", note = "Use `SCB::sys_reset`")] pub fn system_reset(&mut self) -> ! { ::asm::dsb(); unsafe { @@ -637,6 +638,25 @@ impl SCB { ::asm::nop(); // avoid rust-lang/rust#28728 } } + + /// Initiate a system reset request to reset the MCU + pub fn sys_reset() -> ! { + ::asm::dsb(); + unsafe { + (*Self::ptr()).aircr.modify( + |r| { + SCB_AIRCR_VECTKEY | // otherwise the write is ignored + r & SCB_AIRCR_PRIGROUP_MASK | // keep priority group unchanged + SCB_AIRCR_SYSRESETREQ + }, // set the bit + ) + }; + ::asm::dsb(); + loop { + // wait for the reset + ::asm::nop(); // avoid rust-lang/rust#28728 + } + } } const SCB_ICSR_PENDSVSET: u32 = 1 << 28; |