Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/core/inc/ux_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ typedef signed char SCHAR;
#define AZURE_RTOS_USBX
#define USBX_MAJOR_VERSION 6
#define USBX_MINOR_VERSION 4
#define USBX_PATCH_VERSION 3
#define USBX_BUILD_VERSION 202503
#define USBX_HOTFIX_VERSION ''
#define USBX_PATCH_VERSION 5
#define USBX_BUILD_VERSION 202504
#define USBX_HOTFIX_VERSION ' '

/* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */

Expand Down
5 changes: 5 additions & 0 deletions common/usbx_device_classes/inc/ux_device_class_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ typedef struct UX_SLAVE_CLASS_HID_STRUCT
UINT ux_device_class_hid_state;
UINT (*ux_device_class_hid_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);
UINT (*ux_device_class_hid_get_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);
VOID (*ux_device_class_hid_set_protocol_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, ULONG protocol);
VOID (*ux_slave_class_hid_instance_activate)(VOID *);
VOID (*ux_slave_class_hid_instance_deactivate)(VOID *);
UCHAR *ux_device_class_hid_report_address;
Expand Down Expand Up @@ -365,6 +366,10 @@ typedef struct UX_SLAVE_CLASS_HID_PARAMETER_STRUCT
ULONG ux_device_class_hid_parameter_report_length;
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). */
VOID (*ux_device_class_hid_parameter_set_protocol_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, ULONG protocol);

#if defined(UX_DEVICE_CLASS_HID_FLEXIBLE_EVENTS_QUEUE)
ULONG ux_device_class_hid_parameter_event_max_number;
ULONG ux_device_class_hid_parameter_event_max_length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,28 @@ UX_SLAVE_CLASS_HID *hid;

case UX_DEVICE_CLASS_HID_COMMAND_GET_PROTOCOL:

/* Send the protocol. */
/* Send the protocol to host. */
*transfer_request -> ux_slave_transfer_request_data_pointer = (UCHAR)hid -> ux_device_class_hid_protocol;
_ux_device_stack_transfer_request(transfer_request, 1, request_length);
break;

case UX_DEVICE_CLASS_HID_COMMAND_SET_PROTOCOL:

/* Check protocol must be 0 (Boot) or 1 (Report). */
if ((request_value != UX_DEVICE_CLASS_HID_PROTOCOL_BOOT) &&
(request_value != UX_DEVICE_CLASS_HID_PROTOCOL_REPORT))
{
/* Invalid value: not handled. */
return (UX_ERROR);
}

/* Accept the protocol. */
hid -> ux_device_class_hid_protocol = request_value;

/* If there is a callback defined by the application, send the protocol to it. */
if (hid -> ux_device_class_hid_set_protocol_callback != UX_NULL)
hid -> ux_device_class_hid_set_protocol_callback(hid, request_value);
Comment on lines +226 to +228
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The new callback invocation lacks test coverage. The existing test file does not set up or verify the ux_device_class_hid_set_protocol_callback. Consider adding test coverage to verify that the callback is properly invoked when a SET_PROTOCOL request is received.

Copilot uses AI. Check for mistakes.
Comment on lines +215 to +228
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The new callback functionality for set protocol requests lacks test coverage. The existing test file "usbx_ux_device_class_hid_control_request_test.c" tests SET_PROTOCOL requests but does not verify that the new callback is invoked correctly when set. Consider adding test cases that:

  1. Verify the callback is called with the correct protocol value (both boot and report)
  2. Verify the callback receives the correct HID instance pointer
  3. Verify that when the callback is NULL, the code still functions correctly (this is already handled but should be tested)

Copilot uses AI. Check for mistakes.

break;

default:
Expand All @@ -225,4 +238,3 @@ UX_SLAVE_CLASS_HID *hid;
/* It's handled. */
return(UX_SUCCESS);
}

Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ UCHAR *buffer;
/* Store the callback function. */
hid -> ux_device_class_hid_callback = hid_parameter -> ux_device_class_hid_parameter_callback;
hid -> ux_device_class_hid_get_callback = hid_parameter -> ux_device_class_hid_parameter_get_callback;
hid -> ux_device_class_hid_set_protocol_callback = hid_parameter -> ux_device_class_hid_parameter_set_protocol_callback;

#if defined(UX_DEVICE_CLASS_HID_FLEXIBLE_EVENTS_QUEUE)

Expand Down
2 changes: 2 additions & 0 deletions common/usbx_host_classes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_idle_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_idle_set.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_idle_set_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_protocol_set.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_protocol_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_instance_clean.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_interrupt_endpoint_search.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_item_data_get.c
Expand Down
Loading