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:
- 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 keyboard CAPSLOCK state:
- ON: CAPSLOCK active
- OFF: CAPSLOCK disabled
- LED 2 shows the keyboard NUMLOCK state:
- ON: NUMLOCK active
- OFF: NUMLOCK disabled
- LED 3 shows that a USB HID report has been received or transmitted:
- TOGGLE: Report received or transmitted
- LED 4 shows the USB device library status:
- ON: USB library STARTED
- OFF: USB library STOPPED
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:
- Compile and program the application.
- Connect the development kit to the host computer.
- The device will enumerate as a HID mouse and a HID keyboard class.
- Press the buttons on the development kit and observe the results on the host computer and on the LEDs.
- Press NUMLOCK and CAPSLOCK keys on the keyboard and observe the LEDs state change on the board.