2019-09-24 02:01:25 +02:00
|
|
|
//! examples/idle.rs
|
|
|
|
#![feature(generator_trait)]
|
|
|
|
#![feature(generators)]
|
|
|
|
#![feature(never_type)]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
use core::ops::Generator;
|
|
|
|
use cortex_m_semihosting::{debug, hprintln};
|
|
|
|
use lm3s6965::Interrupt;
|
|
|
|
use panic_semihosting as _;
|
2019-09-24 17:20:15 +02:00
|
|
|
use rtfm::{Exclusive, Mutex};
|
2019-09-24 02:01:25 +02:00
|
|
|
|
|
|
|
#[rtfm::app(device = lm3s6965)]
|
|
|
|
const APP: () = {
|
2019-09-24 17:20:15 +02:00
|
|
|
struct Resources {
|
|
|
|
#[init(0)]
|
|
|
|
shared: u32,
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:01:25 +02:00
|
|
|
#[init]
|
|
|
|
fn init(_: init::Context) {
|
|
|
|
hprintln!("init").unwrap();
|
|
|
|
rtfm::pend(Interrupt::GPIOA);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[idle]
|
|
|
|
fn idle(_: idle::Context) -> ! {
|
|
|
|
|
|
|
|
hprintln!("idle").unwrap();
|
2019-09-24 17:20:15 +02:00
|
|
|
rtfm::pend(Interrupt::GPIOA);
|
|
|
|
rtfm::pend(Interrupt::GPIOA);
|
2019-09-24 02:01:25 +02:00
|
|
|
|
|
|
|
debug::exit(debug::EXIT_SUCCESS);
|
|
|
|
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2019-09-24 17:20:15 +02:00
|
|
|
#[task(binds = GPIOA, resources = [shared])]
|
|
|
|
// fn foo1(ctx: &'static mut foo1::Context) -> impl Generator<Yield = (), Return = !> {
|
2019-09-24 02:01:25 +02:00
|
|
|
fn foo1(ctx: foo1::Context) -> impl Generator<Yield = (), Return = !> {
|
2019-09-24 17:20:15 +02:00
|
|
|
let mut local = 0;
|
|
|
|
//let shared_res = Exclusive(ctx.resources.shared);
|
|
|
|
// static shared_res : &mut u32 = ctx.resources.shared;
|
2019-09-24 02:01:25 +02:00
|
|
|
move || loop {
|
2019-09-24 17:20:15 +02:00
|
|
|
hprintln!("foo1_1 {}", local).unwrap();
|
|
|
|
local += 1;
|
|
|
|
// shared_res.lock(|s| hprintln!("s {}", s));
|
|
|
|
// *shared_res += 1;
|
|
|
|
// *ctx.resources.shared += 1;
|
2019-09-24 02:01:25 +02:00
|
|
|
yield;
|
2019-09-24 17:20:15 +02:00
|
|
|
hprintln!("foo1_2 {}", local).unwrap();
|
|
|
|
local += 1;
|
2019-09-24 02:01:25 +02:00
|
|
|
yield;
|
|
|
|
}
|
|
|
|
}
|
2019-09-24 17:20:15 +02:00
|
|
|
|
|
|
|
// #[task(binds = GPIOB, resources = [shared], priority = 2)]
|
|
|
|
// fn foo2(ctx: foo2::Context) {}
|
2019-09-24 02:01:25 +02:00
|
|
|
};
|