52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
|
use stm32f4xx_hal::{
|
||
|
watchdog::IndependentWatchdog,
|
||
|
rcc::RccExt,
|
||
|
pac::{CorePeripherals, Peripherals},
|
||
|
time::MegaHertz, prelude::_stm32f4xx_hal_gpio_GpioExt,
|
||
|
};
|
||
|
use fugit::ExtU32;
|
||
|
use log::info;
|
||
|
use super::{log_setup, sys_timer, usb};
|
||
|
|
||
|
#[cfg(not(feature = "semihosting"))]
|
||
|
const WATCHDOG_PERIOD: u32 = 1000;
|
||
|
#[cfg(feature = "semihosting")]
|
||
|
const WATCHDOG_PERIOD: u32 = 30000;
|
||
|
|
||
|
pub fn bootup (mut core_perif : CorePeripherals, perif : Peripherals) -> (
|
||
|
IndependentWatchdog
|
||
|
) {
|
||
|
|
||
|
log_setup::init_log();
|
||
|
info!("Kirdy init");
|
||
|
|
||
|
core_perif.SCB.enable_icache();
|
||
|
core_perif.SCB.enable_dcache(&mut core_perif.CPUID);
|
||
|
|
||
|
|
||
|
let clocks = perif.RCC.constrain()
|
||
|
.cfgr
|
||
|
.use_hse(MegaHertz::from_raw(8).convert())
|
||
|
.sysclk(MegaHertz::from_raw(168).convert())
|
||
|
.hclk(MegaHertz::from_raw(168).convert())
|
||
|
.pclk1(MegaHertz::from_raw(32).convert())
|
||
|
.pclk2(MegaHertz::from_raw(64).convert())
|
||
|
.freeze();
|
||
|
|
||
|
// let (pins, eth_pins, usb) = Pins::setup(
|
||
|
// clocks, perif.TIM4,
|
||
|
// perif.GPIOA, perif.GPIOB, perif.GPIOC, perif.GPIOD, perif.GPIOE, perif.GPIOF, perif.GPIOG,
|
||
|
// perif.SPI1, perif.SPI2, perif.SPI3,
|
||
|
// perif.ADC1,
|
||
|
// perif.OTG_FS_GLOBAL, perif.OTG_FS_DEVICE, perif.OTG_FS_PWRCLK,
|
||
|
// );
|
||
|
|
||
|
let mut wd = IndependentWatchdog::new(perif.IWDG);
|
||
|
wd.start(WATCHDOG_PERIOD.millis());
|
||
|
wd.feed();
|
||
|
|
||
|
sys_timer::setup(core_perif.SYST, clocks);
|
||
|
|
||
|
(wd)
|
||
|
|
||
|
}
|