1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** HUB Class */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_host_class_hub.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_hub_port_change_process PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function will process a port change indication. */
46 /* */
47 /* INPUT */
48 /* */
49 /* hub Pointer to HUB class */
50 /* port Port number */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* Completion Status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _ux_host_class_hub_port_change_connection_process */
59 /* Process connection */
60 /* _ux_host_class_hub_port_change_enable_process */
61 /* Enable process */
62 /* _ux_host_class_hub_port_change_over_current_process */
63 /* Change over current process */
64 /* _ux_host_class_hub_port_change_reset_process */
65 /* Reset process */
66 /* _ux_host_class_hub_port_change_suspend_process */
67 /* Suspend process */
68 /* _ux_host_class_hub_status_get Get HUB status */
69 /* */
70 /* CALLED BY */
71 /* */
72 /* HUB Class */
73 /* */
74 /* RELEASE HISTORY */
75 /* */
76 /* DATE NAME DESCRIPTION */
77 /* */
78 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
79 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
80 /* resulting in version 6.1 */
81 /* */
82 /**************************************************************************/
_ux_host_class_hub_port_change_process(UX_HOST_CLASS_HUB * hub,UINT port)83 UINT _ux_host_class_hub_port_change_process(UX_HOST_CLASS_HUB *hub, UINT port)
84 {
85
86 USHORT port_status;
87 USHORT port_change;
88 UINT status;
89
90
91 /* First step is to retrieve the status on the port with a GET_STATUS. */
92 status = _ux_host_class_hub_status_get(hub, port, &port_status, &port_change);
93 if (status != UX_SUCCESS)
94 return(status);
95
96 /* On return of the GET_STATUS, the port change field has been updated
97 check for each of the bits it may contain. */
98 if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_CONNECTION)
99 _ux_host_class_hub_port_change_connection_process(hub, port, port_status);
100
101 if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_ENABLE)
102 _ux_host_class_hub_port_change_enable_process(hub, port, port_status);
103
104 if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_SUSPEND)
105 _ux_host_class_hub_port_change_suspend_process(hub, port, port_status);
106
107 if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_OVER_CURRENT)
108 _ux_host_class_hub_port_change_over_current_process(hub, port, port_status);
109
110 if (port_change & UX_HOST_CLASS_HUB_PORT_CHANGE_RESET)
111 _ux_host_class_hub_port_change_reset_process(hub, port, port_status);
112
113 /* Return successful completion. */
114 return(UX_SUCCESS);
115 }
116
117