aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/custom-type.rs50
-rw-r--r--examples/full-syntax.rs4
-rw-r--r--examples/generics.rs2
-rw-r--r--examples/late-resources.rs1
-rw-r--r--examples/one-task.rs2
-rw-r--r--examples/preemption.rs2
-rw-r--r--examples/two-tasks.rs4
7 files changed, 57 insertions, 8 deletions
diff --git a/examples/custom-type.rs b/examples/custom-type.rs
new file mode 100644
index 00000000..79d6cc46
--- /dev/null
+++ b/examples/custom-type.rs
@@ -0,0 +1,50 @@
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![feature(proc_macro)]
+#![no_std]
+
+extern crate cortex_m_rtfm as rtfm;
+extern crate stm32f103xx;
+
+use rtfm::{app, Threshold};
+
+pub struct Foo;
+
+app! {
+ device: stm32f103xx,
+
+ resources: {
+ static CO_OWNED: Foo = Foo;
+ static ON: Foo = Foo;
+ static OWNED: Foo = Foo;
+ static SHARED: Foo = Foo;
+ },
+
+ idle: {
+ resources: [OWNED, SHARED],
+ },
+
+ tasks: {
+ SYS_TICK: {
+ path: sys_tick,
+ resources: [CO_OWNED, ON, SHARED],
+ },
+
+ TIM2: {
+ enabled: false,
+ path: tim2,
+ priority: 1,
+ resources: [CO_OWNED],
+ },
+ },
+}
+
+fn init(_p: ::init::Peripherals, _r: ::init::Resources) {}
+
+fn idle(_t: &mut Threshold, _r: ::idle::Resources) -> ! {
+ loop {}
+}
+
+fn sys_tick(_t: &mut Threshold, _r: SYS_TICK::Resources) {}
+
+fn tim2(_t: &mut Threshold, _r: TIM2::Resources) {}
diff --git a/examples/full-syntax.rs b/examples/full-syntax.rs
index b84077fb..5b274122 100644
--- a/examples/full-syntax.rs
+++ b/examples/full-syntax.rs
@@ -73,12 +73,12 @@ mod main {
}
}
-fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
+fn sys_tick(_t: &mut Threshold, mut r: SYS_TICK::Resources) {
*r.ON = !*r.ON;
*r.CO_OWNED += 1;
}
-fn tim2(_t: &mut Threshold, r: TIM2::Resources) {
+fn tim2(_t: &mut Threshold, mut r: TIM2::Resources) {
*r.CO_OWNED += 1;
}
diff --git a/examples/generics.rs b/examples/generics.rs
index 7cf9257b..ca7726d0 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -70,5 +70,5 @@ fn exti0(t: &mut Threshold, r: EXTI0::Resources) {
// This task has direct access to the resources
fn exti1(t: &mut Threshold, r: EXTI1::Resources) {
- work(t, r.GPIOA, r.SPI1);
+ work(t, &r.GPIOA, &r.SPI1);
}
diff --git a/examples/late-resources.rs b/examples/late-resources.rs
index d42431c2..07c321f6 100644
--- a/examples/late-resources.rs
+++ b/examples/late-resources.rs
@@ -1,5 +1,4 @@
//! Demonstrates initialization of resources in `init`.
-
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
diff --git a/examples/one-task.rs b/examples/one-task.rs
index 90eb459a..07def59b 100644
--- a/examples/one-task.rs
+++ b/examples/one-task.rs
@@ -77,7 +77,7 @@ fn idle() -> ! {
// `r` is the set of resources this task has access to. `SYS_TICK::Resources`
// has one field per resource declared in `app!`.
#[allow(unsafe_code)]
-fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
+fn sys_tick(_t: &mut Threshold, mut r: SYS_TICK::Resources) {
// toggle state
*r.ON = !*r.ON;
diff --git a/examples/preemption.rs b/examples/preemption.rs
index 07e93621..8e501887 100644
--- a/examples/preemption.rs
+++ b/examples/preemption.rs
@@ -42,7 +42,7 @@ fn idle() -> ! {
}
}
-fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
+fn sys_tick(_t: &mut Threshold, mut r: SYS_TICK::Resources) {
// ..
// This task can't be preempted by `tim2` so it has direct access to the
diff --git a/examples/two-tasks.rs b/examples/two-tasks.rs
index e9d31e78..4f567f0c 100644
--- a/examples/two-tasks.rs
+++ b/examples/two-tasks.rs
@@ -42,7 +42,7 @@ fn idle() -> ! {
// As both tasks are running at the same priority one can't preempt the other.
// Thus both tasks have direct access to the resource
-fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
+fn sys_tick(_t: &mut Threshold, mut r: SYS_TICK::Resources) {
// ..
*r.COUNTER += 1;
@@ -50,7 +50,7 @@ fn sys_tick(_t: &mut Threshold, r: SYS_TICK::Resources) {
// ..
}
-fn tim2(_t: &mut Threshold, r: TIM2::Resources) {
+fn tim2(_t: &mut Threshold, mut r: TIM2::Resources) {
// ..
*r.COUNTER += 1;