1
#![cfg_attr(not(test), no_std)]
2

            
3
#![allow(non_camel_case_types)]
4
#![allow(non_snake_case)]
5
#![allow(non_upper_case_globals)]
6

            
7
#![allow(dead_code)]
8
#![allow(static_mut_refs)]
9
#![allow(unused_imports)]
10
#![allow(unused_macros)]
11
#![allow(unused_parens)]
12
#![allow(unused_unsafe)]
13
#![allow(unused_variables)]
14

            
15
// Do not edit this file as it will be overwritten if codegen is rerun
16

            
17
mod bridge;
18
mod component;
19
mod logging;
20

            
21
#[cfg(test)]
22
mod test;
23

            
24
use crate::bridge::thermostat_thermostat_api::{self as api, *};
25
use crate::component::thermostat_thermostat_app::*;
26
use data::*;
27

            
28
static mut app: Option<thermostat_thermostat> = None;
29
static mut init_api: thermostat_thermostat_Application_Api<thermostat_thermostat_Initialization_Api> = api::init_api();
30
static mut compute_api: thermostat_thermostat_Application_Api<thermostat_thermostat_Compute_Api> = api::compute_api();
31

            
32
#[no_mangle]
33
526
pub extern "C" fn thermostat_thermostat_initialize() {
34
526
  logging::init_logging();
35
526

            
36
526
  unsafe {
37
526
    #[cfg(test)]
38
526
    crate::bridge::extern_c_api::initialize_test_globals();
39
526

            
40
526
    let mut _app = thermostat_thermostat::new();
41
526
    _app.initialize(&mut init_api);
42
526
    app = Some(_app);
43
526
  }
44
526
}
45

            
46
#[no_mangle]
47
244
pub extern "C" fn thermostat_thermostat_timeTriggered() {
48
  unsafe {
49
244
    if let Some(_app) = app.as_mut() {
50
244
      _app.timeTriggered(&mut compute_api);
51
244
    } else {
52
      panic!("Unexpected: app is None");
53
    }
54
  }
55
244
}
56

            
57
#[no_mangle]
58
pub extern "C" fn thermostat_thermostat_notify(channel: microkit_channel) {
59
  unsafe {
60
    if let Some(_app) = app.as_mut() {
61
      _app.notify(channel);
62
    } else {
63
      panic!("Unexpected: app is None");
64
    }
65
  }
66
}
67

            
68
// Need a Panic handler in a no_std environment
69
#[panic_handler]
70
#[cfg(not(test))]
71
fn panic(info: &core::panic::PanicInfo) -> ! {
72
  log::error!("PANIC: {info:#?}");
73
  loop {}
74
}