@@ -7,9 +7,9 @@ use volatile_register::RW;
7
7
#[ cfg( not( armv6m) ) ]
8
8
use super :: cpuid:: CsselrCacheType ;
9
9
#[ cfg( not( armv6m) ) ]
10
- use super :: CPUID ;
11
- #[ cfg( not( armv6m) ) ]
12
10
use super :: CBP ;
11
+ #[ cfg( not( armv6m) ) ]
12
+ use super :: CPUID ;
13
13
use super :: SCB ;
14
14
15
15
/// Register block
@@ -604,13 +604,18 @@ impl SCB {
604
604
/// Initiate a system reset request to reset the MCU
605
605
pub fn system_reset ( & mut self ) -> ! {
606
606
:: asm:: dsb ( ) ;
607
- unsafe { self . aircr . modify ( |r|
608
- SCB_AIRCR_VECTKEY | // otherwise the write is ignored
607
+ unsafe {
608
+ self . aircr . modify (
609
+ |r| {
610
+ SCB_AIRCR_VECTKEY | // otherwise the write is ignored
609
611
r & SCB_AIRCR_PRIGROUP_MASK | // keep priority group unchanged
610
- SCB_AIRCR_SYSRESETREQ // set the bit
611
- ) } ;
612
+ SCB_AIRCR_SYSRESETREQ
613
+ } , // set the bit
614
+ )
615
+ } ;
612
616
:: asm:: dsb ( ) ;
613
- loop { // wait for the reset
617
+ loop {
618
+ // wait for the reset
614
619
:: asm:: nop ( ) ; // avoid rust-lang/rust#28728
615
620
}
616
621
}
@@ -619,6 +624,9 @@ impl SCB {
619
624
const SCB_ICSR_PENDSVSET : u32 = 1 << 28 ;
620
625
const SCB_ICSR_PENDSVCLR : u32 = 1 << 27 ;
621
626
627
+ const SCB_ICSR_PENDSTSET : u32 = 1 << 26 ;
628
+ const SCB_ICSR_PENDSTCLR : u32 = 1 << 25 ;
629
+
622
630
impl SCB {
623
631
/// Set the PENDSVSET bit in the ICSR register which will pend the PendSV interrupt
624
632
pub fn set_pendsv ( ) {
@@ -629,9 +637,7 @@ impl SCB {
629
637
630
638
/// Check if PENDSVSET bit in the ICSR register is set meaning PendSV interrupt is pending
631
639
pub fn is_pendsv_pending ( ) -> bool {
632
- unsafe {
633
- ( * Self :: ptr ( ) ) . icsr . read ( ) & SCB_ICSR_PENDSVSET == SCB_ICSR_PENDSVSET
634
- }
640
+ unsafe { ( * Self :: ptr ( ) ) . icsr . read ( ) & SCB_ICSR_PENDSVSET == SCB_ICSR_PENDSVSET }
635
641
}
636
642
637
643
/// Set the PENDSVCLR bit in the ICSR register which will clear a pending PendSV interrupt
@@ -640,4 +646,26 @@ impl SCB {
640
646
( * Self :: ptr ( ) ) . icsr . write ( SCB_ICSR_PENDSVCLR ) ;
641
647
}
642
648
}
649
+
650
+ /// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt
651
+ #[ inline]
652
+ pub fn set_pendst ( ) {
653
+ unsafe {
654
+ ( * Self :: ptr ( ) ) . icsr . write ( SCB_ICSR_PENDSTSET ) ;
655
+ }
656
+ }
657
+
658
+ /// Check if PENDSTSET bit in the ICSR register is set meaning SysTick interrupt is pending
659
+ #[ inline]
660
+ pub fn is_pendst_pending ( ) -> bool {
661
+ unsafe { ( * Self :: ptr ( ) ) . icsr . read ( ) & SCB_ICSR_PENDSTSET == SCB_ICSR_PENDSTSET }
662
+ }
663
+
664
+ /// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt
665
+ #[ inline]
666
+ pub fn clear_pendst ( ) {
667
+ unsafe {
668
+ ( * Self :: ptr ( ) ) . icsr . write ( SCB_ICSR_PENDSTCLR ) ;
669
+ }
670
+ }
643
671
}
0 commit comments