aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2019-04-14 08:15:03 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2019-04-14 08:15:03 +0000
commita842718ab2e038c13ab7a17d32ccdc208d248112 (patch)
tree645a7effa5ed64425d48ca5cc469291624cd587b /src
parentc61e3af53a9509420f70f4974caa9f6de64d807d (diff)
parent3605ad2e6592f6c41cc1888a8f1bd60944150f2d (diff)
downloadcortex-m-a842718ab2e038c13ab7a17d32ccdc208d248112.tar.gz
cortex-m-a842718ab2e038c13ab7a17d32ccdc208d248112.tar.zst
cortex-m-a842718ab2e038c13ab7a17d32ccdc208d248112.zip
Merge #138
138: scb: add static version of system_reset as sys_reset r=korken89 a=hdhoang As suggested in https://github.com/ah-/anne-key/pull/94. I branched this off v0.5.8 to verify the function in that PR, and against rtfm v0.3 in https://github.com/hdhoang/anne-key/commit/d6fb831cbbb46bc10a6184b78bf13e00245234d6 I have cloned the body of `system_reset`, do you think we should call one from the other (e.g. ignoring `self` in `system_reset`, or stealing `Peripherals` in `system_reset2`)? Co-authored-by: Hoàng Đức Hiếu <code@hdhoang.space>
Diffstat (limited to 'src')
-rw-r--r--src/peripheral/scb.rs20
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;