734: executor: Add `Spawner::for_current_executor`. r=Dirbaio a=Dirbaio This is needed to spawn non-Send tasks in an InterruptExecutor, after the fixes in #730 . `@matoushybl` could you check if this works for your use case? 735: stm32: add stm32u5 GPDMA, SPIv4 support, add HIL tests. r=Dirbaio a=Dirbaio Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
24
examples/nrf/src/bin/self_spawn_current_executor.rs
Normal file
24
examples/nrf/src/bin/self_spawn_current_executor.rs
Normal file
@ -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)));
|
||||
}
|
29
examples/stm32u5/src/bin/blinky.rs
Normal file
29
examples/stm32u5/src/bin/blinky.rs
Normal file
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user