Skip to content

Commit 454bb4e

Browse files
committed
Fix duplicate PendSV.
1 parent 19d3534 commit 454bb4e

File tree

1 file changed

+28
-56
lines changed

1 file changed

+28
-56
lines changed

src/peripheral/scb.rs

Lines changed: 28 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,6 @@ impl VectActive {
297297
mod scb_consts {
298298
pub const SCB_CCR_IC_MASK: u32 = (1 << 17);
299299
pub const SCB_CCR_DC_MASK: u32 = (1 << 16);
300-
301-
pub const SCB_ICSR_PENDSVSET_MASK: u32 = 1 << 28;
302-
pub const SCB_ICSR_PENDSVCLR_MASK: u32 = 1 << 27;
303-
304-
pub const SCB_ICSR_PENDSTSET_MASK: u32 = 1 << 26;
305-
pub const SCB_ICSR_PENDSTCLR_MASK: u32 = 1 << 25;
306300
}
307301

308302
#[cfg(not(armv6m))]
@@ -582,56 +576,6 @@ impl SCB {
582576
::asm::dsb();
583577
::asm::isb();
584578
}
585-
586-
/// Pending SV Flag
587-
///
588-
/// return true if PendSV exception is pending, otherwise false
589-
#[inline]
590-
pub fn is_pendsv() -> bool {
591-
// NOTE(unsafe) atomic read with no side effects
592-
unsafe { (*Self::ptr()).icsr.read() & SCB_ICSR_PENDSVSET_MASK != 0 }
593-
}
594-
595-
/// Changes PendSV exception state to pending Set Pending SV Flag
596-
#[inline]
597-
pub fn set_pendsv(&mut self) {
598-
unsafe {
599-
self.icsr.write(SCB_ICSR_PENDSVSET_MASK);
600-
}
601-
}
602-
603-
/// Removes the pending state from the PendSV exception
604-
#[inline]
605-
pub fn clear_pendsv(&mut self) {
606-
unsafe {
607-
self.icsr.write(SCB_ICSR_PENDSVCLR_MASK);
608-
}
609-
}
610-
611-
/// ICSR SysTick flag
612-
///
613-
/// return true if SysTick exception is pending, otherwise false
614-
#[inline]
615-
pub fn is_systick_pending() -> bool {
616-
// NOTE(unsafe) atomic read with no side effects
617-
unsafe { (*Self::ptr()).icsr.read() & SCB_ICSR_PENDSTSET_MASK != 0 }
618-
}
619-
620-
/// Changes SysTick exception state to pending
621-
#[inline]
622-
pub fn set_systick_pending(&mut self) {
623-
unsafe {
624-
self.icsr.write(SCB_ICSR_PENDSTSET_MASK);
625-
}
626-
}
627-
628-
/// Removes the pending state from the SysTick exception
629-
#[inline]
630-
pub fn clear_systick_pending(&mut self) {
631-
unsafe {
632-
self.icsr.write(SCB_ICSR_PENDSTCLR_MASK);
633-
}
634-
}
635579
}
636580

637581
const SCB_SCR_SLEEPDEEP: u32 = 0x1 << 2;
@@ -675,6 +619,9 @@ impl SCB {
675619
const SCB_ICSR_PENDSVSET: u32 = 1 << 28;
676620
const SCB_ICSR_PENDSVCLR: u32 = 1 << 27;
677621

622+
const SCB_ICSR_PENDSTSET: u32 = 1 << 26;
623+
const SCB_ICSR_PENDSTCLR: u32 = 1 << 25;
624+
678625
impl SCB {
679626
/// Set the PENDSVSET bit in the ICSR register which will pend the PendSV interrupt
680627
pub fn set_pendsv() {
@@ -696,4 +643,29 @@ impl SCB {
696643
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSVCLR);
697644
}
698645
}
646+
647+
/// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt
648+
#[inline]
649+
pub fn set_systick(&mut self) {
650+
unsafe {
651+
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSTSET);
652+
}
653+
}
654+
655+
/// Check if PENDSTSET bit in the ICSR register is set meaning SysTick interrupt is pending
656+
#[inline]
657+
pub fn is_systick_pending() -> bool {
658+
unsafe {
659+
(*Self::ptr()).icsr.read() & SCB_ICSR_PENDSTSET == SCB_ICSR_PENDSTSET
660+
}
661+
}
662+
663+
664+
/// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt
665+
#[inline]
666+
pub fn clear_systick_pending(&mut self) {
667+
unsafe {
668+
(*Self::ptr()).icsr.write(SCB_ICSR_PENDSTCLR);
669+
}
670+
}
699671
}

0 commit comments

Comments
 (0)