rtt logging works

This commit is contained in:
Robin Müller 2024-06-11 23:59:09 +02:00
parent 841b8e1273
commit 4bddc009bc
Signed by: muellerr
GPG Key ID: A649FB78196E3849
3 changed files with 28 additions and 10 deletions

View File

@ -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"]}

View File

@ -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);
}
}

View File

@ -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"]}