6 #ifndef HOST_LIB_SLABHIDUART_INCLUDE_SLABHIDTOUART_H_INCLUDED_XF4QYQM3BK 7 #define HOST_LIB_SLABHIDUART_INCLUDE_SLABHIDTOUART_H_INCLUDED_XF4QYQM3BK 46 #include "silabs_defs.h" 47 #include "silabs_sal.h" 60 #if defined(HID_TO_UART_EXPORTS) 61 #define HID_TO_UART_API 63 #if defined(SILABS_STATIC_LINK) 64 #define HID_TO_UART_API extern 65 #pragma comment(lib, "SLABHIDtoUART.static.lib") 66 #else // defined(SILABS_STATIC_LINK) 67 #define HID_TO_UART_API __declspec(dllimport) 68 #pragma comment(lib, "SLABHIDtoUART.lib") 69 #endif // defined(SILABS_STATIC_LINK) 70 #endif // defined(HID_TO_UART_EXPORTS) 72 #define HID_TO_UART_API 82 #if !defined(USE_LEGACY_HID_UART_STATUS) 83 typedef enum _HID_UART_STATUS {
108 #else // defined(USE_LEGACY_HID_UART_STATUS) 115 #define HID_UART_SUCCESS 0x00 116 #define HID_UART_DEVICE_NOT_FOUND 0x01 117 #define HID_UART_INVALID_HANDLE 0x02 118 #define HID_UART_INVALID_DEVICE_OBJECT 0x03 119 #define HID_UART_INVALID_PARAMETER 0x04 120 #define HID_UART_INVALID_REQUEST_LENGTH 0x05 122 #define HID_UART_READ_ERROR 0x10 123 #define HID_UART_WRITE_ERROR 0x11 124 #define HID_UART_READ_TIMED_OUT 0x12 125 #define HID_UART_WRITE_TIMED_OUT 0x13 126 #define HID_UART_DEVICE_IO_FAILED 0x14 127 #define HID_UART_DEVICE_ACCESS_ERROR 0x15 128 #define HID_UART_DEVICE_NOT_SUPPORTED 0x16 129 #define HID_UART_INVALID_CONFIG_VERSION 0x17 131 #define HID_UART_UNKNOWN_ERROR SILABS_STATUS_UNKNOWN_ERROR 132 #endif // defined(USE_LEGACY_HID_UART_STATUS) 142 #define HID_UART_GET_VID_STR 0x01 143 #define HID_UART_GET_PID_STR 0x02 144 #define HID_UART_GET_PATH_STR 0x03 145 #define HID_UART_GET_SERIAL_STR 0x04 146 #define HID_UART_GET_MANUFACTURER_STR 0x05 147 #define HID_UART_GET_PRODUCT_STR 0x06 151 #define HID_UART_DEVICE_STRLEN 260 152 typedef char HID_UART_DEVICE_STR[HID_UART_DEVICE_STRLEN]; 164 #define HID_UART_PARITY_ERROR 0x01 165 #define HID_UART_OVERRUN_ERROR 0x02 167 #define HID_UART_LINE_BREAK_INACTIVE 0x00 169 #define HID_UART_LINE_BREAK_ACTIVE 0x01 172 #define HID_UART_FIVE_DATA_BITS 0x00 177 #define HID_UART_SIX_DATA_BITS 0x01 178 #define HID_UART_SEVEN_DATA_BITS 0x02 179 #define HID_UART_EIGHT_DATA_BITS 0x03 182 #define HID_UART_NO_PARITY 0x00 187 #define HID_UART_ODD_PARITY 0x01 188 #define HID_UART_EVEN_PARITY 0x02 189 #define HID_UART_MARK_PARITY 0x03 190 #define HID_UART_SPACE_PARITY 0x04 193 #define HID_UART_SHORT_STOP_BIT 0x00 201 #define HID_UART_LONG_STOP_BIT 0x01 204 #define HID_UART_NO_FLOW_CONTROL 0x00 209 #define HID_UART_RTS_CTS_FLOW_CONTROL 0x01 215 #define HID_UART_MIN_READ_SIZE 1 216 #define HID_UART_MAX_READ_SIZE 32768 217 #define HID_UART_MIN_WRITE_SIZE 1 218 #define HID_UART_MAX_WRITE_SIZE 4096 228 #define HID_UART_LOCK_PRODUCT_STR_1 0x0001 229 #define HID_UART_LOCK_PRODUCT_STR_2 0x0002 230 #define HID_UART_LOCK_SERIAL_STR 0x0004 231 #define HID_UART_LOCK_PIN_CONFIG 0x0008 232 #define HID_UART_LOCK_VID 0x0100 233 #define HID_UART_LOCK_PID 0x0200 234 #define HID_UART_LOCK_POWER 0x0400 235 #define HID_UART_LOCK_POWER_MODE 0x0800 236 #define HID_UART_LOCK_RELEASE_VERSION 0x1000 237 #define HID_UART_LOCK_FLUSH_BUFFERS 0x2000 238 #define HID_UART_LOCK_MFG_STR_1 0x4000 239 #define HID_UART_LOCK_MFG_STR_2 0x8000 245 #define HID_UART_LOCK_UNLOCKED 1 246 #define HID_UART_LOCK_LOCKED 0 249 #define HID_UART_BUS_POWER_MAX 0xFA 252 #define HID_UART_BUS_POWER 0x00 256 #define HID_UART_SELF_POWER_VREG_DIS 0x01 257 #define HID_UART_SELF_POWER_VREG_EN 0x02 260 #define HID_UART_FLUSH_TX_OPEN 0x01 264 #define HID_UART_FLUSH_TX_CLOSE 0x02 265 #define HID_UART_FLUSH_RX_OPEN 0x04 266 #define HID_UART_FLUSH_RX_CLOSE 0x08 269 #define HID_UART_SET_VID 0x01 274 #define HID_UART_SET_PID 0x02 275 #define HID_UART_SET_POWER 0x04 276 #define HID_UART_SET_POWER_MODE 0x08 277 #define HID_UART_SET_RELEASE_VERSION 0x10 278 #define HID_UART_SET_FLUSH_BUFFERS 0x20 280 #define HID_UART_SET_IGNORE 0 282 #define HID_UART_SET_PROGRAM 1 285 #define HID_UART_MFG_STRLEN 62 289 #define HID_UART_PRODUCT_STRLEN 62 290 #define HID_UART_SERIAL_STRLEN 30 312 #define HID_UART_GPIO_MODE_INPUT 0x00 313 #define HID_UART_GPIO_MODE_OUTPUT_OD 0x01 314 #define HID_UART_GPIO_MODE_OUTPUT_PP 0x02 315 #define HID_UART_GPIO_MODE_FUNCTION1 0x03 316 #define HID_UART_GPIO_MODE_FUNCTION2 0x04 319 #define HID_UART_VALUE_SUSPEND_LO 0 323 #define HID_UART_VALUE_SUSPEND_HI 1 326 #define HID_UART_MODE_SUSPEND_OD 0 330 #define HID_UART_MODE_SUSPEND_PP 1 333 #define HID_UART_MODE_RS485_ACTIVE_LO 0x00 337 #define HID_UART_MODE_RS485_ACTIVE_HI 0x01 348 typedef unsigned char U8;
351 typedef unsigned short U16;
359 #endif // __cplusplus 376 HidUart_GetNumDevices(_Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ LPDWORD lpdwNumDevices, _In_ _Pre_defensive_
const WORD vid, _In_ _Pre_defensive_
const WORD pid);
405 HidUart_GetString(_In_ _Pre_defensive_
const DWORD deviceNum, _In_ _Pre_defensive_
const WORD vid, _In_ _Pre_defensive_
const WORD pid, _Out_ _Pre_defensive_
char* deviceString, _In_ _Pre_defensive_
const DWORD options);
453 HidUart_GetIndexedString(_In_ _Pre_defensive_
const DWORD deviceNum, _In_ _Pre_defensive_
const WORD vid, _In_ _Pre_defensive_
const WORD pid, _In_ _Pre_defensive_
const DWORD stringIndex,
char* deviceString);
498 HidUart_GetAttributes(_In_ _Pre_defensive_
const DWORD deviceNum, _In_ _Pre_defensive_
const WORD vid, _In_ _Pre_defensive_
const WORD pid, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* deviceVid, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* devicePid, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pDeviceReleaseNumber);
517 HidUart_GetOpenedAttributes(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pDeviceVid, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pDevicePid, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pDeviceReleaseNumber);
544 HidUart_Open(_Out_
HID_UART_DEVICE* pdevice, _In_ _Pre_defensive_
const DWORD deviceNum, _In_ _Pre_defensive_
const WORD vid, _In_ _Pre_defensive_
const WORD pid);
634 HidUart_Read(_In_ _Pre_defensive_
const HID_UART_DEVICE device,
BYTE* buffer, _In_ _Pre_defensive_
const DWORD numBytesToRead, _Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ DWORD* pNumBytesRead);
665 HidUart_Write(_In_ _Pre_defensive_
const HID_UART_DEVICE device,
BYTE* buffer, _In_ _Pre_defensive_
const DWORD numBytesToWrite, _Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ DWORD* pNumBytesWritten);
720 HidUart_SetTimeouts(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _In_ _Pre_defensive_
const DWORD ReadTimeoutInMilliseconds, _In_ _Pre_defensive_
const DWORD WriteTimeoutInMilliseconds);
738 HidUart_GetTimeouts(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ DWORD* pReadTimeoutInMilliseconds, _Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ DWORD* pWriteTimeoutInMilliseconds);
763 HidUart_GetUartStatus(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* transmitFifoSize, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* receiveFifoSize, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* errorStatus, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* lineBreakStatus);
787 HidUart_SetUartConfig(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _In_ _Pre_defensive_
const DWORD baudRate, _In_ _Pre_defensive_
const BYTE dataBits, _In_ _Pre_defensive_
const BYTE parity, _In_ _Pre_defensive_
const BYTE stopBits, _In_ _Pre_defensive_
const BYTE flowControl);
811 HidUart_GetUartConfig(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _Out_writes_bytes_(
sizeof(DWORD)) _Pre_defensive_ DWORD* pBaudRate, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pDataBits, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pParity, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pStopBits, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pFlowControl);
991 HidUart_GetHidGuidSafe(_Out_ GUID *pHIDGuid);
1076 HidUart_GetUsbConfig(_In_ _Pre_defensive_
const HID_UART_DEVICE device, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pVid, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pPid, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pPower, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pPowerMode, _Out_writes_bytes_(
sizeof(WORD)) _Pre_defensive_ WORD* pReleaseVersion, _Out_writes_bytes_(
sizeof(
BYTE)) _Pre_defensive_
BYTE* pFlushBuffers);
1188 #endif // __cplusplus 1192 #endif // HOST_LIB_SLABHIDUART_INCLUDE_SLABHIDTOUART_H_INCLUDED_XF4QYQM3BK HID_UART_STATUS HidUart_GetOpenedIndexedString(const HID_UART_DEVICE device, const DWORD stringIndex, char *deviceString)
This function returns a null-terminated USB string descriptor for the device specified by device...
HID_UART_STATUS HidUart_GetProductString(const HID_UART_DEVICE device, char *productString, BYTE *strlen)
Retrieves the USB product string.
HID_UART_STATUS HidUart_Write(const HID_UART_DEVICE device, BYTE *buffer, const DWORD numBytesToWrite, DWORD *pNumBytesWritten)
Write the specified number of bytes from the supplied buffer to the device. This function returns syn...
a parameter was not valid
Definition: SLABHIDtoUART.h:90
the device or device property could not be accessed.Either the device is not opened, already opened when trying to open, or an error occurred when trying to get HID information.
Definition: SLABHIDtoUART.h:98
HID_UART_STATUS HidUart_SetUartEnable(const HID_UART_DEVICE device, const BOOL enable)
Enables or disables the UART.
HID_UART_STATUS HidUart_FlushBuffers(const HID_UART_DEVICE device, const BOOL bFlushTransmit, const BOOL bFlushReceive)
Flushes the receive buffer in the device and the HID driver and/or the transmit buffer in the device...
HID_UART_STATUS HidUart_GetOpenedString(const HID_UART_DEVICE device, char *deviceString, const DWORD options)
This function returns a null-terminated vendor ID string, product ID string, serial number string...
HID_UART_STATUS HidUart_GetHidLibraryVersion(BYTE *pMajor, BYTE *pMinor, BOOL *pIsReleaseBuild)
Returns the version of the underlying HID Device Interface Library that is currently in use...
#define WINAPI
Win API.
Definition: SLABHIDtoUART.h:73
the current device does not support the corresponding action
Definition: SLABHIDtoUART.h:99
HID_UART_STATUS
Definition: SLABHIDtoUART.h:85
HID_UART_STATUS HidUart_CancelIo(const HID_UART_DEVICE device)
cancels any pending HID reads and writes. (Windows only)
HID_UART_STATUS HidUart_SetManufacturingString(const HID_UART_DEVICE device, char *manufacturingString, const BYTE strlen)
Allows one-time customization of the USB manufacturing string.
HID_UART_STATUS HidUart_GetUartEnable(const HID_UART_DEVICE device, BOOL *penable)
Returns the UART enable status.
#define HID_UART_SERIAL_STRLEN
device Max Serial Number string length
Definition: SLABHIDtoUART.h:290
HID_UART_STATUS HidUart_GetHidGuid(void *pHIDGuid)
Return the GUID for HIDClass devices ("return the HID GUID") (Windows only)
HID_UART_STATUS HidUart_GetLibraryVersion(BYTE *pMajor, BYTE *pMinor, BOOL *pIsReleaseBuild)
Returns the HID-to-UART Interface Library version information.
HID_UART_STATUS HidUart_ReadLatch(const HID_UART_DEVICE device, WORD *pLatchValue)
Get the current port latch value from the device.
This value should never be returned.
Definition: SLABHIDtoUART.h:104
HID_UART_STATUS HidUart_IsOpened(const HID_UART_DEVICE device, BOOL *pbIsOpened)
Returns the device opened status.
HID_UART_STATUS HidUart_WriteLatch(const HID_UART_DEVICE device, const WORD LatchValue, const WORD LatchMask)
Sets the current port latch value to the device.
HID_UART_STATUS HidUart_SetProductString(const HID_UART_DEVICE device, char *productString, const BYTE strlen)
Allows one-time customization of the USB product string.
unsigned char U8
unsigned uint 8
Definition: SLABHIDtoUART.h:348
HID_UART_STATUS HidUart_GetAttributes(const DWORD deviceNum, const WORD vid, const WORD pid, WORD *deviceVid, WORD *devicePid, WORD *pDeviceReleaseNumber)
This function returns the device vendor ID, product ID, and device release number for the device spec...
HID_UART_STATUS HidUart_GetUartStatus(const HID_UART_DEVICE device, WORD *transmitFifoSize, WORD *receiveFifoSize, BYTE *errorStatus, BYTE *lineBreakStatus)
Returns the number of bytes held in the device receive and transmit FIFO. Returns the parity/error st...
HID_UART_STATUS HidUart_SetLock(const HID_UART_DEVICE device, const WORD lock)
Permanently locks/disables device customization.
Success.
Definition: SLABHIDtoUART.h:86
unsigned short U16
unsigned uint 16
Definition: SLABHIDtoUART.h:351
HID_UART_STATUS HidUart_StartBreak(const HID_UART_DEVICE device, const BYTE DurationInMilliseconds)
Causes the device to transmit a line break, holding the TX pin low, for the specified duration in mil...
enum _HID_UART_STATUS * PHID_UART_STATUS
API Status Return Codes pointer.
HID_UART_STATUS HidUart_GetPartNumber(const HID_UART_DEVICE device, BYTE *pPartNumber, BYTE *pVersion)
Retrieves the part number and version of the CP211x device.
HID_UART_STATUS HidUart_SetUartConfig(const HID_UART_DEVICE device, const DWORD baudRate, const BYTE dataBits, const BYTE parity, const BYTE stopBits, const BYTE flowControl)
Sets the baud rate, data bits, parity, stop bits, and flow control.
char HID_UART_SERIAL_STR[30]
HID to UART serial string.
Definition: SLABHIDtoUART.h:303
#define HID_TO_UART_API
HID to UART API.
Definition: SLABHIDtoUART.h:72
an handle parameter was not valid
Definition: SLABHIDtoUART.h:88
HID_UART_STATUS HidUart_StopBreak(const HID_UART_DEVICE device)
Stops the device from transmitting a line break.
HID_UART_STATUS HidUart_Read(const HID_UART_DEVICE device, BYTE *buffer, const DWORD numBytesToRead, DWORD *pNumBytesRead)
Reads the available number of bytes into the supplied buffer and returns the number of bytes read whi...
HID_UART_STATUS HidUart_GetLock(const HID_UART_DEVICE device, WORD *lock)
Returns the device customization lock status.
the specified device was not found
Definition: SLABHIDtoUART.h:87
HID_UART_STATUS HidUart_GetNumDevices(LPDWORD lpdwNumDevices, const WORD vid, const WORD pid)
Determines the number of devices connected to the system with matching Vendor ID and Product ID...
HID_UART_STATUS HidUart_SetSerialString(const HID_UART_DEVICE device, char *serialString, const BYTE strlen)
Allows one-time customization of the USB serial number string.
a read failed to return the number of bytes requested before the read timeout elapsed.
Definition: SLABHIDtoUART.h:95
HID_UART_STATUS HidUart_Reset(const HID_UART_DEVICE device)
Initiates a full device reset.
HID_UART_STATUS HidUart_GetIndexedString(const DWORD deviceNum, const WORD vid, const WORD pid, const DWORD stringIndex, char *deviceString)
This function returns a null-terminated USB string descriptor for the device specified by an index pa...
HID_UART_STATUS HidUart_GetSerialString(const HID_UART_DEVICE device, char *serialString, BYTE *strlen)
Retrieves the USB Serial Number string.
HID_UART_STATUS HidUart_GetOpenedAttributes(const HID_UART_DEVICE device, WORD *pDeviceVid, WORD *pDevicePid, WORD *pDeviceReleaseNumber)
This function returns the device vendor ID, product ID, and device release number for the opened devi...
unsigned char BYTE
Byte definition.
Definition: silabs_defs.h:41
HID_UART_STATUS HidUart_GetUsbConfig(const HID_UART_DEVICE device, WORD *pVid, WORD *pPid, BYTE *pPower, BYTE *pPowerMode, WORD *pReleaseVersion, BYTE *pFlushBuffers)
Retrieves USB configuration, which includes vendor ID, product ID, power, power mode, release version, and flush buffers setting.
host was unable to get or set a feature report.
Definition: SLABHIDtoUART.h:97
char HID_UART_MFG_STR[62]
HID to UART manufacturing string.
Definition: SLABHIDtoUART.h:295
the device object pointer does not match the address of a valid HID - to - UART device ...
Definition: SLABHIDtoUART.h:89
an otherwise unclassified error occurred
Definition: silabs_defs.h:280
HID_UART_STATUS HidUart_SetTimeouts(const HID_UART_DEVICE device, const DWORD ReadTimeoutInMilliseconds, const DWORD WriteTimeoutInMilliseconds)
Sets the read and write timeouts.
the read was not successful and did not time out.
Definition: SLABHIDtoUART.h:93
#define HID_UART_PRODUCT_STRLEN
device Max Product string length
Definition: SLABHIDtoUART.h:289
the write was not successful.
Definition: SLABHIDtoUART.h:94
HID_UART_STATUS HidUart_GetString(const DWORD deviceNum, const WORD vid, const WORD pid, char *deviceString, const DWORD options)
This function returns a null-terminated vendor ID string, product ID string, serial number string...
tbd
Definition: SLABHIDtoUART.h:100
HID_UART_STATUS HidUart_SetUsbConfig(const HID_UART_DEVICE device, const WORD vid, const WORD pid, const BYTE power, const BYTE powerMode, const WORD releaseVersion, const BYTE flushBuffers, const BYTE mask)
Allows one-time customization of the USB configuration, which includes vendor ID, product ID...
HID_UART_STATUS HidUart_Close(const HID_UART_DEVICE device)
Closes an opened device using the device object pointer provided by HidUart_Open().
a write failed to complete sending the number of bytes requested before the write timeout elapsed...
Definition: SLABHIDtoUART.h:96
the specified number of bytes to read or write is invalid.
Definition: SLABHIDtoUART.h:91
HID_UART_STATUS HidUart_Open(HID_UART_DEVICE *pdevice, const DWORD deviceNum, const WORD vid, const WORD pid)
Opens a device using a device number between 0 and HidUart_GetNumDevices() - 1, enables the UART...
char HID_UART_PRODUCT_STR[62]
HID to UART product string.
Definition: SLABHIDtoUART.h:299
HID_UART_STATUS HidUart_GetUartConfig(const HID_UART_DEVICE device, DWORD *pBaudRate, BYTE *pDataBits, BYTE *pParity, BYTE *pStopBits, BYTE *pFlowControl)
Gets the baud rate, data bits, parity, stop bits, and flow control.
HID_UART_STATUS HidUart_GetTimeouts(const HID_UART_DEVICE device, DWORD *pReadTimeoutInMilliseconds, DWORD *pWriteTimeoutInMilliseconds)
Returns the current read and write timeouts specified in milliseconds.
HID_UART_STATUS HidUart_GetManufacturingString(const HID_UART_DEVICE device, char *manufacturingString, BYTE *strlen)
Retrieves the USB manufacturing string.
void * HID_UART_DEVICE
HID to UART device.
Definition: SLABHIDtoUART.h:345
#define HID_UART_MFG_STRLEN
device Max Manufacturing string length
Definition: SLABHIDtoUART.h:288
the specified device is already (exclusively) opened
Definition: SLABHIDtoUART.h:102