Writer

Struct Writer 

Source
pub struct Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,
{ /* private fields */ }
Expand description

Half of an UartPeripheral that is only capable of writing. Obtained by calling UartPeripheral::split()

Implementations§

Source§

impl<D, P> Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source

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 (unwritten) slice is returned.

Source

pub fn write_full_blocking(&self, data: &[u8])

Writes bytes to the UART.

This function blocks until the full buffer has been sent.

Source

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.

Source

pub fn disable_tx_interrupt(&mut self)

Disables the Transmit Interrupt.

Source

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.

The device won’t be able to send anything while breaking.
§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();
}
Source

pub fn lowlevel_break_stop(&mut self)

Terminates a break condition.

See lowlevel_break_start for more details.

Trait Implementations§

Source§

impl<D, P> ErrorType for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

type Error = Infallible

Error type
Source§

impl<D, P> ErrorType for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

type Error = Infallible

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

impl<D, P> Write<u8> for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

type Error = Infallible

Write error
Source§

fn write( &mut self, word: u8, ) -> Result<(), Error<<Writer<D, P> as Write<u8>>::Error>>

Writes a single word to the serial interface
Source§

fn flush(&mut self) -> Result<(), Error<<Writer<D, P> as Write<u8>>::Error>>

Ensures that none of the previously written words are still buffered
Source§

impl<D, P> Write for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

fn write( &mut self, word: u8, ) -> Result<(), Error<<Writer<D, P> as ErrorType>::Error>>

Writes a single word to the serial interface.
Source§

fn flush(&mut self) -> Result<(), Error<<Writer<D, P> as ErrorType>::Error>>

Ensures that none of the previously written words are still buffered.
Source§

impl<D, P> Write for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

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

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl<D, P> Write for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

fn write( &mut self, buf: &[u8], ) -> Result<usize, <Writer<D, P> as ErrorType>::Error>

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

fn flush(&mut self) -> Result<(), <Writer<D, P> as ErrorType>::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<D, P> WriteReady for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

fn write_ready(&mut self) -> Result<bool, <Writer<D, P> as ErrorType>::Error>

Get whether the writer is ready for immediately writing. Read more
Source§

impl<D, P> WriteTarget for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

type TransmittedWord = u8

Type which is transferred in a single DMA transfer.
Source§

fn tx_treq() -> Option<u8>

Returns the DREQ number for this data sink (None for memory buffers).
Source§

fn tx_address_count(&mut self) -> (u32, u32)

Returns the address and the maximum number of words that can be transferred from this data source in a single DMA operation. Read more
Source§

fn tx_increment(&self) -> bool

Returns whether the address shall be incremented after each transfer.
Source§

impl<D, P> EndlessWriteTarget for Writer<D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Auto Trait Implementations§

§

impl<D, P> Freeze for Writer<D, P>
where D: Freeze,

§

impl<D, P> RefUnwindSafe for Writer<D, P>

§

impl<D, P> Send for Writer<D, P>
where D: Send, P: Send,

§

impl<D, P> Sync for Writer<D, P>
where D: Sync, P: Sync,

§

impl<D, P> Unpin for Writer<D, P>
where D: Unpin, P: Unpin,

§

impl<D, P> UnwindSafe for Writer<D, P>
where D: UnwindSafe, P: UnwindSafe,

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<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. 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.