Skip to content

Commit 6d769ab

Browse files
authored
Merge pull request #227 from bjoernQ/fix/multicore-example
Fix multicore example
2 parents a8e879b + 53ad16e commit 6d769ab

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

esp32-hal/examples/multicore.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ fn cpu1_task(
6969
loop {
7070
block!(timer.wait()).unwrap();
7171

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+
});
7376
}
7477
}

esp32s3-hal/examples/adc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fn main() -> ! {
4141

4242
let mut adc1_config = AdcConfig::new();
4343

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);
4546

4647
let mut adc1 = ADC::<ADC1>::adc(analog.adc1, adc1_config).unwrap();
4748

esp32s3-hal/examples/multicore.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ fn cpu1_task(
6969
loop {
7070
block!(timer.wait()).unwrap();
7171

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+
});
7376
}
7477
}

0 commit comments

Comments
 (0)