rtic/examples/types.rs

58 lines
1.5 KiB
Rust
Raw Normal View History

2018-11-03 17:02:41 +01:00
//! examples/types.rs
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_semihosting::debug;
use panic_semihosting as _;
use rtfm::cyccnt::Instant;
2018-11-03 17:02:41 +01:00
#[rtfm::app(device = lm3s6965, peripherals = true, monotonic = rtfm::cyccnt::CYCCNT)]
2018-11-03 17:02:41 +01:00
const APP: () = {
2019-07-10 22:42:44 +02:00
struct Resources {
#[init(0)]
shared: u32,
}
2018-11-03 17:02:41 +01:00
#[init(schedule = [foo], spawn = [foo])]
2019-04-21 20:10:40 +02:00
fn init(c: init::Context) {
let _: Instant = c.start;
let _: rtfm::Peripherals = c.core;
let _: lm3s6965::Peripherals = c.device;
let _: init::Schedule = c.schedule;
let _: init::Spawn = c.spawn;
2018-11-03 17:02:41 +01:00
debug::exit(debug::EXIT_SUCCESS);
}
2019-06-20 06:19:59 +02:00
#[task(binds = SVCall, schedule = [foo], spawn = [foo])]
fn svcall(c: svcall::Context) {
2019-04-21 20:10:40 +02:00
let _: Instant = c.start;
2019-06-20 06:19:59 +02:00
let _: svcall::Schedule = c.schedule;
let _: svcall::Spawn = c.spawn;
2018-11-03 17:02:41 +01:00
}
2019-07-10 22:42:44 +02:00
#[task(binds = UART0, resources = [shared], schedule = [foo], spawn = [foo])]
2019-06-20 06:19:59 +02:00
fn uart0(c: uart0::Context) {
2019-04-21 20:10:40 +02:00
let _: Instant = c.start;
2019-07-10 22:42:44 +02:00
let _: resources::shared = c.resources.shared;
2019-06-20 06:19:59 +02:00
let _: uart0::Schedule = c.schedule;
let _: uart0::Spawn = c.spawn;
2018-11-03 17:02:41 +01:00
}
2019-07-10 22:42:44 +02:00
#[task(priority = 2, resources = [shared], schedule = [foo], spawn = [foo])]
2019-04-21 20:10:40 +02:00
fn foo(c: foo::Context) {
let _: Instant = c.scheduled;
2019-07-10 22:42:44 +02:00
let _: &mut u32 = c.resources.shared;
2019-04-21 20:10:40 +02:00
let _: foo::Resources = c.resources;
let _: foo::Schedule = c.schedule;
let _: foo::Spawn = c.spawn;
2018-11-03 17:02:41 +01:00
}
extern "C" {
fn UART1();
}
};