Description
RTIC (Real-Time Interrupt-driven Concurrency) is a crate to write simple and efficient Firmware for embedded Systems.
Features
Tasks
- Tasks that run to completion (no infinite loops)
- Tasks can be event triggered or spawned on demand
- Trigger through Hardware (e.g. pressing a button)
- Trigger through Software (e.g. function call)
- Message passing between tasks
- Timer queue Software tasks can be scheduled to run at some time in future
- Prioitization of tasks Also known as preemptive multitasking Tasks gets done sequentielly
- Efficient and data race free memory sharing and priority based Mutex which never fail
- Deadlock free execution guaranteed at compile time
- Minimal scheduling overhead Hardware based scheduling instead of software based
- Highly efficient memory usage No stackoverflows
Advantages through Rust
-
Compiles to native code
-
No built-in runtime
-
Support for most popular architectures
Rust utilizes LLVM
-
Standardized API (embeddedhal)
-
Code is portable with small adjustment for other ESP
Demo Explanation
App Macro
#![no_main]
#![no_std]
use panic_halt as _;
#[rtic::app(device = stm32l4xx_hal::stm32, peripherals = true)]
mod app {
use stm32l4xx_hal as _;
#[shared]
struct Shared {
}
#[local]
struct Local {
}
#[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
(
Shared {
},
Local {
},
init::Monotonics(),
)
}
#[idle]
fn idle(_ctx: idle::Context) -> ! {
loop {
}
}
}
Shared
There we define shared resources or in other terms resources which should be accessible by every fn
Local
resources which should be only be accessible by local functions such as an counter
Resources
RTIC: Real Time Interrupt driven Concurrency - YouTube GitHub - korken89/oxidize2020-rtic rtic-examples/rticv1/rp-picolocalinitilzdresources/src/main.rs at master … Example code for RPI Pico RTIC: Real time concurrency on ARM Cortex-M | Rust Wrocław #26, 23.06.2022 - … How to communicate over USB to rpico