From 8a2c59843f3c3936bd5e3ee6d82bd284ab35749a Mon Sep 17 00:00:00 2001 From: Levi Pearson Date: Fri, 10 Jul 2020 01:29:18 -0600 Subject: [PATCH] Switch to using rtt for cargo embed, update deps --- Cargo.toml | 11 ++++------- Embed.toml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 11 +++++++++-- 3 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 Embed.toml diff --git a/Cargo.toml b/Cargo.toml index 14f00b3..5e35065 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,10 @@ edition = "2018" [dependencies] cortex-m = "0.6.2" cortex-m-rt = "0.6.12" -panic-halt = "0.2.0" embedded-hal = "0.2.3" -nb = "0.1.2" +nb = "1.0.0" +panic-rtt-target = { version = "0.1.0", features = ["cortex-m"] } +rtt-target = { version = "0.2.0", features = ["cortex-m"] } ssd1306 = "0.3.1" switch-hal = "0.3.2" @@ -22,12 +23,8 @@ default-features = false [dependencies.embedded-graphics] version = "0.6.1" -[dependencies.stm32f1] -version = "0.10.0" -features = ["stm32f103", "rt"] - [dependencies.stm32f1xx-hal] -version = "0.5.3" +version = "0.6.1" features = ["rt", "stm32f103", "medium"] [dependencies.either] diff --git a/Embed.toml b/Embed.toml new file mode 100644 index 0000000..8a45ee4 --- /dev/null +++ b/Embed.toml @@ -0,0 +1,50 @@ +[default.probe] +# USB vendor ID +# usb_vid = "1337" +# USB product ID +# usb_pid = "1337" +# Serial number +# serial = "12345678" +# The protocol to be used for communicating with the target. +protocol = "Swd" +# The speed in kHz of the data link to the target. +# speed = 1337 + +[default.flashing] +# Whether or not the target should be flashed. +enabled = true +# Whether or not the target should be halted after flashing. +halt_afterwards = false +# Whether or not bytes erased but not rewritten with data from the ELF +# should be restored with their contents before erasing. +restore_unwritten_bytes = false +# The path where an SVG of the assembled flash layout should be written to. +# flash_layout_output_path = "out.svg" + +[default.general] +# The chip name of the chip to be debugged. +chip = "stm32f103C8" +# A list of chip descriptions to be loaded during runtime. +chip_descriptions = [] +# The default log level to be used. +log_level = "Warn" + +[default.rtt] +# Whether or not an RTTUI should be opened after flashing. +# This is exclusive and cannot be used with GDB at the moment. +enabled = true +# A list of channel associations to be displayed. If left empty, all channels are displayed. +channels = [ + # { up = 0, down = 0, name = "name" } +] +# The duration in ms for which the logger should retry to attach to RTT. +timeout = 3000 +# Whether timestamps in the RTTUI are enabled +show_timestamps = true + +[default.gdb] +# Whether or not a GDB server should be opened after flashing. +# This is exclusive and cannot be used with RTT at the moment. +enabled = false +# The connection string in host:port format wher the GDB server will open a socket. +# gdb_connection_string diff --git a/src/main.rs b/src/main.rs index 8220a15..abc697f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,14 @@ #![no_std] -#![no_main] +#![cfg_attr(not(doc), no_main)] use core::{ cell::RefCell, fmt::Write, }; -use panic_halt as _; +use rtt_target::{rprintln, rtt_init_print}; +use panic_rtt_target as _; + use cortex_m_rt::entry; @@ -64,6 +66,9 @@ static COUNT: Mutex> = Mutex::new(RefCell::new(0)); #[entry] fn main() -> ! { + // Init buffers for debug printing + rtt_init_print!(); + // Get access to the core peripherals from the cortex-m crate let mut core_periph = CorePeripherals::take().unwrap(); @@ -170,6 +175,8 @@ fn main() -> ! { // Turn the LED on via the OutputPin trait led.on().unwrap(); + rprintln!("Finished init, starting main loop"); + let mut button_last = false; // Microcontroller programs never exit main, so we must loop! loop {