diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-07-15 21:23:14 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-15 21:23:14 +0200 |
| commit | 7ed43cd843bbb8e3fdbf8546d6cd4780bfa1bd78 (patch) | |
| tree | 936020003205a563844b33203d0baddb2418e0eb /examples/stm32f0/src | |
| parent | 8a172ac12325ddc382e5ac0ffa637120a166d057 (diff) | |
| parent | 697f93ad423fb70aa134c8810237622642a301d6 (diff) | |
Merge pull request #296 from thalesfragoso/f0-dmarst
Allow for RccPeripheral without reset field and add F0 example
Diffstat (limited to 'examples/stm32f0/src')
| -rw-r--r-- | examples/stm32f0/src/bin/hello.rs | 23 | ||||
| -rw-r--r-- | examples/stm32f0/src/example_common.rs | 17 |
2 files changed, 40 insertions, 0 deletions
diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs new file mode 100644 index 000000000..a78b9892f --- /dev/null +++ b/examples/stm32f0/src/bin/hello.rs | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(min_type_alias_impl_trait)] | ||
| 4 | #![feature(impl_trait_in_bindings)] | ||
| 5 | #![feature(type_alias_impl_trait)] | ||
| 6 | #![allow(incomplete_features)] | ||
| 7 | |||
| 8 | use defmt::info; | ||
| 9 | |||
| 10 | use embassy::executor::Spawner; | ||
| 11 | use embassy::time::{Duration, Timer}; | ||
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | |||
| 14 | #[path = "../example_common.rs"] | ||
| 15 | mod example_common; | ||
| 16 | |||
| 17 | #[embassy::main] | ||
| 18 | async fn main(_spawner: Spawner, _p: Peripherals) -> ! { | ||
| 19 | loop { | ||
| 20 | Timer::after(Duration::from_secs(1)).await; | ||
| 21 | info!("Hello"); | ||
| 22 | } | ||
| 23 | } | ||
diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs new file mode 100644 index 000000000..54d633837 --- /dev/null +++ b/examples/stm32f0/src/example_common.rs | |||
| @@ -0,0 +1,17 @@ | |||
| 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! {"{=u64}", { | ||
| 11 | static COUNT: AtomicUsize = AtomicUsize::new(0); | ||
| 12 | // NOTE(no-CAS) `timestamps` runs with interrupts disabled | ||
| 13 | let n = COUNT.load(Ordering::Relaxed); | ||
| 14 | COUNT.store(n + 1, Ordering::Relaxed); | ||
| 15 | n as u64 | ||
| 16 | } | ||
| 17 | } | ||
