pub use embedded_hal; ///! Module for all hardware-specific setup of Stabilizer pub use stm32h7xx_hal as hal; pub mod adc; pub mod afe; pub mod cycle_counter; pub mod dac; pub mod design_parameters; pub mod input_stamper; pub mod pounder; pub mod setup; pub mod signal_generator; pub mod system_timer; mod eeprom; mod timers; // Type alias for the analog front-end (AFE) for ADC0. pub type AFE0 = afe::ProgrammableGainAmplifier< hal::gpio::gpiof::PF2>, hal::gpio::gpiof::PF5>, >; // Type alias for the analog front-end (AFE) for ADC1. pub type AFE1 = afe::ProgrammableGainAmplifier< hal::gpio::gpiod::PD14>, hal::gpio::gpiod::PD15>, >; // Type alias for digital input 0 (DI0). pub type DigitalInput0 = hal::gpio::gpiog::PG9>; // Type alias for digital input 1 (DI1). pub type DigitalInput1 = hal::gpio::gpioc::PC15>; pub type NetworkStack = smoltcp_nal::NetworkStack< 'static, 'static, hal::ethernet::EthernetDMA<'static>, >; pub type EthernetPhy = hal::ethernet::phy::LAN8742A; #[inline(never)] #[panic_handler] fn panic(info: &core::panic::PanicInfo) -> ! { use core::{ fmt::Write, sync::atomic::{AtomicBool, Ordering}, }; use cortex_m::asm; use rtt_target::{ChannelMode, UpChannel}; cortex_m::interrupt::disable(); // Recursion protection static PANICKED: AtomicBool = AtomicBool::new(false); while PANICKED.load(Ordering::Relaxed) { asm::bkpt(); } PANICKED.store(true, Ordering::Relaxed); // Turn on both red LEDs, FP_LED_1, FP_LED_3 let gpiod = unsafe { &*hal::stm32::GPIOD::ptr() }; gpiod.odr.modify(|_, w| w.odr6().high().odr12().high()); // Analogous to panic-rtt-target if let Some(mut channel) = unsafe { UpChannel::conjure(0) } { channel.set_mode(ChannelMode::BlockIfFull); writeln!(channel, "{}", info).ok(); } // Abort asm::udf(); // Halt // loop { core::sync::atomic::compiler_fence(Ordering::SeqCst); } } #[cortex_m_rt::exception] unsafe fn HardFault(ef: &cortex_m_rt::ExceptionFrame) -> ! { panic!("HardFault at {:#?}", ef); } #[cortex_m_rt::exception] unsafe fn DefaultHandler(irqn: i16) { panic!("Unhandled exception (IRQn = {})", irqn); }