refactor: blinky as in typst
This commit is contained in:
parent
d24370dd03
commit
2794f7ec8a
1 changed files with 9 additions and 10 deletions
|
@ -1,6 +1,5 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
extern crate panic_halt;
|
extern crate panic_halt;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
|
@ -8,27 +7,27 @@ use hal::{pac, prelude::*, rcc::Config};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
|
// get access to the peripherals
|
||||||
let dp = pac::Peripherals::take().unwrap();
|
let dp = pac::Peripherals::take().unwrap();
|
||||||
let cp = cortex_m::Peripherals::take().unwrap();
|
let cp = cortex_m::Peripherals::take().unwrap();
|
||||||
|
|
||||||
// Configure the clock.
|
// configure the clock
|
||||||
let mut rcc = dp.RCC.freeze(Config::hsi16());
|
let mut rcc = dp.RCC.freeze(Config::hsi16());
|
||||||
|
|
||||||
// Acquire the GPIOA peripheral. This also enables the clock for GPIOA in
|
// get access to GPIO Port A
|
||||||
// the RCC register.
|
|
||||||
let gpioa = dp.GPIOA.split(&mut rcc);
|
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();
|
let mut led = gpioa.pa5.into_push_pull_output();
|
||||||
|
|
||||||
// Get the delay provider.
|
// prepare delays (sleeping)
|
||||||
let mut delay = cp.SYST.delay(rcc.clocks);
|
let mut delay = cp.SYST.delay(rcc.clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
led.set_high().unwrap();
|
led.set_high().unwrap(); // light on
|
||||||
delay.delay_ms(500_u16);
|
delay.delay_ms(500_u16); // wait
|
||||||
|
|
||||||
led.set_low().unwrap();
|
led.set_low().unwrap(); // light off
|
||||||
delay.delay_ms(500_u16);
|
delay.delay_ms(500_u16); // wait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue