From 9e897cbea92dc9b99a65802cc4e0661919001be1 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 26 Apr 2022 19:08:18 +0200 Subject: executor: Add `Spawner::for_current_executor`. --- .../nrf/src/bin/self_spawn_current_executor.rs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 examples/nrf/src/bin/self_spawn_current_executor.rs (limited to 'examples') diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs new file mode 100644 index 000000000..4850d295d --- /dev/null +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -0,0 +1,24 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::{info, unwrap}; +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; +use embassy_nrf::Peripherals; + +use defmt_rtt as _; // global logger +use panic_probe as _; + +#[embassy::task(pool_size = 2)] +async fn my_task(n: u32) { + Timer::after(Duration::from_secs(1)).await; + info!("Spawning self! {}", n); + unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); +} + +#[embassy::main] +async fn main(spawner: Spawner, _p: Peripherals) { + info!("Hello World!"); + unwrap!(spawner.spawn(my_task(0))); +} -- cgit From 009bb8e4e1b7afbe9d9d7d89135f8d4dd3c4e808 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 26 Apr 2022 23:57:26 +0200 Subject: stm32: add stm32u5 GPDMA, SPIv4 support, add HIL tests. --- examples/stm32u5/src/bin/blinky.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/stm32u5/src/bin/blinky.rs (limited to 'examples') 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 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use defmt_rtt as _; +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; +use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_stm32::Peripherals; +// global logger +use panic_probe as _; + +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) -> ! { + info!("Hello World!"); + + let mut led = Output::new(p.PH7, Level::Low, Speed::Medium); + + loop { + defmt::info!("on!"); + led.set_low(); + Timer::after(Duration::from_millis(200)).await; + + defmt::info!("off!"); + led.set_high(); + Timer::after(Duration::from_millis(200)).await; + } +} -- cgit