Configuring USB composite HID mouse + keyboard

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring USB composite HID mouse + keyboard

Configuring USB composite HID mouse + keyboard

MCUXpresso Config Tools provide a USB configuration component that allows configuring USB settings in a graphical environment and generates a configuration and sample C code according to the configuration. 

This tutorial shows how to create the configuration and sample code for the mouse and keyboard HID USB class for the RT1050 EVKB board and build it using the MCUXpresso IDE. 

Note: The i.MX RT1050 EVKB board is used; however, the instructions are applicable in a similar way on other NXP EVK boards.  

Prerequisites

  1. EVKB-IMXRT1050 board 
  2. MCUXpresso IDE (v.11.x) 
  3. The SDK package for the board (EVKB-IMRT1050) 
    must be imported and ready to use into MCUXpresso IDE (in the installed SDKs) 

Steps

1. Launch MCUXpresso IDE and click Create a new C/C++ project…: 
Petr_H_1-1731334710575.png

2. Select the EVKBIMXRT1050 board in the MIMXRT1050 processor folder, click  Next: 

2024_10_09_000017.png

3. Specify the project name (for example, Test_USB). In the Middleware section, select USB > USB Device. Then click Finish:

2024_10_09_000018.png4. Unfold the drop-down menu (down arrow) of the Config tools icon (X) and launch the Peripherals tool:
2024_10_09_000019.png

5. In the Peripherals view of the Peripherals tool, click the USB1 peripheral checkbox, ignore the error for now:

2024_10_09_000020.png

6. When the Add configuration component instance dialog appears, select the USB configuration component, click  OK:

2024_10_09_000021.png

6. The USB configuration component instance is added. As it requires the component for MPU initialization, click the + icon to add it. 

2024_10_09_000022.png

Confirm the selection of the MPU utility component in the dialog that appeared.

2024_10_09_000023.png

Keep the MPU component in the default setting and close its editor tab.

Petr_H_1-1731337472335.png
7. In the USB component settings editor, select the HID Keyboard (bare metal) in the preset drop-down list:

2024_10_09_000024.png

The keyboard interfaces are now added to the Supported interfaces list and pre-configured.

8. To add the mouse interface, click the + in the Supported interfaces section.

Select the newly added item and change the Class item to HID.

Petr_H_2-1731337559367.png
 
9. Check that the Use case Preset for the interface #1 is set to 'Mouse':
2024_11_11_000037.png

10. The Problems view shows an error as the clock function is inactive by default.

To enable it, right-click on the error and select “Enable USBPHY1 PLL clock”:
2024_10_09_000027.png

Note:  Optionally, it's possible to click the Show the problem… and adjust it in the Clocks tool.

11. Click the Update Code button in the main toolbar, a pop-up appears:

2024_10_09_000028.png
In the pop-up, confirm the code update by clicking the OK button:
2024_10_09_000029.png

Build the application using the Build Command in the Quickstart Panel.

2024_10_09_000031.png
 
13. Now connect the board to the computer via the USB debug connection.

Note: The EVKB-IMXRT1050 board provides multiple USB connectors. For flashing the application, it is it’s necessary to use the debug connection.  Also ensure that the board power is configured properly. There are several other configuration jumpers on the board. So in case the application cannot be flashed or debugged,  follow the user guide of the board.

2024_10_09_000033.png

14. To launch the application in the debugger, click the Debug text located in the bottom-left corner of the IDE.

2024_10_09_000030.png
 
This launches the debugging and the connected board should be detected. Confirm the selection of the debug probe.
 
2024_10_09_000032.png

Once the connection is successful, launch the application by clicking the Run button.

2024_10_09_000034.png

If the application connects successfully, connect an additional USB cable from the application USB connector to your PC.

The generated source code files contain a sample code that moves a mouse cursor in a loop and sends Home and End keys. After the cable is connected and the application runs, the movement of the mouse cursor and the text cursor moves left to right are visible.

 

 
No ratings
Version history
Last update:
‎11-11-2024 08:35 AM
Updated by: