2020-03-28 12:24:53 +00:00
|
|
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
|
|
//
|
2021-01-01 10:28:32 +00:00
|
|
|
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
2020-03-28 12:24:53 +00:00
|
|
|
|
|
|
|
//! System console.
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
// Public Definitions
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// Console interfaces.
|
|
|
|
pub mod interface {
|
|
|
|
use core::fmt;
|
|
|
|
|
|
|
|
/// Console write functions.
|
|
|
|
pub trait Write {
|
|
|
|
/// Write a single character.
|
|
|
|
fn write_char(&self, c: char);
|
|
|
|
|
|
|
|
/// Write a Rust format string.
|
|
|
|
fn write_fmt(&self, args: fmt::Arguments) -> fmt::Result;
|
|
|
|
|
2021-01-23 21:43:59 +00:00
|
|
|
/// Block until the last buffered character has been physically put on the TX wire.
|
2020-03-28 12:24:53 +00:00
|
|
|
fn flush(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Console read functions.
|
|
|
|
pub trait Read {
|
|
|
|
/// Read a single character.
|
|
|
|
fn read_char(&self) -> char {
|
|
|
|
' '
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Clear RX buffers, if any.
|
2021-01-04 13:37:17 +00:00
|
|
|
fn clear_rx(&self);
|
2020-03-28 12:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Console statistics.
|
|
|
|
pub trait Statistics {
|
|
|
|
/// Return the number of characters written.
|
|
|
|
fn chars_written(&self) -> usize {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return the number of characters read.
|
|
|
|
fn chars_read(&self) -> usize {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Trait alias for a full-fledged console.
|
|
|
|
pub trait All = Write + Read + Statistics;
|
|
|
|
}
|