Skip to content

Commit 74ab7e0

Browse files
Merge #128
128: examples: fix for ITM logging in examples that use CorePeripherals r=richardeoin a=richardeoin ITM logging as added by PR #107 `stm32::CorePeripherals::take()` ([re-exported here](https://github.com/stm32-rs/stm32-rs-nightlies/blob/master/stm32h7/src/stm32h743v/mod.rs#L701)) will only return `Some` once. Use `steal()` instead, and assume the user won't try to access the ITM peripheral from any of the examples. Co-authored-by: Richard Meadows <[email protected]>
2 parents d0a7ba5 + 4e4d186 commit 74ab7e0

19 files changed

+9
-18
lines changed

examples/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ cargo build --features=stm32h750v,rt,log-itm --examples
5555

5656
Note that you may need to configure your debugger to output ITM, and/or
5757
configure the ITM yourself. See [ITM.md](ITM.md)
58+
59+
If you select this feature flag, then the call to `logger::init()` internally
60+
configures the ITM peripheral. If you also interact with the ITM peripheral
61+
yourself, you should be aware that it has already been configured.

examples/adc12.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! For an example of using ADC3, see examples/temperature.rs
44
//! For an example of using ADC1 alone, see examples/adc.rs
55
6-
#![deny(unsafe_code)]
76
#![no_main]
87
#![no_std]
98

examples/blinky.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/blinky_random.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/blinky_timer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/dac.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/fractional-pll.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/mco.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/prec_kernel_clocks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/pwm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/qspi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/rcc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/sai_pdm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/sdmmc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! SDMMC card example
22
33
#![deny(warnings)]
4-
#![deny(unsafe_code)]
54
#![no_main]
65
#![no_std]
76

examples/serial.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/spi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

examples/temperature.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! For an example of using ADC1, see examples/adc.rs
44
//! For an example of using ADC1 and ADC2 together, see examples/adc12.rs
55
6-
#![deny(unsafe_code)]
76
#![no_main]
87
#![no_std]
98

examples/utilities/logger.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ cfg_if::cfg_if! {
1717
lazy_static! {
1818
static ref LOGGER: Logger<ItmSync<InterruptFree>> = Logger {
1919
level: LevelFilter::Info,
20-
inner: InterruptSync::new(ItmDest::new(cortex_m::Peripherals::take().unwrap().ITM)),
20+
inner: unsafe {
21+
InterruptSync::new(
22+
ItmDest::new(cortex_m::Peripherals::steal().ITM)
23+
)
24+
},
2125
};
2226
}
2327

examples/vos0.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![deny(unsafe_code)]
32
#![no_main]
43
#![no_std]
54

0 commit comments

Comments
 (0)