SLAB_USB_SPI  1.0
Silicon Labs CP2130 USB-to-SPI Interface Library
Data Structures
SLAB_USB_SPI.h File Reference

This file defines the API of the CP2130 Interface Library. More...

Go to the source code of this file.

Data Structures

struct  DEVICE_DESCRIPTOR
 This struct has the same format as _USB_DEVICE_DESCRIPTOR, as defined in Windows usb100.h. More...
 
struct  SPI_CMD
 SPI Command Word. More...
 

Macros

Windows Definitions
#define MAX_PATH   260
 
#define CALLBACK   __stdcall
 
Definitions specific to USB SPI code
#define BULK_PACKETSIZE   64
 
#define EP_BUFSIZE   BULK_PACKETSIZE
 
#define CMD_SIZE   8
 
#define CMD_TIMEOUT_MS   1000
 
#define STRING_DESCRIPTOR_SIZE   256
 
#define SIZE_PIN_CONFIG   20
 
#define WRITEREAD_MAX_BLOCKSIZE   256
 
#define CP213x_NUM_GPIO   11
 
#define CSMODE_IDLE   0
 
#define CSMODE_ACTIVE   1
 
#define CSMODE_ACTIVE_OTHERS_IDLE   2
 
#define GPIO_MODE_INPUT   0
 
#define GPIO_MODE_OUTPUT_OD   1
 
#define GPIO_MODE_OUTPUT_PP   2
 
#define GPIO_MODE_CHIPSELECT   3
 
#define GPIO_MODE__RTR_ACTLOW   4
 
#define GPIO_MODE__RTR_ACTHIGH   5
 
#define GPIO_MODE__EVTCNTR_RISING   4
 
#define GPIO_MODE__EVTCNTR_FALLING   5
 
#define GPIO_MODE__EVTCNTR_NEGPULSE   6
 
#define GPIO_MODE__EVTCNTR_POSPULSE   7
 
#define GPIO_MODE__CLK_OUT   4
 
#define GPIO_MODE__SPI_ACTIVITY   4
 
#define GPIO_MODE__SUSPEND   4
 
#define GPIO_MODE__SUSPENDBAR   4
 
#define SHORT_STRING_LEN   60
 
#define LONG_STRING_LEN_1   61
 
#define LONG_STRING_LEN_2   63
 
SPI Data Transfer command and subcommands
#define CMD_TRANSFER_DATA   0x0000
 
#define SUBCMD_READ   0
 
#define SUBCMD_WRITE   1
 
#define SUBCMD_WRITEREAD   2
 
#define SUBCMD_RTREAD   4
 
#define SUBCMD_MSB_RELEASE_BUS   0x80
 
SPI Control Word bitfield definitions
#define SPICTL_CPHA_SHIFT   5
 
#define SPICTL_CPHA_MASK   0x20
 
#define SPICTL_CPHA_LEADING_EDGE   0
 
#define SPICTL_CPHA_TRAILING_EDGE   1
 
#define SPICTL_CPOL_SHIFT   4
 
#define SPICTL_CPOL_MASK   0x10
 
#define SPICTL_CPOL_ACTIVE_HIGH   0
 
#define SPICTL_CPOL_ACTIVE_LOW   1
 
#define SPICTL_CSMODE_SHIFT   3
 
#define SPICTL_CSMODE_MASK   0x08
 
#define SPICTL_CSMODE_OPENDRAIN   0
 
#define SPICTL_CSMODE_PUSHPULL   1
 
#define SPICTL_CLKRATE_SHIFT   0
 
#define SPICTL_CLKRATE_MASK   0x07
 
#define SPICTL_CLKRATE_12M   0
 
#define SPICTL_CLKRATE_6M   1
 
#define SPICTL_CLKRATE_3M   2
 
#define SPICTL_CLKRATE_1M5   3
 
#define SPICTL_CLKRATE_750K   4
 
#define SPICTL_CLKRATE_375K   5
 
#define SPICTL_CLKRATE_187K5   6
 
#define SPICTL_CLKRATE_93K75   7
 
Return values for BOOL-returning functions
#define bRESULT_PASS   TRUE
 
#define bRESULT_FAIL   FALSE
 
CP2130 General Errors
#define USB_SPI_ERRCODE_SUCCESS   0x00
 
#define USB_SPI_ERRCODE_ALLOC_FAILURE   0x01
 
#define USB_SPI_ERRCODE_INVALID_ENUM_VALUE   0x02
 
#define USB_SPI_ERRCODE_NULL_POINTER   0x03
 
#define USB_SPI_ERRCODE_INVALID_CHANNEL_INDEX   0x04
 
#define USB_SPI_ERRCODE_INVALID_GPIO_MODE   0x05
 
#define USB_SPI_ERRCODE_UNKNOWN_ERROR   0xFFFFFFFF
 
