feat: it blinks super slow!
This commit is contained in:
parent
5d2919c635
commit
2d8bfaad02
6 changed files with 16 additions and 104 deletions
37
Cargo.lock
generated
37
Cargo.lock
generated
|
@ -61,7 +61,6 @@ checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bare-metal 0.2.5",
|
"bare-metal 0.2.5",
|
||||||
"bitfield",
|
"bitfield",
|
||||||
"critical-section",
|
|
||||||
"embedded-hal",
|
"embedded-hal",
|
||||||
"volatile-register",
|
"volatile-register",
|
||||||
]
|
]
|
||||||
|
@ -86,12 +85,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "critical-section"
|
|
||||||
version = "1.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embedded-hal"
|
name = "embedded-hal"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
@ -130,10 +123,8 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
|
||||||
name = "nucleo-l053r8-blink"
|
name = "nucleo-l053r8-blink"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cortex-m",
|
|
||||||
"cortex-m-rt",
|
"cortex-m-rt",
|
||||||
"panic-rtt-target",
|
"panic-halt",
|
||||||
"rtt-target",
|
|
||||||
"stm32l0xx-hal",
|
"stm32l0xx-hal",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -200,14 +191,10 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "panic-rtt-target"
|
name = "panic-halt"
|
||||||
version = "0.1.3"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "608d1d809dd8960d5e8364981279c7ab280a13d98b99eae049885a7ab2b1cbfe"
|
checksum = "a513e167849a384b7f9b746e517604398518590a9142f4846a32e3c2a4de7b11"
|
||||||
dependencies = [
|
|
||||||
"critical-section",
|
|
||||||
"rtt-target",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
|
@ -236,16 +223,6 @@ dependencies = [
|
||||||
"chrono",
|
"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]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
|
@ -317,12 +294,6 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ufmt-write"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
|
|
28
Cargo.toml
28
Cargo.toml
|
@ -3,27 +3,11 @@ name = "nucleo-l053r8-blink"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
|
cortex-m-rt = "0.7.5"
|
||||||
cortex-m-rt = "0.7.3"
|
panic-halt = "1.0.0"
|
||||||
panic-rtt-target = "0.1.3"
|
stm32l0xx-hal = { version = "0.10.0", features = [
|
||||||
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",
|
|
||||||
"mcu-STM32L053R8Hx",
|
"mcu-STM32L053R8Hx",
|
||||||
] }
|
"rt",
|
||||||
|
] } # mcu-STM32L053R8Hx or mcu-STM32L053R8Tx not sure
|
||||||
[[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
|
|
||||||
|
|
13
Embed.toml
13
Embed.toml
|
@ -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
|
|
16
build.rs
16
build.rs
|
@ -1,17 +1,3 @@
|
||||||
use std::env;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::Write;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Put the linker script somewhere the linker can find it
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
8
memory.x
8
memory.x
|
@ -1,8 +0,0 @@
|
||||||
# FLASH 0x08000000 - 0x0802FFFF 192K
|
|
||||||
# RAM 0x20000000 - 0x20004FFF 20K
|
|
||||||
|
|
||||||
MEMORY
|
|
||||||
{
|
|
||||||
FLASH : ORIGIN = 0x08000000, LENGTH = 192K
|
|
||||||
RAM : ORIGIN = 0x20000000, LENGTH = 20K
|
|
||||||
}
|
|
18
src/main.rs
18
src/main.rs
|
@ -1,20 +1,12 @@
|
||||||
#![no_std]
|
#![deny(unsafe_code)]
|
||||||
#![no_main]
|
#![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
|
extern crate panic_halt;
|
||||||
// an underscore since we don't directly use any of its symbols.
|
|
||||||
extern crate cortex_m;
|
|
||||||
|
|
||||||
// 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 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]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let dp = pac::Peripherals::take().unwrap();
|
let dp = pac::Peripherals::take().unwrap();
|
||||||
|
@ -27,7 +19,7 @@ fn main() -> ! {
|
||||||
let gpioa = dp.GPIOA.split(&mut rcc);
|
let gpioa = dp.GPIOA.split(&mut rcc);
|
||||||
|
|
||||||
// Configure PA1 as output.
|
// Configure PA1 as output.
|
||||||
let mut led = gpioa.pa3.into_push_pull_output();
|
let mut led = gpioa.pa5.into_push_pull_output();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Set the LED high one million times in a row.
|
// Set the LED high one million times in a row.
|
||||||
|
|
Loading…
Add table
Reference in a new issue