Skip to content

Commit 062147b

Browse files
bors[bot]ekohandel
andcommitted
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 <[email protected]>
2 parents a0a771e + f72a289 commit 062147b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/peripheral/scb.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,29 @@ impl SCB {
615615
}
616616
}
617617
}
618+
619+
const SCB_ICSR_PENDSVSET: u32 = 1 << 28;
620+
const SCB_ICSR_PENDSVCLR: u32 = 1 << 27;
621+
622+
impl SCB {
623+
/// Set the PENDSVSET bit in the ICSR register which will pend the PendSV interrupt
624+
pub fn set_pendsv() {
625+
unsafe {
626+
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSVSET);
627+
}
628+
}
629+
630+
/// Check if PENDSVSET bit in the ICSR register is set meaning PendSV interrupt is pending
631+
pub fn is_pendsv_pending() -> bool {
632+
unsafe {
633+
(*Self::ptr()).icsr.read() & SCB_ICSR_PENDSVSET == SCB_ICSR_PENDSVSET
634+
}
635+
}
636+
637+
/// Set the PENDSVCLR bit in the ICSR register which will clear a pending PendSV interrupt
638+
pub fn clear_pendsv() {
639+
unsafe {
640+
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSVCLR);
641+
}
642+
}
643+
}

0 commit comments

Comments
 (0)