Move example and remove success test

This commit is contained in:
Albin Hedman 2025-10-19 19:12:39 +02:00
parent d9fe447a5d
commit 1e8c175c51
3 changed files with 44 additions and 73 deletions

View file

@ -1,42 +0,0 @@
#![no_main]
#![no_std]
use core::marker::PhantomData;
use rtic::app;
use {defmt_rtt as _, panic_probe as _};
pub mod pac {
pub use embassy_stm32::pac::Interrupt as interrupt;
pub use embassy_stm32::pac::*;
}
#[app(device = pac, peripherals = false, dispatchers = [SPI1])]
mod app {
use super::*;
#[shared]
struct Shared {}
#[local]
struct Local {}
#[init]
fn init(_cx: init::Context) -> (Shared, Local) {
task1::spawn().ok();
//task2::spawn(Default::default()).ok(); <--- This is rejected since it is a local task
(Shared {}, Local {})
}
#[task(priority = 1)]
async fn task1(cx: task1::Context) {
defmt::info!("Hello from task1!");
cx.local_spawner.task2(Default::default()).ok();
}
#[task(priority = 1, is_local_task = true)]
async fn task2(_cx: task2::Context, _nsns: super::NotSendNotSync) {
defmt::info!("Hello from task1!");
}
}
#[derive(Default)]
struct NotSendNotSync(PhantomData<*mut u8>);

View file

@ -0,0 +1,44 @@
#![no_main]
#![no_std]
use panic_semihosting as _;
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
mod app {
use cortex_m_semihosting::hprintln;
use super::*;
#[shared]
struct Shared {}
#[local]
struct Local {}
#[init]
fn init(_cx: init::Context) -> (Shared, Local) {
task1::spawn().unwrap();
//task2::spawn(Default::default()).ok(); <--- This is rejected since it is a local task
(Shared {}, Local {})
}
#[task(priority = 1)]
async fn task1(cx: task1::Context) {
hprintln!("Hello from task1!");
cx.local_spawner.task2(Default::default()).unwrap();
cx.local_spawner.task3(Default::default()).unwrap();
}
#[task(priority = 1, local_task = true)]
async fn task2(_cx: task2::Context, _nsns: NotSendNotSync) {
hprintln!("Hello from task2!");
}
// The value of `local_task` may be omitted and is in that case interpreted as `true`
#[task(priority = 1, local_task)]
async fn task3(_cx: task3::Context, _nsns: NotSendNotSync) {
hprintln!("Hello from task3!");
}
}
#[derive(Default, Debug)]
struct NotSendNotSync(core::marker::PhantomData<*mut u8>);

View file

@ -1,31 +0,0 @@
#![no_main]
use std::marker::PhantomData;
#[rtic_macros::mock_app(device = mock, dispatchers = [EXTI0])]
mod app {
use super::*;
#[shared]
struct Shared {}
#[local]
struct Local {}
#[init]
fn init(_cx: init::Context) -> (Shared, Local) {
task1::spawn().ok();
(Shared {}, Local {})
}
#[task(priority = 1)]
async fn task1(cx: task1::Context) {
cx.local_spawner.task2(Default::default()).ok();
}
#[task(priority = 1, is_local_task = true)]
async fn task2(_cx: task2::Context, _nsns: super::NotSendNotSync) {}
}
#[derive(Default)]
struct NotSendNotSync(PhantomData<*mut u8>);