aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Abe Kohandel <e.kohandel@gmail.com> 2018-09-02 14:54:56 -0700
committerGravatar Abe Kohandel <e.kohandel@gmail.com> 2018-09-03 18:03:53 -0700
commitf72a289c9ddc493c22a8fe4f8f6b5dedc82a48a1 (patch)
tree0ae88d63e83a6434059d3a0f150539eebd4e8407 /src
parent278ab0d5b929dc23e6d9538faf1bc2ac633b9caa (diff)
downloadcortex-m-f72a289c9ddc493c22a8fe4f8f6b5dedc82a48a1.tar.gz
cortex-m-f72a289c9ddc493c22a8fe4f8f6b5dedc82a48a1.tar.zst
cortex-m-f72a289c9ddc493c22a8fe4f8f6b5dedc82a48a1.zip
Add PendSV exception set and clear to SCB
Diffstat (limited to 'src')
-rw-r--r--src/peripheral/scb.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/peripheral/scb.rs b/src/peripheral/scb.rs
index d26e0a6..939d5a7 100644
--- a/src/peripheral/scb.rs
+++ b/src/peripheral/scb.rs
@@ -615,3 +615,29 @@ impl SCB {
}
}
}
+
+const SCB_ICSR_PENDSVSET: u32 = 1 << 28;
+const SCB_ICSR_PENDSVCLR: u32 = 1 << 27;
+
+impl SCB {
+ /// Set the PENDSVSET bit in the ICSR register which will pend the PendSV interrupt
+ pub fn set_pendsv() {
+ unsafe {
+ (*Self::ptr()).icsr.write(SCB_ICSR_PENDSVSET);
+ }
+ }
+
+ /// Check if PENDSVSET bit in the ICSR register is set meaning PendSV interrupt is pending
+ pub fn is_pendsv_pending() -> bool {
+ unsafe {
+ (*Self::ptr()).icsr.read() & SCB_ICSR_PENDSVSET == SCB_ICSR_PENDSVSET
+ }
+ }
+
+ /// Set the PENDSVCLR bit in the ICSR register which will clear a pending PendSV interrupt
+ pub fn clear_pendsv() {
+ unsafe {
+ (*Self::ptr()).icsr.write(SCB_ICSR_PENDSVCLR);
+ }
+ }
+}