SLAB_USB_SPI  1.0
Silicon Labs CP2130 USB-to-SPI Interface Library
Functions
SLAB_USB_SPI.cpp File Reference

Functions

SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetLibraryVersion (BYTE *pMajor, BYTE *pMinor, BOOL *pIsRelease)
 Get the Interface Library version numbers. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetGuid (LPGUID pDevGuid)
 Return the GUID used for device managment. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetGuid (LPGUID pDevGuid)
 Set the GUID used for device managment. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_Reset (CP213x_DEVICE hDevice)
 Reset device. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetRtrStop (CP213x_DEVICE hDevice, BYTE stopRtr)
 Stop 'Read with RTR' operation. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetRtrState (CP213x_DEVICE hDevice, BYTE *inRtrMode)
 Read status of RTR operation. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetDeviceVersion (CP213x_DEVICE hDevice, BYTE *majorVersion, BYTE *minorVersion)
 Get the read-only device version. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetSpiControlByte (CP213x_DEVICE hDevice, BYTE channel, BYTE controlByte)
 Set the SPI control word. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetSpiControlBytes (CP213x_DEVICE hDevice, BYTE controlBytes[CP213x_NUM_GPIO])
 Get the SPI control word. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetSpiDelay (CP213x_DEVICE hDevice, BYTE channel, BYTE delayMode, WORD interByteDelay, WORD postAssertDelay, WORD preDeassertDelay)
 Set the SPI delay values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetSpiDelay (CP213x_DEVICE hDevice, BYTE channel, BYTE *delayMode, WORD *interByteDelay, WORD *postAssertDelay, WORD *preDeassertDelay)
 Get the SPI delay values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetFifoFullThreshold (CP213x_DEVICE hDevice, BYTE fifoFullThreshold)
 Set the FIFO full threshold. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetFifoFullThreshold (CP213x_DEVICE hDevice, BYTE *pFifoFullThreshold)
 Get the FIFO full threshold value. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetChipSelect (CP213x_DEVICE hDevice, BYTE channel, BYTE mode)
 Set SPI chip select control word. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetChipSelect (CP213x_DEVICE hDevice, WORD *channelCsEnable, WORD *pinCsEnable)
 Get SPI chip select control word. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetGpioModeAndLevel (CP213x_DEVICE hDevice, BYTE index, BYTE mode, BYTE level)
 Set the GPIO mode control. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetGpioModeAndLevel (CP213x_DEVICE hDevice, BYTE channel, BYTE *mode, BYTE *level)
 Get the GPIO mode control. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetGpioValues (CP213x_DEVICE hDevice, WORD mask, WORD gpioValues)
 Set the GPIO values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetGpioValues (CP213x_DEVICE hDevice, WORD *gpioValues)
 Get the GPIO values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetEventCounter (CP213x_DEVICE hDevice, BYTE mode, WORD count)
 Set the Event Count value. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetEventCounter (CP213x_DEVICE hDevice, BYTE *mode, WORD *count)
 Get the Event Count value. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetClockDivider (CP213x_DEVICE hDevice, BYTE clockDivider)
 Set clock divider. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetClockDivider (CP213x_DEVICE hDevice, BYTE *pClockDivider)
 Get clock divider. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_ControlTransfer (CP213x_DEVICE hDevice, SETUP_PACKET SetupPacket, PUCHAR Buffer, PULONG LengthTransferred)
 Perform a USB control transfer. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_TransferWrite (CP213x_DEVICE hDevice, BYTE pWriteBuf[], DWORD length, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyWritten)
 Perform SPI Write. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_TransferReadSync (CP213x_DEVICE hDevice, BYTE pReadBuf[], DWORD length, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyRead)
 Perform SPI Read (synchronous) More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_TransferWriteRead (CP213x_DEVICE hDevice, BYTE pWriteBuf[], BYTE pReadBuf[], DWORD length, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyTransferred)
 Perform SPI Write/Read (synchronous) More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_TransferReadRtrSync (CP213x_DEVICE hDevice, BYTE pReadBuf[], DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer, DWORD timeoutMs, DWORD *pBytesActuallyRead)
 Perform SPI Read with RTR (synchronous) More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_TransferReadRtrAsync (CP213x_DEVICE hDevice, DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer)
 Perform SPI Read with RTR (asynchronous) More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_TransferReadAsync (CP213x_DEVICE hDevice, DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer)
 Perform SPI Read (asynchronous) More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_ReadPoll (CP213x_DEVICE hDevice, BYTE pReadBuf[], DWORD maxLength, DWORD *pBytesActuallyRead)
 Read bytes received during an asynchronous Read or ReadRTR operation. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_ReadAbort (CP213x_DEVICE hDevice)
 Abort an asynchronous Read or ReadRTR operation. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetLock (CP213x_DEVICE hDevice, WORD lockValue)
 Set the Lock values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetLock (CP213x_DEVICE hDevice, WORD *lockValue)
 Get the Lock values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetUsbConfig (CP213x_DEVICE hDevice, WORD vid, WORD pid, BYTE power, BYTE powerMode, WORD releaseVersion, BYTE transferPriority, BYTE mask)
 Set the USB device Configuration info. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetUsbConfig (CP213x_DEVICE hDevice, WORD *vid, WORD *pid, BYTE *power, BYTE *powerMode, WORD *releaseVersion, BYTE *transferPriority)
 Get the USB Device Configuration info. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetManufacturingString (CP213x_DEVICE hDevice, LPSTR manufacturingString, BYTE *strlen)
 Get the USB device Manufacturer string. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetManufacturingString (CP213x_DEVICE hDevice, LPCSTR manufacturingString, BYTE strlen)
 Set the USB device Manufacturer string. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetProductString (CP213x_DEVICE hDevice, LPSTR productString, BYTE *strlen)
 Get the USB device Product string. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetProductString (CP213x_DEVICE hDevice, LPCSTR productString, BYTE strlen)
 Set the USB device Product string. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetSerialString (CP213x_DEVICE hDevice, LPSTR serialString, BYTE *strlen)
 Get the USB device Serial Number string. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetSerialString (CP213x_DEVICE hDevice, LPCSTR serialString, BYTE strlen)
 Set the USB device Serial Number string. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetPinConfig (CP213x_DEVICE hDevice, BYTE *pinConfig)
 Get the USB device Pin Configuration info. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetPinConfig (CP213x_DEVICE hDevice, BYTE pinConfig[SIZE_PIN_CONFIG])
 Set the USB device Pin Configuration info. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_ReadProm (CP213x_DEVICE hDevice, BYTE pRbuffer[])
 Read device EPROM configuration. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_WriteProm (CP213x_DEVICE hDevice, BYTE pWbuffer[])
 Write device EPROM configuration. More...
 
