Start with a built-in profile if it fits your project. This page covers two extra tasks: sharing settings through a feature report, and describing your own report layout.
A feature report is a separate block for settings or status. Use it when the PC needs to read or change a small set of settings without mixing them into normal data reports. Its size is fixed, and it travels through HID control requests.
Call USB_GetEvents(), then test the USB_EV_FEATURE bit in USB_LastEvents. Check the received bytes before using them. A PC write replaces the feature array only: your code must apply the settings, save them to Flash if needed, or change the hardware. If you need separate command and status fields, decide their byte layout with the PC program.
In polling mode, read or update the array between service calls. In interrupt mode, use the shared-data protection when copying several bytes, so an interrupt cannot see a half-finished update. Copy received settings into your own variables before doing slow work. The feature event is a flag; it does not keep a list of every earlier write.
The stack also answers host queries for the current reports. An input query returns the saved input state. For the mouse profile, relative X/Y bytes are cleared after queuing motion, so queries and idle repeats do not repeat that motion. An output query returns the last output delivered to the application; a feature query reads USB_Feature[]. Editing an unfinished TXReport does not change the saved input snapshot.
The host controls HID idle repetition. A zero idle rate disables automatic repetition; other values use 4 ms units. The library handles the timer and resends the saved state as required. Your own USB_Write() calls still send reports even when unchanged. Keyboard and mouse accept boot/report-protocol requests; the supplied layouts work with both.
For a custom descriptor, select profile 5 and paste hexadecimal bytes into Custom descriptor. Spaces, commas or semicolons may separate bytes; $05, 0x05 and 05 are accepted forms. Then:
The editor accepts up to 4096 descriptor bytes. Do not change only a buffer size while leaving the descriptor unchanged. Use a built-in profile when it already fits: a custom descriptor describes your data layout; it does not implement the application behaviour for you.
Created with the Personal Edition of HelpNDoc: Leave the tedious WinHelp HLP to CHM conversion process behind with HelpNDoc