use stm32f4xx_hal::gpio::{Input, Output, PushPull, PE10, PE11, PE8, PE9};
use crate::device::sys_timer::sleep;
pub struct HwRevPins{
pub h0: PE8,
pub h1: PE9,
pub h2: PE10,
pub h3: PE11,
}
pub struct HWRev {
pub major: u8,
pub minor: u8,
}
impl HWRev {
pub fn detect_hw_rev(hwrev_pins: HwRevPins) -> Self {
let (h0, h1, h2, h3) = (
hwrev_pins.h0.is_high(), hwrev_pins.h1.is_high(),
hwrev_pins.h2.is_high(), hwrev_pins.h3.is_high()
);
match (h0, h1, h2, h3) {
(true, true, true, true) => HWRev { major: 0, minor: 3 },
(_, _, _, _) => HWRev { major: 0, minor: 0 }
}
}
/// On Rev0_3, during power up, digital power rails are stabilized way before analog power rails
/// This causes improper initialization on any peripherals requiring calibrations
/// See Issue #32 on Kirdy Hw Repo
pub fn startup_delay_before_gpio_init(&mut self){
if self.major == 0 && self.minor == 3 {
sleep(5000);
}
}
}