@@ -16,7 +16,8 @@ use crate::hal::{
16
16
use cortex_m_rt:: entry;
17
17
18
18
use 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 ;
20
21
21
22
// A type definition for the GPIO pin to be used for our LED
22
23
type LEDPIN = gpioa:: PA5 < Output < PushPull > > ;
@@ -35,14 +36,14 @@ fn TIM7() {
35
36
static mut INT : Option < Timer < TIM7 > > = None ;
36
37
37
38
let led = LED . get_or_insert_with ( || {
38
- cortex_m :: interrupt :: free ( |cs| {
39
+ critical_section :: with ( |cs| {
39
40
// Move LED pin here, leaving a None in its place
40
41
GLED . borrow ( cs) . replace ( None ) . unwrap ( )
41
42
} )
42
43
} ) ;
43
44
44
45
let int = INT . get_or_insert_with ( || {
45
- cortex_m :: interrupt :: free ( |cs| {
46
+ critical_section :: with ( |cs| {
46
47
// Move LED pin here, leaving a None in its place
47
48
GINT . borrow ( cs) . replace ( None ) . unwrap ( )
48
49
} )
@@ -55,7 +56,7 @@ fn TIM7() {
55
56
#[ entry]
56
57
fn main ( ) -> ! {
57
58
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| {
59
60
let mut rcc = p
60
61
. RCC
61
62
. configure ( )
@@ -68,7 +69,7 @@ fn main() -> ! {
68
69
let gpioa = p. GPIOA . split ( & mut rcc) ;
69
70
70
71
// (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) ;
72
73
73
74
// Move the pin into our global storage
74
75
* GLED . borrow ( cs) . borrow_mut ( ) = Some ( led) ;
0 commit comments