diff --git a/Cargo.lock b/Cargo.lock index 4ceab4399..2ad63388e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,17 @@ dependencies = [ "memchr", ] +[[package]] +name = "application" +version = "0.1.0" +dependencies = [ + "embassy-executor", + "embassy-time", + "linkme", + "riot-rs", + "riot-rs-boards", +] + [[package]] name = "arrayvec" version = "0.7.4" diff --git a/examples/application/Cargo.toml b/examples/application/Cargo.toml new file mode 100644 index 000000000..a08647535 --- /dev/null +++ b/examples/application/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "application" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +publish = false + +[dependencies] +riot-rs = { path = "../../src/riot-rs" } +riot-rs-boards = { path = "../../src/riot-rs-boards" } +embassy-executor = { workspace = true, default-features = false } +embassy-time = { workspace = true, default-features = false } +linkme.workspace = true diff --git a/examples/application/README.md b/examples/application/README.md new file mode 100644 index 000000000..3f48b44f1 --- /dev/null +++ b/examples/application/README.md @@ -0,0 +1,5 @@ +# application + +## About + +This folder contains a minimal `Application` example. diff --git a/examples/application/laze.yml b/examples/application/laze.yml new file mode 100644 index 000000000..7b93f3c0c --- /dev/null +++ b/examples/application/laze.yml @@ -0,0 +1,4 @@ +apps: + - name: application + selects: + - ?release diff --git a/examples/application/src/main.rs b/examples/application/src/main.rs new file mode 100644 index 000000000..0a6c06803 --- /dev/null +++ b/examples/application/src/main.rs @@ -0,0 +1,34 @@ +#![no_main] +#![no_std] +#![feature(type_alias_impl_trait)] +#![feature(used_with_arg)] + +use riot_rs::embassy::{arch, Application, ApplicationInitError, Drivers, InitializationArgs}; + +use riot_rs::rt::debug::println; + +struct MyApplication { + state: u32, // some state +} + +impl Application for MyApplication { + fn initialize( + _peripherals: &mut arch::OptionalPeripherals, + _init_args: InitializationArgs, + ) -> Result<&dyn Application, ApplicationInitError> { + println!("MyApplication::initialize()"); + Ok(&Self { state: 0 }) + } + + fn start(&self, _spawner: embassy_executor::Spawner, _drivers: Drivers) { + println!("MyApplication::start()"); + // ... + } +} + +riot_rs::embassy::riot_initialize!(MyApplication); + +#[no_mangle] +fn riot_main() { + riot_rs::rt::debug::exit(Ok(())) +} diff --git a/examples/laze.yml b/examples/laze.yml index d819f1775..19459a0a9 100644 --- a/examples/laze.yml +++ b/examples/laze.yml @@ -4,6 +4,7 @@ defaults: - riot-rs subdirs: + - application - benchmark - bottles - core-sizes