SLAA453A january   2011  – may 2023

 

  1.   1
  2. 1MSP430™ USB HID Windows API Programmer's Guide
  3. 2Introduction
  4. 3Implementation
    1. 3.1 Overview
    2. 3.2 File Organization
    3. 3.3 System Requirements
    4. 3.4 MSP430 USB API Stacks
    5. 3.5 How Windows Maps Physical USB HID Devices to the Host Application
    6. 3.6 Locating a Specific HID Device/Interface on the System and Opening It
    7. 3.7 Sending/Receiving Data
    8. 3.8 Detecting the Dynamic Connection/Disconnection of HID Devices
  5. 4Function Call Reference
    1. 4.1 Device Connection Management and Initialization Calls
      1. 4.1.1 VOID HID_Init(struct strHidDevice* pstrHidDevice)
      2. 4.1.2 DWORD HID_GetSerNums(WORD vid, WORD pid, struct strTrackSerialNumbers *serialNumList)
      3. 4.1.3 DWORD HID_GetNumOfInterfaces(WORD vid, WORD pid, DWORD numSerNums)
      4. 4.1.4 BYTE HID_Open(struct strHidDevice* pstrHidDevice, WORD vid, WORD pid, DWORD deviceIndex, char serialNumber[SERNUM_LEN], DWORD totalDevNum, DWORD totalSerNum)
      5. 4.1.5 BYTE HID_Close(struct strHidDevice* pstrHidDevice)
      6. 4.1.6 BYTE HID_GetVersionNumber(struct strHidDevice* pstrHidDevice, USHORT * VersionNumber)
    2. 4.2 Sending/Receiving Data
      1. 4.2.1 BYTE HID_WriteFile(struct strHidDevice* pstrHidDevice, BYTE* buffer, DWORD bufferSize, DWORD* bytesSent)
      2. 4.2.2 BYTE HID_ReadFile(struct strHidDevice* pStrHidDevice, BYTE* buffer, DWORD bufferSize, DWORD* bytesReturned)
    3. 4.3 Plug and Play Management
      1. 4.3.1 BYTE HID_RegisterForDeviceNotification(HWND hWnd, HDEVNOTIFY* diNotifyHandle)
      2. 4.3.2 BYTE HID_UnregisterForDeviceNotification(HDEVNOTIFY* diNotifyHandle)
      3. 4.3.3 BOOL IsDeviceAffected(struct strHidDevice* pstrHidDevice)
  6. 5Demo Application
  7. 6MSP430 USB Tool Suite
  8.   HID Interface Data Structure: strHidDevice
  9.   Format of Reports on HID-Datapipe Devices
  10.   C References
  11.   C Revision History

Introduction

The USB Human Interface Device (HID) class is one of the most widely-supported device classes among operating systems. Although originally developed for mice and keyboards, it has many advantages in general-purpose usage.

A common choice for general-purpose USB applications is the virtual COM port, which can be implemented using the Communications Device Class (CDC). COM ports are easy to implement on host platforms, and they are well understood by developers. A downside is that USB virtual COM port solutions for Windows machines require the end user to go through a device installation process. In addition to being a minor hassle, this process can go wrong if the user chooses the wrong options. Further, some users in corporate environments do not have administrative rights, so they are not able to do device installations without the help of a network administrator. In contrast, an HID device loads silently, bypassing all these issues.

HID does have a few disadvantages. Compared to virtual COM ports, many software engineers are unfamiliar with its use. HID relies on "reports" to carry the data, and often these complex formats provide no real value to a general-purpose application. The bandwidth on basic HID implementations is limited to 64KB/sec.

To make up for these disadvantages, TI provides a Windows HID API and demo project. It is streamlined for use with the datapipe interface that can be implemented by the MSP430 HID API stack, which eliminates the need to create HID reports. It works with composite HID devices, allowing multiple HID interfaces to easily be put in composite within the USB device, multiplying the bandwidth.

Used together, the MSP430 HID API stack and Windows HID API form an end-to-end solution that is more advantageous than virtual COM ports for many general-purpose applications.

For the USB support software for MSP430 MCUs, see the MSP430 USB Developers Package at https://www.ti.com/tool/MSP430USBDEVPACK.