Skip to content

Conversation

@ayedm1
Copy link
Owner

@ayedm1 ayedm1 commented Jan 10, 2026

No description provided.

@github-actions
Copy link

github-actions bot commented Jan 10, 2026

Test Results

0 tests   0 ✔️  0s ⏱️
0 suites  0 💤
0 files    0

Results for commit 8a7e153.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
core.src 96% 92%
usbx_device_classes.src 97% 90%
usbx_host_classes.src 97% 93%
Summary 97% (7606 / 7872) 92% (3378 / 3663)

update regression test to test host set/get api and device set protocol callback
@ayedm1 ayedm1 force-pushed the add_set_protocol_callback branch from 988c15b to 828a0fb Compare January 10, 2026 14:37
…lass invoked when protocol change

- add optional device hid callback ux_device_class_hid_parameter_set_protocol_callback invoked when protocol changes (boot/report).
- add host hid api to set/get protocol.
- update regression test to test host set/get api and device set protocol callback.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for an optional HID set protocol callback, enabling applications to be notified when the USB HID protocol switches between Boot (0) and Report (1) modes. The implementation includes both host-side API functions for getting/setting the protocol and device-side callback infrastructure.

Changes:

  • Added new host class APIs ux_host_class_hid_protocol_set() and ux_host_class_hid_protocol_get() for protocol management
  • Added optional device-side callback ux_device_class_hid_parameter_set_protocol_callback that applications can register to be notified of protocol changes
  • Implemented comprehensive test coverage for the new callback functionality including NULL callback scenarios

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/regression/usbxtestcontrol.c Registered new test case and removed trailing whitespace
test/regression/usbx_ux_device_class_hid_set_protocol_callback_test.c New comprehensive test validating callback invocation and NULL callback handling
test/cmake/usbx/regression/CMakeLists.txt Added new test to build configuration
common/usbx_host_classes/src/ux_host_class_hid_protocol_set.c New host API to set HID protocol (Boot/Report)
common/usbx_host_classes/src/ux_host_class_hid_protocol_get.c New host API to get current HID protocol
common/usbx_host_classes/inc/ux_host_class_hid.h Added function declarations, macros, and protocol constants; fixed formatting
common/usbx_host_classes/CMakeLists.txt Added new source files to build
common/usbx_device_classes/src/ux_device_class_hid_initialize.c Initialize callback pointer from parameters; formatting fixes
common/usbx_device_classes/src/ux_device_class_hid_control_request.c Added protocol validation and callback invocation in SET_PROTOCOL handler
common/usbx_device_classes/inc/ux_device_class_hid.h Added callback field to structures and parameter struct

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

UINT (*ux_device_class_hid_parameter_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);
UINT (*ux_device_class_hid_parameter_get_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);

/* Optional callback invoked when protocol changes (boot/report). */
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 370 describes the callback as being invoked when protocol changes between boot and report. However, it would be clearer to specify the exact values of the protocol parameter: "protocol is 0 for Boot or 1 for Report protocol" to match the USB HID specification.

Suggested change
/* Optional callback invoked when protocol changes (boot/report). */
/* Optional callback invoked when protocol changes; protocol is 0 for Boot or 1 for Report. */

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1173 to +1182

#endif
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate #endif directive at end of file. Line 1180 already closes the include guard, making line 1182 redundant and causing a preprocessing error.

Suggested change
#endif

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/* Initialize HID class parameters, including set_protocol callback. */
hid_parameter.ux_device_class_hid_parameter_report_address = hid_report_descriptor;
hid_parameter.ux_device_class_hid_parameter_report_length = HID_REPORT_LENGTH;
hid_parameter.ux_device_class_hid_parameter_callback = UX_NULL; /* Not used in this test. */
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hid_parameter structure is not fully initialized. The field ux_device_class_hid_parameter_get_callback is not set, which could lead to undefined behavior if the structure is not guaranteed to be zero-initialized. While the global static hid_parameter from the common header will be zero-initialized, it's better practice to explicitly initialize all fields for clarity and maintainability, especially when some fields are being set.

Suggested change
hid_parameter.ux_device_class_hid_parameter_callback = UX_NULL; /* Not used in this test. */
hid_parameter.ux_device_class_hid_parameter_callback = UX_NULL; /* Not used in this test. */
hid_parameter.ux_device_class_hid_parameter_get_callback = UX_NULL; /* Explicitly unused in this test. */

Copilot uses AI. Check for mistakes.
@ayedm1 ayedm1 deleted the branch master January 13, 2026 22:01
@ayedm1 ayedm1 closed this Jan 13, 2026
@ayedm1 ayedm1 reopened this Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants