Skip to main content

Uart

Struct Uart 

Source
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

Source

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.

Source

pub fn raw(&self) -> ove_uart_t

Return the underlying handle.

Source

pub fn write(&self, data: &[u8], timeout: Duration) -> Result<usize>

Write data to the UART. Returns the number of bytes written.

Source

pub fn read(&self, buf: &mut [u8], timeout: Duration) -> Result<usize>

Read data from the UART RX buffer. Returns the number of bytes read.

Source

pub fn bytes_available(&self) -> usize

Query the number of bytes available in the RX buffer.

Source

pub fn flush(&self) -> Result<()>

Flush the TX hardware buffer.

Source

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 Clone for Uart

Source§

fn clone(&self) -> Uart

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Uart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ErrorType for Uart

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl Read for Uart

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl Write for Uart

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more
Source§

fn write_fmt( &mut self, fmt: Arguments<'_>, ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
Source§

impl Copy for Uart

Auto Trait Implementations§

§

impl Freeze for Uart

§

impl RefUnwindSafe for Uart

§

impl !Send for Uart

§

impl !Sync for Uart

§

impl Unpin for Uart

§

impl UnsafeUnpin for Uart

§

impl UnwindSafe for Uart

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.