Device Management Functions
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetNumDevices (DWORD *numDevices)
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetDevicePath (DWORD deviceIndex, LPSTR path)
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetVidPid (DWORD deviceIndex, WORD *vid, WORD *pid)
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetOpenedDevicePath (CP213x_DEVICE device, LPSTR path)
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetOpenedVidPid (CP213x_DEVICE device, WORD *vid, WORD *pid)
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_OpenByIndex (DWORD deviceIndex, CP213x_DEVICE *device)
 Opens a USB device using a device index and returns a device object pointer which will be used for subsequent access. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_OpenByDevicePath (LPCSTR devicePath, CP213x_DEVICE *phDevice)
 Open device using specified Device Path. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_Close (CP213x_DEVICE hDevice)
 Close device handle. More...
 
SLAB_USB_SPI_API BOOL WINAPI CP213x_IsOpened (CP213x_DEVICE device)
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetDeviceDescriptor (CP213x_DEVICE hDevice, PDEVICE_DESCRIPTOR pDescriptor)
 Get specified device descriptor. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetStringDescriptor (CP213x_DEVICE hDevice, BYTE index, BYTE stringDescriptor[STRING_DESCRIPTOR_SIZE])
 Get specified string descriptor. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_AbortInputPipe (CP213x_DEVICE hDevice)
 Abort USB input pipe. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_FlushInputPipe (CP213x_DEVICE hDevice)
 Flush USB input pipe. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_AbortOutputPipe (CP213x_DEVICE hDevice)
 Abort USB output pipe. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_FlushOutputPipe (CP213x_DEVICE hDevice)
 Flush USB output pipe. More...
 

Function Documentation

SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetLibraryVersion ( BYTE *  pMajor,
BYTE *  pMinor,
BOOL *  pIsRelease 
)

Get the Interface Library version numbers.

Parameters
[out]pMajorMajor release number
[out]pMinorMinor release number
[out]pIsRelease0: Not released version, 1: Released version
Returns
USB_SPI_ERRCODE_SUCCESS
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetGuid ( LPGUID  pDevGuid)

