stm32_rust_template/apps/
mod.rs1pub mod blink;
10pub mod empty;
11
12use alloc::boxed::Box;
13use alloc::vec::Vec;
14
15pub trait App {
16 fn init(&mut self) -> Result<(), i32>;
17 fn loop_step(&mut self);
18}
19
20static mut APPS: Option<Vec<Box<dyn App>>> = None;
21
22pub fn init_app_registry() {
23 unsafe {
24 APPS = Some(Vec::new());
25 }
26}
27
28pub fn register_app(app: Box<dyn App>) {
29 unsafe {
30 if let Some(ref mut apps) = APPS {
31 apps.push(app);
32 }
33 }
34}
35
36pub fn init_all_apps() -> Result<(), i32> {
37 unsafe {
38 if let Some(ref mut apps) = APPS {
39 for app in apps.iter_mut() {
40 app.init()?;
41 }
42 }
43 }
44 Ok(())
45}
46
47pub fn run_all_loop_steps() {
48 unsafe {
49 if let Some(ref mut apps) = APPS {
50 for app in apps.iter_mut() {
51 app.loop_step();
52 }
53 }
54 }
55}
56
57pub mod interrupts;