Gate uart enable behind cargo feature

This commit is contained in:
Berkus Decker 2019-01-17 19:40:23 +02:00
parent 3831a411b9
commit c2bdfafb43
3 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@ publish = false
[features]
unstable = []
realtime = []
noserial = []
#[lib]
#name = "nucleus"

View File

@ -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/

View File

@ -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() {