Return the GUID used for device managment.

Parameters
[out]pDevGuidPointer to DEVGUID struct
Returns
USB_SPI_ERRCODE_SUCCESS
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetGuid ( LPGUID  pDevGuid)

Set the GUID used for device managment.

Application must call GetNumDevices() after the GUID is changed.

Parameters
[in]pDevGuidPointer to DEVGUID struct
Returns
USB_SPI_ERRCODE_SUCCESS
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetNumDevices ( DWORD *  numDevices)

Returns the number of CP213x devices connected to the system

Parameters
[in]numDevicesA return value of 0 indicates that no devices are available. Otherwise this parameter returns the number of connected devices. When refering to a device by deviceIndex, the index may range from 0 to (CP213x_GetNumDevices() - 1).
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_PARAMETER
Remarks
This function returns the number of connected devices. This does not imply that a device is not already in use. Users must call CP213x_GetNumDevices() before calling any function that takes a device index parameter in order to build an up to date device list. If a device is installed or removed after calling CP213x_GetNumDevices(), then the device list will be out of date, and the results may be unpredictable.
Note
CP213x_GetNumDevices() must be called prior to calling:
CP213x_OpenByIndex()
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_OpenByIndex ( DWORD  deviceIndex,
CP213x_DEVICE *  device 
)

Opens a USB device using a device index and returns a device object pointer which will be used for subsequent access.

Parameters
[in]deviceIndexIndex of device to open
[out]deviceReturns a pointer to a device object used for subsequent device access.
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_DEVICE_OBJECT
USB_SPI_ERRCODE_INVALID_PARAMETER
Note
CP213x_GetNumDevices() must be called prior to calling this function in order to initialize the library's internal device list.
See Also
CP213x_GetNumDevices()
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_OpenByDevicePath ( LPCSTR  devicePath,
CP213x_DEVICE *  phDevice 
)

Open device using specified Device Path.

