pub struct Uart<'d, I: Instance, M: TransferMode> { /* private fields */ }Expand description
UART driver, backed by a RingBuffer and 16-byte on-device FIFO buffer.
Implementations§
Source§impl<'d, I: Instance> Uart<'d, I, Async>
impl<'d, I: Instance> Uart<'d, I, Async>
Sourcepub fn new_async<RxInt: InterruptType, TeInt: InterruptType, TxInt: InterruptType>(
_peri: Peri<'d, I>,
tx_pin: Peri<'d, impl TxPin<I>>,
tx_buffer: &'d mut [u8],
rx_pin: Peri<'d, impl RxPin<I>>,
rx_buffer: &'d mut [u8],
irqs: impl Binding<RxInt, RxInterruptHandler<I>> + Binding<TeInt, TeInterruptHandler<I>> + Binding<TxInt, TxInterruptHandler<I>> + 'd,
config: Config,
) -> Self
pub fn new_async<RxInt: InterruptType, TeInt: InterruptType, TxInt: InterruptType>( _peri: Peri<'d, I>, tx_pin: Peri<'d, impl TxPin<I>>, tx_buffer: &'d mut [u8], rx_pin: Peri<'d, impl RxPin<I>>, rx_buffer: &'d mut [u8], irqs: impl Binding<RxInt, RxInterruptHandler<I>> + Binding<TeInt, TeInterruptHandler<I>> + Binding<TxInt, TxInterruptHandler<I>> + 'd, config: Config, ) -> Self
Configures a new UART and returns the driver.
Source§impl<'d, I: Instance> Uart<'d, I, Blocking>
impl<'d, I: Instance> Uart<'d, I, Blocking>
Sourcepub fn new_blocking(
_peri: Peri<'d, I>,
tx_pin: Peri<'d, impl TxPin<I>>,
rx_pin: Peri<'d, impl RxPin<I>>,
config: Config,
) -> Self
pub fn new_blocking( _peri: Peri<'d, I>, tx_pin: Peri<'d, impl TxPin<I>>, rx_pin: Peri<'d, impl RxPin<I>>, config: Config, ) -> Self
Configures a new UART and returns the driver.
Sourcepub fn blocking_read(&self, data: &mut [u8])
pub fn blocking_read(&self, data: &mut [u8])
Reads data from the UART, blocks until data is full.
Sourcepub fn blocking_write(&mut self, data: &[u8])
pub fn blocking_write(&mut self, data: &[u8])
Writes data to the UART, blocking until the last byte has been sent out on the wire.
Source§impl<'d, I: Instance, M: TransferMode> Uart<'d, I, M>
impl<'d, I: Instance, M: TransferMode> Uart<'d, I, M>
Sourcepub fn set_data_bits(&mut self, n: DataBits)
pub fn set_data_bits(&mut self, n: DataBits)
Sets the number of bits in a byte.
Note:
- 9 bit data is supported by the underlying hardware but not yet by this driver.
- This will disable the transmitter and temporarily disable the receiver (RA4M1 §28.2.9 note 4).
Sourcepub fn set_parity(&mut self, parity: Parity)
pub fn set_parity(&mut self, parity: Parity)
Sets baud rate for the SCI instance.
Note: This will disable the transmitter and temporarily disable the receiver (§28.2.9 note 4).
Sourcepub fn set_stop_bits(&mut self, stop_bits: StopBits)
pub fn set_stop_bits(&mut self, stop_bits: StopBits)
Set stop bit length.
Note: This will disable the transmitter and temporarily disable the receiver (§28.2.9 note 4).
Sourcepub fn set_baud_rate(&mut self, baud_rate: u32)
pub fn set_baud_rate(&mut self, baud_rate: u32)
Sets baud rate for the SCI instance.
Note:
- This will disable the transmitter and temporarily disable the receiver (§28.2.9 note 4).
- Currently depends on micromath. Pending https://github.com/rust-lang/rust/issues/137578.
§Arguments
baud_rate- Desired baud rate.
Trait Implementations§
Source§impl<'d, I: Instance> MutBlockingRx for Uart<'d, I, Blocking>
impl<'d, I: Instance> MutBlockingRx for Uart<'d, I, Blocking>
Source§impl<'d, I: Instance> MutBlockingTx for Uart<'d, I, Blocking>
impl<'d, I: Instance> MutBlockingTx for Uart<'d, I, Blocking>
Source§impl<'d, I: Instance> Read for Uart<'d, I, Async>
impl<'d, I: Instance> Read for Uart<'d, I, Async>
Source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async 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§async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreSource§impl<'d, I: Instance> Write for Uart<'d, I, Async>
impl<'d, I: Instance> Write for Uart<'d, I, Async>
Source§async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Write a buffer into this writer, returning how many bytes were written. Read more
Auto Trait Implementations§
impl<'d, I, M> Forget for Uart<'d, I, M>
impl<'d, I, M> Freeze for Uart<'d, I, M>
impl<'d, I, M> Move for Uart<'d, I, M>
impl<'d, I, M> RefUnwindSafe for Uart<'d, I, M>
impl<'d, I, M> Send for Uart<'d, I, M>
impl<'d, I, M> Sync for Uart<'d, I, M>
impl<'d, I, M> Unpin for Uart<'d, I, M>
impl<'d, I, M> UnsafeUnpin for Uart<'d, I, M>
impl<'d, I, M> UnwindSafe for Uart<'d, I, M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more