USB-ROM-HIDmouse

Source code can be downloaded from source:/Examples/USB_ROM_HIDmouse

Description
This demo shows HID mouse function using USB ROM API.

The code is located in 3 files:

main.c - initialization and button handling.
hid_usbdesc.c - USB descriptors (device, configuration, string and others).
usbd_hid.c - USB callback functions (3 callbacks are used: on set configuration, on IN endpoint request and on get HID report).
Algorithm The program algorithm can be described as follows:
Main initializes USB and enables pull-up to signal host about device connection.
Host sends SET_CONFIGURATION standard request.
When this request is received by the device (configuration event), device sends mouse report to the host.
When report is sent (IN event), device sends it again. So, mouse report is transmitted continuously.
Main loop is scanning buttons.
When no buttons are pressed, X and Y displacement values of the report are zero. When some buttons are pressed X and/or Y values equals to +1 or -1. Since mouse report is transmitted continuously, it is transmitted with zero values when no buttons are pressed and with non-zero when some button is pressed.
Execution
To run this demo project you need:

Open USB_ROM_HIDmouse project and build it.



Start debug and run program.



Press buttons on the LPC-4350-DB1 board and mouse cursor will move up/down.

Неопределенный