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 /**   Host Stack                                                          */
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_stack.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_host_stack_interface_instance_create            PORTABLE C      */
37 /*                                                           6.1.12       */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Chaoqiong Xiao, Microsoft Corporation                               */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function will create an interface instance. It creates each    */
45 /*    endpoint associated with the interface.                             */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    interface                             Pointer to interface          */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    Completion Status                                                   */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _ux_host_stack_endpoint_instance_create Create instance endpoint    */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    USBX Components                                                     */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
68 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*  07-29-2022     Chaoqiong Xiao           Modified comment(s),          */
71 /*                                            fixed parameter/variable    */
72 /*                                            names conflict C++ keyword, */
73 /*                                            resulting in version 6.1.12 */
74 /*                                                                        */
75 /**************************************************************************/
_ux_host_stack_interface_instance_create(UX_INTERFACE * interface_ptr)76 UINT  _ux_host_stack_interface_instance_create(UX_INTERFACE *interface_ptr)
77 {
78 
79 UX_ENDPOINT     *endpoint;
80 UINT            status;
81 
82     /* If trace is enabled, insert this event into the trace buffer.  */
83     UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_CREATE, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0)
84 
85     /* Obtain the first endpoint for this alternate setting.  */
86     endpoint =  interface_ptr -> ux_interface_first_endpoint;
87 
88     /* Loop to create each endpoint.  */
89     while (endpoint != UX_NULL)
90     {
91 
92         /* Create an endpoint for the instance.  */
93         status = _ux_host_stack_endpoint_instance_create(endpoint);
94 
95         /* Check status, the controller may have refused the endpoint creation.  */
96         if (status != UX_SUCCESS)
97 
98             /* An error occurred at the controller level.  */
99             return(status);
100 
101         /* Move to next endpoint.  */
102         endpoint =  endpoint -> ux_endpoint_next_endpoint;
103     }
104 
105     /* If trace is enabled, register this object.  */
106     UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_INTERFACE, interface_ptr, 0, 0, 0);
107 
108     /* Return completion status.  */
109     return(UX_SUCCESS);
110 }
111 
112