Parameters
[in]devicePathThe specified Device Path
[out]phDevice[Pointer to device handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_INVALID_DEVICE_OBJECT
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_Close ( CP213x_DEVICE  hDevice)

Close device handle.

Parameters
[in]hDevicePointer to device handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_DEVICE_OBJECT
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetDeviceDescriptor ( CP213x_DEVICE  hDevice,
PDEVICE_DESCRIPTOR  pDescriptor 
)

Get specified device descriptor.

Parameters
[in]hDeviceInterface Handle
[out]pDescriptorPointer to device descriptor
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_ALLOC_FAILURE
USB_SPI_ERRCODE_UNKNOWN_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetStringDescriptor ( CP213x_DEVICE  hDevice,
BYTE  index,
BYTE  stringDescriptor[STRING_DESCRIPTOR_SIZE] 
)

Get specified string descriptor.

Parameters
[in]hDeviceDevice Handle
[in]indexString descriptor index
[out]stringDescriptorString descriptor
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_ALLOC_FAILURE
USB_SPI_ERRCODE_UNKNOWN_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_AbortInputPipe ( CP213x_DEVICE  hDevice)

Abort USB input pipe.

Calls WinUsb_AbortPipe

Parameters
[in]hDeviceUSB Interface Handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_PIPE_ABORT_FAIL
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_FlushInputPipe ( CP213x_DEVICE  hDevice)

Flush USB input pipe.

Calls WinUsb_FlushPipe

Parameters
[in]hDeviceUSB Interface Handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_PIPE_FLUSH_FAIL
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_AbortOutputPipe ( CP213x_DEVICE  hDevice)

Abort USB output pipe.

Calls WinUsb_AbortPipe

Parameters
[in]hDeviceUSB Interface Handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_PIPE_ABORT_FAIL
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_FlushOutputPipe ( CP213x_DEVICE  hDevice)

Flush USB output pipe.

Calls WinUsb_FlushPipe

Parameters
[in]hDeviceUSB Interface Handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_PIPE_FLUSH_FAIL
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_Reset ( CP213x_DEVICE  hDevice)

Reset device.

Send command to reset the device

Parameters
[in]hDeviceUSB Interface Handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetRtrStop ( CP213x_DEVICE  hDevice,
BYTE  stopRtr 
)

Stop 'Read with RTR' operation.

Parameters
[in]hDeviceUSB Interface Handle
[in]stopRtr0: No effect 1: Stop Read with RTR operation
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetRtrState ( CP213x_DEVICE  hDevice,
BYTE *  inRtrMode 
)

Read status of RTR operation.

Parameters
[in]hDeviceUSB Interface Handle
[out]inRtrMode0: Device is not in RTR mode 1: Device is in RTR mode
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetDeviceVersion ( CP213x_DEVICE  hDevice,
BYTE *  majorVersion,
BYTE *  minorVersion 
)

Get the read-only device version.

Parameters
[in]hDeviceUSB Interface Handle
[out]majorVersion
[out]minorVersion
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetSpiControlByte ( CP213x_DEVICE  hDevice,
BYTE  channel,
BYTE  controlByte 
)

Set the SPI control word.

Set the SPI control byte for a given channel

Parameters
[in]hDeviceUSB Interface Handle
[in]channelChannel for which to set SPI control byte
[in]controlByteSPI control byte
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetSpiControlBytes ( CP213x_DEVICE  hDevice,
BYTE  controlBytes[CP213x_NUM_GPIO] 
)

Get the SPI control word.

Parameters
[in]hDeviceUSB Interface Handle
[out]controlBytesBuffer that contains the SPI control bytes for each channel
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetSpiDelay ( CP213x_DEVICE  hDevice,
BYTE  channel,
BYTE  delayMode,
WORD  interByteDelay,
WORD  postAssertDelay,
WORD  preDeassertDelay 
)

Set the SPI delay values.

Parameters
[in]hDeviceUSB Interface Handle
[in]channelSPI channel for which to set delays
[in]delayMode
[in]interByteDelay
[in]postAssertDelay
[in]preDeassertDelay
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetSpiDelay ( CP213x_DEVICE  hDevice,
BYTE  channel,
BYTE *  delayMode,
WORD *  interByteDelay,
WORD *  postAssertDelay,
WORD *  preDeassertDelay 
)

Get the SPI delay values.

Pass the desired SPI channel number in buffer[0]

Parameters
[in]hDeviceUSB Interface Handle
[in]channelSPI channel for which to get delays
[out]delayMode
[out]interByteDelay
[out]postAssertDelay
[out]preDeassertDelay
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetFifoFullThreshold ( CP213x_DEVICE  hDevice,
BYTE  fifoFullThreshold 
)

Set the FIFO full threshold.

Parameters
[in]hDeviceUSB Interface Handle
[in]fifoFullThresholdThe FIFO full threshold value to set
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetFifoFullThreshold ( CP213x_DEVICE  hDevice,
BYTE *  pFifoFullThreshold 
)

Get the FIFO full threshold value.

Parameters
[in]hDeviceUSB Interface Handle
[out]pFifoFullThresholdThe FIFO full threshold
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetChipSelect ( CP213x_DEVICE  hDevice,
BYTE  channel,
BYTE  mode 
)

Set SPI chip select control word.

Parameters
[in]hDeviceUSB Interface Handle
[in]channel
[in]modeChip select mode 0: Idle, 1: Active, 2: Active; all other channels idle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetChipSelect ( CP213x_DEVICE  hDevice,
WORD *  channelCsEnable,
WORD *  pinCsEnable 
)

Get SPI chip select control word.

Parameters
[in]hDeviceUSB Interface Handle
[out]channelCsEnable
[out]pinCsEnable
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetGpioModeAndLevel ( CP213x_DEVICE  hDevice,
BYTE  index,
BYTE  mode,
BYTE  level 
)

Set the GPIO mode control.

Parameters
[in]hDeviceUSB Interface Handle
[in]indexGPIO number to configure
[in]modeGPIO mode
[in]levelGPIO state [0,1]
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetGpioModeAndLevel ( CP213x_DEVICE  hDevice,
BYTE  channel,
BYTE *  mode,
BYTE *  level 
)

Get the GPIO mode control.

Parameters
[in]hDeviceUSB Interface Handle
[in]channelThe GPIO line
[out]modeThe mode for the specified GPIO line
[out]levelThe level for the specified GPIO line
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetGpioValues ( CP213x_DEVICE  hDevice,
WORD  mask,
WORD  gpioValues 
)

Set the GPIO values.

Parameters
[in]hDeviceUSB Interface Handle
[in]maskThe mask of which GPIO values to set
[in]gpioValuesThe GPIO values to set for the specified mask
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetGpioValues ( CP213x_DEVICE  hDevice,
WORD *  gpioValues 
)

Get the GPIO values.

Parameters
[in]hDeviceUSB Interface Handle
[out]gpioValuesThe GPIO values
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetEventCounter ( CP213x_DEVICE  hDevice,
BYTE  mode,
WORD  count 
)

Set the Event Count value.

Parameters
[in]hDeviceUSB Interface Handle
[in]modeEvent Counter mode
[in]countEvent count value to set
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetEventCounter ( CP213x_DEVICE  hDevice,
BYTE *  mode,
WORD *  count 
)

Get the Event Count value.

Parameters
[in]hDeviceUSB Interface Handle
[out]modeThe current Event Counter mode
[out]countThe current Event Counter count
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetClockDivider ( CP213x_DEVICE  hDevice,
BYTE  clockDivider 
)

Set clock divider.

Parameters
[in]hDeviceUSB Interface Handle
[in]clockDividerClock divider value
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetClockDivider ( CP213x_DEVICE  hDevice,
BYTE *  pClockDivider 
)

Get clock divider.

Parameters
[in]hDeviceUSB Interface Handle
[out]pClockDividerClock divider value
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ControlTransfer ( CP213x_DEVICE  hDevice,
SETUP_PACKET  SetupPacket,
PUCHAR  Buffer,
PULONG  LengthTransferred 
)

Perform a USB control transfer.

Parameters
[in]hDeviceUSB Interface Handle
[in]SetupPacketUSB Setup Packet
[in]BufferData to transfer
[out]LengthTransferredNumber of bytes actually transferred
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferWrite ( CP213x_DEVICE  hDevice,
BYTE  pWriteBuf[],
DWORD  length,
BOOL  releaseBusAfterTransfer,
DWORD  timeoutMs,
DWORD *  pBytesActuallyWritten 
)

Perform SPI Write.

Parameters
[in]hDeviceUSB Interface Handle
[in]pWriteBufBuffer of data to write
[in]lengthNumber of bytes to write
[in]releaseBusAfterTransfer1: Release buffer after transfer is complete
[in]timeoutMsTimeout (ms)
[out]pBytesActuallyWrittenNumber of bytes actually written
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT
USB_SPI_ERRCODE_PIPE_WRITE_FAIL
USB_SPI_ERRCODE_INVALID_ENUM_VALUE
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadSync ( CP213x_DEVICE  hDevice,
BYTE  pReadBuf[],
DWORD  length,
BOOL  releaseBusAfterTransfer,
DWORD  timeoutMs,
DWORD *  pBytesActuallyRead 
)

Perform SPI Read (synchronous)

This function returns after 'length' bytes have been read, or a timeout or error occurs

Parameters
[in]hDeviceUSB Interface Handle
[in]pReadBufBuffer of data to read
[in]lengthNumber of bytes to read
[in]releaseBusAfterTransfer1: Release buffer after transfer is complete
[in]timeoutMsTimeout (ms)
[out]pBytesActuallyReadNumber of bytes actually read
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT
USB_SPI_ERRCODE_PIPE_READ_FAIL
USB_SPI_ERRCODE_INVALID_ENUM_VALUE
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferWriteRead ( CP213x_DEVICE  hDevice,
BYTE  pWriteBuf[],
BYTE  pReadBuf[],
DWORD  length,
BOOL  releaseBusAfterTransfer,
DWORD  timeoutMs,
DWORD *  pBytesActuallyTransferred 
)

Perform SPI Write/Read (synchronous)

This function returns after 'length' bytes have been written and read, or a timeout or error occurs

Parameters
[in]hDeviceUSB Interface Handle
[in]pWriteBufBuffer of data to write
[in]pReadBufBuffer of data to read
[in]lengthNumber of bytes to write and read
[in]releaseBusAfterTransferRelease buf after transfer is complete
[in]timeoutMsTimeout (ms)
[out]pBytesActuallyTransferredNumber of bytes actually written and read
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT
USB_SPI_ERRCODE_PIPE_WRITE_FAIL
USB_SPI_ERRCODE_PIPE_READ_FAIL
USB_SPI_ERRCODE_INVALID_ENUM_VALUE
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadRtrSync ( CP213x_DEVICE  hDevice,
BYTE  pReadBuf[],
DWORD  totalSize,
DWORD  blockSize,
BOOL  releaseBusAfterTransfer,
DWORD  timeoutMs,
DWORD *  pBytesActuallyRead 
)

Perform SPI Read with RTR (synchronous)

The device reads SPI data in 'blockSize' chunks while the RTR pin is asserted. This function returns after 'totalSize' bytes have been read, or a timeout or error occurs.

Parameters
[in]hDeviceUSB Interface Handle
[in]pReadBufBuffer of data to read
[in]totalSizeTotal number of bytes to read
[in]blockSizeNumber of bytes to read at a time
[in]releaseBusAfterTransfer1: Release buffer after transfer is complete
[in]timeoutMsTimeout (ms)
[out]pBytesActuallyReadNumber of bytes actually read
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_PIPE_ABORT_FAIL
USB_SPI_ERRCODE_PIPE_FLUSH_FAIL
USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT
USB_SPI_ERRCODE_PIPE_WRITE_FAIL
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadRtrAsync ( CP213x_DEVICE  hDevice,
DWORD  totalSize,
DWORD  blockSize,
BOOL  releaseBusAfterTransfer 
)

Perform SPI Read with RTR (asynchronous)

The device reads SPI data in 'blockSize' chunks while the RTR pin is asserted. This function returns immediately. The application should call CP213x_ReadPoll() periodically to read data. When 'totalSize' bytes have been read, the Read operation is terminated. To terminate the operation before then, the application should call 'CP213x_ReadAbort'.

Parameters
[in]hDeviceUSB Interface Handle
[in]totalSizeTotal number of bytes to read
[in]blockSizeNumber of bytes to read at a time
[in]releaseBusAfterTransferRelease buf after transfer is complete
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_PARAMETER
USB_SPI_ERRCODE_READ_THREAD_CREATE_FAILURE
USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT
USB_SPI_ERRCODE_INVALID_ENUM_VALUE
USB_SPI_ERRCODE_PIPE_READ_FAIL
USB_SPI_ERRCODE_READ_THREAD_START_FAILURE
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_TransferReadAsync ( CP213x_DEVICE  hDevice,
DWORD  totalSize,
DWORD  blockSize,
BOOL  releaseBusAfterTransfer 
)

Perform SPI Read (asynchronous)

The device reads SPI data in 'blockSize' chunks. This function returns immediately. The application should call CP213x_ReadPoll() periodically to read data. When 'totalSize' bytes have been read, the Read operation is terminated. To terminate the operation before then, the application should call 'CP213x_ReadAbort'.

Parameters
[in]hDeviceUSB Interface Handle
[in]totalSizeTotal number of bytes to read
[in]blockSizeNumber of bytes to read at a time
[in]releaseBusAfterTransferRelease buf after transfer is complete
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_READ_THREAD_CREATE_FAILURE
USB_SPI_ERRCODE_PIPE_ABORT_FAIL
USB_SPI_ERRCODE_PIPE_FLUSH_FAIL
USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT
USB_SPI_ERRCODE_PIPE_WRITE_FAIL
USB_SPI_ERRCODE_READ_THREAD_START_FAILURE
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ReadPoll ( CP213x_DEVICE  hDevice,
BYTE  pReadBuf[],
DWORD  maxLength,
DWORD *  pBytesActuallyRead 
)

Read bytes received during an asynchronous Read or ReadRTR operation.

Parameters
[in]hDeviceUSB Interface Handle
[in]pReadBufBuffer of data to read
[in]maxLengthMaximum number of bytes to read
[out]pBytesActuallyReadNumber of bytes actually read
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_NULL_POINTER
USB_SPI_ERRCODE_READ_THREAD_NOT_RUNNING
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ReadAbort ( CP213x_DEVICE  hDevice)

Abort an asynchronous Read or ReadRTR operation.

Parameters
[in]hDeviceUSB Interface Handle
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_NULL_POINTER
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetLock ( CP213x_DEVICE  hDevice,
WORD  lockValue 
)

Set the Lock values.

Parameters
[in]hDeviceUSB Interface Handle
[in]lockValueThe Lock values to set
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetLock ( CP213x_DEVICE  hDevice,
WORD *  lockValue 
)

Get the Lock values.

Parameters
[in]hDeviceUSB Interface Handle
[out]lockValueThe Lock values
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetUsbConfig ( CP213x_DEVICE  hDevice,
WORD  vid,
WORD  pid,
BYTE  power,
BYTE  powerMode,
WORD  releaseVersion,
BYTE  transferPriority,
BYTE  mask 
)

Set the USB device Configuration info.

Parameters
[in]hDeviceUSB Interface Handle
[in]vidNew VID to be set in the device
[in]pidNew PID to be set in the device
[in]powerNew Power to be set in the device
[in]powerModeNew Power Mode to be set in the device
[in]releaseVersionNew Release version to be set in the device
[in]transferPriorityNew Transfer priority to be set in the device
[in]maskMask that represents which of the settings to write to the device
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetUsbConfig ( CP213x_DEVICE  hDevice,
WORD *  vid,
WORD *  pid,
BYTE *  power,
BYTE *  powerMode,
WORD *  releaseVersion,
BYTE *  transferPriority 
)

Get the USB Device Configuration info.

Parameters
[in]hDeviceUSB Interface Handle
[out]vidVID of the device
[out]pidPID of the device
[out]powerPower of the device
[out]powerModePower Mode of the device
[out]releaseVersionRelease version of the device
[out]transferPriorityTransfer priority of the device
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetManufacturingString ( CP213x_DEVICE  hDevice,
LPSTR  manufacturingString,
BYTE *  strlen 
)

Get the USB device Manufacturer string.

Parameters
[in]hDeviceUSB Interface Handle
[out]manufacturingStringPointer to buffer that will be populated with Manufacturer string
[out]strlenPointer to BYTE that will be set to the Manufacturer string length
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetManufacturingString ( CP213x_DEVICE  hDevice,
LPCSTR  manufacturingString,
BYTE  strlen 
)

Set the USB device Manufacturer string.

Parameters
[in]hDeviceUSB Interface Handle
[in]manufacturingStringBuffer containing the USB device Manufacturer string to be set
[in]strlenThe length of the supplied Manufacturer string
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetProductString ( CP213x_DEVICE  hDevice,
LPSTR  productString,
BYTE *  strlen 
)

Get the USB device Product string.

Parameters
[in]hDeviceUSB Interface Handle
[out]productStringBuffer that will be populated with the USB device Product string
[out]strlenPointer to BYTE that will be set to the Product string length
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetProductString ( CP213x_DEVICE  hDevice,
LPCSTR  productString,
BYTE  strlen 
)

Set the USB device Product string.

Parameters
[in]hDeviceUSB Interface Handle
[in]productStringBuffer containing the USB device Product string
[in]strlenThe length of the supplied Product string
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetSerialString ( CP213x_DEVICE  hDevice,
LPSTR  serialString,
BYTE *  strlen 
)

Get the USB device Serial Number string.

Parameters
[in]hDeviceUSB Interface Handle
[out]serialStringBuffer that will be populated with the USB device Serial Number string
[out]strlenPointer to BYTE that will be set to the Serial Number string length
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetSerialString ( CP213x_DEVICE  hDevice,
LPCSTR  serialString,
BYTE  strlen 
)

Set the USB device Serial Number string.

Parameters
[in]hDeviceUSB Interface Handle
[in]serialStringBuffer containing the USB device Serial Number string
[in]strlenThe length of the supplied Serial Number string
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_GetPinConfig ( CP213x_DEVICE  hDevice,
BYTE *  pinConfig 
)

Get the USB device Pin Configuration info.

Parameters
[in]hDeviceUSB Interface Handle
[out]pinConfigBuffer containing the USB device Pin Configuration info
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_SetPinConfig ( CP213x_DEVICE  hDevice,
BYTE  pinConfig[SIZE_PIN_CONFIG] 
)

Set the USB device Pin Configuration info.

Parameters
[in]hDeviceUSB Interface Handle
[in]pinConfigBuffer containing the USB device Pin Configuration info
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_ReadProm ( CP213x_DEVICE  hDevice,
BYTE  pRbuffer[] 
)

Read device EPROM configuration.

Parameters
[in]hDeviceUSB Interface Handle
[out]pRbufferPointer to byte array to be filled
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR
SLAB_USB_SPI_API USB_SPI_STATUS WINAPI CP213x_WriteProm ( CP213x_DEVICE  hDevice,
BYTE  pWbuffer[] 
)

Write device EPROM configuration.

Parameters
[in]hDeviceUSB Interface Handle
[in]pWbufferPointer to byte array containing data to write to EPROM
Returns
USB_SPI_ERRCODE_SUCCESS
USB_SPI_ERRCODE_INVALID_HANDLE
USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR