embassy-usb-host

Crates

git

Versions

default

Flavors

Cp210xDevice

Struct Cp210xDevice 

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

CP210x device — owns the shared control pipe on endpoint 0.

Open one Cp210xPort per UART interface via Cp210xDevice::port. Control requests from all open ports are serialized through the device’s internal async mutex; bulk I/O on different ports runs concurrently.

Construct with Cp210xDevice::new for the common single-task case; the control-pipe mutex is a NoopRawMutex and has no runtime cost. To use ports concurrently, construct with Cp210xDevice::new_with_raw_mutex and pick a Sync raw mutex:

use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
let device = Cp210xDevice::<_, CriticalSectionRawMutex>::new_with_raw_mutex(
    &bus, &enum_info,
)?;

Implementations§

Source§

impl<'d, A> Cp210xDevice<'d, A, NoopRawMutex>
where A: UsbHostAllocator<'d>,

Source

pub fn new(alloc: &A, enum_info: &EnumerationInfo) -> Result<Self, Cp210xError>

Allocate the device-level control pipe on endpoint 0, using a NoopRawMutex for the shared control pipe.

The resulting device is !Sync. Use this constructor for single-port parts, or whenever the device and all its ports stay confined to one task. For multi-task sharing, use Cp210xDevice::new_with_raw_mutex instead.

Performs no I/O.

Source§

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

Source

pub fn new_with_raw_mutex( alloc: &A, enum_info: &EnumerationInfo, ) -> Result<Self, Cp210xError>

Allocate the device-level control pipe on endpoint 0, using the caller-chosen raw mutex M for the shared control pipe.

Pick a Sync raw mutex (e.g. CriticalSectionRawMutex) to drive multiple ports concurrently. For single-port devices, prefer Cp210xDevice::new.

Performs no I/O.

Source

pub fn port<'dev>( &'dev self, config_desc: &[u8], interface_idx: u8, ) -> Result<Cp210xPort<'dev, 'd, A, M>, Cp210xError>

Open the interface_idx-th UART port.

Locates the interface_idx-th vendor-class interface with a bulk IN / bulk OUT pair (use 0 for single-port parts; 0..2 for CP2105; 0..4 for CP2108) and allocates its bulk pipes.

No I/O is performed with the device. The caller must call Cp210xPort::enable before transferring data; existing baud-rate, line-coding, flow-control, and modem-line settings inside the CP210x are preserved.

The driver does not validate which port is in use. Avoid opening the same port multiple times.

Auto Trait Implementations§

§

impl<'d, A, M = NoopRawMutex> !Freeze for Cp210xDevice<'d, A, M>

§

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

§

impl<'d, A, M> Send for Cp210xDevice<'d, A, M>
where A: Send, M: Send, <A as UsbHostAllocator<'d>>::Pipe<Control, InOut>: Send,

§

impl<'d, A, M> Sync for Cp210xDevice<'d, A, M>
where A: Sync, M: Sync, <A as UsbHostAllocator<'d>>::Pipe<Control, InOut>: Send,

§

impl<'d, A, M> Unpin for Cp210xDevice<'d, A, M>
where A: Unpin, M: Unpin, <A as UsbHostAllocator<'d>>::Pipe<Control, InOut>: Unpin,

§

impl<'d, A, M> UnwindSafe for Cp210xDevice<'d, A, M>

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