pub struct UartPeripheral<S, D, P>{ /* private fields */ }Expand description
An UART Peripheral based on an underlying UART device.
Implementations§
Source§impl<S, D, P> UartPeripheral<S, D, P>
impl<S, D, P> UartPeripheral<S, D, P>
Source§impl<D, P> UartPeripheral<Disabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> UartPeripheral<Disabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Sourcepub fn new(
device: D,
pins: P,
resets: &mut RESETS,
) -> UartPeripheral<Disabled, D, P>
pub fn new( device: D, pins: P, resets: &mut RESETS, ) -> UartPeripheral<Disabled, D, P>
Creates an UartPeripheral in Disabled state.
Sourcepub fn enable(
self,
config: UartConfig,
frequency: Rate<u32, 1, 1>,
) -> Result<UartPeripheral<Enabled, D, P>, Error>
pub fn enable( self, config: UartConfig, frequency: Rate<u32, 1, 1>, ) -> Result<UartPeripheral<Enabled, D, P>, Error>
Enables the provided UART device with the given configuration.
Source§impl<D, P> UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Sourcepub fn disable(self) -> UartPeripheral<Disabled, D, P>
pub fn disable(self) -> UartPeripheral<Disabled, D, P>
Disable this UART Peripheral, falling back to the Disabled state.
Sourcepub fn set_fifos(&mut self, enable: bool)
pub fn set_fifos(&mut self, enable: bool)
Enable/disable the rx/tx FIFO
Unfortunately, it’s not possible to enable/disable rx/tx independently on this chip Default is false
Sourcepub fn set_rx_watermark(&mut self, watermark: FifoWatermark)
pub fn set_rx_watermark(&mut self, watermark: FifoWatermark)
Set rx FIFO watermark
See DS: Table 423
Sourcepub fn set_tx_watermark(&mut self, watermark: FifoWatermark)
pub fn set_tx_watermark(&mut self, watermark: FifoWatermark)
Set tx FIFO watermark
See DS: Table 423
Sourcepub fn enable_rx_interrupt(&mut self)
pub fn enable_rx_interrupt(&mut self)
Enables the Receive Interrupt.
The relevant UARTx IRQ will fire when there is data in the receive register.
Sourcepub fn enable_tx_interrupt(&mut self)
pub fn enable_tx_interrupt(&mut self)
Enables the Transmit Interrupt.
The relevant UARTx IRQ will fire when there is space in the transmit FIFO.
Sourcepub fn disable_rx_interrupt(&mut self)
pub fn disable_rx_interrupt(&mut self)
Disables the Receive Interrupt.
Sourcepub fn disable_tx_interrupt(&mut self)
pub fn disable_tx_interrupt(&mut self)
Disables the Transmit Interrupt.
Sourcepub fn uart_is_writable(&self) -> bool
pub fn uart_is_writable(&self) -> bool
Is there space in the UART TX FIFO for new data to be written?
Sourcepub fn uart_is_busy(&self) -> bool
pub fn uart_is_busy(&self) -> bool
Is the UART still busy transmitting data?
Sourcepub fn uart_is_readable(&self) -> bool
pub fn uart_is_readable(&self) -> bool
Is there data in the UART RX FIFO ready to be read?
Sourcepub fn write_raw<'d>(
&self,
data: &'d [u8],
) -> Result<&'d [u8], Error<Infallible>>
pub fn write_raw<'d>( &self, data: &'d [u8], ) -> Result<&'d [u8], Error<Infallible>>
Writes bytes to the UART. This function writes as long as it can. As soon that the FIFO is full, if :
- 0 bytes were written, a WouldBlock Error is returned
- some bytes were written, it is deemed to be a success
Upon success, the remaining slice is returned.
Sourcepub fn read_raw<'b>(
&self,
buffer: &'b mut [u8],
) -> Result<usize, Error<ReadError<'b>>>
pub fn read_raw<'b>( &self, buffer: &'b mut [u8], ) -> Result<usize, Error<ReadError<'b>>>
Reads bytes from the UART. This function reads as long as it can. As soon that the FIFO is empty, if :
- 0 bytes were read, a WouldBlock Error is returned
- some bytes were read, it is deemed to be a success
Upon success, it will return how many bytes were read.
Sourcepub fn write_full_blocking(&self, data: &[u8])
pub fn write_full_blocking(&self, data: &[u8])
Writes bytes to the UART.
This function blocks until the full buffer has been sent.
Sourcepub fn read_full_blocking(&self, buffer: &mut [u8]) -> Result<(), ReadErrorType>
pub fn read_full_blocking(&self, buffer: &mut [u8]) -> Result<(), ReadErrorType>
Reads bytes from the UART.
This function blocks until the full buffer has been received.
Sourcepub fn lowlevel_break_start(&mut self)
pub fn lowlevel_break_start(&mut self)
Initiates a break
If transmitting, this takes effect immediately after the current byte has completed.
For proper execution of the break command, this must be held for at least 2 complete frames
worth of time.
§Example
serial.lowlevel_break_start();
// at 115_200Bps on 8N1 configuration, 20bits takes (20*10⁶)/115200 = 173.611…μs.
timer.delay_us(175);
serial.lowlevel_break_stop();
}Sourcepub fn lowlevel_break_stop(&mut self)
pub fn lowlevel_break_stop(&mut self)
Terminates a break condition.
See lowlevel_break_start for more details.
Source§impl<P> UartPeripheral<Enabled, UART0, P>where
P: ValidUartPinout<UART0>,
impl<P> UartPeripheral<Enabled, UART0, P>where
P: ValidUartPinout<UART0>,
Trait Implementations§
Source§impl<D, P> ErrorType for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> ErrorType for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§type Error = ReadErrorType
type Error = ReadErrorType
Source§impl<D, P> ErrorType for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> ErrorType for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§type Error = ReadErrorType
type Error = ReadErrorType
Source§impl<D, P> Read<u8> for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Read<u8> for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§impl<D, P> Read for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Read for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§impl<D, P> Read for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Read for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§fn read(
&mut self,
buf: &mut [u8],
) -> Result<usize, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
fn read( &mut self, buf: &mut [u8], ) -> Result<usize, <UartPeripheral<Enabled, D, P> as ErrorType>::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 moreSource§impl<D, P> ReadReady for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> ReadReady for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§fn read_ready(
&mut self,
) -> Result<bool, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
fn read_ready( &mut self, ) -> Result<bool, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
Source§impl<D, P> Write<u8> for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Write<u8> for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§impl<D, P> Write for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Write for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§impl<D, P> Write for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Write for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§impl<D, P> Write for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> Write for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§fn write(
&mut self,
buf: &[u8],
) -> Result<usize, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
fn write( &mut self, buf: &[u8], ) -> Result<usize, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
Source§fn flush(
&mut self,
) -> Result<(), <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
fn flush( &mut self, ) -> Result<(), <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
Source§impl<D, P> WriteReady for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
impl<D, P> WriteReady for UartPeripheral<Enabled, D, P>where
D: UartDevice,
P: ValidUartPinout<D>,
Source§fn write_ready(
&mut self,
) -> Result<bool, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
fn write_ready( &mut self, ) -> Result<bool, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>
Auto Trait Implementations§
impl<S, D, P> Freeze for UartPeripheral<S, D, P>
impl<S, D, P> RefUnwindSafe for UartPeripheral<S, D, P>
impl<S, D, P> Send for UartPeripheral<S, D, P>
impl<S, D, P> Sync for UartPeripheral<S, D, P>
impl<S, D, P> Unpin for UartPeripheral<S, D, P>
impl<S, D, P> UnwindSafe for UartPeripheral<S, D, P>
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
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more