From 2794f7ec8ad2efcfb97cb58f2e300267e83f156c Mon Sep 17 00:00:00 2001 From: cscherr Date: Wed, 14 May 2025 17:26:45 +0200 Subject: [PATCH] refactor: blinky as in typst --- examples/blinky.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/blinky.rs b/examples/blinky.rs index 18472e5..41e49ac 100755 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -1,6 +1,5 @@ #![no_main] #![no_std] - extern crate panic_halt; use cortex_m_rt::entry; @@ -8,27 +7,27 @@ use hal::{pac, prelude::*, rcc::Config}; #[entry] fn main() -> ! { + // get access to the peripherals let dp = pac::Peripherals::take().unwrap(); let cp = cortex_m::Peripherals::take().unwrap(); - // Configure the clock. + // configure the clock let mut rcc = dp.RCC.freeze(Config::hsi16()); - // Acquire the GPIOA peripheral. This also enables the clock for GPIOA in - // the RCC register. + // get access to GPIO Port A let gpioa = dp.GPIOA.split(&mut rcc); - // Configure PA5 as output. + // configure Pin 5 og GPIO Port A as output let mut led = gpioa.pa5.into_push_pull_output(); - // Get the delay provider. + // prepare delays (sleeping) let mut delay = cp.SYST.delay(rcc.clocks); loop { - led.set_high().unwrap(); - delay.delay_ms(500_u16); + led.set_high().unwrap(); // light on + delay.delay_ms(500_u16); // wait - led.set_low().unwrap(); - delay.delay_ms(500_u16); + led.set_low().unwrap(); // light off + delay.delay_ms(500_u16); // wait } }