33 lines
809 B
Rust
Executable file
33 lines
809 B
Rust
Executable file
#![no_main]
|
|
#![no_std]
|
|
extern crate panic_halt;
|
|
|
|
use cortex_m_rt::entry;
|
|
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
|
|
let mut rcc = dp.RCC.freeze(Config::hsi16());
|
|
|
|
// get access to GPIO Port A
|
|
let gpioa = dp.GPIOA.split(&mut rcc);
|
|
|
|
// configure Pin 5 og GPIO Port A as output
|
|
let mut led = gpioa.pa5.into_push_pull_output();
|
|
|
|
// prepare delays (sleeping)
|
|
let mut delay = cp.SYST.delay(rcc.clocks);
|
|
|
|
loop {
|
|
led.set_high().unwrap(); // light on
|
|
delay.delay_ms(500_u16); // wait
|
|
|
|
led.set_low().unwrap(); // light off
|
|
delay.delay_ms(500_u16); // wait
|
|
}
|
|
}
|