2019-04-16 21:54:19 +02:00
|
|
|
//! `examples/shared-with-init.rs`
|
|
|
|
|
|
|
|
#![deny(unsafe_code)]
|
|
|
|
#![deny(warnings)]
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
extern crate panic_halt;
|
|
|
|
|
|
|
|
use cortex_m_semihosting::debug;
|
|
|
|
use lm3s6965::Interrupt;
|
|
|
|
use rtfm::app;
|
|
|
|
|
|
|
|
pub struct MustBeSend;
|
|
|
|
|
|
|
|
#[app(device = lm3s6965)]
|
|
|
|
const APP: () = {
|
|
|
|
static mut SHARED: Option<MustBeSend> = None;
|
|
|
|
|
|
|
|
#[init(resources = [SHARED])]
|
2019-04-21 20:10:40 +02:00
|
|
|
fn init(c: init::Context) {
|
2019-04-16 21:54:19 +02:00
|
|
|
// this `message` will be sent to task `UART0`
|
|
|
|
let message = MustBeSend;
|
2019-04-21 20:10:40 +02:00
|
|
|
*c.resources.SHARED = Some(message);
|
2019-04-16 21:54:19 +02:00
|
|
|
|
|
|
|
rtfm::pend(Interrupt::UART0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[interrupt(resources = [SHARED])]
|
2019-04-21 20:10:40 +02:00
|
|
|
fn UART0(c: UART0::Context) {
|
|
|
|
if let Some(message) = c.resources.SHARED.take() {
|
2019-04-16 21:54:19 +02:00
|
|
|
// `message` has been received
|
|
|
|
drop(message);
|
|
|
|
|
|
|
|
debug::exit(debug::EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|