Skip to content

Commit

Permalink
docs(examples/application): minimal Application user
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Jan 9, 2024
1 parent 4ba4193 commit 5843680
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions examples/application/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions examples/application/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# application

## About

This folder contains a minimal `Application` example.
4 changes: 4 additions & 0 deletions examples/application/laze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apps:
- name: application
selects:
- ?release
34 changes: 34 additions & 0 deletions examples/application/src/main.rs
Original file line number Diff line number Diff line change
@@ -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(()))
}
1 change: 1 addition & 0 deletions examples/laze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defaults:
- riot-rs

subdirs:
- application
- benchmark
- bottles
- core-sizes
Expand Down

0 comments on commit 5843680

Please sign in to comment.