start with rust report

This commit is contained in:
2025-10-28 18:44:39 +01:00
parent 79ab15ca4e
commit 8ddada6531
15 changed files with 27846 additions and 2 deletions

View File

@@ -0,0 +1,57 @@
#![deny(unsafe_code)]
#![allow(clippy::empty_loop)]
#![no_main]
#![no_std]
// Halt on panic
use panic_halt as _; // panic handler
use cortex_m_rt::entry;
use stm32f4xx_hal::{self as hal};
use crate::hal::{pac, prelude::*};
use cortex_m_semihosting::hprintln;
mod leds;
use crate::leds::{UpdateLeds, Leds};
mod state_machine;
use crate::state_machine::StateMachine;
#[entry]
fn main() -> ! {
if let (Some(dp), Some(cp)) = (
pac::Peripherals::take(),
cortex_m::peripheral::Peripherals::take(),
) {
//GPIOD ophalen
let gpiod = dp.GPIOD.split();
//pd12 is pin type
let mut green = gpiod.pd12.into_push_pull_output();
let mut red = gpiod.pd14.into_push_pull_output();
let mut blue = gpiod.pd15.into_push_pull_output();
let mut leds = Leds::new(&mut red, &mut green, &mut blue);
let mut state_machine = StateMachine::new(&mut leds);
//Klok instellen
let rcc = dp.RCC.constrain();
let clocks = rcc.cfgr.sysclk(48.MHz()).freeze();
// Create a delay abstraction based on SysTick
let mut delay = cp.SYST.delay(&clocks);
let mut status:bool = false;
loop {
// On for 1s, off for 1s.
let _ = leds.red_toggle();
let _ = leds.green_toggle();
let _ = leds.blue_toggle();
status ^= true;
delay.delay_ms(1000_u32);
//dit verschijnt in een van de open terminals in vscode
hprintln!("Led {:?}", status.then(|| "aan!").unwrap_or("uit!"));
}
}
loop {}
}