blob: 28083480770ae6ddd27e110b4a574dba57120ab0 (
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/hardware.rs
#![feature(generator_trait)]
#![feature(generators)]
#![feature(never_type)]
#![feature(type_alias_impl_trait)]
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
struct Resources {
#[init(0)]
x: i64,
}
#[init]
fn init(_: init::Context) {
hprintln!("init").ok();
}
#[idle]
fn idle(_: idle::Context) -> ! {
hprintln!("idle").ok();
rtfm::pend(Interrupt::UART0);
hprintln!("C").ok();
rtfm::pend(Interrupt::UART0);
hprintln!("E").ok();
debug::exit(debug::EXIT_SUCCESS);
loop {}
}
#[task(binds = UART0, priority = 1, resources = [x])]
fn uart0(mut cx: uart0::Context) -> impl Generator<Yield = (), Return = !> {
hprintln!("A").ok();
move || loop {
hprintln!("B").ok();
yield;
cx.resources.x.lock(|x| {
hprintln!("lock").ok();
*x += 1;
});
hprintln!("D").ok();
yield;
}
}
#[task(binds = UART1, priority = 2, resources = [x])]
fn uart1(_: uart1::Context) {}
};
|