feat: it blinks super slow!

This commit is contained in:
cscherr 2025-04-24 12:23:35 +02:00
parent 5d2919c635
commit 2d8bfaad02
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
6 changed files with 16 additions and 104 deletions

37
Cargo.lock generated
View file

@ -61,7 +61,6 @@ checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9"
dependencies = [
"bare-metal 0.2.5",
"bitfield",
"critical-section",
"embedded-hal",
"volatile-register",
]
@ -86,12 +85,6 @@ dependencies = [
"syn",
]
[[package]]
name = "critical-section"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
[[package]]
name = "embedded-hal"
version = "0.2.7"
@ -130,10 +123,8 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
name = "nucleo-l053r8-blink"
version = "0.1.0"
dependencies = [
"cortex-m",
"cortex-m-rt",
"panic-rtt-target",
"rtt-target",
"panic-halt",
"stm32l0xx-hal",
]
@ -200,14 +191,10 @@ dependencies = [
]
[[package]]
name = "panic-rtt-target"
version = "0.1.3"
name = "panic-halt"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "608d1d809dd8960d5e8364981279c7ab280a13d98b99eae049885a7ab2b1cbfe"
dependencies = [
"critical-section",
"rtt-target",
]
checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11"
[[package]]
name = "proc-macro2"
@ -236,16 +223,6 @@ dependencies = [
"chrono",
]
[[package]]
name = "rtt-target"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10b34c9e6832388e45f3c01f1bb60a016384a0a4ad80cdd7d34913bed25037f0"
dependencies = [
"critical-section",
"ufmt-write",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
@ -317,12 +294,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "ufmt-write"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
[[package]]
name = "unicode-ident"
version = "1.0.18"

View file

@ -3,27 +3,11 @@ name = "nucleo-l053r8-blink"
version = "0.1.0"
edition = "2024"
[dependencies]
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
panic-rtt-target = "0.1.3"
rtt-target = "0.5.0"
hal = { package = "stm32l0xx-hal", version = "0.10.0", features = [
"rt",
# "stm32l0x3",
# "flash-192",
# "ram-20",
# "io-STM32L051",
# "mcu-STM32L053R8", # does not exist in that crate
# "disable-linker-script",
cortex-m-rt = "0.7.5"
panic-halt = "1.0.0"
stm32l0xx-hal = { version = "0.10.0", features = [
"mcu-STM32L053R8Hx",
] }
[[bin]]
name = "nucleo-l053r8-blink"
test = false
bench = false
[profile.release]
opt-level = 'z' # turn on maximum optimizations. We only have 64kB
lto = true # Link-time-optimizations for further size reduction
"rt",
] } # mcu-STM32L053R8Hx or mcu-STM32L053R8Tx not sure

View file

@ -1,13 +0,0 @@
# i dont think this is used anywhere but am paranoid
[default.general]
chip = "STM32L053R8"
[default.rtt]
enabled = true
[default.probe]
protocol = "Swd"
[default.gdb]
enabled = false

View file

@ -1,17 +1,3 @@
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
}

View file

@ -1,8 +0,0 @@
# FLASH 0x08000000 - 0x0802FFFF 192K
# RAM 0x20000000 - 0x20004FFF 20K
MEMORY
{
FLASH : ORIGIN = 0x08000000, LENGTH = 192K
RAM : ORIGIN = 0x20000000, LENGTH = 20K
}

View file

@ -1,20 +1,12 @@
#![no_std]
#![deny(unsafe_code)]
#![no_main]
#![no_std]
// We need to use cortex_m here so the linker can find it's critical-section, but we import is as
// an underscore since we don't directly use any of its symbols.
extern crate cortex_m;
extern crate panic_halt;
// The entry import gives us a macro to indicate where the microcontroller should start the
// program, and also sets up the FPU on our Cortex-M4F.
use cortex_m_rt::entry;
use stm32l0xx_hal::{pac, prelude::*, rcc::Config};
use hal::{pac, prelude::*, rcc::Config};
// Provides functions that allow printing back to probe-rs.
use panic_rtt_target as _;
// use rtt_target::{rprintln, rtt_init_print};
// Start here, and don't ever return from this function.
#[entry]
fn main() -> ! {
let dp = pac::Peripherals::take().unwrap();
@ -27,7 +19,7 @@ fn main() -> ! {
let gpioa = dp.GPIOA.split(&mut rcc);
// Configure PA1 as output.
let mut led = gpioa.pa3.into_push_pull_output();
let mut led = gpioa.pa5.into_push_pull_output();
loop {
// Set the LED high one million times in a row.