mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-05-05 10:09:08 +00:00
code to enable uarte0
This commit is contained in:
parent
70ce745930
commit
e55713fe16
|
@ -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"
|
||||
|
|
38
down-the-stack/apps/src/bin/uarte_enable.rs
Normal file
38
down-the-stack/apps/src/bin/uarte_enable.rs
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue