diff --git a/common/usbx_device_classes/inc/ux_device_class_hid.h b/common/usbx_device_classes/inc/ux_device_class_hid.h index 5dead7db..dfa588a1 100644 --- a/common/usbx_device_classes/inc/ux_device_class_hid.h +++ b/common/usbx_device_classes/inc/ux_device_class_hid.h @@ -1,10 +1,10 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -14,7 +14,7 @@ /** */ /** USBX Component */ /** */ -/** HID Class */ +/** Device HID Class */ /** */ /**************************************************************************/ /**************************************************************************/ @@ -389,7 +389,7 @@ typedef struct UX_SLAVE_CLASS_HID_PARAMETER_STRUCT /* Define HID Class function prototypes. */ UINT _ux_device_class_hid_descriptor_send(UX_SLAVE_CLASS_HID *hid, ULONG descriptor_type, - ULONG request_index, ULONG host_length); + ULONG request_index, ULONG host_length); UINT _ux_device_class_hid_activate(UX_SLAVE_CLASS_COMMAND *command); UINT _ux_device_class_hid_deactivate(UX_SLAVE_CLASS_COMMAND *command); UINT _ux_device_class_hid_control_request(UX_SLAVE_CLASS_COMMAND *command); @@ -398,18 +398,18 @@ VOID _ux_device_class_hid_interrupt_thread(ULONG hid_class); UINT _ux_device_class_hid_initialize(UX_SLAVE_CLASS_COMMAND *command); UINT _ux_device_class_hid_uninitialize(UX_SLAVE_CLASS_COMMAND *command); UINT _ux_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid, - UX_SLAVE_CLASS_HID_EVENT *hid_event); + UX_SLAVE_CLASS_HID_EVENT *hid_event); UINT _ux_device_class_hid_event_check(UX_SLAVE_CLASS_HID *hid, UX_DEVICE_CLASS_HID_EVENT **hid_event); VOID _ux_device_class_hid_event_free(UX_SLAVE_CLASS_HID *hid); UINT _ux_device_class_hid_event_get(UX_SLAVE_CLASS_HID *hid, - UX_SLAVE_CLASS_HID_EVENT *hid_event); + UX_SLAVE_CLASS_HID_EVENT *hid_event); UINT _ux_device_class_hid_report_set(UX_SLAVE_CLASS_HID *hid, ULONG descriptor_type, - ULONG request_index, ULONG host_length); + ULONG request_index, ULONG host_length); UINT _ux_device_class_hid_report_get(UX_SLAVE_CLASS_HID *hid, ULONG descriptor_type, - ULONG request_index, ULONG host_length); + ULONG request_index, ULONG host_length); -UINT _ux_device_class_hid_tasks_run(VOID *class_instance); +UINT _ux_device_class_hid_tasks_run(VOID *hid_instance); UINT _ux_device_class_hid_read(UX_SLAVE_CLASS_HID *hid, UCHAR *buffer, ULONG requested_length, @@ -417,16 +417,16 @@ UINT _ux_device_class_hid_read(UX_SLAVE_CLASS_HID *hid, VOID _ux_device_class_hid_receiver_thread(ULONG hid_class); UINT _ux_device_class_hid_receiver_initialize(UX_SLAVE_CLASS_HID *hid, - UX_SLAVE_CLASS_HID_PARAMETER *parameter, - UX_DEVICE_CLASS_HID_RECEIVER **receiver); + UX_SLAVE_CLASS_HID_PARAMETER *parameter, + UX_DEVICE_CLASS_HID_RECEIVER **receiver); VOID _ux_device_class_hid_receiver_uninitialize(UX_DEVICE_CLASS_HID_RECEIVER *receiver); UINT _ux_device_class_hid_receiver_event_get(UX_SLAVE_CLASS_HID *hid, - UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event); + UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event); UINT _ux_device_class_hid_receiver_event_free(UX_SLAVE_CLASS_HID *hid); UINT _ux_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid, - UCHAR *buffer, ULONG requested_length, - ULONG *actual_length); + UCHAR *buffer, ULONG requested_length, + ULONG *actual_length); UINT _ux_device_class_hid_receiver_tasks_run(UX_SLAVE_CLASS_HID *hid); @@ -436,16 +436,16 @@ UINT _uxe_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid, UINT _uxe_device_class_hid_event_get(UX_SLAVE_CLASS_HID *hid, UX_SLAVE_CLASS_HID_EVENT *hid_event); UINT _uxe_device_class_hid_read(UX_SLAVE_CLASS_HID *hid, - UCHAR *buffer, ULONG requested_length, - ULONG *actual_length); + UCHAR *buffer, ULONG requested_length, + ULONG *actual_length); UINT _uxe_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid, - UCHAR *buffer, ULONG requested_length, - ULONG *actual_length); + UCHAR *buffer, ULONG requested_length, + ULONG *actual_length); UINT _uxe_device_class_hid_receiver_initialize(UX_SLAVE_CLASS_HID *hid, - UX_SLAVE_CLASS_HID_PARAMETER *parameter, - UX_DEVICE_CLASS_HID_RECEIVER **receiver); + UX_SLAVE_CLASS_HID_PARAMETER *parameter, + UX_DEVICE_CLASS_HID_RECEIVER **receiver); UINT _uxe_device_class_hid_receiver_event_get(UX_SLAVE_CLASS_HID *hid, - UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event); + UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event); UINT _uxe_device_class_hid_receiver_event_free(UX_SLAVE_CLASS_HID *hid); @@ -493,4 +493,4 @@ UINT _uxe_device_class_hid_receiver_event_free(UX_SLAVE_CLASS_HID *hid); } #endif -#endif +#endif /* UX_DEVICE_CLASS_HID_H */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_activate.c b/common/usbx_device_classes/src/ux_device_class_hid_activate.c index 5bc715a4..08cdc109 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_activate.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_activate.c @@ -1,13 +1,15 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + +/**************************************************************************/ /**************************************************************************/ /** */ /** USBX Component */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_control_request.c b/common/usbx_device_classes/src/ux_device_class_hid_control_request.c index 83305021..edecc7b0 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_control_request.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_control_request.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Device HID Class */ /** */ @@ -28,44 +29,44 @@ #include "ux_device_stack.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_device_class_hid_control_request PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_device_class_hid_control_request PORTABLE C */ /* 6.1.12 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ -/* This function manages the based sent by the host on the control */ -/* endpoints with a CLASS or VENDOR SPECIFIC type. */ -/* */ -/* INPUT */ -/* */ -/* hid Pointer to hid class */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* _ux_device_stack_transfer_request Transfer request */ +/* */ +/* This function manages the based sent by the host on the control */ +/* endpoints with a CLASS or VENDOR SPECIFIC type. */ +/* */ +/* INPUT */ +/* */ +/* command Pointer to hid command */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* _ux_device_stack_transfer_request Transfer request */ /* _ux_device_class_hid_report_get Process Get_Report request */ /* _ux_device_class_hid_report_set Process Set_Report request */ /* _ux_device_class_hid_descriptor_send Send requested descriptor */ -/* */ -/* CALLED BY */ -/* */ +/* */ +/* CALLED BY */ +/* */ /* HID Class */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* prefixed UX to MS_TO_TICK, */ @@ -119,10 +120,10 @@ UX_SLAVE_CLASS_HID *hid; /* Duration - upper byte of wValue. */ duration = *(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_VALUE + 1); - + /* Get the class container. */ class_ptr = command -> ux_slave_class_command_class_ptr; - + /* Get the storage instance from this class container. */ hid = (UX_SLAVE_CLASS_HID *) class_ptr -> ux_slave_class_instance; @@ -149,8 +150,8 @@ UX_SLAVE_CLASS_HID *hid; /* Send the requested descriptor to the host. */ _ux_device_class_hid_descriptor_send(hid, request_value, request_index, request_length); - break; - + break; + case UX_DEVICE_CLASS_HID_COMMAND_GET_IDLE: case UX_DEVICE_CLASS_HID_COMMAND_SET_IDLE: diff --git a/common/usbx_device_classes/src/ux_device_class_hid_deactivate.c b/common/usbx_device_classes/src/ux_device_class_hid_deactivate.c index 55033ca0..6b11308f 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_deactivate.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_deactivate.c @@ -8,6 +8,7 @@ * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_descriptor_send.c b/common/usbx_device_classes/src/ux_device_class_hid_descriptor_send.c index 833469f0..a5c124ec 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_descriptor_send.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_descriptor_send.c @@ -1,18 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Device HID Class */ /** */ @@ -51,23 +51,23 @@ /* */ /* OUTPUT */ /* */ -/* Completion Status */ +/* Completion Status */ +/* */ +/* CALLS */ /* */ -/* CALLS */ -/* */ -/* (ux_slave_dcd_function) DCD dispatch function */ +/* (ux_slave_dcd_function) DCD dispatch function */ /* _ux_device_stack_transfer_request Process transfer request */ -/* _ux_utility_memory_copy Memory copy */ -/* */ -/* CALLED BY */ -/* */ -/* Application */ +/* _ux_utility_memory_copy Memory copy */ +/* */ +/* CALLED BY */ +/* */ +/* Application */ /* Device Stack */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* verified memset and memcpy */ @@ -78,8 +78,8 @@ /* resulting in version 6.1.8 */ /* */ /**************************************************************************/ -UINT _ux_device_class_hid_descriptor_send(UX_SLAVE_CLASS_HID *hid, ULONG descriptor_type, - ULONG request_index, ULONG host_length) +UINT _ux_device_class_hid_descriptor_send(UX_SLAVE_CLASS_HID *hid, ULONG descriptor_type, + ULONG request_index, ULONG host_length) { UX_SLAVE_DCD *dcd; @@ -103,7 +103,7 @@ UCHAR interface_number = 0xFF; /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; - + /* Get the control endpoint associated with the device. */ endpoint = &device -> ux_slave_device_control_endpoint; @@ -112,7 +112,7 @@ UCHAR interface_number = 0xFF; /* Set the direction to OUT. */ transfer_request -> ux_slave_transfer_request_phase = UX_TRANSFER_PHASE_DATA_OUT; - + /* Shift the descriptor type in the low byte field. */ descriptor_type = (UCHAR) ((descriptor_type >> 8) & 0xff); @@ -121,12 +121,12 @@ UCHAR interface_number = 0xFF; { case UX_DEVICE_CLASS_HID_DESCRIPTOR_HID: - + /* We should have a HID descriptor as part of the config descriptor. */ device_framework = _ux_system_slave -> ux_system_slave_device_framework; device_framework_end = device_framework + _ux_system_slave -> ux_system_slave_device_framework_length; - /* Parse the device framework and locate the HID descriptor. + /* Parse the device framework and locate the HID descriptor. There is only one HID descriptor. */ while (device_framework < device_framework_end) { @@ -150,8 +150,8 @@ UCHAR interface_number = 0xFF; and do not return more than what is allowed. */ if (descriptor_length < host_length) length = descriptor_length; - else - length = host_length; + else + length = host_length; /* Check buffer length, since descriptor length may exceed buffer... */ if (length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) @@ -169,13 +169,13 @@ UCHAR interface_number = 0xFF; } /* Copy the device descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, + _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, device_framework, length); /* Use case of memcpy is verified. */ /* We can return the configuration descriptor. */ status = _ux_device_stack_transfer_request(transfer_request, length, host_length); break; - + } /* Point to the next descriptor. */ @@ -189,7 +189,7 @@ UCHAR interface_number = 0xFF; break; case UX_DEVICE_CLASS_HID_DESCRIPTOR_REPORT: - + /* Get the length of entire configuration descriptor. */ descriptor_length = hid -> ux_device_class_hid_report_length; @@ -197,8 +197,8 @@ UCHAR interface_number = 0xFF; and do not return more than what is allowed. */ if (descriptor_length < host_length) length = descriptor_length; - else - length = host_length; + else + length = host_length; /* Check buffer length, since total descriptors length may exceed buffer... */ if (length > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH) @@ -216,17 +216,17 @@ UCHAR interface_number = 0xFF; } /* Copy the device descriptor into the transfer request memory. */ - _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, + _ux_utility_memory_copy(transfer_request -> ux_slave_transfer_request_data_pointer, hid -> ux_device_class_hid_report_address, length); /* Use case of memcpy is verified. */ /* We can return the report descriptor. */ status = _ux_device_stack_transfer_request(transfer_request, length, host_length); break; - + case UX_DEVICE_CLASS_HID_DESCRIPTOR_PHYSICAL: - + /* Not treated for now. Fall through and Stall endpoint. */ - + default: /* Stall the endpoint. */ @@ -237,4 +237,3 @@ UCHAR interface_number = 0xFF; /* Return the status to the caller. */ return(status); } - diff --git a/common/usbx_device_classes/src/ux_device_class_hid_entry.c b/common/usbx_device_classes/src/ux_device_class_hid_entry.c index 27cae494..22222e7e 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_entry.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_entry.c @@ -8,6 +8,7 @@ * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -75,10 +76,10 @@ /* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ /* added error checks support, */ /* resulting in version 6.3.0 */ -/* xx-xx-xxxx Mohamed ayed Modified comment(s), */ +/* 24-02-2025 Mohamed ayed Modified comment(s), */ /* fix typo, */ /* remove extra spaces, */ -/* resulting in version 6.x */ +/* resulting in version 6.4.2 */ /* */ /**************************************************************************/ UINT _ux_device_class_hid_entry(UX_SLAVE_CLASS_COMMAND *command) @@ -156,4 +157,3 @@ UINT status; return(UX_FUNCTION_NOT_SUPPORTED); } } - diff --git a/common/usbx_device_classes/src/ux_device_class_hid_event_get.c b/common/usbx_device_classes/src/ux_device_class_hid_event_get.c index a9d074e1..eae13247 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_event_get.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_event_get.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_event_set.c b/common/usbx_device_classes/src/ux_device_class_hid_event_set.c index 1dccc46f..84b99e2f 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_event_set.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_event_set.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Device HID Class */ /** */ @@ -28,43 +29,43 @@ #include "ux_device_stack.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_device_class_hid_event_set PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_device_class_hid_event_set PORTABLE C */ /* 6.3.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ -/* This function sends an event to the hid class. It is processed */ -/* asynchronously by the interrupt thread. */ -/* */ -/* INPUT */ -/* */ -/* hid Address of hid class */ -/* event Pointer of the event */ -/* */ -/* OUTPUT */ -/* */ -/* status UX_SUCCESS if there is an */ -/* event */ -/* CALLS */ -/* */ +/* */ +/* This function sends an event to the hid class. It is processed */ +/* asynchronously by the interrupt thread. */ +/* */ +/* INPUT */ +/* */ +/* hid Address of hid class */ +/* event Pointer of the event */ +/* */ +/* OUTPUT */ +/* */ +/* status UX_SUCCESS if there is an */ +/* event */ +/* CALLS */ +/* */ /* _ux_utility_memory_copy Copy memory */ /* _ux_device_event_flags_set Set event flags */ -/* */ -/* CALLED BY */ -/* */ -/* ThreadX */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* CALLED BY */ +/* */ +/* ThreadX */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* added standalone support, */ @@ -83,8 +84,8 @@ /* resulting in version 6.3.0 */ /* */ /**************************************************************************/ -UINT _ux_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid, - UX_SLAVE_CLASS_HID_EVENT *hid_event) +UINT _ux_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid, + UX_SLAVE_CLASS_HID_EVENT *hid_event) { UX_DEVICE_CLASS_HID_EVENT *current_hid_event; @@ -100,7 +101,7 @@ UCHAR *next_position; /* If the pointer is NULL, the round robin buffer has not been activated. */ if (current_hid_event == UX_NULL) return (UX_ERROR); - + /* Calculate the next position. */ next_position = (UCHAR *)current_hid_event + UX_DEVICE_CLASS_HID_EVENT_QUEUE_ITEM_SIZE(hid); if (next_position >= (UCHAR *)hid -> ux_device_class_hid_event_array_end) @@ -143,13 +144,13 @@ UCHAR *next_position; _ux_utility_memory_copy(UX_DEVICE_CLASS_HID_EVENT_BUFFER(current_hid_event) + 1, hid_event -> ux_device_class_hid_event_buffer, hid_event -> ux_device_class_hid_event_length); /* Use case of memcpy is verified. */ - + /* fill in the event structure from the user. */ - current_hid_event -> ux_device_class_hid_event_length = hid_event -> ux_device_class_hid_event_length + 1; + current_hid_event -> ux_device_class_hid_event_length = hid_event -> ux_device_class_hid_event_length + 1; } else { - + /* No report ID to consider. */ /* Store copy of data so application can free event there (easier use). */ @@ -158,7 +159,7 @@ UCHAR *next_position; hid_event -> ux_device_class_hid_event_length); /* Use case of memcpy is verified. */ /* fill in the event structure from the user. */ - current_hid_event -> ux_device_class_hid_event_length = hid_event -> ux_device_class_hid_event_length; + current_hid_event -> ux_device_class_hid_event_length = hid_event -> ux_device_class_hid_event_length; } #if defined(UX_DEVICE_STANDALONE) @@ -170,7 +171,7 @@ UCHAR *next_position; #else /* Set an event to wake up the interrupt thread. */ - _ux_device_event_flags_set(&hid -> ux_device_class_hid_event_flags_group, UX_DEVICE_CLASS_HID_NEW_EVENT, UX_OR); + _ux_device_event_flags_set(&hid -> ux_device_class_hid_event_flags_group, UX_DEVICE_CLASS_HID_NEW_EVENT, UX_OR); #endif /* Return event status to the user. */ @@ -216,7 +217,7 @@ UCHAR *next_position; /* 10-31-2023 Chaoqiong Xiao Initial Version 6.3.0 */ /* */ /**************************************************************************/ -UINT _uxe_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid, +UINT _uxe_device_class_hid_event_set(UX_SLAVE_CLASS_HID *hid, UX_SLAVE_CLASS_HID_EVENT *hid_event) { diff --git a/common/usbx_device_classes/src/ux_device_class_hid_initialize.c b/common/usbx_device_classes/src/ux_device_class_hid_initialize.c index a23aca30..2366cdee 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_initialize.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_initialize.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/**************************************************************************/ +/** */ +/** USBX Component */ /** */ /** Device HID Class */ /** */ @@ -27,46 +28,46 @@ #include "ux_device_stack.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_device_class_hid_initialize PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_device_class_hid_initialize PORTABLE C */ /* 6.3.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ -/* This function initializes the USB HID device. */ -/* This function is called by the class register function. It is only */ -/* done once. */ -/* */ -/* INPUT */ -/* */ -/* command Pointer to hid command */ -/* */ -/* OUTPUT */ -/* */ -/* Completion Status */ -/* */ -/* CALLS */ -/* */ +/* */ +/* This function initializes the USB HID device. */ +/* This function is called by the class register function. It is only */ +/* done once. */ +/* */ +/* INPUT */ +/* */ +/* command Pointer to hid command */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* CALLS */ +/* */ /* _ux_utility_memory_allocate Allocate memory */ /* _ux_utility_memory_free Free memory */ /* _ux_device_thread_create Create thread */ /* _ux_device_thread_delete Delete thread */ /* _ux_utility_event_flags_create Create event flags group */ -/* */ -/* CALLED BY */ -/* */ -/* USBX Source Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* CALLED BY */ +/* */ +/* USBX Source Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* used UX prefix to refer to */ @@ -97,7 +98,7 @@ /**************************************************************************/ UINT _ux_device_class_hid_initialize(UX_SLAVE_CLASS_COMMAND *command) { - + UX_SLAVE_CLASS_HID *hid; UX_SLAVE_CLASS_HID_PARAMETER *hid_parameter; UX_SLAVE_CLASS *class_ptr; @@ -149,9 +150,9 @@ UCHAR *buffer; #if !defined(UX_DEVICE_STANDALONE) /* Allocate some memory for the thread stack. */ - class_ptr -> ux_slave_class_thread_stack = + class_ptr -> ux_slave_class_thread_stack = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY, UX_DEVICE_CLASS_HID_THREAD_STACK_SIZE); - + /* Check for successful allocation. */ if (class_ptr -> ux_slave_class_thread_stack == UX_NULL) status = UX_MEMORY_INSUFFICIENT; @@ -160,7 +161,7 @@ UCHAR *buffer; a new thread. We pass a pointer to the class to the new thread. This thread does not start until we have a instance of the class. */ if (status == UX_SUCCESS) - status = _ux_device_thread_create(&class_ptr -> ux_slave_class_thread, "ux_slave_hid_thread", + status = _ux_device_thread_create(&class_ptr -> ux_slave_class_thread, "ux_slave_hid_thread", _ux_device_class_hid_interrupt_thread, (ULONG) (ALIGN_TYPE) class_ptr, (VOID *) class_ptr -> ux_slave_class_thread_stack, UX_DEVICE_CLASS_HID_THREAD_STACK_SIZE, UX_THREAD_PRIORITY_CLASS, @@ -263,7 +264,7 @@ UCHAR *buffer; if (hid -> ux_device_class_hid_event_array != UX_NULL) { - /* Initialize the head and tail of the notification round robin buffers. + /* Initialize the head and tail of the notification round robin buffers. At first, the head and tail are pointing to the beginning of the array. */ hid -> ux_device_class_hid_event_array_head = hid -> ux_device_class_hid_event_array; hid -> ux_device_class_hid_event_array_tail = hid -> ux_device_class_hid_event_array; @@ -392,7 +393,7 @@ UCHAR *buffer; /* */ /* INPUT */ /* */ -/* command Pointer to hid command */ +/* command Pointer to hid command */ /* */ /* OUTPUT */ /* */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_interrupt_thread.c b/common/usbx_device_classes/src/ux_device_class_hid_interrupt_thread.c index 2ce0c1fb..2d785723 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_interrupt_thread.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_interrupt_thread.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ -/** */ -/** USBX Component */ +/** */ +/** USBX Component */ /** */ /** Device HID Class */ /** */ @@ -29,47 +30,47 @@ #if !defined(UX_DEVICE_STANDALONE) -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _ux_device_class_hid_interrupt_thread PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _ux_device_class_hid_interrupt_thread PORTABLE C */ /* 6.3.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ -/* */ -/* This function is the thread of the hid interrupt (IN) endpoint */ -/* */ +/* */ +/* This function is the thread of the hid interrupt (IN) endpoint */ +/* */ /* It's for RTOS mode. */ -/* */ -/* INPUT */ -/* */ -/* hid_class Address of hid class */ -/* container */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ +/* */ +/* INPUT */ +/* */ +/* hid_class Address of hid class */ +/* container */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ /* _ux_utility_event_flags_get Get event flags */ /* _ux_device_class_hid_event_get Get HID event */ -/* _ux_device_stack_transfer_request Request transfer */ -/* _ux_utility_memory_copy Copy memory */ +/* _ux_device_stack_transfer_request Request transfer */ +/* _ux_utility_memory_copy Copy memory */ /* _ux_device_thread_suspend Suspend thread */ -/* */ -/* CALLED BY */ -/* */ -/* ThreadX */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ +/* */ +/* CALLED BY */ +/* */ +/* ThreadX */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* verified memset and memcpy */ @@ -103,13 +104,13 @@ ULONG actual_flags; /* Cast properly the hid instance. */ UX_THREAD_EXTENSION_PTR_GET(class_ptr, UX_SLAVE_CLASS, hid_class) - + /* Get the hid instance from this class container. */ hid = (UX_SLAVE_CLASS_HID *) class_ptr -> ux_slave_class_instance; - + /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; - + /* This thread runs forever but can be suspended or resumed. */ while(1) { @@ -119,7 +120,7 @@ ULONG actual_flags; /* As long as the device is in the CONFIGURED state. */ while (device -> ux_slave_device_state == UX_DEVICE_CONFIGURED) - { + { /* Wait until we have a event sent by the application or a change in the idle state to send last or empty report. */ @@ -156,7 +157,7 @@ ULONG actual_flags; } /* Send the request to the device controller. */ - status = _ux_device_stack_transfer_request(transfer_request_in, + status = _ux_device_stack_transfer_request(transfer_request_in, transfer_request_in -> ux_slave_transfer_request_requested_length, transfer_request_in -> ux_slave_transfer_request_requested_length); @@ -195,13 +196,13 @@ ULONG actual_flags; #else /* Prepare the event data payload from the hid event structure. Get a pointer to the buffer area. */ buffer = transfer_request_in -> ux_slave_transfer_request_data_pointer; - + /* Copy the event buffer into the target buffer. */ _ux_utility_memory_copy(buffer, UX_DEVICE_CLASS_HID_EVENT_BUFFER(hid_event), hid_event -> ux_device_class_hid_event_length); /* Use case of memcpy is verified. */ #endif /* Send the request to the device controller. */ - status = _ux_device_stack_transfer_request(transfer_request_in, hid_event -> ux_device_class_hid_event_length, + status = _ux_device_stack_transfer_request(transfer_request_in, hid_event -> ux_device_class_hid_event_length, hid_event -> ux_device_class_hid_event_length); /* The queue tail is handled and should be freed. */ @@ -213,11 +214,11 @@ ULONG actual_flags; /* Error trap. */ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, status); - } + } } - + /* We need to suspend ourselves. We will be resumed by the device enumeration module. */ _ux_device_thread_suspend(&class_ptr -> ux_slave_class_thread); } } -#endif +#endif /* !UX_DEVICE_STANDALONE */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_read.c b/common/usbx_device_classes/src/ux_device_class_hid_read.c index 2f3831a6..feb4b352 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_read.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_read.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -273,7 +274,7 @@ ULONG local_requested_length; /* */ /**************************************************************************/ UINT _uxe_device_class_hid_read(UX_SLAVE_CLASS_HID *hid, UCHAR *buffer, - ULONG requested_length, ULONG *actual_length) + ULONG requested_length, ULONG *actual_length) { /* Sanity checks. */ @@ -287,4 +288,4 @@ UINT _uxe_device_class_hid_read(UX_SLAVE_CLASS_HID *hid, UCHAR *buffer, /* Invoke function to read data. */ return(_ux_device_class_hid_read(hid, buffer, requested_length, actual_length)); } -#endif +#endif /* !UX_DEVICE_STANDALONE */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_read_run.c b/common/usbx_device_classes/src/ux_device_class_hid_read_run.c index 35de1d5a..99948ad2 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_read_run.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_read_run.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -274,7 +275,7 @@ UINT status= UX_SUCCESS; /* Keep waiting. */ return(UX_STATE_WAIT); - + /* Receiver running states. */ case UX_DEVICE_CLASS_HID_RECEIVER_START: /* Fall through. */ case UX_DEVICE_CLASS_HID_RECEIVER_WAIT: /* Fall through. */ @@ -337,7 +338,7 @@ UINT status= UX_SUCCESS; /* */ /**************************************************************************/ UINT _uxe_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid, UCHAR *buffer, - ULONG requested_length, ULONG *actual_length) + ULONG requested_length, ULONG *actual_length) { /* Sanity checks. */ @@ -351,4 +352,4 @@ UINT _uxe_device_class_hid_read_run(UX_SLAVE_CLASS_HID *hid, UCHAR *buffer, /* Invoke function to run reading state machine. */ return(_ux_device_class_hid_read_run(hid, buffer, requested_length, actual_length)); } -#endif +#endif /* UX_DEVICE_STANDALONE */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_free.c b/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_free.c index 9ee83860..98a03634 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_free.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_free.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_get.c b/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_get.c index a2f45c05..0a2e4225 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_get.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_receiver_event_get.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -156,7 +157,7 @@ UX_DEVICE_CLASS_HID_RECEIVED_EVENT *pos; /* */ /**************************************************************************/ UINT _uxe_device_class_hid_receiver_event_get(UX_SLAVE_CLASS_HID *hid, - UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event) + UX_DEVICE_CLASS_HID_RECEIVED_EVENT *event) { /* Sanity check. */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_receiver_initialize.c b/common/usbx_device_classes/src/ux_device_class_hid_receiver_initialize.c index 819ca03a..45d16b34 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_receiver_initialize.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_receiver_initialize.c @@ -1,13 +1,15 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + +/**************************************************************************/ /**************************************************************************/ /** */ /** USBX Component */ @@ -82,8 +84,8 @@ /* */ /**************************************************************************/ UINT _ux_device_class_hid_receiver_initialize(UX_SLAVE_CLASS_HID *hid, - UX_SLAVE_CLASS_HID_PARAMETER *parameter, - UX_DEVICE_CLASS_HID_RECEIVER **receiver) + UX_SLAVE_CLASS_HID_PARAMETER *parameter, + UX_DEVICE_CLASS_HID_RECEIVER **receiver) { #if !defined(UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT) UX_PARAMETER_NOT_USED(hid); diff --git a/common/usbx_device_classes/src/ux_device_class_hid_receiver_tasks_run.c b/common/usbx_device_classes/src/ux_device_class_hid_receiver_tasks_run.c index b9c710b2..4ce8fbfa 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_receiver_tasks_run.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_receiver_tasks_run.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -213,4 +214,4 @@ ULONG temp; /* Task is idle. */ return(UX_STATE_IDLE); } -#endif +#endif /* UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT && UX_DEVICE_STANDALONE */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_receiver_thread.c b/common/usbx_device_classes/src/ux_device_class_hid_receiver_thread.c index bc6dd891..79d0d75b 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_receiver_thread.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_receiver_thread.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -45,7 +46,7 @@ /* */ /* INPUT */ /* */ -/* hid_class Address of hid class */ +/* hid_instance Address of hid class */ /* container */ /* */ /* OUTPUT */ @@ -145,7 +146,7 @@ ULONG temp; #endif /* Issue the transfer request. */ - status = _ux_device_stack_transfer_request(transfer, + status = _ux_device_stack_transfer_request(transfer, receiver -> ux_device_class_hid_receiver_event_buffer_size, receiver -> ux_device_class_hid_receiver_event_buffer_size); @@ -188,4 +189,4 @@ ULONG temp; receiver -> ux_device_class_hid_receiver_event_callback(hid); } } -#endif +#endif /* UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT && !UX_DEVICE_STANDALONE */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_receiver_uninitialize.c b/common/usbx_device_classes/src/ux_device_class_hid_receiver_uninitialize.c index 6605db03..ee46b3a4 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_receiver_uninitialize.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_receiver_uninitialize.c @@ -1,13 +1,15 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + +/**************************************************************************/ /**************************************************************************/ /** */ /** USBX Component */ @@ -88,4 +90,4 @@ VOID _ux_device_class_hid_receiver_uninitialize(UX_DEVICE_CLASS_HID_RECEIVER *re /* Free receiver and events memory. */ _ux_utility_memory_free(receiver); } -#endif +#endif /* UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_tasks_run.c b/common/usbx_device_classes/src/ux_device_class_hid_tasks_run.c index 49bc51b9..56b27e55 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_tasks_run.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_tasks_run.c @@ -1,13 +1,14 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ + /**************************************************************************/ /**************************************************************************/ /** */ @@ -47,7 +48,7 @@ /* */ /* INPUT */ /* */ -/* hid_class Address of hid class */ +/* hid_instance Address of hid class */ /* container */ /* */ /* OUTPUT */ @@ -77,7 +78,7 @@ /* resulting in version 6.3.0 */ /* */ /**************************************************************************/ -UINT _ux_device_class_hid_tasks_run(VOID *instance) +UINT _ux_device_class_hid_tasks_run(VOID *hid_instance) { UX_SLAVE_CLASS_HID *hid; @@ -89,7 +90,7 @@ UINT status; /* Get HID instance. */ - hid = (UX_SLAVE_CLASS_HID *) instance; + hid = (UX_SLAVE_CLASS_HID *) hid_instance; /* Get the pointer to the device. */ device = &_ux_system_slave -> ux_system_slave_device; @@ -208,4 +209,4 @@ UINT status; return(UX_STATE_IDLE); } } -#endif +#endif /* UX_DEVICE_STANDALONE */ diff --git a/common/usbx_device_classes/src/ux_device_class_hid_uninitialize.c b/common/usbx_device_classes/src/ux_device_class_hid_uninitialize.c index 1c67a5dd..0060ce23 100644 --- a/common/usbx_device_classes/src/ux_device_class_hid_uninitialize.c +++ b/common/usbx_device_classes/src/ux_device_class_hid_uninitialize.c @@ -8,6 +8,7 @@ * SPDX-License-Identifier: MIT **************************************************************************/ +/**************************************************************************/ /**************************************************************************/ /** */ /** USBX Component */ @@ -149,4 +150,3 @@ UX_SLAVE_CLASS *class_ptr; /* Return completion status. */ return(UX_SUCCESS); } -