#![no_main] #![no_std] use rtic::app; mod device; mod laser_diode; mod network; // 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, TIM8_BRK_TIM12])] mod app { use crate::device::{boot::bootup, log_setup}; use crate::network::network; use fugit::ExtU32; use log::info; use stm32f4xx_hal::watchdog::IndependentWatchdog; use systick_monotonic::Systick; #[monotonic(binds = SysTick, default = true)] type SystickTimer = Systick<1000>; #[shared] struct Shared {} #[local] struct Local { wd: IndependentWatchdog, // server_storage: network::network::ServerStorage::new(), server_handle: network::ServerHandle, } #[init( local = [server_storage: network::ServerStorage = network::ServerStorage::new()] )] 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 server_storage = cx.local.server_storage; let (wd, systick, server_handle) = bootup(core_perif, perif, server_storage); wd_feed::spawn().unwrap(); // server_poll::spawn().unwrap(); ( Shared {}, Local { wd, server_handle }, 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(); } #[task(binds = ETH, priority = 2, local = [server_handle, data: [u8; 512] = [0u8; 512]])] fn server_poll(cx: server_poll::Context) { let data = cx.local.data; let server_handle = cx.local.server_handle; server_handle.poll(data); // server_poll::spawn_at(start + 10_u32.millis()).unwrap(); } #[idle] fn idle(_: idle::Context) -> ! { loop { cortex_m::asm::nop(); } } }