blob: a6293c3881ccb1f951682cfefc933bece67101dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
//! 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 _;
use rtfm::{Exclusive, Mutex};
#[rtfm::app(device = lm3s6965)]
const APP: () = {
struct Resources {
#[init(0)]
shared: u32,
}
#[init]
fn init(_: init::Context) {
hprintln!("init").unwrap();
rtfm::pend(Interrupt::GPIOA);
}
#[idle]
fn idle(_: idle::Context) -> ! {
hprintln!("idle").unwrap();
rtfm::pend(Interrupt::GPIOA);
rtfm::pend(Interrupt::GPIOA);
debug::exit(debug::EXIT_SUCCESS);
loop {}
}
#[task(binds = GPIOA, resources = [shared])]
// fn foo1(ctx: &'static mut foo1::Context) -> impl Generator<Yield = (), Return = !> {
fn foo1(ctx: foo1::Context) -> impl Generator<Yield = (), Return = !> {
let mut local = 0;
//let shared_res = Exclusive(ctx.resources.shared);
// static shared_res : &mut u32 = ctx.resources.shared;
move || loop {
hprintln!("foo1_1 {}", local).unwrap();
local += 1;
// shared_res.lock(|s| hprintln!("s {}", s));
// *shared_res += 1;
// *ctx.resources.shared += 1;
yield;
hprintln!("foo1_2 {}", local).unwrap();
local += 1;
yield;
}
}
// #[task(binds = GPIOB, resources = [shared], priority = 2)]
// fn foo2(ctx: foo2::Context) {}
};
|