2021-01-18 23:47:47 +08:00
|
|
|
///! Module for all hardware-specific setup of Stabilizer
|
|
|
|
use stm32h7xx_hal as hal;
|
|
|
|
|
2021-01-18 23:55:56 +08:00
|
|
|
#[cfg(feature = "semihosting")]
|
|
|
|
use panic_semihosting as _;
|
|
|
|
|
|
|
|
#[cfg(not(any(feature = "nightly", feature = "semihosting")))]
|
|
|
|
use panic_halt as _;
|
|
|
|
|
2021-01-18 23:47:47 +08:00
|
|
|
mod adc;
|
|
|
|
mod afe;
|
|
|
|
mod configuration;
|
|
|
|
mod dac;
|
2021-02-04 19:48:25 +08:00
|
|
|
pub mod design_parameters;
|
2021-01-18 23:47:47 +08:00
|
|
|
mod digital_input_stamper;
|
|
|
|
mod eeprom;
|
2021-02-08 22:24:52 +08:00
|
|
|
pub mod pounder;
|
2021-01-18 23:47:47 +08:00
|
|
|
mod timers;
|
|
|
|
|
|
|
|
pub use adc::{Adc0Input, Adc1Input};
|
|
|
|
pub use afe::Gain as AfeGain;
|
|
|
|
pub use dac::{Dac0Output, Dac1Output};
|
2021-01-20 21:29:29 +08:00
|
|
|
pub use digital_input_stamper::InputStamper;
|
2021-01-18 23:47:47 +08:00
|
|
|
pub use pounder::DdsOutput;
|
|
|
|
|
|
|
|
// Type alias for the analog front-end (AFE) for ADC0.
|
|
|
|
pub type AFE0 = afe::ProgrammableGainAmplifier<
|
|
|
|
hal::gpio::gpiof::PF2<hal::gpio::Output<hal::gpio::PushPull>>,
|
|
|
|
hal::gpio::gpiof::PF5<hal::gpio::Output<hal::gpio::PushPull>>,
|
|
|
|
>;
|
|
|
|
|
|
|
|
// Type alias for the analog front-end (AFE) for ADC1.
|
|
|
|
pub type AFE1 = afe::ProgrammableGainAmplifier<
|
|
|
|
hal::gpio::gpiod::PD14<hal::gpio::Output<hal::gpio::PushPull>>,
|
|
|
|
hal::gpio::gpiod::PD15<hal::gpio::Output<hal::gpio::PushPull>>,
|
|
|
|
>;
|
|
|
|
|
2021-01-31 01:48:27 +08:00
|
|
|
pub type NetworkStack = smoltcp_nal::NetworkStack<
|
2021-01-18 23:47:47 +08:00
|
|
|
'static,
|
|
|
|
'static,
|
|
|
|
hal::ethernet::EthernetDMA<'static>,
|
|
|
|
>;
|
|
|
|
|
|
|
|
pub use configuration::{setup, PounderDevices, StabilizerDevices};
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[panic_handler]
|
|
|
|
#[cfg(all(feature = "nightly", not(feature = "semihosting")))]
|
|
|
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|
|
|
let gpiod = unsafe { &*hal::stm32::GPIOD::ptr() };
|
|
|
|
gpiod.odr.modify(|_, w| w.odr6().high().odr12().high()); // FP_LED_1, FP_LED_3
|
|
|
|
#[cfg(feature = "nightly")]
|
|
|
|
core::intrinsics::abort();
|
|
|
|
#[cfg(not(feature = "nightly"))]
|
|
|
|
unsafe {
|
|
|
|
core::intrinsics::abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cortex_m_rt::exception]
|
|
|
|
fn HardFault(ef: &cortex_m_rt::ExceptionFrame) -> ! {
|
|
|
|
panic!("HardFault at {:#?}", ef);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cortex_m_rt::exception]
|
|
|
|
fn DefaultHandler(irqn: i16) {
|
|
|
|
panic!("Unhandled exception (IRQn = {})", irqn);
|
|
|
|
}
|