diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-04-02 04:35:06 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-02 04:35:06 +0200 |
| commit | 82803bffdab0842bf6c3e4bce21131d437b06669 (patch) | |
| tree | 588c65c93b31b897f53d389f7876dc2703eb0fa8 /examples/stm32f2 | |
| parent | a9e63167e1ec230ca3d28da771378f5f4936a840 (diff) | |
Use embassy/defmt-timestamp-uptime in all examples.
Diffstat (limited to 'examples/stm32f2')
| -rw-r--r-- | examples/stm32f2/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/stm32f2/src/bin/blinky.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f2/src/example_common.rs | 19 |
3 files changed, 5 insertions, 24 deletions
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index ee1d7ce2b..4eef3a6fe 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -6,7 +6,7 @@ version = "0.1.0" | |||
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } | 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 11 | 11 | ||
| 12 | defmt = "0.3" | 12 | defmt = "0.3" |
diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 637c2f4fd..395f4df51 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs | |||
| @@ -2,14 +2,14 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | #[path = "../example_common.rs"] | 5 | use defmt::*; |
| 6 | mod example_common; | ||
| 7 | |||
| 8 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 11 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 12 | use example_common::*; | 10 | |
| 11 | use defmt_rtt as _; // global logger | ||
| 12 | use panic_probe as _; | ||
| 13 | 13 | ||
| 14 | #[embassy::main] | 14 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32f2/src/example_common.rs b/examples/stm32f2/src/example_common.rs deleted file mode 100644 index e14517033..000000000 --- a/examples/stm32f2/src/example_common.rs +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | #![macro_use] | ||
| 2 | |||
| 3 | use defmt_rtt as _; // global logger | ||
| 4 | use panic_probe as _; | ||
| 5 | |||
| 6 | pub use defmt::*; | ||
| 7 | |||
| 8 | use core::sync::atomic::{AtomicUsize, Ordering}; | ||
| 9 | |||
| 10 | defmt::timestamp! { | ||
| 11 | "{=u64}", | ||
| 12 | { | ||
| 13 | static COUNT: AtomicUsize = AtomicUsize::new(0); | ||
| 14 | // NOTE(no-CAS) `timestamps` runs with interrupts disabled | ||
| 15 | let n = COUNT.load(Ordering::Relaxed); | ||
| 16 | COUNT.store(n + 1, Ordering::Relaxed); | ||
| 17 | n as u64 | ||
| 18 | } | ||
| 19 | } | ||
