summaryrefslogtreecommitdiff
path: root/common/usbx_host_classes/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/usbx_host_classes/src')
-rw-r--r--common/usbx_host_classes/src/ux_host_class_hid_idle_get.c25
-rw-r--r--common/usbx_host_classes/src/ux_host_class_hid_idle_set.c21
-rw-r--r--common/usbx_host_classes/src/ux_host_class_hid_report_get.c14
3 files changed, 54 insertions, 6 deletions
diff --git a/common/usbx_host_classes/src/ux_host_class_hid_idle_get.c b/common/usbx_host_classes/src/ux_host_class_hid_idle_get.c
index acf0f01..5deb535 100644
--- a/common/usbx_host_classes/src/ux_host_class_hid_idle_get.c
+++ b/common/usbx_host_classes/src/ux_host_class_hid_idle_get.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_idle_get PORTABLE C */
-/* 6.0 */
+/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,6 +70,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
+/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
+/* protected default control */
+/* endpoint before using it, */
+/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_host_class_hid_idle_get(UX_HOST_CLASS_HID *hid, USHORT *idle_time, USHORT report_id)
@@ -116,6 +120,25 @@ UINT status;
return(UX_MEMORY_INSUFFICIENT);
}
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&hid -> ux_host_class_hid_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+
+ /* Something went wrong. */
+
+ /* Free allocated memory. */
+ _ux_utility_memory_free(idle_byte);
+
+ /* Unprotect thread reentry to this instance. */
+ _ux_utility_semaphore_put(&hid -> ux_host_class_hid_semaphore);
+
+ return(status);
+ }
+
/* Create a transfer request for the GET_IDLE request. */
transfer_request -> ux_transfer_request_data_pointer = idle_byte;
transfer_request -> ux_transfer_request_requested_length = 1;
diff --git a/common/usbx_host_classes/src/ux_host_class_hid_idle_set.c b/common/usbx_host_classes/src/ux_host_class_hid_idle_set.c
index a7fd64d..42eaf96 100644
--- a/common/usbx_host_classes/src/ux_host_class_hid_idle_set.c
+++ b/common/usbx_host_classes/src/ux_host_class_hid_idle_set.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_idle_set PORTABLE C */
-/* 6.0 */
+/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,6 +70,10 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
+/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
+/* protected default control */
+/* endpoint before using it, */
+/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_host_class_hid_idle_set(UX_HOST_CLASS_HID *hid, USHORT idle_time, USHORT report_id)
@@ -97,6 +101,21 @@ UINT status;
if (status != UX_SUCCESS)
return(status);
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&hid -> ux_host_class_hid_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+
+ /* Something went wrong. */
+ /* Unprotect thread reentry to this instance. */
+ _ux_utility_semaphore_put(&hid -> ux_host_class_hid_semaphore);
+
+ return(status);
+ }
+
/* We need to get the default control endpoint transfer request pointer. */
control_endpoint = &hid -> ux_host_class_hid_device -> ux_device_control_endpoint;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
diff --git a/common/usbx_host_classes/src/ux_host_class_hid_report_get.c b/common/usbx_host_classes/src/ux_host_class_hid_report_get.c
index add69ce..0c3cd1d 100644
--- a/common/usbx_host_classes/src/ux_host_class_hid_report_get.c
+++ b/common/usbx_host_classes/src/ux_host_class_hid_report_get.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hid_report_get PORTABLE C */
-/* 6.0 */
+/* 6.0.2 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -75,6 +75,11 @@
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
+/* 08-14-2020 Chaoqiong Xiao Modified comment(s), */
+/* verified memset and memcpy */
+/* cases, accepted both INPUT */
+/* and FEATURE reports, */
+/* resulting in version 6.0.2 */
/* */
/**************************************************************************/
UINT _ux_host_class_hid_report_get(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report)
@@ -112,8 +117,9 @@ UINT status;
/* Get the report pointer from the caller. */
hid_report = client_report -> ux_host_class_hid_client_report;
- /* Ensure this is a INPUT report. */
- if (hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_INPUT)
+ /* Ensure this is a INPUT report or FEATURE report. */
+ if (hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_INPUT &&
+ hid_report -> ux_host_class_hid_report_type != UX_HOST_CLASS_HID_REPORT_TYPE_FEATURE)
{
/* Unprotect thread reentry to this instance. */
@@ -202,7 +208,7 @@ UINT status;
{
/* We have enough memory to store the raw buffer. */
- _ux_utility_memory_copy(client_report -> ux_host_class_hid_client_report_buffer, report_buffer, transfer_request -> ux_transfer_request_actual_length);
+ _ux_utility_memory_copy(client_report -> ux_host_class_hid_client_report_buffer, report_buffer, transfer_request -> ux_transfer_request_actual_length); /* Use case of memcpy is verified. */
/* Set status to success. */
status = UX_SUCCESS;