This commit is contained in:
Jorge Aparicio 2019-06-20 06:19:59 +02:00
parent b150ab29e2
commit 4e51bb68b9
33 changed files with 143 additions and 142 deletions

View file

@ -35,8 +35,8 @@ const APP: () = {
}
}
#[interrupt(spawn = [foo])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, spawn = [foo])]
fn uart0(c: uart0::Context) {
hprintln!("UART0(baseline = {:?})", c.start).unwrap();
// `foo` inherits the baseline of `UART0`: its `start` time

View file

@ -30,7 +30,7 @@ const APP: () = {
loop {}
}
#[interrupt(binds = UART0)]
#[task(binds = UART0)]
fn foo(_: foo::Context) {
static mut TIMES: u32 = 0;

View file

@ -16,8 +16,8 @@ const APP: () = {
rtfm::pend(Interrupt::UART0);
}
#[interrupt(spawn = [foo, bar])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, spawn = [foo, bar])]
fn uart0(c: uart0::Context) {
c.spawn.foo(0).unwrap();
c.spawn.foo(1).unwrap();
c.spawn.foo(2).unwrap();

View file

@ -20,8 +20,8 @@ const APP: () = {
rtfm::pend(Interrupt::UART1);
}
#[interrupt(resources = [SHARED])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [SHARED])]
fn uart0(c: uart0::Context) {
static mut STATE: u32 = 0;
hprintln!("UART0(STATE = {})", *STATE).unwrap();
@ -33,8 +33,8 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS);
}
#[interrupt(priority = 2, resources = [SHARED])]
fn UART1(c: UART1::Context) {
#[task(binds = UART1, priority = 2, resources = [SHARED])]
fn uart1(c: uart1::Context) {
static mut STATE: u32 = 0;
hprintln!("UART1(STATE = {})", *STATE).unwrap();

View file

@ -33,8 +33,8 @@ const APP: () = {
loop {}
}
#[interrupt]
fn UART0(_: UART0::Context) {
#[task(binds = UART0)]
fn uart0(_: uart0::Context) {
static mut TIMES: u32 = 0;
// Safe access to local `static mut` variable

View file

@ -47,8 +47,8 @@ const APP: () = {
}
}
#[interrupt(resources = [P])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [P])]
fn uart0(c: uart0::Context) {
c.resources.P.enqueue(42).unwrap();
}
};

View file

@ -19,8 +19,8 @@ const APP: () = {
}
// when omitted priority is assumed to be `1`
#[interrupt(resources = [SHARED])]
fn GPIOA(mut c: GPIOA::Context) {
#[task(binds = GPIOA, resources = [SHARED])]
fn gpioa(mut c: gpioa::Context) {
hprintln!("A").unwrap();
// the lower priority task requires a critical section to access the data
@ -44,16 +44,16 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS);
}
#[interrupt(priority = 2, resources = [SHARED])]
fn GPIOB(c: GPIOB::Context) {
#[task(binds = GPIOB, priority = 2, resources = [SHARED])]
fn gpiob(c: gpiob::Context) {
// the higher priority task does *not* need a critical section
*c.resources.SHARED += 1;
hprintln!("D - SHARED = {}", *c.resources.SHARED).unwrap();
}
#[interrupt(priority = 3)]
fn GPIOC(_: GPIOC::Context) {
#[task(binds = GPIOC, priority = 3)]
fn gpioc(_: gpioc::Context) {
hprintln!("C").unwrap();
}
};

View file

@ -29,8 +29,8 @@ const APP: () = {
rtfm::pend(Interrupt::I2C0);
}
#[interrupt(priority = 2, spawn = [foo, bar])]
fn I2C0(c: I2C0::Context) {
#[task(binds = I2C0, priority = 2, spawn = [foo, bar])]
fn i2c0(c: i2c0::Context) {
// claim a memory block, leave it uninitialized and ..
let x = P::alloc().unwrap().freeze();

View file

@ -31,16 +31,16 @@ const APP: () = {
}
// `SHARED` can be access from this context
#[interrupt(resources = [SHARED])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [SHARED])]
fn uart0(c: uart0::Context) {
*c.resources.SHARED += 1;
hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap();
}
// `SHARED` can be access from this context
#[interrupt(resources = [SHARED])]
fn UART1(c: UART1::Context) {
#[task(binds = UART1, resources = [SHARED])]
fn uart1(c: uart1::Context) {
*c.resources.SHARED += 1;
hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap();

View file

@ -25,8 +25,8 @@ const APP: () = {
rtfm::pend(Interrupt::UART0);
}
#[interrupt(resources = [SHARED])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [SHARED])]
fn uart0(c: uart0::Context) {
if let Some(message) = c.resources.SHARED.take() {
// `message` has been received
drop(message);

View file

@ -23,15 +23,15 @@ const APP: () = {
init::LateResources { KEY: 0xdeadbeef }
}
#[interrupt(resources = [KEY])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [KEY])]
fn uart0(c: uart0::Context) {
hprintln!("UART0(KEY = {:#x})", c.resources.KEY).unwrap();
debug::exit(debug::EXIT_SUCCESS);
}
#[interrupt(priority = 2, resources = [KEY])]
fn UART1(c: UART1::Context) {
#[task(binds = UART1, priority = 2, resources = [KEY])]
fn uart1(c: uart1::Context) {
hprintln!("UART1(KEY = {:#x})", c.resources.KEY).unwrap();
}
};

View file

@ -12,12 +12,14 @@ const APP: () = {
#[init]
fn init(_: init::Context) {}
#[exception(binds = SVCall)]
// Cortex-M exception
#[task(binds = SVCall)]
fn foo(c: foo::Context) {
foo_trampoline(c)
}
#[interrupt(binds = UART0)]
// LM3S6965 interrupt
#[task(binds = UART0)]
fn bar(c: bar::Context) {
bar_trampoline(c)
}

View file

@ -51,8 +51,8 @@ const APP: () = {
loop {}
}
#[interrupt(resources = [O3, S1, S2, S3])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [O3, S1, S2, S3])]
fn uart0(c: uart0::Context) {
// owned by interrupt == `&mut`
let _: &mut u32 = c.resources.O3;
@ -66,8 +66,8 @@ const APP: () = {
let _: &u32 = c.resources.S3;
}
#[interrupt(resources = [S2, O5])]
fn UART1(c: UART1::Context) {
#[task(binds = UART1, resources = [S2, O5])]
fn uart1(c: uart1::Context) {
// owned by interrupt == `&` if read-only
let _: &u32 = c.resources.O5;

View file

@ -26,15 +26,15 @@ const APP: () = {
loop {}
}
#[exception(schedule = [foo, bar, baz])]
fn SVCall(c: SVCall::Context) {
#[task(binds = SVCall, schedule = [foo, bar, baz])]
fn svcall(c: svcall::Context) {
let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles());
let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0);
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1);
}
#[interrupt(schedule = [foo, bar, baz])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, schedule = [foo, bar, baz])]
fn uart0(c: uart0::Context) {
let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles());
let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0);
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1);

View file

@ -25,15 +25,15 @@ const APP: () = {
loop {}
}
#[exception(spawn = [foo, bar, baz])]
fn SVCall(c: SVCall::Context) {
#[task(binds = SVCall, spawn = [foo, bar, baz])]
fn svcall(c: svcall::Context) {
let _: Result<(), ()> = c.spawn.foo();
let _: Result<(), u32> = c.spawn.bar(0);
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
}
#[interrupt(spawn = [foo, bar, baz])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, spawn = [foo, bar, baz])]
fn uart0(c: uart0::Context) {
let _: Result<(), ()> = c.spawn.foo();
let _: Result<(), u32> = c.spawn.bar(0);
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);

View file

@ -24,19 +24,19 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS);
}
#[exception(schedule = [foo], spawn = [foo])]
fn SVCall(c: SVCall::Context) {
#[task(binds = SVCall, schedule = [foo], spawn = [foo])]
fn svcall(c: svcall::Context) {
let _: Instant = c.start;
let _: SVCall::Schedule = c.schedule;
let _: SVCall::Spawn = c.spawn;
let _: svcall::Schedule = c.schedule;
let _: svcall::Spawn = c.spawn;
}
#[interrupt(resources = [SHARED], schedule = [foo], spawn = [foo])]
fn UART0(c: UART0::Context) {
#[task(binds = UART0, resources = [SHARED], schedule = [foo], spawn = [foo])]
fn uart0(c: uart0::Context) {
let _: Instant = c.start;
let _: resources::SHARED = c.resources.SHARED;
let _: UART0::Schedule = c.schedule;
let _: UART0::Spawn = c.spawn;
let _: uart0::Schedule = c.schedule;
let _: uart0::Spawn = c.spawn;
}
#[task(priority = 2, resources = [SHARED], schedule = [foo], spawn = [foo])]