diff options
| author | MAY <[email protected]> | 2026-06-04 21:25:54 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-06-04 15:25:54 -0400 |
| commit | 35927220c0165c06dc90e6c9aa7a8eb9b5806065 (patch) | |
| tree | 445b00cc418ce9a86762f900bd95a189d8ebc324 /docs/USBX_Host_Stack_UVC_User_Guide.docx | |
| parent | c048e1ce16f90ab4c670238d0ebbc487faac9118 (diff) | |
Added optional device HID protocol change callback and host HID protocol get/set API (#244)
This pull request adds host-side HID API functions to get and set the HID protocol (boot vs. report mode), and introduces an optional device-sidecallback invoked when the protocol changes.
New features
- Added host-side APIs ux_host_class_hid_protocol_set() and ux_host_class_hid_protocol_get() with error-checking wrappers (_uxe_ variants).
- Added optional device-side callback ux_device_class_hid_set_protocol_callback, invoked when the host changes the active protocol.
- Added a comprehensive test to verify the new protocol callback functionality.
Bug fixes (host-side protocol get/set)
1. DMA buffer safety (protocol_get): The received byte is now written into a cache-safe allocated buffer instead of the caller's USHORT* directly. Stack memory is not DMA-safe on cache-incoherent embedded targets, and writing 1 byte into a USHORT* yields incorrect results on big-endianplatforms. Follows the same pattern as ux_host_class_hid_idle_get.
2. Missing device protection semaphore (both functions): In RTOS mode, ux_device_protection_semaphore is now acquired before submitting the transfer, in addition to the HID instance semaphore. All other HID control transfer functions (idle_get, idle_set) take both semaphores; omitting it allowed concurrent callers to corrupt the shared transfer_request fields.
3. Missing standalone locking (both functions): Added proper UX_HOST_STANDALONE support using UX_DISABLE/UX_RESTORE to atomically check and setUX_HOST_CLASS_HID_FLAG_LOCK and UX_DEVICE_FLAG_LOCK, and set UX_TRANSFER_FLAG_AUTO_DEVICE_UNLOCK + UX_TRANSFER_STATE_RESET on the transfer request before initiating. Follows the idle_get inline standalone pattern.
Co-authored-by: Frédéric Desbiens <[email protected]>
Co-authored-by: Copilot <[email protected]>
Diffstat (limited to 'docs/USBX_Host_Stack_UVC_User_Guide.docx')
0 files changed, 0 insertions, 0 deletions
