Updated crates for the fimrware part
This commit is contained in:
parent
475e9621a1
commit
ceb4dc035f
5 changed files with 489 additions and 570 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use core::{mem::MaybeUninit, ptr::addr_of_mut};
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
use stm32f4xx_hal::pac;
|
||||
|
||||
|
|
@ -9,7 +9,7 @@ fn jump_to_bootloader() {
|
|||
let address: u32 = 0x1FFF0000;
|
||||
|
||||
let device = pac::Peripherals::steal();
|
||||
device.SYSCFG.memrm.modify(|_, w| w.bits(0x01));
|
||||
device.SYSCFG.memrmp().modify(|_, w| w.bits(0x01));
|
||||
|
||||
let mut p = cortex_m::Peripherals::steal();
|
||||
p.SCB.invalidate_icache();
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue