diff options
| author | Dion Dokter <[email protected]> | 2022-12-09 11:04:55 +0100 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2022-12-09 11:04:55 +0100 |
| commit | f22297e3d62975a810f4bc7588ede421f14ebd93 (patch) | |
| tree | 4690d5c574013afae63bc8eabc290f547cc046a8 /examples/stm32f0/src | |
| parent | 1d2f97b4e226871014c2cf470070343df15d74a0 (diff) | |
| parent | 58ab82904970f2df3984e54c722955a7b7c81391 (diff) | |
Merge branch 'master' into nrf91/53-nvmc
Diffstat (limited to 'examples/stm32f0/src')
| -rw-r--r-- | examples/stm32f0/src/bin/blinky.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/stm32f0/src/bin/blinky.rs b/examples/stm32f0/src/bin/blinky.rs new file mode 100644 index 000000000..9f923399c --- /dev/null +++ b/examples/stm32f0/src/bin/blinky.rs | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | // main is itself an async function. | ||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_spawner: Spawner) { | ||
| 14 | let p = embassy_stm32::init(Default::default()); | ||
| 15 | info!("Hello World!"); | ||
| 16 | //PA5 is the onboard LED on the Nucleo F091RC | ||
| 17 | let mut led = Output::new(p.PA5, Level::High, Speed::Low); | ||
| 18 | |||
| 19 | loop { | ||
| 20 | info!("high"); | ||
| 21 | led.set_high(); | ||
| 22 | Timer::after(Duration::from_millis(300)).await; | ||
| 23 | |||
| 24 | info!("low"); | ||
| 25 | led.set_low(); | ||
| 26 | Timer::after(Duration::from_millis(300)).await; | ||
| 27 | } | ||
| 28 | } | ||
