46 lines
1.1 KiB
Rust
Executable file
46 lines
1.1 KiB
Rust
Executable file
#![no_main]
|
|
#![no_std]
|
|
|
|
use defmt_rtt as _; // global logger
|
|
//
|
|
use panic_probe as _;
|
|
use cortex_m_rt::entry;
|
|
use hal::{pac, prelude::*, rcc::Config};
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let dp = pac::Peripherals::take().unwrap();
|
|
let cp = cortex_m::Peripherals::take().unwrap();
|
|
|
|
let mut rcc = dp.RCC.freeze(Config::hsi16());
|
|
|
|
let gpioa = dp.GPIOA.split(&mut rcc);
|
|
let gpiob = dp.GPIOB.split(&mut rcc);
|
|
|
|
let mut builtin_led = gpioa.pa5.into_push_pull_output();
|
|
let mut led0 = gpiob.pb5.into_push_pull_output(); // D4
|
|
let mut led1 = gpiob.pb4.into_push_pull_output(); // D5
|
|
|
|
let mut delay = cp.SYST.delay(rcc.clocks);
|
|
|
|
builtin_led.set_high().unwrap();
|
|
led0.set_high().unwrap();
|
|
led1.set_high().unwrap();
|
|
|
|
loop {
|
|
builtin_led.set_high().unwrap();
|
|
led0.set_low().unwrap();
|
|
led1.set_low().unwrap();
|
|
delay.delay_ms(100_u16);
|
|
|
|
led0.set_high().unwrap();
|
|
delay.delay_ms(100_u16);
|
|
|
|
builtin_led.set_low().unwrap();
|
|
delay.delay_ms(100_u16);
|
|
|
|
led0.set_low().unwrap();
|
|
led1.set_high().unwrap();
|
|
delay.delay_ms(100_u16);
|
|
}
|
|
}
|