Basis for firmware

This commit is contained in:
2025-06-10 21:12:18 +02:00
parent 9311470b1c
commit b70026d562
8 changed files with 955 additions and 0 deletions

45
firmware/src/main.rs Normal file
View File

@@ -0,0 +1,45 @@
#![no_std]
#![no_main]
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f0xx_hal::{
prelude::*,
stm32,
delay::Delay,
};
#[entry]
fn main() -> ! {
// Get device peripherals
let mut dp = stm32::Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().unwrap();
// Configure the clock to 48 MHz
let mut rcc = dp.RCC.configure()
.hsi48()
.enable_crs(dp.CRS)
.sysclk(48.mhz())
.pclk(24.mhz())
.freeze(&mut dp.FLASH);
// Set up delay provider
let mut delay = Delay::new(cp.SYST, &rcc);
// Configure GPIO
let gpioa = dp.GPIOA.split(&mut rcc);
// Configure PA5 as push-pull output (common LED pin)
let mut led = cortex_m::interrupt::free(|cs| {
gpioa.pa5.into_push_pull_output(cs)
});
// Blink loop
loop {
led.set_high().ok();
delay.delay_ms(500u16);
led.set_low().ok();
delay.delay_ms(500u16);
}
}