summaryrefslogtreecommitdiff
path: root/common/core/src
diff options
context:
space:
mode:
authorYuxin Zhou <[email protected]>2021-02-02 00:52:59 +0000
committerYuxin Zhou <[email protected]>2021-02-02 00:52:59 +0000
commit5d2acef877e3a9215ef495bf350fbceb06349bb5 (patch)
treef68e6c13b1503f87be8f346bb97a715d8dc3a723 /common/core/src
parent9823f3857d7eb54c8416d9eab316aab0257130f9 (diff)
Release 6.1.4v6.1.4_rel
Diffstat (limited to 'common/core/src')
-rw-r--r--common/core/src/ux_host_stack_class_interface_scan.c101
-rw-r--r--common/core/src/ux_host_stack_configuration_interface_scan.c179
-rw-r--r--common/core/src/ux_host_stack_configuration_set.c8
-rw-r--r--common/core/src/ux_host_stack_device_configuration_activate.c137
-rw-r--r--common/core/src/ux_host_stack_device_configuration_deactivate.c160
-rw-r--r--common/core/src/ux_host_stack_device_configuration_reset.c19
-rw-r--r--common/core/src/ux_host_stack_device_configuration_select.c16
-rw-r--r--common/core/src/ux_host_stack_device_remove.c58
-rw-r--r--common/core/src/ux_host_stack_device_string_get.c126
-rwxr-xr-x[-rw-r--r--]common/core/src/ux_host_stack_hcd_thread_entry.c0
-rwxr-xr-x[-rw-r--r--]common/core/src/ux_host_stack_hcd_unregister.c0
-rw-r--r--common/core/src/ux_host_stack_hnp_polling_thread_entry.c107
-rw-r--r--common/core/src/ux_host_stack_new_device_create.c14
-rwxr-xr-x[-rw-r--r--]common/core/src/ux_host_stack_rh_change_process.c0
-rw-r--r--common/core/src/ux_host_stack_rh_device_insertion.c52
-rwxr-xr-x[-rw-r--r--]common/core/src/ux_utility_delay_ms.c0
16 files changed, 766 insertions, 211 deletions
diff --git a/common/core/src/ux_host_stack_class_interface_scan.c b/common/core/src/ux_host_stack_class_interface_scan.c
index 62b39e8..85a6348 100644
--- a/common/core/src/ux_host_stack_class_interface_scan.c
+++ b/common/core/src/ux_host_stack_class_interface_scan.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_class_interface_scan PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -83,20 +83,18 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* used internal function call */
+/* to scan interfaces, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_class_interface_scan(UX_DEVICE *device)
{
UX_CONFIGURATION *configuration;
-UX_INTERFACE *interface;
-UINT nb_class_owners;
-UX_HOST_CLASS *class;
-UX_HOST_CLASS_COMMAND class_command;
UINT status;
- /* Initialize class owners to 0. */
- nb_class_owners = 0;
/* Get the 1st and only configuration. If the device has multiple
configurations, we simply use the first one as default. */
@@ -104,94 +102,9 @@ UINT status;
if (configuration == UX_NULL)
return(UX_ERROR);
- /* Get the first interface container for this configuration. */
- interface = configuration -> ux_configuration_first_interface;
+ /* Scan interfaces for this configuration. */
+ status = _ux_host_stack_configuration_interface_scan(configuration);
- /* We now scan all the alternate settings 0 for each of the interfaces. */
- while (interface != UX_NULL)
- {
-
- /* Is there a default interface? */
- if(interface -> ux_interface_descriptor.bAlternateSetting == 0)
- {
-
- /* We have a default interface for this configuration. Call each class
- with the class\subclass\protocol. We include the IAD for the cdc classes. */
- class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_QUERY;
- class_command.ux_host_class_command_container = (VOID *)interface;
- class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_CSP;
- class_command.ux_host_class_command_class = interface -> ux_interface_descriptor.bInterfaceClass;
- class_command.ux_host_class_command_subclass = interface -> ux_interface_descriptor.bInterfaceSubClass;
- class_command.ux_host_class_command_protocol = interface -> ux_interface_descriptor.bInterfaceProtocol;
- class_command.ux_host_class_command_iad_class = interface -> ux_interface_iad_class ;
- class_command.ux_host_class_command_iad_subclass = interface -> ux_interface_iad_subclass;
- class_command.ux_host_class_command_iad_protocol = interface -> ux_interface_iad_protocol;
-
- class = _ux_host_stack_class_call(&class_command);
-
- /* On return, either we have found a class or the interface is still an orphan. */
- if (class != UX_NULL)
- {
-
- /* There is a class. */
- nb_class_owners++;
- interface -> ux_interface_class = class;
- }
- }
-
- /* point to the next interface until end of the list. */
- interface = interface -> ux_interface_next_interface;
- }
-
- /* Assume no classes. */
- status = UX_NO_CLASS_MATCH;
-
- /* Check the number of class owner found. */
- if (nb_class_owners != 0)
- {
-
- /* If we have found one or more classes for any of the interfaces,
- we can safely do a SET_CONFIGURATION of the device. */
- status = _ux_host_stack_device_configuration_select(configuration);
-
- /* Check the completion status. */
- if (status == UX_SUCCESS)
- {
-
- /* The device is in the CONFIGURED state, we have to call each of the classes
- again with an ACTIVATE signal. */
- interface = configuration -> ux_configuration_first_interface;
-
- while (interface != UX_NULL)
- {
-
- /* Is there a default interface? */
- if (interface -> ux_interface_descriptor.bAlternateSetting == 0)
- {
-
- /* We have found the default interface. If this interface is owned,
- activate its class. */
- class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE;
- class_command.ux_host_class_command_container = (VOID *) interface;
-
- if (interface -> ux_interface_class != UX_NULL)
- {
-
- /* Save the class in the command container */
- class_command.ux_host_class_command_class_ptr = interface -> ux_interface_class;
-
- /* Send the ACTIVATE command to the class */
- status = interface -> ux_interface_class -> ux_host_class_entry_function(&class_command);
-
- }
- }
-
- /* Point to the next interface until end of the list. */
- interface = interface -> ux_interface_next_interface;
- }
- }
- }
-
/* Return operation result. */
return(status);
}
diff --git a/common/core/src/ux_host_stack_configuration_interface_scan.c b/common/core/src/ux_host_stack_configuration_interface_scan.c
new file mode 100644
index 0000000..6f83f3e
--- /dev/null
+++ b/common/core/src/ux_host_stack_configuration_interface_scan.c
@@ -0,0 +1,179 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) Microsoft Corporation. All rights reserved. */
+/* */
+/* This software is licensed under the Microsoft Software License */
+/* Terms for Microsoft Azure RTOS. Full text of the license can be */
+/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
+/* and in the root directory of this software. */
+/* */
+/**************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** USBX Component */
+/** */
+/** Host Stack */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+
+/* Include necessary system files. */
+
+#define UX_SOURCE_CODE
+
+#include "ux_api.h"
+#include "ux_host_stack.h"
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_host_stack_configuration_interface_scan PORTABLE C */
+/* 6.1.4 */
+/* AUTHOR */
+/* */
+/* Chaoqiong Xiao, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function will scan all default interfaces for a specific */
+/* configuration and call the registered class with the */
+/* Class/SubClass/Protocol of the interface. */
+/* */
+/* INPUT */
+/* */
+/* configuration Configuration pointer */
+/* */
+/* OUTPUT */
+/* */
+/* Result of operation */
+/* */
+/* CALLS */
+/* */
+/* _ux_host_stack_class_call Call class command */
+/* _ux_host_stack_device_configuration_select */
+/* Select configuration */
+/* _ux_host_stack_class_call Call class from host stack */
+/* (ux_host_class_entry_function) Class entry function */
+/* */
+/* CALLED BY */
+/* */
+/* USBX Components */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */
+/* */
+/**************************************************************************/
+UINT _ux_host_stack_configuration_interface_scan(UX_CONFIGURATION *configuration)
+{
+
+UX_INTERFACE *interface;
+UINT nb_class_owners;
+UX_HOST_CLASS *class;
+UX_HOST_CLASS_COMMAND class_command;
+UINT status;
+
+
+ /* Initialize class owners to 0. */
+ nb_class_owners = 0;
+
+ /* Get the first interface container for this configuration. */
+ interface = configuration -> ux_configuration_first_interface;
+
+ /* We now scan all the alternate settings 0 for each of the interfaces. */
+ while (interface != UX_NULL)
+ {
+
+ /* Is there a default interface? */
+ if(interface -> ux_interface_descriptor.bAlternateSetting == 0)
+ {
+
+ /* We have a default interface for this configuration. Call each class
+ with the class\subclass\protocol. We include the IAD for the cdc classes. */
+ class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_QUERY;
+ class_command.ux_host_class_command_container = (VOID *)interface;
+ class_command.ux_host_class_command_usage = UX_HOST_CLASS_COMMAND_USAGE_CSP;
+ class_command.ux_host_class_command_class = interface -> ux_interface_descriptor.bInterfaceClass;
+ class_command.ux_host_class_command_subclass = interface -> ux_interface_descriptor.bInterfaceSubClass;
+ class_command.ux_host_class_command_protocol = interface -> ux_interface_descriptor.bInterfaceProtocol;
+ class_command.ux_host_class_command_iad_class = interface -> ux_interface_iad_class ;
+ class_command.ux_host_class_command_iad_subclass = interface -> ux_interface_iad_subclass;
+ class_command.ux_host_class_command_iad_protocol = interface -> ux_interface_iad_protocol;
+
+ class = _ux_host_stack_class_call(&class_command);
+
+ /* On return, either we have found a class or the interface is still an orphan. */
+ if (class != UX_NULL)
+ {
+
+ /* There is a class. */
+ nb_class_owners++;
+ interface -> ux_interface_class = class;
+ }
+ }
+
+ /* point to the next interface until end of the list. */
+ interface = interface -> ux_interface_next_interface;
+ }
+
+ /* Assume no classes. */
+ status = UX_NO_CLASS_MATCH;
+
+ /* Check the number of class owner found. */
+ if (nb_class_owners != 0)
+ {
+
+ /* If we have found one or more classes for any of the interfaces,
+ we can safely do a SET_CONFIGURATION of the device. */
+ status = _ux_host_stack_device_configuration_select(configuration);
+
+ /* Check the completion status. */
+ if (status == UX_SUCCESS)
+ {
+
+ /* The device is in the CONFIGURED state, we have to call each of the classes
+ again with an ACTIVATE signal. */
+ interface = configuration -> ux_configuration_first_interface;
+
+ while (interface != UX_NULL)
+ {
+
+ /* Is there a default interface? */
+ if (interface -> ux_interface_descriptor.bAlternateSetting == 0)
+ {
+
+ /* We have found the default interface. If this interface is owned,
+ activate its class. */
+ class_command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE;
+ class_command.ux_host_class_command_container = (VOID *) interface;
+
+ if (interface -> ux_interface_class != UX_NULL)
+ {
+
+ /* Save the class in the command container */
+ class_command.ux_host_class_command_class_ptr = interface -> ux_interface_class;
+
+ /* Send the ACTIVATE command to the class */
+ status = interface -> ux_interface_class -> ux_host_class_entry_function(&class_command);
+
+ }
+ }
+
+ /* Point to the next interface until end of the list. */
+ interface = interface -> ux_interface_next_interface;
+ }
+ }
+ }
+
+ /* Return operation result. */
+ return(status);
+}
+
diff --git a/common/core/src/ux_host_stack_configuration_set.c b/common/core/src/ux_host_stack_configuration_set.c
index 26312d0..4ffba3e 100644
--- a/common/core/src/ux_host_stack_configuration_set.c
+++ b/common/core/src/ux_host_stack_configuration_set.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_configuration_set PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,6 +70,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* used pointer for current */
+/* selected configuration, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_configuration_set(UX_CONFIGURATION *configuration)
@@ -150,7 +154,7 @@ UX_HCD *hcd;
device -> ux_device_state = UX_DEVICE_CONFIGURED;
/* Store the new configuration value in the device container. */
- device -> ux_device_current_configuration = configuration -> ux_configuration_descriptor.bConfigurationValue;
+ device -> ux_device_current_configuration = configuration;
}
/* Return status to caller. */
diff --git a/common/core/src/ux_host_stack_device_configuration_activate.c b/common/core/src/ux_host_stack_device_configuration_activate.c
new file mode 100644
index 0000000..47f659a
--- /dev/null
+++ b/common/core/src/ux_host_stack_device_configuration_activate.c
@@ -0,0 +1,137 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) Microsoft Corporation. All rights reserved. */
+/* */
+/* This software is licensed under the Microsoft Software License */
+/* Terms for Microsoft Azure RTOS. Full text of the license can be */
+/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
+/* and in the root directory of this software. */
+/* */
+/**************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** USBX Component */
+/** */
+/** Host Stack */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+
+/* Include necessary system files. */
+
+#define UX_SOURCE_CODE
+
+#include "ux_api.h"
+#include "ux_host_stack.h"
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_host_stack_device_configuration_activate PORTABLE C */
+/* 6.1.4 */
+/* AUTHOR */
+/* */
+/* Chaoqiong Xiao, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function selects a specific configuration for a device. */
+/* When this configuration is set to the device, by default all the */
+/* device interface and their associated alternate setting 0 is */
+/* activated on the device. */
+/* */
+/* INPUT */
+/* */
+/* configuration Pointer to configuration */
+/* */
+/* OUTPUT */
+/* */
+/* Completion Status */
+/* */
+/* CALLS */
+/* */
+/* _ux_utility_semaphore_get Get semaphore */
+/* _ux_utility_semaphore_put Put semaphore */
+/* _ux_host_stack_configuration_interface_scan Scan and activate */
+/* interfaces */
+/* */
+/* CALLED BY */
+/* */
+/* Application */
+/* USBX Components */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */
+/* */
+/**************************************************************************/
+UINT _ux_host_stack_device_configuration_activate(UX_CONFIGURATION *configuration)
+{
+
+UX_DEVICE *device;
+UINT status;
+
+
+ /* Check for validity of the configuration handle. */
+ if (configuration -> ux_configuration_handle != (ULONG) (ALIGN_TYPE) configuration)
+ {
+
+ /* Error trap. */
+ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_CONFIGURATION_HANDLE_UNKNOWN);
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_CONFIGURATION_HANDLE_UNKNOWN, configuration, 0, 0, UX_TRACE_ERRORS, 0, 0)
+
+ return(UX_CONFIGURATION_HANDLE_UNKNOWN);
+ }
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_CONFIGURATION_ACTIVATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
+
+ /* Get the device container for this configuration. */
+ device = configuration -> ux_configuration_device;
+
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+
+ /* Error trap. */
+ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_SEMAPHORE_ERROR);
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_SEMAPHORE_ERROR, configuration, 0, 0, UX_TRACE_ERRORS, 0, 0)
+
+ return(UX_SEMAPHORE_ERROR);
+ }
+
+ /* Check for the state of the device . If the device is already configured,
+ we need to cancel the existing configuration before enabling this one. */
+ if (device -> ux_device_state == UX_DEVICE_CONFIGURED)
+ {
+
+ /* If this configuration is already activated, we are good,
+ otherwise report error. */
+ status = (device -> ux_device_current_configuration == configuration) ?
+ UX_SUCCESS : UX_ALREADY_ACTIVATED;
+ _ux_utility_semaphore_put(&device -> ux_device_protection_semaphore);
+ return(status);
+ }
+
+ /* Scan and activate the interfaces. */
+ status = _ux_host_stack_configuration_interface_scan(configuration);
+
+ /* Return completion status. */
+ return(status);
+}
diff --git a/common/core/src/ux_host_stack_device_configuration_deactivate.c b/common/core/src/ux_host_stack_device_configuration_deactivate.c
new file mode 100644
index 0000000..384b556
--- /dev/null
+++ b/common/core/src/ux_host_stack_device_configuration_deactivate.c
@@ -0,0 +1,160 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) Microsoft Corporation. All rights reserved. */
+/* */
+/* This software is licensed under the Microsoft Software License */
+/* Terms for Microsoft Azure RTOS. Full text of the license can be */
+/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
+/* and in the root directory of this software. */
+/* */
+/**************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** USBX Component */
+/** */
+/** Host Stack */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+
+/* Include necessary system files. */
+
+#define UX_SOURCE_CODE
+
+#include "ux_api.h"
+#include "ux_host_stack.h"
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_host_stack_device_configuration_deactivate PORTABLE C */
+/* 6.1.4 */
+/* AUTHOR */
+/* */
+/* Chaoqiong Xiao, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function deactivate current configuration for a device. */
+/* When this configuration is deactivated, all the device interfaces */
+/* are deactivated on the device. */
+/* */
+/* INPUT */
+/* */
+/* */
+/* OUTPUT */
+/* */
+/* Completion Status */
+/* */
+/* CALLS */
+/* */
+/* _ux_utility_semaphore_get Get semaphore */
+/* _ux_utility_semaphore_put Put semaphore */
+/* (ux_host_class_entry_function) Class entry function */
+/* */
+/* CALLED BY */
+/* */
+/* Application */
+/* USBX Components */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */
+/* */
+/**************************************************************************/
+UINT _ux_host_stack_device_configuration_deactivate(UX_DEVICE *device)
+{
+
+UX_HOST_CLASS_COMMAND command;
+UX_CONFIGURATION *configuration;
+UX_INTERFACE *interface;
+UINT status;
+
+
+ /* Do a sanity check on the device handle. */
+ if (device -> ux_device_handle != (ULONG) (ALIGN_TYPE) device)
+ {
+
+ /* Error trap. */
+ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_DEVICE_HANDLE_UNKNOWN);
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_DEVICE_HANDLE_UNKNOWN, device, 0, 0, UX_TRACE_ERRORS, 0, 0)
+
+ return(UX_DEVICE_HANDLE_UNKNOWN);
+ }
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_CONFIGURATION_DEACTIVATE, device, configuration, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
+
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+
+ /* Error trap. */
+ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_SEMAPHORE_ERROR);
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_SEMAPHORE_ERROR, configuration, 0, 0, UX_TRACE_ERRORS, 0, 0)
+
+ return(UX_SEMAPHORE_ERROR);
+ }
+
+ /* Get the configuration. */
+ configuration = device -> ux_device_current_configuration;
+
+ /* Check for the state of the device, if not configured, we are done. */
+ if (device -> ux_device_state != UX_DEVICE_CONFIGURED)
+ {
+ _ux_utility_semaphore_put(&device -> ux_device_protection_semaphore);
+ return(UX_SUCCESS);
+ }
+
+ /* Deactivate classes by command. */
+ command.ux_host_class_command_request = UX_HOST_CLASS_COMMAND_DEACTIVATE;
+
+ /* Search for the active configuration. */
+ configuration = device -> ux_device_current_configuration;
+
+ /* If device configured configuration must be activated. */
+
+ /* We have the correct configuration, search the interface(s). */
+ interface = configuration -> ux_configuration_first_interface;
+
+ /* Loop to perform the search. */
+ while (interface != UX_NULL)
+ {
+
+ /* Check if an instance of the interface is present. */
+ if (interface -> ux_interface_class_instance != UX_NULL)
+ {
+
+ /* We need to stop the class instance for the device. */
+ command.ux_host_class_command_instance = interface -> ux_interface_class_instance;
+
+ /* Call the class. */
+ interface -> ux_interface_class -> ux_host_class_entry_function(&command);
+ }
+
+ /* Move to next interface. */
+ interface = interface -> ux_interface_next_interface;
+ }
+
+ /* The device can now be un-configured. */
+ status = _ux_host_stack_device_configuration_reset(device);
+
+ /* Return completion status. */
+ return(status);
+}
diff --git a/common/core/src/ux_host_stack_device_configuration_reset.c b/common/core/src/ux_host_stack_device_configuration_reset.c
index b340d75..20aa20d 100644
--- a/common/core/src/ux_host_stack_device_configuration_reset.c
+++ b/common/core/src/ux_host_stack_device_configuration_reset.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_configuration_reset PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -68,6 +68,10 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* used pointer for current */
+/* selected configuration, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_configuration_reset(UX_DEVICE *device)
@@ -92,20 +96,15 @@ UINT status;
{
/* The device is configured. Get the first configuration pointer. */
- current_configuration = device -> ux_device_first_configuration;
-
- /* Traverse the configuration list until we find the right one. */
- while (current_configuration -> ux_configuration_descriptor.bConfigurationValue !=
- device -> ux_device_current_configuration)
- {
-
- current_configuration = current_configuration -> ux_configuration_next_configuration;
- }
+ current_configuration = device -> ux_device_current_configuration;
/* Deselect this instance */
_ux_host_stack_configuration_instance_delete(current_configuration);
}
+ /* No configuration is selected now. */
+ device -> ux_device_current_configuration = UX_NULL;
+
/* Set state of device to ATTACHED. */
device -> ux_device_state = UX_DEVICE_ATTACHED;
diff --git a/common/core/src/ux_host_stack_device_configuration_select.c b/common/core/src/ux_host_stack_device_configuration_select.c
index dd8224a..80597dc 100644
--- a/common/core/src/ux_host_stack_device_configuration_select.c
+++ b/common/core/src/ux_host_stack_device_configuration_select.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_configuration_select PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -78,6 +78,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* used pointer for current */
+/* selected configuration, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_configuration_select(UX_CONFIGURATION *configuration)
@@ -112,15 +116,7 @@ UINT status;
{
/* The device is configured. Get the first configuration pointer. */
- current_configuration = device -> ux_device_first_configuration;
-
- /* Traverse the configuration list until we find the right one. */
- while (current_configuration -> ux_configuration_descriptor.bConfigurationValue !=
- device -> ux_device_current_configuration)
- {
-
- current_configuration = current_configuration -> ux_configuration_next_configuration;
- }
+ current_configuration = device -> ux_device_current_configuration;
/* Deselect this instance */
_ux_host_stack_configuration_instance_delete(current_configuration);
diff --git a/common/core/src/ux_host_stack_device_remove.c b/common/core/src/ux_host_stack_device_remove.c
index 020c900..1a46658 100644
--- a/common/core/src/ux_host_stack_device_remove.c
+++ b/common/core/src/ux_host_stack_device_remove.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_device_remove PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -71,6 +71,12 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* used pointer for current */
+/* selected configuration, */
+/* added notification for */
+/* device disconnection, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_device_remove(UX_HCD *hcd, UX_DEVICE *parent, UINT port_index)
@@ -160,46 +166,42 @@ UX_HOST_CLASS_COMMAND command;
{
/* Search for the active configuration. */
- configuration = device -> ux_device_first_configuration;
+ configuration = device -> ux_device_current_configuration;
- /* Parse the interface(s) for this device in search of the classes
- who own this device. */
- while (configuration != UX_NULL)
+ /* If configuration is activated. */
+ if (configuration != UX_NULL)
{
- /* Is this the correct configuration? */
- if (configuration -> ux_configuration_descriptor.bConfigurationValue ==
- device -> ux_device_current_configuration)
- {
+ /* We have the correct configuration, search the interface(s). */
+ interface = configuration -> ux_configuration_first_interface;
- /* We have the correct configuration, search the interface(s). */
- interface = configuration -> ux_configuration_first_interface;
+ /* Loop to perform the search. */
+ while (interface != UX_NULL)
+ {
- /* Loop to perform the search. */
- while (interface != UX_NULL)
+ /* Check if an instance of the interface is present. */
+ if (interface -> ux_interface_class_instance != UX_NULL)
{
- /* Check if an instance of the interface is present. */
- if (interface -> ux_interface_class_instance != UX_NULL)
- {
-
- /* We need to stop the class instance for the device. */
- command.ux_host_class_command_instance = interface -> ux_interface_class_instance;
+ /* We need to stop the class instance for the device. */
+ command.ux_host_class_command_instance = interface -> ux_interface_class_instance;
- /* Call the class. */
- interface -> ux_interface_class -> ux_host_class_entry_function(&command);
- }
-
- /* Move to next interface. */
- interface = interface -> ux_interface_next_interface;
+ /* Call the class. */
+ interface -> ux_interface_class -> ux_host_class_entry_function(&command);
}
- }
- /* Move to next configuration in the list. */
- configuration = configuration -> ux_configuration_next_configuration;
+ /* Move to next interface. */
+ interface = interface -> ux_interface_next_interface;
+ }
}
}
+ /* Notify application for disconnection of existing physical device. */
+ if (_ux_system_host -> ux_system_host_change_function)
+ {
+ _ux_system_host -> ux_system_host_change_function(UX_DEVICE_DISCONNECTION, UX_NULL, (VOID*)device);
+ }
+
/* Now all the resources for this device must be free. */
_ux_host_stack_device_resources_free(device);
diff --git a/common/core/src/ux_host_stack_device_string_get.c b/common/core/src/ux_host_stack_device_string_get.c
new file mode 100644
index 0000000..90274ab
--- /dev/null
+++ b/common/core/src/ux_host_stack_device_string_get.c
@@ -0,0 +1,126 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) Microsoft Corporation. All rights reserved. */
+/* */
+/* This software is licensed under the Microsoft Software License */
+/* Terms for Microsoft Azure RTOS. Full text of the license can be */
+/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
+/* and in the root directory of this software. */
+/* */
+/**************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** USBX Component */
+/** */
+/** Host Stack */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+
+/* Include necessary system files. */
+
+#define UX_SOURCE_CODE
+
+#include "ux_api.h"
+#include "ux_host_class_printer.h"
+#include "ux_host_stack.h"
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_host_stack_device_string_get PORTABLE C */
+/* 6.1.4 */
+/* AUTHOR */
+/* */
+/* Chaoqiong Xiao, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function obtains the device string descriptor. */
+/* */
+/* INPUT */
+/* */
+/* device Pointer to device instance */
+/* descriptor_buffer Pointer to a buffer to fill */
+/* LANGID or STRING descriptor */
+/* length Length of buffer */
+/* language_id 0 to obtain LANGID descriptor */
+/* valid language ID to obtain */
+/* string descriptor */
+/* string_index Index of the string */
+/* */
+/* OUTPUT */
+/* */
+/* Completion Status */
+/* */
+/* CALLS */
+/* */
+/* _ux_host_stack_transfer_request Process transfer request */
+/* _ux_utility_semaphore_get Get Semaphore */
+/* */
+/* CALLED BY */
+/* */
+/* Application */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */
+/* */
+/**************************************************************************/
+UINT _ux_host_stack_device_string_get(UX_DEVICE *device, UCHAR *descriptor_buffer, ULONG length, ULONG language_id, ULONG string_index)
+{
+UX_ENDPOINT *control_endpoint;
+UX_TRANSFER *transfer_request;
+UINT status;
+
+
+ /* Do a sanity check on the device handle. */
+ if (device -> ux_device_handle != (ULONG) (ALIGN_TYPE) device)
+ {
+
+ /* Error trap. */
+ _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, UX_DEVICE_HANDLE_UNKNOWN);
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_DEVICE_HANDLE_UNKNOWN, device, 0, 0, UX_TRACE_ERRORS, 0, 0)
+
+ return(UX_DEVICE_HANDLE_UNKNOWN);
+ }
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_DEVICE_STRING_GET, device, descriptor_buffer, length, (language_id << 16) | string_index, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
+
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ return(UX_SEMAPHORE_ERROR);
+
+ /* We need to get the default control endpoint transfer request pointer. */
+ control_endpoint = &device -> ux_device_control_endpoint;
+ transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
+
+ /* Create a transfer request for the GET_DEVICE_ID request. */
+ transfer_request -> ux_transfer_request_data_pointer = descriptor_buffer;
+ transfer_request -> ux_transfer_request_requested_length = length;
+ transfer_request -> ux_transfer_request_function = UX_GET_DESCRIPTOR;
+ transfer_request -> ux_transfer_request_type = UX_REQUEST_IN | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE;
+ transfer_request -> ux_transfer_request_value = (UX_STRING_DESCRIPTOR_ITEM << 8) | string_index;
+ transfer_request -> ux_transfer_request_index = (language_id);
+
+ /* Send request to HCD layer. */
+ status = _ux_host_stack_transfer_request(transfer_request);
+
+ /* Return completion status. */
+ return(status);
+}
diff --git a/common/core/src/ux_host_stack_hcd_thread_entry.c b/common/core/src/ux_host_stack_hcd_thread_entry.c
index bc0042e..bc0042e 100644..100755
--- a/common/core/src/ux_host_stack_hcd_thread_entry.c
+++ b/common/core/src/ux_host_stack_hcd_thread_entry.c
diff --git a/common/core/src/ux_host_stack_hcd_unregister.c b/common/core/src/ux_host_stack_hcd_unregister.c
index 277cf1a..277cf1a 100644..100755
--- a/common/core/src/ux_host_stack_hcd_unregister.c
+++ b/common/core/src/ux_host_stack_hcd_unregister.c
diff --git a/common/core/src/ux_host_stack_hnp_polling_thread_entry.c b/common/core/src/ux_host_stack_hnp_polling_thread_entry.c
index d185cdf..e57bca6 100644
--- a/common/core/src/ux_host_stack_hnp_polling_thread_entry.c
+++ b/common/core/src/ux_host_stack_hnp_polling_thread_entry.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_hnp_polling_thread_entry PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -76,6 +76,10 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* used pointer for current */
+/* selected configuration, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
VOID _ux_host_stack_hnp_polling_thread_entry(ULONG argument)
@@ -153,73 +157,58 @@ UINT status;
/* We have a device on a OTG port. But is it a OTG HNP capable device ?
We need to parse the configuration until we find the one current. */
- configuration = device -> ux_device_first_configuration;
+ configuration = device -> ux_device_current_configuration;
- /* Are we at the of the configuration list ? */
- while (configuration != UX_NULL)
+ /* Check for OTG HNP support. */
+ if (configuration -> ux_configuration_otg_capabilities & UX_OTG_HNP_SUPPORT)
{
-
- /* Is this the current configuration ? */
- if (configuration -> ux_configuration_descriptor.bConfigurationValue ==
- device -> ux_device_current_configuration)
- {
-
- /* Check for OTG HNP support. */
- if (configuration -> ux_configuration_otg_capabilities & UX_OTG_HNP_SUPPORT)
- {
-
- /* Allocate memory for the OTG status. */
- otg_status = _ux_utility_memory_allocate(UX_SAFE_ALIGN, UX_CACHE_SAFE_MEMORY, 16);
-
- /* Check for status. */
- if (otg_status == UX_NULL)
- return;
-
- /* Retrieve the control endpoint and the transfer request associated with it. */
- control_endpoint = &device -> ux_device_control_endpoint;
- transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
+
+ /* Allocate memory for the OTG status. */
+ otg_status = _ux_utility_memory_allocate(UX_SAFE_ALIGN, UX_CACHE_SAFE_MEMORY, 16);
- /* Protect the control endpoint semaphore here. It will be unprotected in the
- transfer request function. */
- status = _ux_utility_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+ /* Check for status. */
+ if (otg_status == UX_NULL)
+ return;
+
+ /* Retrieve the control endpoint and the transfer request associated with it. */
+ control_endpoint = &device -> ux_device_control_endpoint;
+ transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
- /* Perform a GET_STATUS on this device to see if it wants to become the host. */
- /* Create a transfer_request for the SET_CONFIGURATION request. No data for this request. */
- transfer_request -> ux_transfer_request_data_pointer = otg_status;
- transfer_request -> ux_transfer_request_requested_length = 1;
- transfer_request -> ux_transfer_request_function = UX_GET_STATUS;
- transfer_request -> ux_transfer_request_type = UX_REQUEST_IN | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE;
- transfer_request -> ux_transfer_request_value = 0;
- transfer_request -> ux_transfer_request_index = UX_OTG_STATUS_SELECTOR;
-
- /* Send request to HCD layer. */
- status = _ux_host_stack_transfer_request(transfer_request);
-
- /* Check completion status. */
- if(status == UX_SUCCESS && transfer_request -> ux_transfer_request_actual_length == 1)
- {
-
- /* We have an answer from the device. Check the HNP flag. */
- if (*otg_status & UX_OTG_HOST_REQUEST_FLAG)
- {
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
- /* The device has requested a Host swap. Initiate the command and perform the
- stopping of the host. */
- _ux_host_stack_role_swap(device);
- }
-
- }
-
- /* Free all used resources. */
- _ux_utility_memory_free(otg_status);
+ /* Perform a GET_STATUS on this device to see if it wants to become the host. */
+ /* Create a transfer_request for the SET_CONFIGURATION request. No data for this request. */
+ transfer_request -> ux_transfer_request_data_pointer = otg_status;
+ transfer_request -> ux_transfer_request_requested_length = 1;
+ transfer_request -> ux_transfer_request_function = UX_GET_STATUS;
+ transfer_request -> ux_transfer_request_type = UX_REQUEST_IN | UX_REQUEST_TYPE_STANDARD | UX_REQUEST_TARGET_DEVICE;
+ transfer_request -> ux_transfer_request_value = 0;
+ transfer_request -> ux_transfer_request_index = UX_OTG_STATUS_SELECTOR;
+
+ /* Send request to HCD layer. */
+ status = _ux_host_stack_transfer_request(transfer_request);
+
+ /* Check completion status. */
+ if(status == UX_SUCCESS && transfer_request -> ux_transfer_request_actual_length == 1)
+ {
+
+ /* We have an answer from the device. Check the HNP flag. */
+ if (*otg_status & UX_OTG_HOST_REQUEST_FLAG)
+ {
+ /* The device has requested a Host swap. Initiate the command and perform the
+ stopping of the host. */
+ _ux_host_stack_role_swap(device);
}
+
}
+
+ /* Free all used resources. */
+ _ux_utility_memory_free(otg_status);
- /* Move to next configuration in the list. */
- configuration = configuration -> ux_configuration_next_configuration;
-
- }
+ }
}
}
diff --git a/common/core/src/ux_host_stack_new_device_create.c b/common/core/src/ux_host_stack_new_device_create.c
index af6a109..e9ee549 100644
--- a/common/core/src/ux_host_stack_new_device_create.c
+++ b/common/core/src/ux_host_stack_new_device_create.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_new_device_create PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -59,6 +59,8 @@
/* without creating an */
/* OVER_CURRENT condition on */
/* the bus */
+/* created_device Destination to fill created */
+/* device instance */
/* */
/* OUTPUT */
/* */
@@ -96,11 +98,16 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* added a new parameter to */
+/* return created device, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_new_device_create(UX_HCD *hcd, UX_DEVICE *device_owner,
UINT port_index, UINT device_speed,
- UINT port_max_power)
+ UINT port_max_power,
+ UX_DEVICE **created_device)
{
UX_DEVICE *device;
@@ -138,6 +145,9 @@ UX_ENDPOINT *control_endpoint;
return(UX_TOO_MANY_DEVICES);
}
+ /* Store the device instance. */
+ *created_device = device;
+
/* Increment the number of devices on this bus. */
hcd -> ux_hcd_nb_devices++;
diff --git a/common/core/src/ux_host_stack_rh_change_process.c b/common/core/src/ux_host_stack_rh_change_process.c
index ccce8e8..ccce8e8 100644..100755
--- a/common/core/src/ux_host_stack_rh_change_process.c
+++ b/common/core/src/ux_host_stack_rh_change_process.c
diff --git a/common/core/src/ux_host_stack_rh_device_insertion.c b/common/core/src/ux_host_stack_rh_device_insertion.c
index a30ed4a..6e33f47 100644
--- a/common/core/src/ux_host_stack_rh_device_insertion.c
+++ b/common/core/src/ux_host_stack_rh_device_insertion.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_stack_rh_device_insertion PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -73,11 +73,20 @@
/* checked HCD status before */
/* retrying enumeration, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* handled more fail cases, */
+/* updated internal call, */
+/* added notification for */
+/* device connection, */
+/* added disconnection check */
+/* in enumeration retries, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_stack_rh_device_insertion(UX_HCD *hcd, UINT port_index)
{
+UX_DEVICE *device;
UINT index_loop;
UINT device_speed;
ULONG port_status;
@@ -125,12 +134,20 @@ UINT status;
return(UX_DEVICE_ENUMERATION_FAILURE);
}
+ /* Check if device is still connected. */
+ if ((port_status & UX_PS_CCS) == 0)
+ {
+
+ /* Device disconnected during enumeration retries. */
+ return(UX_DEVICE_ENUMERATION_FAILURE);
+ }
+
/* Set the device speed. */
device_speed = port_status >> UX_PS_DS;
/* Ask the USB stack to enumerate this device. A root hub is considered self
powered. */
- status = _ux_host_stack_new_device_create(hcd, UX_NULL, port_index, device_speed, UX_MAX_SELF_POWER);
+ status = _ux_host_stack_new_device_create(hcd, UX_NULL, port_index, device_speed, UX_MAX_SELF_POWER, &device);
/* Check return status. */
if (status == UX_SUCCESS)
@@ -143,6 +160,12 @@ UINT status;
function again */
hcd -> ux_hcd_rh_device_connection |= (ULONG)(1 << port_index);
+ /* If the device instance is ready, notify application for connection. */
+ if (_ux_system_host -> ux_system_host_change_function)
+ {
+ _ux_system_host -> ux_system_host_change_function(UX_DEVICE_CONNECTION, UX_NULL, (VOID*)device);
+ }
+
/* Return success to the caller. */
return(UX_SUCCESS);
}
@@ -153,10 +176,18 @@ UINT status;
if (hcd -> ux_hcd_status != UX_HCD_STATUS_OPERATIONAL)
return(UX_CONTROLLER_DEAD);
+ /* No retry if there are too many devices. */
+ if (status == UX_TOO_MANY_DEVICES)
+ break;
+
+ /* No retry if there is no class found. */
+ if (status == UX_NO_CLASS_MATCH)
+ break;
+
/* Simulate remove to free allocated resources if retry. */
if (index_loop < UX_RH_ENUMERATION_RETRY - 1)
- _ux_host_stack_device_remove(hcd, UX_NULL, port_index);
- }
+ _ux_host_stack_device_remove(hcd, UX_NULL, port_index);
+ }
}
/* We get here if something did not go well. Either the port did not respond
@@ -165,10 +196,19 @@ UINT status;
_ux_utility_delay_ms(UX_RH_ENUMERATION_RETRY_DELAY);
}
- /* If we get here, the device did not enumerate completely. The device is still attached to the root
- hub and therefore there is a physical connection with a unenumerated device. */
+ /* If we get here, the device did not enumerate completely.
+ The device is still attached to the root hub and therefore
+ there could be a physical connection with a unconfigured device. */
hcd -> ux_hcd_rh_device_connection |= (ULONG)(1 << port_index);
+ /* Notify application for a physical connection failed to be enumed.
+ Device instance NULL indicates too many devices.
+ Device state unconfigured indicates enumeration fail. */
+ if (_ux_system_host -> ux_system_host_change_function)
+ {
+ _ux_system_host -> ux_system_host_change_function(UX_DEVICE_CONNECTION, UX_NULL, (VOID*)device);
+ }
+
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE);
diff --git a/common/core/src/ux_utility_delay_ms.c b/common/core/src/ux_utility_delay_ms.c
index e996b04..e996b04 100644..100755
--- a/common/core/src/ux_utility_delay_ms.c
+++ b/common/core/src/ux_utility_delay_ms.c