feat: i think blinky would work but I'm loading wrong
This commit is contained in:
parent
965bdc5b8e
commit
26f439acd0
4 changed files with 42 additions and 20 deletions
|
@ -21,3 +21,7 @@ hal = { package = "stm32l0xx-hal", version = "0.10.0", features = [
|
|||
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
Executable file
13
Embed.toml
Executable file
|
@ -0,0 +1,13 @@
|
|||
# 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
|
9
build.rs
9
build.rs
|
@ -1,9 +0,0 @@
|
|||
// We could do a lot of fancy build tricks here, but all we need is a linker script from
|
||||
// cortext-m-rt to include our memory map, so the tools know how much RAM and flash the chip has
|
||||
// and where to find them.
|
||||
fn main() {
|
||||
// Set the linker script to the one provided by cortex-m-rt.
|
||||
println!("cargo:rustc-link-arg=-Tlink.x");
|
||||
|
||||
// Apperently, this loads the memory map provided in `memory.x`
|
||||
}
|
36
src/main.rs
36
src/main.rs
|
@ -3,27 +3,41 @@
|
|||
|
||||
// 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.
|
||||
use cortex_m as _;
|
||||
use cortex_m::delay::Delay;
|
||||
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 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};
|
||||
|
||||
use hal as _;
|
||||
// use rtt_target::{rprintln, rtt_init_print};
|
||||
|
||||
// Start here, and don't ever return from this function.
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
// Initialise our debug printer.
|
||||
rtt_init_print!();
|
||||
// Send a message back via the debugger.
|
||||
rprintln!("Hello, world!");
|
||||
let dp = pac::Peripherals::take().unwrap();
|
||||
|
||||
// Do nothing, forever.
|
||||
loop {}
|
||||
// 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.pa3.into_push_pull_output();
|
||||
|
||||
loop {
|
||||
// Set the LED high one million times in a row.
|
||||
for _ in 0..1_000_000 {
|
||||
led.set_high().unwrap();
|
||||
}
|
||||
|
||||
// Set the LED low one million times in a row.
|
||||
for _ in 0..1_000_000 {
|
||||
led.set_low().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue