aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-09-09 17:35:25 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-09-09 17:35:25 +0000
commit062147bf5787c3c624fbf9d2f113afa549628635 (patch)
tree221a3675336d10bf7021925a34dd1ff24a9e2ce8 /src
parenta0a771e814910fc172129f1867aadf3d4a5aa2fd (diff)
parentf72a289c9ddc493c22a8fe4f8f6b5dedc82a48a1 (diff)
downloadcortex-m-062147bf5787c3c624fbf9d2f113afa549628635.tar.gz
cortex-m-062147bf5787c3c624fbf9d2f113afa549628635.tar.zst
cortex-m-062147bf5787c3c624fbf9d2f113afa549628635.zip
Merge #112
112: Add PendSV exception set and clear to SCB r=adamgreig a=ekohandel This change adds the ability to easily set, clear, and inquire the status of the PendSV exception via the SCB peripheral on all Cortex-M platforms. Co-authored-by: Abe Kohandel <e.kohandel@gmail.com>
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);
+ }
+ }
+}