From c2bdfafb4376454eeecef7825ed38d8ad3dac35a Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Thu, 17 Jan 2019 19:40:23 +0200 Subject: [PATCH] Gate uart enable behind cargo feature --- Cargo.toml | 1 + device.sh | 2 +- src/platform/uart.rs | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8b2e2f8..906ac43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ publish = false [features] unstable = [] realtime = [] +noserial = [] #[lib] #name = "nucleus" diff --git a/device.sh b/device.sh index 2cbc734..9fdc65a 100755 --- a/device.sh +++ b/device.sh @@ -1,5 +1,5 @@ #!/bin/sh -cargo xbuild --target=targets/aarch64-vesper-metta.json --release && \ +cargo xbuild --target=targets/aarch64-vesper-metta.json --release --features "noserial" && \ sh .cargo/runscript.sh target/aarch64-vesper-metta/release/vesper && \ cp target/aarch64-vesper-metta/release/vesper.bin /Volumes/boot/vesper && \ diskutil eject /Volumes/boot/ diff --git a/src/platform/uart.rs b/src/platform/uart.rs index ad7c8d5..0b05df1 100644 --- a/src/platform/uart.rs +++ b/src/platform/uart.rs @@ -150,6 +150,7 @@ impl MiniUart { } ///Set baud rate and characteristics (115200 8N1) and map to GPIO + #[cfg(not(feature = "noserial"))] pub fn init(&self) { // initialize UART self.AUX_ENABLES.modify(AUX_ENABLES::MINI_UART_ENABLE::SET); @@ -180,7 +181,11 @@ impl MiniUart { .write(AUX_MU_CNTL::RX_EN::Enabled + AUX_MU_CNTL::TX_EN::Enabled); } + #[cfg(feature = "noserial")] + pub fn init(&self) {} + /// Send a character + #[cfg(not(feature = "noserial"))] pub fn send(&self, c: char) { // wait until we can send loop_until(|| self.AUX_MU_LSR.is_set(AUX_MU_LSR::TX_EMPTY)); @@ -189,7 +194,11 @@ impl MiniUart { self.AUX_MU_IO.set(c as u32); } + #[cfg(feature = "noserial")] + pub fn send(&self, _c: char) {} + /// Receive a character + #[cfg(not(feature = "noserial"))] pub fn getc(&self) -> char { // wait until something is in the buffer loop_until(|| self.AUX_MU_LSR.is_set(AUX_MU_LSR::DATA_READY)); @@ -205,6 +214,11 @@ impl MiniUart { } } + #[cfg(feature = "noserial")] + pub fn getc(&self) -> char { + '\n' + } + /// Display a string pub fn puts(&self, string: &str) { for c in string.chars() {