aboutsummaryrefslogtreecommitdiff
path: root/examples/zero-prio-task.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-01-08 21:10:06 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:33:28 +0100
commit6d252785e83218eeb5d080836281c90b86ca0e03 (patch)
tree7220026f04871b30fa01d3ddddd5d40c87f89f8b /examples/zero-prio-task.rs
parent35c97b61c17a30de675eb1c7f852a100b200a0c2 (diff)
downloadrtic-6d252785e83218eeb5d080836281c90b86ca0e03.tar.gz
rtic-6d252785e83218eeb5d080836281c90b86ca0e03.tar.zst
rtic-6d252785e83218eeb5d080836281c90b86ca0e03.zip
Support 0 prio tasks
Diffstat (limited to 'examples/zero-prio-task.rs')
-rw-r--r--examples/zero-prio-task.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/examples/zero-prio-task.rs b/examples/zero-prio-task.rs
new file mode 100644
index 00000000..fc385092
--- /dev/null
+++ b/examples/zero-prio-task.rs
@@ -0,0 +1,56 @@
+#![no_main]
+#![no_std]
+#![feature(type_alias_impl_trait)]
+
+use core::marker::PhantomData;
+use panic_semihosting as _;
+
+pub struct NotSend {
+ _0: PhantomData<*const ()>,
+}
+
+#[rtic::app(device = lm3s6965, peripherals = true)]
+mod app {
+ use super::NotSend;
+ use core::marker::PhantomData;
+ use cortex_m_semihosting::{debug, hprintln};
+
+ #[shared]
+ struct Shared {
+ x: NotSend,
+ }
+
+ #[local]
+ struct Local {
+ y: NotSend,
+ }
+
+ #[init]
+ fn init(_cx: init::Context) -> (Shared, Local) {
+ hprintln!("init");
+
+ async_task::spawn().unwrap();
+ async_task2::spawn().unwrap();
+
+ (
+ Shared {
+ x: NotSend { _0: PhantomData },
+ },
+ Local {
+ y: NotSend { _0: PhantomData },
+ },
+ )
+ }
+
+ #[task(priority = 0, shared = [x], local = [y])]
+ async fn async_task(_: async_task::Context) {
+ hprintln!("hello from async");
+ }
+
+ #[task(priority = 0, shared = [x])]
+ async fn async_task2(_: async_task2::Context) {
+ hprintln!("hello from async2");
+
+ debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ }
+}