From 9653df09b64ebb729056ed8e1785337a714eeead Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sun, 23 Aug 2020 15:06:11 +0200 Subject: [PATCH] Switched to probe-run --- .cargo/config | 4 ++-- Cargo.toml | 1 + openocd.gdb | 11 ----------- openocd.sh | 2 -- src/main.rs | 16 +++++++--------- 5 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 openocd.gdb delete mode 100755 openocd.sh diff --git a/.cargo/config b/.cargo/config index 452cdff..cab4708 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,9 +1,9 @@ -[target.thumbv7m-none-eabi] -runner = "arm-none-eabi-gdb -q -x openocd.gdb" +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] rustflags = [ "-C", "linker=rust-lld", "-C", "link-arg=-Tlink.x", ] +runner = "probe-run --chip STM32F103CB" [build] target = "thumbv7m-none-eabi" diff --git a/Cargo.toml b/Cargo.toml index 455f7df..78074d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ cortex-m-rt = "0.6" stm32f1xx-hal = { version = "0.5.3", features = ["stm32f103", "stm32-usbd", "rt"] } panic-semihosting = "0.5" embedded-hal = "0.2.3" +rtt-target = {version = "0.2.2", features = ["cortex-m"]} # this lets you use `cargo fix`! diff --git a/openocd.gdb b/openocd.gdb deleted file mode 100644 index 7aed67f..0000000 --- a/openocd.gdb +++ /dev/null @@ -1,11 +0,0 @@ -set history save on -set confirm off -target extended-remote :3333 -set print asm-demangle on -monitor arm semihosting enable -monitor reset halt -load -# monitor verify -# monitor reset -# quit -continue diff --git a/openocd.sh b/openocd.sh deleted file mode 100755 index 7d889ae..0000000 --- a/openocd.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg diff --git a/src/main.rs b/src/main.rs index 51d43a8..055a1e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,20 +2,17 @@ #![no_std] #![no_main] - extern crate panic_semihosting; - -use stm32f1xx_hal::{ - prelude::*, - pac, - delay::Delay, -}; use cortex_m_rt::entry; use embedded_hal::digital::v2::OutputPin; +use rtt_target::{rprintln, rtt_init_print}; +use stm32f1xx_hal::{delay::Delay, pac, prelude::*}; #[entry] fn main() -> ! { + rtt_init_print!(); + // Get access to the core peripherals from the cortex-m crate let cp = cortex_m::Peripherals::take().unwrap(); // Get access to the device specific peripherals from the peripheral access crate @@ -37,13 +34,14 @@ fn main() -> ! { // in order to configure the port. For pins 0-7, crl should be passed instead. let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh); - let mut delay = Delay::new(cp.SYST, clocks); - // Wait for the timer to trigger an update and change the state of the LED + // Blink using the delay function loop { + rprintln!("blink"); led.set_high().unwrap(); delay.delay_ms(1000u16); + rprintln!("blonk"); led.set_low().unwrap(); delay.delay_ms(1000u16); }