diff options
| author | Ulf Lilleengen <[email protected]> | 2021-12-10 12:27:44 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-12-10 12:27:44 +0100 |
| commit | e93f2679b1edbedd83e09fbc3b7a07dbf1ef80a4 (patch) | |
| tree | aff850c0df6739881abe25171509694f9e0ac962 /examples/nrf/src | |
| parent | b48fcd9229b40800cc96ff3157d8b36057dc2047 (diff) | |
More content
Diffstat (limited to 'examples/nrf/src')
| -rw-r--r-- | examples/nrf/src/bin/blinky.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index a12fe58ff..3a1440684 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs | |||
| @@ -8,18 +8,21 @@ mod example_common; | |||
| 8 | use defmt::unwrap; | 8 | use defmt::unwrap; |
| 9 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 10 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 11 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 11 | use embassy_nrf::{Peripherals, peripherals::P0_13, gpio::{Level, Output, OutputDrive}; |
| 12 | use embassy_nrf::Peripherals; | ||
| 13 | use embedded_hal::digital::v2::OutputPin; | 12 | use embedded_hal::digital::v2::OutputPin; |
| 14 | 13 | ||
| 15 | #[embassy::main] | 14 | #[embassh::task] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn blinker(led: Output<'static, P0_13>, interval: Duration) { |
| 17 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 18 | |||
| 19 | loop { | 16 | loop { |
| 20 | unwrap!(led.set_high()); | 17 | unwrap!(led.set_high()); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 18 | Timer::after(interval).await; |
| 22 | unwrap!(led.set_low()); | 19 | unwrap!(led.set_low()); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 20 | Timer::after(interval).await; |
| 24 | } | 21 | } |
| 25 | } | 22 | } |
| 23 | |||
| 24 | #[embassy::main] | ||
| 25 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 26 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 27 | unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); | ||
| 28 | } | ||
