kirdy/src/main.rs

45 lines
855 B
Rust
Raw Normal View History

2022-10-20 15:17:43 +08:00
#![no_main]
#![no_std]
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;
2022-10-22 21:00:17 +08:00
use device::{boot::bootup, log_setup, sys_timer};
// If RTT is used, print panic info through RTT
#[cfg(feature = "RTT")]
use {
core::panic::PanicInfo,
2022-10-23 16:59:15 +08:00
rtt_target::rprintln,
2022-10-22 21:00:17 +08:00
};
#[cfg(feature = "RTT")]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
rprintln!("{}", info);
loop {}
}
// Otherwise use panic halt
#[cfg(not(feature = "RTT"))]
use panic_halt as _;
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
}