We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d663483 + 30b40eb commit 498e72aCopy full SHA for 498e72a
src/peripheral/scb.rs
@@ -598,3 +598,23 @@ impl SCB {
598
}
599
600
601
+
602
+const SCB_AIRCR_VECTKEY: u32 = 0x05FA << 16;
603
+const SCB_AIRCR_PRIGROUP_MASK: u32 = 0x5 << 8;
604
+const SCB_AIRCR_SYSRESETREQ: u32 = 1 << 2;
605
606
+impl SCB {
607
+ /// Initiate a system reset request to reset the MCU
608
+ pub fn system_reset(&mut self) -> ! {
609
+ ::asm::dsb();
610
+ unsafe { self.aircr.modify(|r|
611
+ SCB_AIRCR_VECTKEY | // otherwise the write is ignored
612
+ r & SCB_AIRCR_PRIGROUP_MASK | // keep priority group unchanged
613
+ SCB_AIRCR_SYSRESETREQ // set the bit
614
+ ) };
615
616
+ loop { // wait for the reset
617
+ ::asm::nop(); // avoid rust-lang/rust#28728
618
+ }
619
620
+}
0 commit comments