mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
a58be575cb
see rtic-rs/rfcs#52 for details includes: core proposal and `#[init]` and `memory-watermark` extensions Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
47 lines
1 KiB
Rust
47 lines
1 KiB
Rust
#![no_main]
|
|
#![no_std]
|
|
|
|
use panic_semihosting as _;
|
|
|
|
#[rtic::app(device = lm3s6965, dispatchers = [GPIOA])]
|
|
mod app {
|
|
use cortex_m_semihosting::{debug, hprintln};
|
|
use rtic_actor_traits::Receive;
|
|
|
|
#[derive(Debug)]
|
|
struct Actor {
|
|
state: i32,
|
|
}
|
|
|
|
struct AssertActorWasInitialized;
|
|
|
|
const INITIAL_STATE: i32 = 42;
|
|
|
|
impl Receive<AssertActorWasInitialized> for Actor {
|
|
fn receive(&mut self, _: AssertActorWasInitialized) {
|
|
assert_eq!(INITIAL_STATE, self.state);
|
|
hprintln!("OK").ok();
|
|
debug::exit(debug::EXIT_SUCCESS);
|
|
}
|
|
}
|
|
|
|
#[actors]
|
|
struct Actors {
|
|
#[subscribe(AssertActorWasInitialized)]
|
|
#[init(Actor { state: INITIAL_STATE })]
|
|
actor: Actor,
|
|
}
|
|
|
|
#[init]
|
|
fn init(mut cx: init::Context) -> (Shared, Local, init::Monotonics, Actors) {
|
|
cx.poster.post(AssertActorWasInitialized).ok();
|
|
|
|
(Shared {}, Local {}, init::Monotonics(), Actors {})
|
|
}
|
|
|
|
#[shared]
|
|
struct Shared {}
|
|
|
|
#[local]
|
|
struct Local {}
|
|
}
|