aboutsummaryrefslogtreecommitdiff
path: root/examples/t-spawn.no_rs
diff options
context:
space:
mode:
authorGravatar Per Lindgren <per.lindgren@ltu.se> 2023-01-07 17:59:39 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:33:24 +0100
commit9a4f97ca5ebf19e6612115db5c763d0d61dd28a1 (patch)
tree1f37d247f715ad3d5215aa7de3aa6d4eb94a7027 /examples/t-spawn.no_rs
parent5606ba3cf38c80be5d3e9c88ad4da9982b114851 (diff)
downloadrtic-9a4f97ca5ebf19e6612115db5c763d0d61dd28a1.tar.gz
rtic-9a4f97ca5ebf19e6612115db5c763d0d61dd28a1.tar.zst
rtic-9a4f97ca5ebf19e6612115db5c763d0d61dd28a1.zip
more examples
Diffstat (limited to 'examples/t-spawn.no_rs')
-rw-r--r--examples/t-spawn.no_rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/examples/t-spawn.no_rs b/examples/t-spawn.no_rs
new file mode 100644
index 00000000..dad0c83a
--- /dev/null
+++ b/examples/t-spawn.no_rs
@@ -0,0 +1,69 @@
+//! [compile-pass] Check code generation of `spawn`
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+#![feature(type_alias_impl_trait)]
+
+use panic_semihosting as _;
+
+#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+mod app {
+ use cortex_m_semihosting::debug;
+
+ #[shared]
+ struct Shared {}
+
+ #[local]
+ struct Local {}
+
+ #[init]
+ fn init(_: init::Context) -> (Shared, Local) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
+
+ debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+
+ (Shared {}, Local {})
+ }
+
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
+
+ loop {
+ cortex_m::asm::nop();
+ }
+ }
+
+ #[task(binds = SVCall)]
+ fn svcall(_: svcall::Context) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
+ }
+
+ #[task(binds = UART0)]
+ fn uart0(_: uart0::Context) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
+ }
+
+ #[task]
+ async fn foo(_: foo::Context) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
+ }
+
+ #[task]
+ async fn bar(_: bar::Context, _x: u32) {}
+
+ #[task]
+ async fn baz(_: baz::Context, _x: u32, _y: u32) {}
+}