refactor: make blinky an example

This commit is contained in:
cscherr 2025-04-24 13:25:32 +02:00
parent 3c3066afe2
commit 1aac7bd456
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
4 changed files with 36 additions and 26 deletions

View file

@ -3,6 +3,7 @@ target = "thumbv6m-none-eabi"
[target.thumbv6m-none-eabi]
runner = 'probe-rs run --chip STM32L053R8'
rustflags = ["-Clink-args=-Tlink.x"]
[alias]
cflash = "flash --chip STM32L053R8"

View file

@ -1,3 +0,0 @@
fn main() {
println!("cargo:rustc-link-arg-bins=-Tlink.x");
}

34
examples/blinky.rs Executable file
View file

@ -0,0 +1,34 @@
#![no_main]
#![no_std]
extern crate panic_halt;
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();
// 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.
let gpioa = dp.GPIOA.split(&mut rcc);
// Configure PA1 as output.
let mut led = gpioa.pa5.into_push_pull_output();
// Get the delay provider.
let mut delay = cp.SYST.delay(rcc.clocks);
loop {
led.set_high().unwrap();
delay.delay_ms(500_u16);
led.set_low().unwrap();
delay.delay_ms(500_u16);
}
}

View file

@ -8,27 +8,5 @@ use hal::{pac, prelude::*, rcc::Config};
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().unwrap();
// 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.
let gpioa = dp.GPIOA.split(&mut rcc);
// Configure PA1 as output.
let mut led = gpioa.pa5.into_push_pull_output();
// Get the delay provider.
let mut delay = cp.SYST.delay(rcc.clocks);
loop {
led.set_high().unwrap();
delay.delay_ms(500_u16);
led.set_low().unwrap();
delay.delay_ms(500_u16);
}
compile_error!("Use blinky example")
}