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 /**   Slave Simulator Controller Driver                                   */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define UX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "ux_api.h"
29 #include "ux_dcd_sim_slave.h"
30 #include "ux_hcd_sim_host.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_dcd_sim_slave_state_change                      PORTABLE C      */
38 /*                                                           6.1.10       */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function will set the state of the controller to the desired   */
46 /*    value.                                                              */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    dcd_sim_slave                         Pointer to device controller  */
51 /*    state                                 Desired state                 */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    Completion Status                                                   */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Slave Simulator Controller Driver                                   */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
70 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*  04-02-2021     Chaoqiong Xiao           Modified comment(s),          */
73 /*                                            simulate force disconnect,  */
74 /*                                            resulting in version 6.1.6  */
75 /*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
76 /*                                            added standalone support,   */
77 /*                                            resulting in version 6.1.10 */
78 /*                                                                        */
79 /**************************************************************************/
_ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE * dcd_sim_slave,ULONG state)80 UINT  _ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG state)
81 {
82 
83 UX_HCD              *hcd;
84 
85 
86     UX_PARAMETER_NOT_USED(state);
87 
88     if (state == UX_DEVICE_FORCE_DISCONNECT)
89     {
90 
91         /* Simulate port detach & attach on host side.  */
92 
93         /* Get HCD.  */
94         hcd = (UX_HCD *)dcd_sim_slave -> ux_dcd_sim_slave_hcd;
95 
96         /* Something happened on this port. Signal it to the root hub thread.  */
97         if (hcd)
98         {
99             hcd -> ux_hcd_root_hub_signal[0] = 2;
100             _ux_host_semaphore_put(&_ux_system_host -> ux_system_host_enum_semaphore);
101         }
102     }
103 
104     /* Nothing to do in simulation mode.  */
105     return(UX_SUCCESS);
106 }
107 
108