diff --git a/Cargo.toml b/Cargo.toml index f7c08af..0813353 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/Embed.toml b/Embed.toml new file mode 100755 index 0000000..e7f2de7 --- /dev/null +++ b/Embed.toml @@ -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 diff --git a/build.rs b/build.rs deleted file mode 100755 index 549a70a..0000000 --- a/build.rs +++ /dev/null @@ -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` -} diff --git a/src/main.rs b/src/main.rs index 21daf2b..62711ad 100755 --- a/src/main.rs +++ b/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(); + } + } }