79 lines
1.6 KiB
Rust
79 lines
1.6 KiB
Rust
#![no_main]
|
|
#![no_std]
|
|
|
|
use rtic::app;
|
|
mod device;
|
|
mod laser_diode;
|
|
|
|
// If RTT is used, print panic info through RTT
|
|
#[cfg(feature = "RTT")]
|
|
use {
|
|
core::panic::PanicInfo,
|
|
rtt_target::rprintln,
|
|
};
|
|
#[cfg(feature = "RTT")]
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
rprintln!("{}", info);
|
|
loop {}
|
|
}
|
|
// Otherwise use panic halt
|
|
#[cfg(not(feature = "RTT"))]
|
|
use panic_halt as _;
|
|
|
|
// #[entry]
|
|
#[app(device = stm32f4xx_hal::pac, peripherals = true, dispatchers = [TIM8_CC])]
|
|
mod app {
|
|
|
|
use log::info;
|
|
use systick_monotonic::Systick;
|
|
use fugit::ExtU32;
|
|
use stm32f4xx_hal::watchdog::IndependentWatchdog;
|
|
use crate::device::{boot::bootup, log_setup};
|
|
|
|
#[monotonic(binds = SysTick, default = true)]
|
|
type SystickTimer = Systick<1000>;
|
|
|
|
#[shared]
|
|
struct Shared {
|
|
|
|
}
|
|
|
|
#[local]
|
|
struct Local {
|
|
wd: IndependentWatchdog,
|
|
}
|
|
|
|
#[init]
|
|
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
|
log_setup::init_log();
|
|
info!("Kirdy init");
|
|
|
|
let core_perif = cx.core;
|
|
let perif = cx.device;
|
|
let (wd, systick) = bootup(core_perif, perif);
|
|
|
|
wd_feed::spawn().unwrap();
|
|
|
|
(Shared {}, Local {wd}, init::Monotonics(systick))
|
|
}
|
|
|
|
#[task(priority = 5, local = [wd])]
|
|
fn wd_feed (cx: wd_feed::Context) {
|
|
let start = monotonics::now();
|
|
let wd = cx.local.wd;
|
|
info!("feed wd");
|
|
wd.feed();
|
|
wd_feed::spawn_at(start + 10_u32.millis()).unwrap();
|
|
}
|
|
|
|
#[idle]
|
|
fn idle(_: idle::Context) -> ! {
|
|
loop {
|
|
cortex_m::asm::nop();
|
|
}
|
|
}
|
|
|
|
}
|
|
|