Updated crates for the fimrware part

This commit is contained in:
Sebastian 2025-12-23 15:16:17 +01:00
parent 475e9621a1
commit ceb4dc035f
5 changed files with 489 additions and 570 deletions

View file

@ -33,6 +33,7 @@ mod app {
otg_fs::{UsbBus, UsbBusType, USB},
pac::{I2C1, SPI1},
prelude::*,
rcc::Config,
signature, spi,
};
use usb_device::prelude::*;
@ -93,26 +94,19 @@ mod app {
bootloader::init();
defmt::info!("init");
let mut rcc = cx
.device
.RCC
.freeze(Config::hse(25.MHz()).sysclk(84.MHz()).require_pll48clk());
let rcc = cx.device.RCC.constrain();
// Freeze the configuration of all the clocks in the system and store the frozen frequencies in
// `clocks`
let clocks = rcc
.cfgr
.use_hse(25.MHz())
.sysclk(84.MHz())
.require_pll48clk()
.freeze();
Mono::start(cx.core.SYST, clocks.sysclk().to_Hz());
Mono::start(cx.core.SYST, rcc.clocks.sysclk().to_Hz());
defmt::info!("Clock Setup done");
// Acquire the GPIO peripherials
let gpioa = cx.device.GPIOA.split();
let gpiob = cx.device.GPIOB.split();
let gpioc = cx.device.GPIOC.split();
let gpioa = cx.device.GPIOA.split(&mut rcc);
let gpiob = cx.device.GPIOB.split(&mut rcc);
let gpioc = cx.device.GPIOC.split(&mut rcc);
let board_led = gpioc.pc13.into_push_pull_output();
@ -128,7 +122,7 @@ mod app {
cx.device.OTG_FS_PWRCLK,
),
(gpioa.pa11, gpioa.pa12),
&clocks,
&rcc.clocks,
);
unsafe {
@ -177,7 +171,7 @@ mod app {
i2c::Mode::Standard {
frequency: 400.kHz(),
},
&clocks,
&mut rcc,
);
defmt::info!("I2C Setup done");
@ -201,13 +195,13 @@ mod app {
let pico = gpioa.pa7.into_push_pull_output();
let spi1 = spi::Spi::new(
cx.device.SPI1,
(sck, poci, pico),
(Some(sck), Some(poci), Some(pico)),
spi::Mode {
polarity: spi::Polarity::IdleLow,
phase: spi::Phase::CaptureOnSecondTransition,
},
8.MHz(),
&clocks,
&mut rcc,
);
defmt::info!("SPI Setup done");