AN496
CP2112 HID USB-
TO
- S M B
US
A P I S
PECIFICATION
1. Introduction
The Silicon Labs HID USB-to-SMBus interface library provides a simple API to configure and operate CP2112
devices. The library provides interface abstraction so that users can develop their application without writing any
USB HID Code. C libraries implementing the CP2112 Interface Specification are provided for Windows 2000 and
later and Mac OS X 10.5 and later. Similarly, various include files are provided to import library functions into
C# .NET, and Visual Basic .NET. Refer to the table below for complete details.
User Application
HID to SMBus Library
HID Driver
(Provided by OS)
USB Root Hub
PC
USB
CP2112 HID USB-to-SMBus
Bridge
SMBus Devices
Figure 1. System Architecture Diagram
Table 1. CP2112 Include Files
Operating System
Windows 2000 and later
Library
SLABHIDtoSMBus.dll*
Include Files
SLABCP2112.h (C/C++)
SLABCP2112.cs (C# .NET)
SLABCP2112.vb (VB .NET)
SLABCP2112.h (C, C++, Obj-C)
Types.h (Compatibility)
Version
1.2
Mac OS X 10.5 and later
libSLABHIDtoSMBus.dylib
1.0
*Note:
Requires SLABHIDDevice.dll version 1.5 during runtime.
Rev. 0.2 11/10
Copyright © 2010 by Silicon Laboratories
AN496
AN496
2. API Functions
Table 2. API Functions Table
Definition
HidSmbus_GetNumDevices()
HidSmbus_GetString()
HidSmbus_GetOpenedString()
HidSmbus_GetIndexedString()
HidSmbus_GetOpenedIndexedString()
HidSmbus_GetAttributes()
HidSmbus_GetOpenedAttributes()
HidSmbus_Open()
HidSmbus_Close()
HidSmbus_IsOpened()
HidSmbus_ReadRequest()
HidSmbus_AddressReadRequest()
HidSmbus_ForceReadResponse()
HidSmbus_GetReadResponse()
HidSmbus_WriteRequest()
HidSmbus_TransferStatusRequest()
Description
Returns the number of devices connected
Returns a string for a device by index
Returns a string for a device by device object pointer
Returns an indexed USB string descriptor by index
(Windows Only)
Returns an indexed USB string descriptor by device object
pointer (Windows Only)
Returns the VID, PID, and release number for a device by
index
Returns the VID, PID and release number for a device by
device object pointer
Opens a device and returns a device object pointer
Cancels pending IO and closes a device
Returns the device opened status
Initiates a fixed length read request to the desired slave
device
Initiates a fixed length read request to the desired slave
device specifying the memory address to read
Forces the device to generate and send a read response
Returns a read response if available
Initiates a write request to the desired slave device
Requests the status of the current read or write request
Page #
3
4
5
6
6
7
7
8
8
9
9
10
11
12
13
13
14
15
16
16
16
17
18
HidSmbus_GetTransferStatusResponse() Returns the status of the current read or write request
HidSmbus_CancelTransfer()
HidSmbus_CancelIo()
HidSmbus_SetTimeouts()
HidSmbus_GetTimeouts()
HidSmbus_SetSmbusConfig()
HidSmbus_GetSmbusConfig()
Cancels the current read or write request
Cancels pending HID reads and writes (Windows Only)
Sets the response timeouts for a device
Gets the response timeouts for a device
Sets the bit rate, master address, timeouts, and transfer
settings
Gets the bit rate, master address, timeouts, and transfer
settings
2
Rev. 0.2
AN496
Table 2. API Functions Table (Continued)
Definition
HidSmbus_Reset()
HidSmbus_SetGpioConfig()
HidSmbus_GetGpioConfig()
HidSmbus_ReadLatch()
HidSmbus_WriteLatch()
HidSmbus_GetPartNumber()
HidSmbus_GetLibraryVersion()
HidSmbus_GetHidLibraryVersion()
HidSmbus_GetHidGuid()
Description
Resets the device with re-enumeration
Sets GPIO direction and mode configuration
Gets GPIO direction and mode configuration
Gets the GPIO latch value
Sets the GPIO latch value using a bitmask
Gets the device part number and version
Gets the DLL Library version
Gets the HID Device Interface Library version
Gets the HID GUID (Windows
®
only)
Page #
18
19
20
21
21
22
22
22
22
2.1. HidSmbus_GetNumDevices
Description:
Prototype:
Parameters:
This function returns the number of devices connected to the host with matching vendor and
product ID (VID, PID).
HID_SMBUS_STATUS HidSmbus_GetNumDevices (DWORD* numDevices, WORD vid,
WORD pid)
1.
numDevices
returns the number of devices connected on return.
2.
vid
filters device results by vendor ID. If both
vid
and
pid
are set to 0x0000, then HID devices
will not be filtered by VID/PID.
3.
pid
filters device results by product ID. If both
vid
and
pid
are set to 0x0000, then HID devices
will not be filtered by VID/PID.
Return Value:
HID_SMBUS_STATUS = HID_SMBUS_SUCCESS
HID_SMBUS_INVALID_PARAMETER
Rev. 0.2
3
AN496
2.2. HidSmbus_GetString
Description:
This function returns a null-terminated vendor ID string, product ID string, serial string, device path
string, manufacturer string, or product string for the device specified by an index passed in
deviceNum.
The index for the first device is 0, and the last device is the value returned by
HidSmbus_GetNumDevices()
– 1.
HID_SMBUS_STATUS HidSmbus_GetString (DWORD deviceNum, WORD vid, WORD
pid, char* deviceString, DWORD options)
1.
deviceNum
is the index of the device for which the string is desired.
2.
vid
filters device results by vendor ID. If both
vid
and
pid
are set to 0x0000, then HID devices
will not be filtered by VID/PID.
3.
pid
filters device results by product ID. If both
vid
and
pid
are set to 0x0000, then HID devices
will not be filtered by VID/PID.
4.
deviceString
is a variable of type HID_SMBUS_DEVICE_STR, which will contain a null-
terminated ASCII device string on return. The string is 260 bytes on Windows and 512 bytes
on Mac OS X.
5.
options
determines if
deviceString
will contain a vendor ID string, product ID string, serial
string, device path string, manufacturer string, or product string.
Definition
HID_SMBUS_GET_VID_STR
HID_SMBUS_GET_PID_STR
HID_SMBUS_GET_PATH_STR
HID_SMBUS_GET_SERIAL_STR
HID_SMBUS_GET_MANUFACTURER_STR
HID_SMBUS_GET_PRODUCT_STR
Value
0x01
0x02
0x03
0x04
0x05
0x06
Length
5
5
260/512
256
256
256
Description
Vendor ID
Product ID
Device path
Serial string
Manufacturer String
Product String
Prototype:
Parameters:
Return Value:
HID_SMBUS_STATUS = HID_SMBUS_SUCCESS
HID_SMBUS_DEVICE_NOT_FOUND
HID_SMBUS_INVALID_PARAMETER
HID_SMBUS_DEVICE_ACCESS_ERROR
4
Rev. 0.2
AN496
2.3. HidSmbus_GetOpenedString
Description:
Prototype:
Parameters:
This function returns a null-terminated vendor ID string, product ID string, serial string, device path
string, manufacturer string, or product string for the device specified by
device.
HID_SMBUS_STATUS
HidSmbus_GetOpenedString
(HID_SMBUS_DEVICE
device,
char* deviceString, DWORD options)
1.
device
is the device object pointer as returned by
HidSmbus_Open().
2.
deviceString
is a variable of type HID_SMBUS_DEVICE_STR, which will contain a null-
terminated ASCII device string on return. The string is 260 bytes on Windows and 512 bytes
on Mac OS X.
3.
options
determines if
deviceString
will contain a vendor ID string, product ID string, serial
string, device path string, manufacturer string, or product string.
Definition
HID_SMBUS_ GET_VID_STR
HID_SMBUS_ GET_PID_STR
HID_SMBUS_ GET_PATH_STR
HID_SMBUS_ GET_SERIAL_STR
HID_SMBUS_GET_MANUFACTURER_STR
HID_SMBUS_GET_PRODUCT_STR
Value
0x01
0x02
0x03
0x04
0x05
0x06
Length
5
5
260/512
256
256
256
Description
Vendor ID
Product ID
Device path
Serial string
Manufacturer String
Product String
Return Value:
HID_SMBUS_STATUS = HID_SMBUS_SUCCESS
HID_SMBUS_INVALID_DEVICE_OBJECT
HID_SMBUS_INVALID_PARAMETER
HID_SMBUS_DEVICE_ACCESS_ERROR
Rev. 0.2
5