mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-25 03:19:34 +01:00
update examples and tests
This commit is contained in:
parent
88599780e0
commit
89c922079e
10 changed files with 23 additions and 17 deletions
|
@ -22,7 +22,7 @@ const APP: () = {
|
||||||
static mut C: Consumer<'static, u32, U4> = ();
|
static mut C: Consumer<'static, u32, U4> = ();
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init() -> init::LateResources {
|
||||||
// NOTE: we use `Option` here to work around the lack of
|
// NOTE: we use `Option` here to work around the lack of
|
||||||
// a stable `const` constructor
|
// a stable `const` constructor
|
||||||
static mut Q: Option<Queue<u32, U4>> = None;
|
static mut Q: Option<Queue<u32, U4>> = None;
|
||||||
|
@ -31,8 +31,7 @@ const APP: () = {
|
||||||
let (p, c) = Q.as_mut().unwrap().split();
|
let (p, c) = Q.as_mut().unwrap().split();
|
||||||
|
|
||||||
// Initialization of late resources
|
// Initialization of late resources
|
||||||
P = p;
|
init::LateResources { P: p, C: c }
|
||||||
C = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle(resources = [C])]
|
#[idle(resources = [C])]
|
||||||
|
|
|
@ -20,10 +20,12 @@ const APP: () = {
|
||||||
static mut P: Pool<M> = ();
|
static mut P: Pool<M> = ();
|
||||||
|
|
||||||
#[init(resources = [M])]
|
#[init(resources = [M])]
|
||||||
fn init() {
|
fn init() -> init::LateResources {
|
||||||
rtfm::pend(Interrupt::I2C0);
|
rtfm::pend(Interrupt::I2C0);
|
||||||
|
|
||||||
P = Pool::new(resources.M);
|
init::LateResources {
|
||||||
|
P: Pool::new(resources.M),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(
|
#[interrupt(
|
||||||
|
|
|
@ -16,11 +16,11 @@ const APP: () = {
|
||||||
static KEY: u32 = ();
|
static KEY: u32 = ();
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init() -> init::LateResources {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
rtfm::pend(Interrupt::UART1);
|
rtfm::pend(Interrupt::UART1);
|
||||||
|
|
||||||
KEY = 0xdeadbeef;
|
init::LateResources { KEY: 0xdeadbeef }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [KEY])]
|
#[interrupt(resources = [KEY])]
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rtfm::app;
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() -> ! {
|
fn init() -> ! {
|
||||||
//~^ ERROR `init` must have type signature `[unsafe] fn()`
|
//~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]`
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,6 @@ use rtfm::app;
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init(undef: u32) {
|
fn init(undef: u32) {
|
||||||
//~^ ERROR `init` must have type signature `[unsafe] fn()`
|
//~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rtfm::app;
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() -> u32 {
|
fn init() -> u32 {
|
||||||
//~^ ERROR `init` must have type signature `[unsafe] fn()`
|
//~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]`
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,8 +22,10 @@ const APP: () = {
|
||||||
static mut X: NotSend = ();
|
static mut X: NotSend = ();
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init() -> init::LateResources {
|
||||||
X = NotSend { _0: PhantomData };
|
init::LateResources {
|
||||||
|
X: NotSend { _0: PhantomData },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [X])]
|
#[interrupt(resources = [X])]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// TODO remove in v0.5.x
|
||||||
|
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,12 @@ const APP: () = {
|
||||||
static mut Y: Option<NotSend> = None;
|
static mut Y: Option<NotSend> = None;
|
||||||
|
|
||||||
#[init(resources = [Y])]
|
#[init(resources = [Y])]
|
||||||
fn init() {
|
fn init() -> init::LateResources {
|
||||||
*resources.Y = Some(NotSend { _0: PhantomData });
|
*resources.Y = Some(NotSend { _0: PhantomData });
|
||||||
|
|
||||||
X = NotSend { _0: PhantomData };
|
init::LateResources {
|
||||||
|
X: NotSend { _0: PhantomData },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle(resources = [X, Y])]
|
#[idle(resources = [X, Y])]
|
||||||
|
|
|
@ -14,8 +14,7 @@ const APP: () = {
|
||||||
static Y: u32 = ();
|
static Y: u32 = ();
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init() -> init::LateResources {
|
||||||
X = 0;
|
init::LateResources { X: 0, Y: 1 }
|
||||||
Y = 1;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue