1
0
Fork 0

flash: Add init boot seq

- Max flash erase time for PSize = 8 and 128KiB Sector is 4s
- Watchdog period is changed accordingly
This commit is contained in:
linuswck 2024-01-15 17:06:27 +08:00
parent 74325a3cee
commit d190b8b192
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
use core::marker::PhantomData;
use super::{gpio, sys_timer, usb};
use crate::device::flash_store::{self, FlashStore};
use crate::laser_diode::current_sources::{*};
use crate::laser_diode::ld_drive::{self, LdDrive};
use crate::thermostat::max1968::MAX1968;
@ -16,14 +17,14 @@ use stm32f4xx_hal::{
use uom::si::{electric_current::ampere, f64::ElectricCurrent};
#[cfg(not(feature = "semihosting"))]
const WATCHDOG_PERIOD: u32 = 1000;
const WATCHDOG_PERIOD: u32 = 4000;
#[cfg(feature = "semihosting")]
const WATCHDOG_PERIOD: u32 = 30000;
pub fn bootup(
mut core_perif: CorePeripherals,
perif: Peripherals,
) -> (IndependentWatchdog, LdDrive, Thermostat) {
) -> (IndependentWatchdog, FlashStore, LdDrive, Thermostat) {
core_perif.SCB.enable_icache();
core_perif.SCB.enable_dcache(&mut core_perif.CPUID);
@ -78,11 +79,13 @@ pub fn bootup(
thermostat.calibrate_dac_value();
thermostat.set_i(ElectricCurrent::new::<ampere>(1.0));
let flash_store = flash_store::store(perif.FLASH);
let mut wd = IndependentWatchdog::new(perif.IWDG);
wd.start(WATCHDOG_PERIOD.millis());
wd.feed();
info!("Kirdy setup complete");
(wd, laser, thermostat)
(wd, flash_store, laser, thermostat)
}

View File

@ -4,7 +4,6 @@
use cortex_m_rt::entry;
use log::info;
use stm32f4xx_hal::pac::{CorePeripherals, Peripherals};
mod device;
mod laser_diode;
mod thermostat;
@ -38,7 +37,7 @@ fn main() -> ! {
let core_perif = CorePeripherals::take().unwrap();
let perif = Peripherals::take().unwrap();
let (mut wd, mut laser, mut thermostat,) = bootup(core_perif, perif);
let (mut wd, _flash_store, mut laser, mut thermostat,) = bootup(core_perif, perif);
// https://github.com/iliekturtles/uom/blob/master/examples/si.rs
let volt_fmt = ElectricPotential::format_args(volt, Abbreviation);