[][src]Struct silabs_usb_xpress::UsbXpress

pub struct UsbXpress { /* fields omitted */ }

Implementations

impl UsbXpress[src]

pub fn open(device_ix: usize) -> Result<Self, SilabsUsbXpressError>[src]

Opens a device and returns a handle

Opens a device (using device number as returned by SI_GetNumDevices) and returns a handle which will be used for subsequent accesses.

  • Supported Devices

C8051F320/1/6/7, C8051F340/1/2/3/4/5/6/7/8/9/A/B/C/D, C8051F380/1/2/3/4/5/6/7, C8051T320/1/2/3/6/7, C8051T620/1/2/3, CP2101/2/3/4/5/8/9

pub fn close(self) -> Result<(), SilabsUsbXpressError>[src]

Cancels pending IO and closes a device

Closes an open device using the handle provided by SI_Open and sets the handle to INVALID_HANDLE_VALUE.

  • Supported Devices

C8051F320/1/6/7, C8051F340/1/2/3/4/5/6/7/8/9/A/B/C/D, C8051F380/1/2/3/4/5/6/7, C8051T320/1/2/3/6/7, C8051T620/1/2/3, CP2101/2/3/4/5/8/9

pub fn read(
    &mut self,
    bytes_to_read: usize
) -> Result<Vec<u8>, SilabsUsbXpressError>
[src]

Reads a block of data from a device

Reads the available number of bytes into the supplied buffer and retrieves the number of bytes that were read (this can be less than the number of bytes requested). This function returns synchronously if the overlapped object is set to NULL (this happens by default) but will not block system execution. If an initialized OVERLAPPED object is passed then the function returns immediately. If the read completed then the status will be SI_SUCCESS but if I/O is still pending then it will return STATUS_IO_PENDING. If STATUS_IO_PENDING is returned, the OVERLAPPED object can then be waited on using WaitForSingleObject(), and retrieve data or cancel using GetOverlappedResult() (as documented on MSDN by Microsoft) or SI_CancelIo() respectively. This functionality allows for multiple reads to be issued and waited on at a time. If any data is available when SI_Read is called it will return so check NumBytesReturned to determine if all requested data was returned. To make sure that SI_Read returns the requested number of bytes use SI_CheckRxQueue().

  • Supported Devices

C8051F320/1/6/7, C8051F340/1/2/3/4/5/6/7/8/9/A/B/C/D, C8051F380/1/2/3/4/5/6/7, C8051T320/1/2/3/6/7, C8051T620/1/2/3, CP2101/2/3/4/5/8/9

pub fn write(
    &mut self,
    to_write: &Vec<u8>
) -> Result<usize, SilabsUsbXpressError>
[src]

Writes a block of data to a device

On USB MCU devices, this function flushes both the receive buffer in the USBXpress device driver and the transmit buffer in the device.

Note: Parameter 2 and 3 of SI_Write have no effect and any value can be passed when used with USB MCU devices.

On CP210x devices, this function operates in accordance with parameters 2 and 3. If parameter 2 (FlushTransmit) is non-zero, the CP210x device’s UART transmit buffer is flushed. If parameter 3 (FlushReceive) is non-zero, the CP210x device’s UART receive buffer is flushed. If parameters 2 and 3 are both non-zero, then both the CP210x device UART transmit buffer and UART receive buffer are flushed.

  • Supported Devices

C8051F320/1/6/7, C8051F340/1/2/3/4/5/6/7/8/9/A/B/C/D, C8051F380/1/2/3/4/5/6/7, C8051T320/1/2/3/6/7, C8051T620/1/2/3, CP2101/2/3/4/5/8/9

pub fn device_io_control(&mut self)[src]

Allows sending low-level commands to the device driver

UNIMPLEMENTED!!!

Interface for any miscellaneous device control functions. A separate call to SI_DeviceIOControl is required for each input or output operation. A single call cannot be used to perform both an input and output operation simultaneously. Refer to DeviceIOControl function definition on MSDN Help for more details.

  • Supported Devices

C8051F320/1/6/7, C8051F340/1/2/3/4/5/6/7/8/9/A/B/C/D, C8051F380/1/2/3/4/5/6/7, C8051T320/1/2/3/6/7, C8051T620/1/2/3

pub fn flush_buffers(&mut self) -> Result<(), SilabsUsbXpressError>[src]

Flushes the TX and RX buffers for a device

On USB MCU devices, this function flushes both the receive buffer in the USBXpress device driver and the transmit buffer in the device.

Note: Parameter 2 and 3 of SI_FlushBuffers have no effect and any value can be passed when used with USB MCU devices.

On CP210x devices, this function operates in accordance with parameters 2 and 3. If parameter 2 (FlushTransmit) is non-zero, the CP210x device’s UART transmit buffer is flushed. If parameter 3 (FlushReceive) is non-zero, the CP210x device’s UART receive buffer is flushed. If parameters 2 and 3 are both non-zero, then both the CP210x device UART transmit buffer and UART receive buffer are flushed.

  • Supported Devices

C8051F320/1/6/7, C8051F340/1/2/3/4/5/6/7/8/9/A/B/C/D, C8051F380/1/2/3/4/5/6/7, C8051T320/1/2/3/6/7, C8051T620/1/2/3, CP2101/2/3/4/5/8/9

pub fn check_rx_queue(&mut self) -> Result<(usize, usize), SilabsUsbXpressError>[src]

Returns the number of bytes in a device's RX queue

Returns the number of bytes in the receive queue and a status value that indicates if an overrun (SI_QUEUE_OVERRUN) has occurred and if the RX queue is ready (SI_QUEUE_READY) for reading. Upon indication of an Overrun condition it is recommended that data transfer be stopped and all buffers be flushed using the SI_FlushBuffers command.

Trait Implementations

impl Debug for UsbXpress[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.