SLAB_USB_SPI  1.0
Silicon Labs CP2130 USB-to-SPI Interface Library
SLAB_USB_SPI Documentation

Introduction

The Silicon Labs USB to SPI Library provides an application programming interface (API) consists of a low-level API to interface directly at the USB device class with WinUSB transfers.

Library Release Files
Operating System
Library
Include Files
Version
Windows 7 and later SLAB_USB_SPI.dll SLAB_USB_SPI.h (C, C++)
1.0

Library Usage

The host library is released with the following files:

C/C++ Projects

The host library is designed to be universally compatible with most programming languages and is exported in C.

Follow these steps to use the library in a C/C++ project:

  1. Add SLAB_USB_SPI.lib as a linker input dependency or
    Add the following code: #pragma comment (lib, "SLAB_USB_SPI.lib")
  2. Include SLAB_USB_SPI.h as needed.
  3. Provide SLAB_USB_SPI.dll with the executable (.exe) file.

Thread Safety

The host library and associated functions are not thread safe. This means that calling library functions simultaneously from multiple threads may have undesirable effects.

To use the library functions in more than one thread, the user should do the following:

  1. Call library functions from within a critical section such that only a single function is being called at any given time. If a function is being called in one thread, then the user must prevent another thread from calling any function until the first function returns.

Surprise Removal

Using the CP2130 Device GUID, Windows applications or services can register for the WM_DEVICECHANGE Windows message. Once registered, the application will receive device arrival and removal notifications for all USB devices with matching GUID. The application should retrieve the device path to filter devices. Similarly if a DBT_DEVICEREMOVECOMPLETE message is received, then the application should check to see if the device path matches the device path of any connected devices. If this is the case, then the device was removed, and the application should close the device. Also if a DBT_DEVICEARRIVAL message is received, then the application might add the new device to a device list so that users can select any USB device matching the required GUID. See accompanying example code for information on how to implement surprise removal and device arrival. Search for Knowledge Base Article # 222649, 311158, and 311153 for programming examples for C++, Visual Basic .NET, and Visual C#.