CP2130 API Errors
#define USB_SPI_ERRCODE_INVALID_PARAMETER   0x10
 
#define USB_SPI_ERRCODE_INVALID_DEVICE_OBJECT   0x11
 
CP2130 Device Errors
#define USB_SPI_ERRCODE_DEVICE_NOT_FOUND   0x20
 
#define USB_SPI_ERRCODE_USB_DEVICE_NOT_OPENED   0x21
 
#define USB_SPI_ERRCODE_INVALID_HANDLE   0x22
 
CP2130 Device Hardware Interface Errors
#define USB_SPI_ERRCODE_HWIF_DEVICE_ERROR   0x30
 
#define USB_SPI_ERRCODE_HWIF_TRANSFER_TIMEOUT   0x31
 
CP2130 Data Transfer Errors
#define USB_SPI_ERRCODE_CONTROL_TRANSFER_ERROR   0x50
 
#define USB_SPI_ERRCODE_INVALID_TRANSFER_SIZE   0x51
 
#define USB_SPI_ERRCODE_PIPE_INIT_FAIL   0x60
 
#define USB_SPI_ERRCODE_PIPE_QUERY_FAIL   0x61
 
#define USB_SPI_ERRCODE_PIPE_WRITE_FAIL   0x62
 
#define USB_SPI_ERRCODE_PIPE_READ_FAIL   0x63
 
#define USB_SPI_ERRCODE_PIPE_ABORT_FAIL   0x64
 
#define USB_SPI_ERRCODE_PIPE_FLUSH_FAIL   0x65
 
#define USB_SPI_ERRCODE_PIPE_INVALID_ID   0x66
 
#define USB_SPI_ERRCODE_READ_THREAD_CREATE_FAILURE   0x70
 
#define USB_SPI_ERRCODE_READ_THREAD_NOT_RUNNING   0x71
 
#define USB_SPI_ERRCODE_READ_THREAD_START_FAILURE   0x72
 
#define USB_SPI_ERRCODE_DEVICE_RETURNED_TOO_MUCH_DATA   0x80
 

Typedefs

Windows Type Definitions
typedef int BOOL
 
typedef unsigned char BYTE
 
typedef unsigned short WORD
 
typedef unsigned long DWORD
 
typedef char * LPSTR
 
typedef const char * LPCSTR
 
Variable type definitions
typedef void * CP213x_DEVICE
 
typedef int USB_SPI_STATUS
 

Functions

Exported API Functions
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetLibraryVersion (BYTE *major, BYTE *minor, BOOL *release)
 Get the Interface Library version numbers. More...
 
CP2130 Device Management
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetGuid (LPGUID guid)
 Return the GUID used for device managment. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetGuid (LPGUID guid)
 Set the GUID used for device managment. More...
 
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_OpenByIndex (DWORD deviceIndex, CP213x_DEVICE *phDevice)
 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_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_Close (CP213x_DEVICE hDevice)
 Close device handle. More...
 
SLAB_USB_SPI_API BOOL WINAPI CP213x_IsOpened (CP213x_DEVICE hDevice)
 
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_GetDeviceVersion (CP213x_DEVICE hDevice, BYTE *majorVersion, BYTE *minorVersion)
 Get the read-only device version. More...
 
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_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_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_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[SIZE_PIN_CONFIG])
 
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_GetLock (CP213x_DEVICE hDevice, WORD *lockValue)
 Get the Lock values. 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_ReadProm (CP213x_DEVICE hDevice, BYTE pReadBuf[])
 Read device EPROM configuration. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_WriteProm (CP213x_DEVICE hDevice, BYTE pWriteBuf[])
 Write device EPROM configuration. More...
 
CP2130 SPI Configuration and Transfer Operations
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_SetSpiControlByte (CP213x_DEVICE hDevice, BYTE channel, BYTE controlByte)
 Set the SPI control word. 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_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_GetChipSelect (CP213x_DEVICE hDevice, WORD *channelCsEnable, WORD *pinCsEnable)
 Get SPI chip select control word. 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_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_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_TransferReadAsync (CP213x_DEVICE hDevice, DWORD totalSize, DWORD blockSize, BOOL releaseBusAfterTransfer)
 Perform SPI Read (asynchronous) 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_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_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_GetRtrState (CP213x_DEVICE hDevice, BYTE *isStopped)
 Read status of RTR operation. 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_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_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...
 
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_SetFifoFullThreshold (CP213x_DEVICE hDevice, BYTE fifoFullThreshold)
 Set the FIFO full threshold. More...
 
