feat: blinky external

This commit is contained in:
cscherr 2025-04-30 14:52:53 +02:00
parent 7d4770dc9e
commit a5c99f4037
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7

46
examples/blinky-external.rs Executable file
View file

@ -0,0 +1,46 @@
#![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);
}
}