diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32u5/src/bin/blinky.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs new file mode 100644 index 000000000..e1bcccf58 --- /dev/null +++ b/examples/stm32u5/src/bin/blinky.rs | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use defmt_rtt as _; | ||
| 7 | use embassy::executor::Spawner; | ||
| 8 | use embassy::time::{Duration, Timer}; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | // global logger | ||
| 12 | use panic_probe as _; | ||
| 13 | |||
| 14 | #[embassy::main] | ||
| 15 | async fn main(_spawner: Spawner, p: Peripherals) -> ! { | ||
| 16 | info!("Hello World!"); | ||
| 17 | |||
| 18 | let mut led = Output::new(p.PH7, Level::Low, Speed::Medium); | ||
| 19 | |||
| 20 | loop { | ||
| 21 | defmt::info!("on!"); | ||
| 22 | led.set_low(); | ||
| 23 | Timer::after(Duration::from_millis(200)).await; | ||
| 24 | |||
| 25 | defmt::info!("off!"); | ||
| 26 | led.set_high(); | ||
| 27 | Timer::after(Duration::from_millis(200)).await; | ||
| 28 | } | ||
| 29 | } | ||
