aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Hoàng Đức Hiếu <code@hdhoang.space> 2019-03-21 09:29:04 +0700
committerGravatar Hoàng Đức Hiếu <code@hdhoang.space> 2019-03-21 11:00:21 +0700
commitc36535dde320a4a5fb186a2753afca262814bd42 (patch)
tree50c66a9e0e211645d793e296c616eb7cd55acbab /src
parent8fd4547db6fb562dbaafe592b8415bae78a76106 (diff)
downloadcortex-m-c36535dde320a4a5fb186a2753afca262814bd42.tar.gz
cortex-m-c36535dde320a4a5fb186a2753afca262814bd42.tar.zst
cortex-m-c36535dde320a4a5fb186a2753afca262814bd42.zip
scb: add static version of system_reset as system_reset2
Diffstat (limited to 'src')
-rw-r--r--src/peripheral/scb.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/peripheral/scb.rs b/src/peripheral/scb.rs
index 888a3db..951c0c1 100644
--- a/src/peripheral/scb.rs
+++ b/src/peripheral/scb.rs
@@ -619,6 +619,27 @@ impl SCB {
::asm::nop(); // avoid rust-lang/rust#28728
}
}
+
+ /// Initiate a system reset request to reset the MCU
+ ///
+ /// Static version of [`SCB::system_reset`].
+ pub fn system_reset2() -> ! {
+ ::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;