embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

FtdiPort

Struct FtdiPort 

Source
pub struct FtdiPort<'dev, 'd, A, M = NoopRawMutex>
where A: UsbHostAllocator<'d>, M: RawMutex,
{ /* private fields */ }
Expand description

FTDI UART port.

Implementations§

Source§

impl<'dev, 'd, A, M> FtdiPort<'dev, 'd, A, M>
where A: UsbHostAllocator<'d>, M: RawMutex,

Source

pub fn info(&self) -> &FtdiInfo

Return descriptor-located info for this port.

Source

pub async fn reset(&mut self) -> Result<(), FtdiError>

Reset port state (SIO reset).

Source

pub async fn purge_rx(&mut self) -> Result<(), FtdiError>

Purge receive queue on device.

Source

pub async fn purge_tx(&mut self) -> Result<(), FtdiError>

Purge transmit queue on device.

Source

pub async fn set_baudrate(&mut self, baud: u32) -> Result<(), FtdiError>

Configure the UART baud rate.

Source

pub async fn set_line_coding( &mut self, line: &LineCoding, ) -> Result<(), FtdiError>

Configure line parameters (data bits, stop bits, parity).

Source

pub async fn set_control_line_state( &mut self, dtr: bool, rts: bool, ) -> Result<(), FtdiError>

Set modem control line states (DTR, RTS).

Source

pub async fn set_flow_control( &mut self, flow: FlowControl, ) -> Result<(), FtdiError>

Configure hardware or software flow control.

Source

pub async fn set_latency_timer( &mut self, latency_ms: u8, ) -> Result<(), FtdiError>

Set latency timer in milliseconds (1 to 255 ms, default 16 ms).

Source

pub async fn get_latency_timer(&mut self) -> Result<u8, FtdiError>

Query the current latency timer value.

Source

pub async fn get_modem_status( &mut self, ) -> Result<(ModemStatus, LineStatus), FtdiError>

Query current modem and line status.

Source

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

Read data from the UART, automatically stripping the 2-byte FTDI status header.

Source

pub async fn write(&mut self, data: &[u8]) -> Result<usize, FtdiError>

Write data to the UART.

Source

pub fn split(self) -> (Reader<'dev, 'd, A, M>, Writer<'dev, 'd, A, M>)

Split into independent reader and writer halves.

Source

pub fn last_modem_status(&self) -> ModemStatus

Last observed modem status from received packets.

Source

pub fn last_line_status(&self) -> LineStatus

Last observed line status from received packets.

Trait Implementations§

Source§

impl<'dev, 'd, A, M> ErrorType for FtdiPort<'dev, 'd, A, M>
where A: UsbHostAllocator<'d>, M: RawMutex,

Available on crate feature embedded-io only.
Source§

type Error = FtdiError

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

impl<'dev, 'd, A, M> Read for FtdiPort<'dev, 'd, A, M>
where A: UsbHostAllocator<'d>, M: RawMutex,

Available on crate feature embedded-io only.
Source§

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>>

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

impl<'dev, 'd, A, M> Write for FtdiPort<'dev, 'd, A, M>
where A: UsbHostAllocator<'d>, M: RawMutex,

Available on crate feature embedded-io only.
Source§

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

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

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
Source§

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

Write an entire buffer into this writer. Read more

Auto Trait Implementations§

§

impl<'dev, 'd, A, M = NoopRawMutex> !RefUnwindSafe for FtdiPort<'dev, 'd, A, M>

§

impl<'dev, 'd, A, M = NoopRawMutex> !UnwindSafe for FtdiPort<'dev, 'd, A, M>

§

impl<'dev, 'd, A, M> Forget for FtdiPort<'dev, 'd, A, M>

§

impl<'dev, 'd, A, M> Freeze for FtdiPort<'dev, 'd, A, M>
where &'dev FtdiDevice<'d, A, M>: Freeze, Reader<'dev, 'd, A, M>: Freeze, Writer<'dev, 'd, A, M>: Freeze,

§

impl<'dev, 'd, A, M> Move for FtdiPort<'dev, 'd, A, M>

§

impl<'dev, 'd, A, M> Send for FtdiPort<'dev, 'd, A, M>
where &'dev FtdiDevice<'d, A, M>: Send, Reader<'dev, 'd, A, M>: Send, Writer<'dev, 'd, A, M>: Send,

§

impl<'dev, 'd, A, M> Sync for FtdiPort<'dev, 'd, A, M>
where &'dev FtdiDevice<'d, A, M>: Sync, Reader<'dev, 'd, A, M>: Sync, Writer<'dev, 'd, A, M>: Sync,

§

impl<'dev, 'd, A, M> Unpin for FtdiPort<'dev, 'd, A, M>
where &'dev FtdiDevice<'d, A, M>: Unpin, Reader<'dev, 'd, A, M>: Unpin, Writer<'dev, 'd, A, M>: Unpin,

§

impl<'dev, 'd, A, M> UnsafeUnpin for FtdiPort<'dev, 'd, A, M>
where &'dev FtdiDevice<'d, A, M>: UnsafeUnpin, Reader<'dev, 'd, A, M>: UnsafeUnpin, Writer<'dev, 'd, A, M>: UnsafeUnpin,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.