2023-12-15 13:11:05 +08:00
|
|
|
#![cfg_attr(not(test), no_main)]
|
|
|
|
#![cfg_attr(not(test), no_std)]
|
2022-10-20 15:17:43 +08:00
|
|
|
|
|
|
|
use cortex_m_rt::entry;
|
2022-10-20 20:57:24 +08:00
|
|
|
use log::info;
|
2022-10-22 15:49:01 +08:00
|
|
|
use stm32f4xx_hal::pac::{CorePeripherals, Peripherals};
|
2022-10-21 12:05:55 +08:00
|
|
|
|
2022-10-20 20:57:24 +08:00
|
|
|
mod device;
|
2022-10-21 12:05:55 +08:00
|
|
|
mod laser_diode;
|
2023-12-20 12:08:48 +08:00
|
|
|
mod thermostat;
|
2022-10-22 21:00:17 +08:00
|
|
|
use device::{boot::bootup, log_setup, sys_timer};
|
|
|
|
|
2023-12-20 12:08:48 +08:00
|
|
|
use crate::thermostat::max1968;
|
|
|
|
|
2022-10-22 21:00:17 +08:00
|
|
|
// If RTT is used, print panic info through RTT
|
2023-12-15 13:11:05 +08:00
|
|
|
#[cfg(all(feature = "RTT", not(test)))]
|
2023-12-20 12:08:48 +08:00
|
|
|
use {core::panic::PanicInfo, rtt_target::rprintln};
|
2023-12-15 13:11:05 +08:00
|
|
|
#[cfg(all(feature = "RTT", not(test)))]
|
2022-10-22 21:00:17 +08:00
|
|
|
#[panic_handler]
|
|
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
|
|
rprintln!("{}", info);
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
// Otherwise use panic halt
|
2023-12-15 13:11:05 +08:00
|
|
|
#[cfg(all(not(feature = "RTT"), not(test)))]
|
2022-10-22 21:00:17 +08:00
|
|
|
use panic_halt as _;
|
2022-10-20 15:17:43 +08:00
|
|
|
|
2023-12-15 13:11:05 +08:00
|
|
|
#[cfg(not(test))]
|
2022-10-20 15:17:43 +08:00
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
2022-10-22 21:00:17 +08:00
|
|
|
log_setup::init_log();
|
|
|
|
info!("Kirdy init");
|
|
|
|
|
2022-10-22 15:49:01 +08:00
|
|
|
let core_perif = CorePeripherals::take().unwrap();
|
2022-10-20 20:57:24 +08:00
|
|
|
let perif = Peripherals::take().unwrap();
|
|
|
|
|
2022-10-22 15:49:01 +08:00
|
|
|
let mut wd = bootup(core_perif, perif);
|
2022-10-20 20:57:24 +08:00
|
|
|
|
|
|
|
loop {
|
|
|
|
wd.feed();
|
2022-10-20 21:21:01 +08:00
|
|
|
info!("looping");
|
|
|
|
sys_timer::sleep(10);
|
2022-10-20 20:57:24 +08:00
|
|
|
}
|
2022-10-22 15:49:01 +08:00
|
|
|
}
|