File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ fn cpu1_task(
69
69
loop {
70
70
block ! ( timer. wait( ) ) . unwrap ( ) ;
71
71
72
- critical_section:: with ( |cs| counter. borrow_ref_mut ( cs) . wrapping_add ( 1 ) ) ;
72
+ critical_section:: with ( |cs| {
73
+ let new_val = counter. borrow_ref_mut ( cs) . wrapping_add ( 1 ) ;
74
+ * counter. borrow_ref_mut ( cs) = new_val;
75
+ } ) ;
73
76
}
74
77
}
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ fn main() -> ! {
41
41
42
42
let mut adc1_config = AdcConfig :: new ( ) ;
43
43
44
- let mut pin3 = adc1_config. enable_pin ( io. pins . gpio3 . into_analog ( ) , Attenuation :: Attenuation11dB ) ;
44
+ let mut pin3 =
45
+ adc1_config. enable_pin ( io. pins . gpio3 . into_analog ( ) , Attenuation :: Attenuation11dB ) ;
45
46
46
47
let mut adc1 = ADC :: < ADC1 > :: adc ( analog. adc1 , adc1_config) . unwrap ( ) ;
47
48
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ fn cpu1_task(
69
69
loop {
70
70
block ! ( timer. wait( ) ) . unwrap ( ) ;
71
71
72
- critical_section:: with ( |cs| counter. borrow_ref_mut ( cs) . wrapping_add ( 1 ) ) ;
72
+ critical_section:: with ( |cs| {
73
+ let new_val = counter. borrow_ref_mut ( cs) . wrapping_add ( 1 ) ;
74
+ * counter. borrow_ref_mut ( cs) = new_val;
75
+ } ) ;
73
76
}
74
77
}
You can’t perform that action at this time.
0 commit comments