1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
64 |
|
1723 |
UINT _ux_host_stack_interface_instance_create(UX_INTERFACE *interface_ptr) |
65 |
|
|
{ |
66 |
|
|
|
67 |
|
|
UX_ENDPOINT *endpoint; |
68 |
|
|
UINT status; |
69 |
|
|
|
70 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
71 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_STACK_INTERFACE_INSTANCE_CREATE, interface_ptr, 0, 0, 0, UX_TRACE_HOST_STACK_EVENTS, 0, 0) |
72 |
|
|
|
73 |
|
|
/* Obtain the first endpoint for this alternate setting. */ |
74 |
|
1723 |
endpoint = interface_ptr -> ux_interface_first_endpoint; |
75 |
|
|
|
76 |
|
|
/* Loop to create each endpoint. */ |
77 |
✓✓ |
3828 |
while (endpoint != UX_NULL) |
78 |
|
|
{ |
79 |
|
|
|
80 |
|
|
/* Create an endpoint for the instance. */ |
81 |
|
2125 |
status = _ux_host_stack_endpoint_instance_create(endpoint); |
82 |
|
|
|
83 |
|
|
/* Check status, the controller may have refused the endpoint creation. */ |
84 |
✓✓ |
2125 |
if (status != UX_SUCCESS) |
85 |
|
|
|
86 |
|
|
/* An error occurred at the controller level. */ |
87 |
|
20 |
return(status); |
88 |
|
|
|
89 |
|
|
/* Move to next endpoint. */ |
90 |
|
2105 |
endpoint = endpoint -> ux_endpoint_next_endpoint; |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
/* If trace is enabled, register this object. */ |
94 |
|
|
UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_INTERFACE, interface_ptr, 0, 0, 0); |
95 |
|
|
|
96 |
|
|
/* Return completion status. */ |
97 |
|
1703 |
return(UX_SUCCESS); |
98 |
|
|
} |
99 |
|
|
|