mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
update examples
This commit is contained in:
parent
e2bde8d21a
commit
2063697c62
2 changed files with 17 additions and 27 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
*.org
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
target/
|
target/
|
||||||
|
|
43
src/lib.rs
43
src/lib.rs
|
@ -37,9 +37,6 @@
|
||||||
//!
|
//!
|
||||||
//! - Tasks must run to completion. That's it, tasks can't contain endless
|
//! - Tasks must run to completion. That's it, tasks can't contain endless
|
||||||
//! loops.
|
//! loops.
|
||||||
//!
|
|
||||||
//! # Limitations
|
|
||||||
//!
|
|
||||||
//! - Task priorities must remain constant at runtime.
|
//! - Task priorities must remain constant at runtime.
|
||||||
//!
|
//!
|
||||||
//! # Dependencies
|
//! # Dependencies
|
||||||
|
@ -79,7 +76,7 @@
|
||||||
//! // device crate generated using svd2rust
|
//! // device crate generated using svd2rust
|
||||||
//! extern crate stm32f30x;
|
//! extern crate stm32f30x;
|
||||||
//!
|
//!
|
||||||
//! use rtfm::{C16, P0};
|
//! use rtfm::{C0, C16, P0};
|
||||||
//!
|
//!
|
||||||
//! // TASKS (None in this example)
|
//! // TASKS (None in this example)
|
||||||
//! tasks!(stm32f30x, {});
|
//! tasks!(stm32f30x, {});
|
||||||
|
@ -90,7 +87,7 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! // IDLE LOOP
|
//! // IDLE LOOP
|
||||||
//! fn idle(_priority: P0) -> ! {
|
//! fn idle(_priority: P0, _ceiling: C0) -> ! {
|
||||||
//! hprintln!("IDLE");
|
//! hprintln!("IDLE");
|
||||||
//!
|
//!
|
||||||
//! // Sleep
|
//! // Sleep
|
||||||
|
@ -130,7 +127,7 @@
|
||||||
//! extern crate stm32f30x;
|
//! extern crate stm32f30x;
|
||||||
//!
|
//!
|
||||||
//! use stm32f30x::interrupt::Tim7;
|
//! use stm32f30x::interrupt::Tim7;
|
||||||
//! use rtfm::{C16, Local, P0, P1};
|
//! use rtfm::{C0, C1, C16, Local, P0, P1};
|
||||||
//!
|
//!
|
||||||
//! // INITIALIZATION PHASE
|
//! // INITIALIZATION PHASE
|
||||||
//! fn init(_priority: P0, _ceiling: &C16) {
|
//! fn init(_priority: P0, _ceiling: &C16) {
|
||||||
|
@ -139,7 +136,7 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! // IDLE LOOP
|
//! // IDLE LOOP
|
||||||
//! fn idle(_priority: P0) -> ! {
|
//! fn idle(_priority: P0, _ceiling: C0) -> ! {
|
||||||
//! // Sleep
|
//! // Sleep
|
||||||
//! loop {
|
//! loop {
|
||||||
//! rtfm::wfi();
|
//! rtfm::wfi();
|
||||||
|
@ -155,7 +152,7 @@
|
||||||
//! },
|
//! },
|
||||||
//! });
|
//! });
|
||||||
//!
|
//!
|
||||||
//! fn periodic(mut task: Tim7, _priority: P1) {
|
//! fn periodic(mut task: Tim7, _priority: P1, _ceiling: C1) {
|
||||||
//! // Task local data
|
//! // Task local data
|
||||||
//! static STATE: Local<bool, Tim7> = Local::new(false);
|
//! static STATE: Local<bool, Tim7> = Local::new(false);
|
||||||
//!
|
//!
|
||||||
|
@ -199,7 +196,7 @@
|
||||||
//! use core::cell::Cell;
|
//! use core::cell::Cell;
|
||||||
//!
|
//!
|
||||||
//! use stm32f30x::interrupt::{Tim6Dacunder, Tim7};
|
//! use stm32f30x::interrupt::{Tim6Dacunder, Tim7};
|
||||||
//! use rtfm::{C1, C16, P0, P1, Resource};
|
//! use rtfm::{C0, C1, C16, P0, P1, Resource};
|
||||||
//!
|
//!
|
||||||
//! // omitted: `idle`, `init`
|
//! // omitted: `idle`, `init`
|
||||||
//!
|
//!
|
||||||
|
@ -223,25 +220,21 @@
|
||||||
//! // ..
|
//! // ..
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn idle(priority: P0) -> ! {
|
//! fn idle(priority: P0, ceiling: C0) -> ! {
|
||||||
//! // Sleep
|
//! // Sleep
|
||||||
//! loop {
|
//! loop {
|
||||||
//! rtfm::wfi();
|
//! rtfm::wfi();
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn t1(_task: Tim6Dacunder, priority: P1) {
|
//! fn t1(_task: Tim6Dacunder, priority: P1, ceiling: C1) {
|
||||||
//! let ceiling = priority.as_ceiling();
|
//! let counter = COUNTER.access(&priority, &ceiling);
|
||||||
//!
|
|
||||||
//! let counter = COUNTER.access(&priority, ceiling);
|
|
||||||
//!
|
//!
|
||||||
//! counter.set(counter.get() + 1);
|
//! counter.set(counter.get() + 1);
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn t2(_task: Tim7, priority: P1) {
|
//! fn t2(_task: Tim7, priority: P1, ceiling: C1) {
|
||||||
//! let ceiling = priority.as_ceiling();
|
//! let counter = COUNTER.access(&priority, &ceiling);
|
||||||
//!
|
|
||||||
//! let counter = COUNTER.access(&priority, ceiling);
|
|
||||||
//!
|
//!
|
||||||
//! counter.set(counter.get() + 2);
|
//! counter.set(counter.get() + 2);
|
||||||
//! }
|
//! }
|
||||||
|
@ -279,7 +272,7 @@
|
||||||
//! use core::cell::Cell;
|
//! use core::cell::Cell;
|
||||||
//!
|
//!
|
||||||
//! use stm32f30x::interrupt::{Tim6Dacunder, Tim7};
|
//! use stm32f30x::interrupt::{Tim6Dacunder, Tim7};
|
||||||
//! use rtfm::{C1, C16, C2, P0, P1, P2, Resource};
|
//! use rtfm::{C0, C1, C16, C2, P0, P1, P2, Resource};
|
||||||
//!
|
//!
|
||||||
//! tasks!(stm32f30x, {
|
//! tasks!(stm32f30x, {
|
||||||
//! t1: Task {
|
//! t1: Task {
|
||||||
|
@ -300,18 +293,16 @@
|
||||||
//! // ..
|
//! // ..
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn idle(priority: P0) -> ! {
|
//! fn idle(priority: P0, ceiling: C0) -> ! {
|
||||||
//! // Sleep
|
//! // Sleep
|
||||||
//! loop {
|
//! loop {
|
||||||
//! rtfm::wfi();
|
//! rtfm::wfi();
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn t1(_task: Tim6Dacunder, priority: P1) {
|
//! fn t1(_task: Tim6Dacunder, priority: P1, ceiling: C1) {
|
||||||
//! // ..
|
//! // ..
|
||||||
//!
|
//!
|
||||||
//! let ceiling: &C1 = priority.as_ceiling();
|
|
||||||
//!
|
|
||||||
//! ceiling.raise(
|
//! ceiling.raise(
|
||||||
//! &COUNTER, |ceiling: &C2| {
|
//! &COUNTER, |ceiling: &C2| {
|
||||||
//! let counter = COUNTER.access(&priority, ceiling);
|
//! let counter = COUNTER.access(&priority, ceiling);
|
||||||
|
@ -323,10 +314,8 @@
|
||||||
//! // ..
|
//! // ..
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn t2(_task: Tim7, priority: P2) {
|
//! fn t2(_task: Tim7, priority: P2, ceiling: C2) {
|
||||||
//! let ceiling = priority.as_ceiling();
|
//! let counter = COUNTER.access(&priority, &ceiling);
|
||||||
//!
|
|
||||||
//! let counter = COUNTER.access(&priority, ceiling);
|
|
||||||
//!
|
//!
|
||||||
//! counter.set(counter.get() + 2);
|
//! counter.set(counter.get() + 2);
|
||||||
//! }
|
//! }
|
||||||
|
|
Loading…
Reference in a new issue