forked from M-Labs/artiq
1
0
Fork 0

firmware: allow building without system UART.

This commit is contained in:
whitequark 2018-03-14 18:34:31 +00:00
parent 158ceb0881
commit 9ea7d7a804
3 changed files with 21 additions and 10 deletions

View File

@ -18,6 +18,7 @@ include!(concat!(env!("BUILDINC_DIRECTORY"), "/generated/sdram_phy.rs"));
pub mod sdram;
pub mod ident;
pub mod clock;
#[cfg(has_uart)]
pub mod uart;
#[cfg(has_spiflash)]
pub mod spiflash;

View File

@ -1,16 +1,24 @@
use core::fmt;
use csr;
pub struct Console;
impl fmt::Write for Console {
#[cfg(has_uart)]
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
use csr;
for c in s.bytes() {
unsafe {
while csr::uart::txfull_read() != 0 {}
csr::uart::rxtx_write(c)
}
}
Ok(())
}
#[cfg(not(has_uart))]
fn write_str(&mut self, _s: &str) -> Result<(), fmt::Error> {
Ok(())
}
}

View File

@ -77,6 +77,7 @@ fn startup() {
#[cfg(has_serwb_phy_amc)]
board_artiq::serwb::wait_init();
#[cfg(has_uart)] {
let t = board::clock::get_ms();
info!("press 'e' to erase startup and idle kernels...");
while board::clock::get_ms() < t + 1000 {
@ -88,6 +89,7 @@ fn startup() {
}
}
info!("continuing boot");
}
#[cfg(has_i2c)]
board_artiq::i2c::init();