From 4bddc009bcea4e6c2751f7fbfd2e7cf3d56c0557 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jun 2024 23:59:09 +0200 Subject: [PATCH] rtt logging works --- va416xx-hal/Cargo.toml | 9 ++++----- va416xx-hal/examples/rtt-log.rs | 24 +++++++++++++++++++++--- vorago-peb1/Cargo.toml | 5 +++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/va416xx-hal/Cargo.toml b/va416xx-hal/Cargo.toml index 6c0cecd..91f4c7e 100644 --- a/va416xx-hal/Cargo.toml +++ b/va416xx-hal/Cargo.toml @@ -11,8 +11,7 @@ keywords = ["no-std", "hal", "cortex-m", "vorago", "va416xx"] categories = ["embedded", "no-std", "hardware-support"] [dependencies] -# cortex-m = "0.7" -cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]} +cortex-m = "0.7" cortex-m-rt = "0.7" nb = "1" @@ -24,7 +23,7 @@ version = "0.1.0" rt = ["va416xx/rt"] [dev-dependencies] -panic-rtt-target = { version = "0.1", features = ["cortex-m"] } -rtt-target = { version = "0.3", features = ["cortex-m"] } +panic-rtt-target = { version = "0.1.3" } +rtt-target = { version = "0.5" } panic-halt = "0.2" -#cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]} +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]} diff --git a/va416xx-hal/examples/rtt-log.rs b/va416xx-hal/examples/rtt-log.rs index 80ce490..a62c369 100644 --- a/va416xx-hal/examples/rtt-log.rs +++ b/va416xx-hal/examples/rtt-log.rs @@ -1,20 +1,38 @@ -//! Code to test RTT logger functionality +//! Code to test RTT logger functionality. #![no_main] #![no_std] use cortex_m_rt::entry; -use panic_halt as _; +use panic_rtt_target as _; use rtt_target::{rprintln, rtt_init_print}; use va416xx as _; +use va416xx_hal::pac; + +// Mask for the LED +const LED_PG5: u32 = 1 << 5; #[entry] fn main() -> ! { + // SAFETY: Peripherals are only stolen once here. + let dp = unsafe { pac::Peripherals::steal() }; + // Enable all peripheral clocks + dp.sysconfig + .peripheral_clk_enable() + .modify(|_, w| unsafe { w.bits(0xffffffff) }); + dp.portg.dir().modify(|_, w| unsafe { w.bits(LED_PG5) }); + dp.portg + .datamask() + .modify(|_, w| unsafe { w.bits(LED_PG5) }); + rtt_init_print!(); rprintln!("-- RTT Demo --"); let mut counter = 0; loop { rprintln!("{}: Hello, world!", counter); + // Still toggle LED. If there are issues with the RTT log, the LED + // blinking ensures that the application is actually running. + dp.portg.togout().write(|w| unsafe { w.bits(LED_PG5) }); counter += 1; - cortex_m::asm::delay(75_000_000); + cortex_m::asm::delay(10_000_000); } } diff --git a/vorago-peb1/Cargo.toml b/vorago-peb1/Cargo.toml index 585755a..4932f59 100644 --- a/vorago-peb1/Cargo.toml +++ b/vorago-peb1/Cargo.toml @@ -23,6 +23,7 @@ version = "0.1.0" rt = ["va416xx-hal/rt"] [dev-dependencies] -panic-rtt-target = { version = "0.1", features = ["cortex-m"] } -rtt-target = { version = "0.3", features = ["cortex-m"] } +panic-rtt-target = { version = "0.1.3" } +rtt-target = { version = "0.5" } panic-halt = "0.2" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]}