diff --git a/down-the-stack/apps/Cargo.toml b/down-the-stack/apps/Cargo.toml index 6449d12..cbb3cc1 100644 --- a/down-the-stack/apps/Cargo.toml +++ b/down-the-stack/apps/Cargo.toml @@ -9,6 +9,7 @@ version = "0.0.0" cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]} cortex-m-rt = "0.7.2" dk_bsc = { path = "../dk_bsc" } +dk_pac = { path = "../dk_pac" } heapless = "0.7.16" panic-probe = { version = "0.3.0", features = ["print-defmt"] } defmt = "0.3.2" diff --git a/down-the-stack/apps/src/bin/uarte_enable.rs b/down-the-stack/apps/src/bin/uarte_enable.rs new file mode 100644 index 0000000..434f114 --- /dev/null +++ b/down-the-stack/apps/src/bin/uarte_enable.rs @@ -0,0 +1,38 @@ +#![no_main] +#![no_std] + +use cortex_m::asm; +use cortex_m_rt::entry; +use dk_pac; + +// this imports `down-the-stack/apps/lib.rs` to retrieve our global logger + panicking-behavior +use apps as _; +use defmt; +use defmt_rtt as _; // global logger + + +#[entry] +fn main() -> ! { + // to enable more verbose logs, go to your `Cargo.toml` and set defmt logging levels + // to `defmt-trace` by changing the `default = []` entry in `[features]` + unsafe { + let periph = dk_pac::Peripherals::steal(); + let uarte = periph.UARTE0; + + uarte.enable.write(|w| w.enable().enabled()); + + if uarte.enable.read().bits() != 0 { + defmt::println!("Uarte0 is enabled"); + + } else { + defmt::println!("Uarte0 is disabled"); + } + + } + + + // this program does not `exit`; use Ctrl+C to terminate it + loop { + asm::nop(); + } +} \ No newline at end of file