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>,
impl<'d, A> Cp210xDevice<'d, A, NoopRawMutex>where
A: UsbHostAllocator<'d>,
Sourcepub fn new(alloc: &A, enum_info: &EnumerationInfo) -> Result<Self, Cp210xError>
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,
impl<'d, A, M> Cp210xDevice<'d, A, M>where
A: UsbHostAllocator<'d>,
M: RawMutex,
Sourcepub fn new_with_raw_mutex(
alloc: &A,
enum_info: &EnumerationInfo,
) -> Result<Self, Cp210xError>
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.
Sourcepub fn port<'dev>(
&'dev self,
config_desc: &[u8],
interface_idx: u8,
) -> Result<Cp210xPort<'dev, 'd, A, M>, Cp210xError>
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.