mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
fix preempt example
This commit is contained in:
parent
69729d78eb
commit
7ca5bbf404
3 changed files with 23 additions and 23 deletions
|
@ -138,10 +138,10 @@ The following example showcases the priority based scheduling of tasks.
|
||||||
$ cargo run --example interrupt
|
$ cargo run --example interrupt
|
||||||
{{#include ../../../../ci/expected/preempt.run}}```
|
{{#include ../../../../ci/expected/preempt.run}}```
|
||||||
|
|
||||||
Note that the task `uart1` does *not* preempt task `uart2` because its priority
|
Note that the task `gpiob` does *not* preempt task `gpioc` because its priority
|
||||||
is the *same* as `uart2`'s. However, once `uart2` terminates the execution of
|
is the *same* as `gpioc`'s. However, once `gpioc` terminates the execution of
|
||||||
task `uart1` is prioritized over `uart0`'s due to its higher priority. `uart0`
|
task `gpiob` is prioritized over `gpioa`'s due to its higher priority. `gpioa`
|
||||||
is resumed only after `uart1` terminates.
|
is resumed only after `gpiob` terminates.
|
||||||
|
|
||||||
One more note about priorities: choosing a priority higher than what the device
|
One more note about priorities: choosing a priority higher than what the device
|
||||||
supports (that is `1 << NVIC_PRIO_BITS`) will result in a compile error. Due to
|
supports (that is `1 << NVIC_PRIO_BITS`) will result in a compile error. Due to
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
UART0 - start
|
GPIOA - start
|
||||||
UART2 - start
|
GPIOC - start
|
||||||
UART2 - end
|
GPIOC - end
|
||||||
UART1
|
GPIOB
|
||||||
UART0 - end
|
GPIOA - end
|
||||||
|
|
|
@ -12,26 +12,26 @@ use rtfm::app;
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) {
|
fn init(_: init::Context) {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::GPIOA);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(binds = UART0, priority = 1)]
|
#[task(binds = GPIOA, priority = 1)]
|
||||||
fn uart0(_: uart0::Context) {
|
fn gpioa(_: gpioa::Context) {
|
||||||
hprintln!("UART0 - start").unwrap();
|
hprintln!("GPIOA - start").unwrap();
|
||||||
rtfm::pend(Interrupt::UART2);
|
rtfm::pend(Interrupt::GPIOC);
|
||||||
hprintln!("UART0 - end").unwrap();
|
hprintln!("GPIOA - end").unwrap();
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(binds = UART1, priority = 2)]
|
#[task(binds = GPIOB, priority = 2)]
|
||||||
fn uart1(_: uart1::Context) {
|
fn gpiob(_: gpiob::Context) {
|
||||||
hprintln!(" UART1").unwrap();
|
hprintln!(" GPIOB").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(binds = UART2, priority = 2)]
|
#[task(binds = GPIOC, priority = 2)]
|
||||||
fn uart2(_: uart2::Context) {
|
fn gpioc(_: gpioc::Context) {
|
||||||
hprintln!(" UART2 - start").unwrap();
|
hprintln!(" GPIOC - start").unwrap();
|
||||||
rtfm::pend(Interrupt::UART1);
|
rtfm::pend(Interrupt::GPIOB);
|
||||||
hprintln!(" UART2 - end").unwrap();
|
hprintln!(" GPIOC - end").unwrap();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue