@@ -16,7 +16,8 @@ use crate::hal::{
1616use cortex_m_rt:: entry;
1717
1818use core:: cell:: RefCell ;
19- use cortex_m:: { interrupt:: Mutex , peripheral:: Peripherals as c_m_Peripherals} ;
19+ use cortex_m:: peripheral:: Peripherals as c_m_Peripherals;
20+ use critical_section:: Mutex ;
2021
2122// A type definition for the GPIO pin to be used for our LED
2223type LEDPIN = gpioa:: PA5 < Output < PushPull > > ;
@@ -35,14 +36,14 @@ fn TIM7() {
3536 static mut INT : Option < Timer < TIM7 > > = None ;
3637
3738 let led = LED . get_or_insert_with ( || {
38- cortex_m :: interrupt :: free ( |cs| {
39+ critical_section :: with ( |cs| {
3940 // Move LED pin here, leaving a None in its place
4041 GLED . borrow ( cs) . replace ( None ) . unwrap ( )
4142 } )
4243 } ) ;
4344
4445 let int = INT . get_or_insert_with ( || {
45- cortex_m :: interrupt :: free ( |cs| {
46+ critical_section :: with ( |cs| {
4647 // Move LED pin here, leaving a None in its place
4748 GINT . borrow ( cs) . replace ( None ) . unwrap ( )
4849 } )
@@ -55,7 +56,7 @@ fn TIM7() {
5556#[ entry]
5657fn main ( ) -> ! {
5758 if let ( Some ( mut p) , Some ( cp) ) = ( Peripherals :: take ( ) , c_m_Peripherals:: take ( ) ) {
58- cortex_m :: interrupt :: free ( move |cs| {
59+ critical_section :: with ( move |cs| {
5960 let mut rcc = p
6061 . RCC
6162 . configure ( )
@@ -68,7 +69,7 @@ fn main() -> ! {
6869 let gpioa = p. GPIOA . split ( & mut rcc) ;
6970
7071 // (Re-)configure PA5 as output
71- let led = gpioa. pa5 . into_push_pull_output ( cs) ;
72+ let led = gpioa. pa5 . into_push_pull_output ( & cs) ;
7273
7374 // Move the pin into our global storage
7475 * GLED . borrow ( cs) . borrow_mut ( ) = Some ( led) ;
0 commit comments