pub struct Uart {
base: usize,
interrupt_id: RwLock<Option<InterruptId>>,
rx_buffer: Mutex<VecDeque<u8>>,
event_emitter: Mutex<DeviceEventEmitter>,
}
Fields§
§base: usize
§interrupt_id: RwLock<Option<InterruptId>>
§rx_buffer: Mutex<VecDeque<u8>>
§event_emitter: Mutex<DeviceEventEmitter>
Implementations§
Source§impl Uart
impl Uart
pub fn new(base: usize) -> Self
pub fn init(&self)
Sourcepub fn enable_interrupts(
&self,
interrupt_id: InterruptId,
) -> Result<(), &'static str>
pub fn enable_interrupts( &self, interrupt_id: InterruptId, ) -> Result<(), &'static str>
Enable UART interrupts
fn reg_write(&self, offset: usize, value: u8)
fn reg_read(&self, offset: usize) -> u8
fn write_byte_internal(&self, c: u8)
fn read_byte_internal(&self) -> u8
fn can_read(&self) -> bool
fn can_write(&self) -> bool
Trait Implementations§
Source§impl CharDevice for Uart
impl CharDevice for Uart
Source§fn write_byte(&self, byte: u8) -> Result<(), &'static str>
fn write_byte(&self, byte: u8) -> Result<(), &'static str>
Write a single byte to the device Read more
Source§impl Device for Uart
impl Device for Uart
fn device_type(&self) -> DeviceType
fn name(&self) -> &'static str
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn as_char_device(&self) -> Option<&dyn CharDevice>
fn as_char_device(&self) -> Option<&dyn CharDevice>
Cast to CharDevice if this device is a character device
Source§fn as_block_device(&self) -> Option<&dyn BlockDevice>
fn as_block_device(&self) -> Option<&dyn BlockDevice>
Cast to BlockDevice if this device is a block device
Source§impl EventCapableDevice for Uart
impl EventCapableDevice for Uart
fn register_event_listener(&self, listener: Weak<dyn DeviceEventListener>)
fn unregister_event_listener(&self, _listener_id: &str)
fn emit_event(&self, event: &dyn DeviceEvent)
Source§impl InterruptCapableDevice for Uart
impl InterruptCapableDevice for Uart
fn handle_interrupt(&self) -> InterruptResult<()>
fn interrupt_id(&self) -> Option<InterruptId>
Source§impl Serial for Uart
impl Serial for Uart
Source§fn get(&self) -> Option<char>
fn get(&self) -> Option<char>
Reads a character from the UART. (non-blocking)
Returns Some(char)
if a character is available, or None
if not.
If interrupts are enabled, reads from the interrupt buffer.
Otherwise, falls back to polling mode.
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Get a mutable reference to Any for downcasting