pub struct Uart { /* private fields */ }Expand description
UART driver.
Wraps an opaque ove_uart_t handle provided by the board configuration.
Construct via Uart::from_handle.
Implementations§
Source§impl Uart
impl Uart
Sourcepub const unsafe fn from_handle(handle: ove_uart_t) -> Self
pub const unsafe fn from_handle(handle: ove_uart_t) -> Self
Wrap an existing ove_uart_t handle.
§Safety
handle must be a valid UART handle returned by the substrate.
The caller is responsible for ensuring no other Uart wrapper
exists for the same handle concurrently.
Sourcepub fn write(&self, data: &[u8], timeout: Duration) -> Result<usize>
pub fn write(&self, data: &[u8], timeout: Duration) -> Result<usize>
Write data to the UART. Returns the number of bytes written.
Sourcepub fn read(&self, buf: &mut [u8], timeout: Duration) -> Result<usize>
pub fn read(&self, buf: &mut [u8], timeout: Duration) -> Result<usize>
Read data from the UART RX buffer. Returns the number of bytes read.
Sourcepub fn bytes_available(&self) -> usize
pub fn bytes_available(&self) -> usize
Query the number of bytes available in the RX buffer.
Sourcepub unsafe fn set_rx_notify(
&self,
cb: Option<unsafe extern "C" fn(*mut c_void)>,
user_data: *mut c_void,
) -> Result<()>
pub unsafe fn set_rx_notify( &self, cb: Option<unsafe extern "C" fn(*mut c_void)>, user_data: *mut c_void, ) -> Result<()>
Register a notify callback fired after every received chunk.
Wraps the C-level ove_uart_set_rx_notify, which delegates to
ove_stream_set_notify on the UART’s internal RX stream.
§Safety
Same as crate::Stream::set_notify: user_data must outlive
the registration, and cb must be ISR-safe (UART RX
typically pushes from ISR context via
ove_uart_rx_isr_push).
Trait Implementations§
Source§impl Read for Uart
impl Read for Uart
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read more