USB HID Composite Example

nRF5 SDK v12.2.0

This information applies to the nRF52840 SoC only.

This example uses the USB HID class modules . See the documentation of these modules for links to relevant specification documents.

This example shows how to use two HID classes as one composite device. A development kit connected to the host computer will enumerate as two independent HID classes:

  • HID mouse
  • HID keyboard
Note
You can reduce the functionality of this composite example to a single mouse or a single keyboard. To do that, modify the definitions of CONFIG_HAS_MOUSE and CONFIG_HAS_KBD.

Setup

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\usbd_hid_composite

LED assignments:

  • LED 1 shows the USB bus state:
    • ON: State RESUME
    • OFF: State SUSPEND
  • LED 2 shows the USB device library status:
    • ON: USB library STARTED
    • OFF: USB library STOPPED
  • LED 3 shows that a USB HID report IN has been sent:
    • TOGGLE - Report sent
  • LED 4 shows that a USB HID report OUT has been received:
    • TOGGLE - Report received

Button assignments:

  • Button 1 moves the HID mouse cursor.
  • Button 2 presses the HID mouse left button.
  • Button 3 presses the HID keyboard Shift key.
  • Button 4 presses the HID keyboard "g" letter.

Testing

Test the USB HID Composite Example application by performing the following steps:

  1. Compile and program the application.
  2. Connect the development kit to the host computer.
  3. The device will enumerate as a HID mouse and a HID keyboard class.
  4. Press the buttons on the development kit and observe the results on the host computer and on the LEDs.