@@ -5,8 +5,9 @@ use core::cell::RefCell;
55
66use panic_semihosting as _;
77
8- use cortex_m:: { asm, interrupt :: Mutex , peripheral:: NVIC } ;
8+ use cortex_m:: { asm, peripheral:: NVIC } ;
99use cortex_m_rt:: entry;
10+ use critical_section:: Mutex ;
1011
1112use stm32f3xx_hal:: {
1213 gpio:: { self , Edge , Input , Output , PushPull } ,
@@ -38,7 +39,7 @@ fn main() -> ! {
3839 led. toggle ( ) . expect ( "unable to toggle led in configuration" ) ;
3940
4041 // Move the ownership of the led to the global LED
41- cortex_m :: interrupt :: free ( |cs| * LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
42+ critical_section :: with ( |cs| * LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
4243
4344 // Configuring the user button to trigger an interrupt when the button is pressed.
4445 let mut user_button = gpioa
@@ -50,7 +51,7 @@ fn main() -> ! {
5051 let interrupt_num = user_button. interrupt ( ) ; // hal::pac::Interrupt::EXTI0
5152
5253 // Moving ownership to the global BUTTON so we can clear the interrupt pending bit.
53- cortex_m :: interrupt :: free ( |cs| * BUTTON . borrow ( cs) . borrow_mut ( ) = Some ( user_button) ) ;
54+ critical_section :: with ( |cs| * BUTTON . borrow ( cs) . borrow_mut ( ) = Some ( user_button) ) ;
5455
5556 unsafe { NVIC :: unmask ( interrupt_num) } ;
5657
@@ -67,7 +68,7 @@ fn main() -> ! {
6768// This may be called more than once per button press from the user since the button may not be debounced.
6869#[ interrupt]
6970fn EXTI0 ( ) {
70- cortex_m :: interrupt :: free ( |cs| {
71+ critical_section :: with ( |cs| {
7172 // Toggle the LED
7273 LED . borrow ( cs)
7374 . borrow_mut ( )
0 commit comments