CP2130 GPIO and Auxiliary-Function Pins
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_SetGpioModeAndLevel (CP213x_DEVICE hDevice, BYTE channel, BYTE mode, BYTE level)
 Set the GPIO mode control. 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_SetGpioValues (CP213x_DEVICE hDevice, WORD mask, WORD gpioValues)
 Set the GPIO values. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetEventCounter (CP213x_DEVICE hDevice, BYTE *mode, WORD *eventCount)
 Get the Event Count value. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetEventCounter (CP213x_DEVICE hDevice, BYTE mode, WORD eventCount)
 Set the Event Count value. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_GetClockDivider (CP213x_DEVICE hDevice, BYTE *clockDivider)
 Get clock divider. More...
 
SLAB_USB_SPI_API
USB_SPI_STATUS WINAPI 
CP213x_SetClockDivider (CP213x_DEVICE hDevice, BYTE clockDivider)
 Set clock divider. More...
 

CP213x Customization Masks

#define CP213x_LOCK_PRODUCT_STR_1   0x0001
 
#define CP213x_LOCK_PRODUCT_STR_2   0x0002
 
#define CP213x_LOCK_SERIAL_STR   0x0004
 
#define CP213x_LOCK_PIN_CONFIG   0x0008
 
#define CP213x_LOCK_VID   0x0100
 
#define CP213x_LOCK_PID   0x0200
 
#define CP213x_LOCK_POWER   0x0400
 
#define CP213x_LOCK_POWER_MODE   0x0800
 
#define CP213x_LOCK_RELEASE_VERSION   0x1000
 
#define CP213x_LOCK_MFG_STR_1   0x2000
 
#define CP213x_LOCK_MFG_STR_2   0x4000
 
#define CP213x_LOCK_TRANSFER_PRIORITY   0x8000
 
#define CP213x_SET_VID   0x01
 
#define CP213x_SET_PID   0x02
 
#define CP213x_SET_POWER   0x04
 
#define CP213x_SET_POWER_MODE   0x08
 
#define CP213x_SET_RELEASE_VERSION   0x10
 
#define CP213x_SET_TRANSFER_PRIORITY   0x80
 
#define MFG_STRLEN   62
 
#define PRODUCT_STRLEN   62
 
#define SERIAL_STRLEN   30
 
#define CP213x_INDEX_GPIO_0   0
 
#define CP213x_INDEX_GPIO_1   1
 
#define CP213x_INDEX_GPIO_2   2
 
#define CP213x_INDEX_GPIO_3   3
 
#define CP213x_INDEX_GPIO_4   4
 
#define CP213x_INDEX_GPIO_5   5
 
#define CP213x_INDEX_GPIO_6   6
 
#define CP213x_INDEX_GPIO_7   7
 
#define CP213x_INDEX_GPIO_8   8
 
#define CP213x_INDEX_GPIO_9   9
 
#define CP213x_INDEX_GPIO_10   10
 
#define CP213x_MASK_SCK   0x0001
 
#define CP213x_MASK_MISO   0x0002
 
#define CP213x_MASK_MOSI   0x0004
 
#define CP213x_MASK_GPIO_0   0x0008
 
#define CP213x_MASK_GPIO_1   0x0010
 
#define CP213x_MASK_GPIO_2   0x0020
 
#define CP213x_MASK_GPIO_3   0x0040
 
#define CP213x_MASK_GPIO_4   0x0080
 
#define CP213x_MASK_GPIO_5   0x0100
 
#define CP213x_MASK_GPIO_6   0x0400
 
#define CP213x_MASK_GPIO_7   0x0800
 
#define CP213x_MASK_GPIO_8   0x1000
 
#define CP213x_MASK_GPIO_9   0x2000
 
#define CP213x_MASK_GPIO_10   0x4000
 
enum  SET_STATUS
 
typedef char MFG_STR [MFG_STRLEN]
 
typedef char PRODUCT_STR [PRODUCT_STRLEN]
 
typedef char SERIAL_STR [SERIAL_STRLEN]
 

Type and structure definitions

#define SPI_INTERBYTE_DELAY_MASK   0x01
 
#define SPI_CS_POSTASSERT_DELAY_MASK   0x02
 
#define SPI_CS_PREDEASSERT_DELAY_MASK   0x04
 
#define SPI_CS_TOGGLE_MASK   0x08
 
typedef struct DEVICE_DESCRIPTOR DEVICE_DESCRIPTOR
 This struct has the same format as _USB_DEVICE_DESCRIPTOR, as defined in Windows usb100.h. More...
 
typedef struct DEVICE_DESCRIPTORPDEVICE_DESCRIPTOR
 
typedef struct SPI_CMD SPI_CMD
 SPI Command Word.
 
typedef struct SPI_CMDPSPI_CMD
 

Detailed Description

This file defines the API of the CP2130 Interface Library.

Typedef Documentation

This struct has the same format as _USB_DEVICE_DESCRIPTOR, as defined in Windows usb100.h.

Using this typedef enables portable application code.

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