Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_host_class_hid.h"
#include "ux_host_stack.h"
...
...
_ux_host_class_hid_activate(UX_HOST_CLASS_COMMAND *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesusbxcommon/usbx_host_classes/src/ux_host_class_hid_activate.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* 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 */ /** */ /** HID Class */ /** */... /**************************************************************************/ /**************************************************************************/ /* Include necessary system files. */ #define UX_SOURCE_CODE #include "ux_api.h" #include "ux_host_class_hid.h" #include "ux_host_stack.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _ux_host_class_hid_activate PORTABLE C */ /* 6.1.10 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function performs the enumeration of the HID class. */ /* */ /* INPUT */ /* */ /* command Pointer to command */ /* */ /* OUTPUT */ /* */ /* Completion Status */ /* */ /* CALLS */ /* */ /* _ux_host_class_hid_client_search HID client search */ /* _ux_host_class_hid_configure Configure HID */ /* _ux_host_class_hid_descriptor_parse Parse descriptor */ /* _ux_host_class_hid_interrupt_endpoint_search Search endpoint */ /* _ux_host_class_hid_instance_clean Clean up instance resources */ /* _ux_host_stack_class_instance_create Create class instance */ /* _ux_host_stack_class_instance_destroy Destroy class instance */ /* _ux_utility_memory_allocate Allocate memory block */ /* _ux_utility_memory_free Free memory */ /* _ux_host_semaphore_create Create semaphore */ /* */ /* CALLED BY */ /* */ /* HID Class */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ /* resulting in version 6.1 */ /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ /* added standalone support, */ /* resulting in version 6.1.10 */ /* */... /**************************************************************************/ UINT _ux_host_class_hid_activate(UX_HOST_CLASS_COMMAND *command) { UX_INTERFACE *interface; UX_HOST_CLASS_HID *hid; UINT status; /* The HID is always activated by the interface descriptor and not the device descriptor. *//* ... */ interface = (UX_INTERFACE *) command -> ux_host_class_command_container; /* Instantiate this HID class */ hid = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY,sizeof(UX_HOST_CLASS_HID)); if (hid == UX_NULL) return(UX_MEMORY_INSUFFICIENT); /* Store the class container into this instance. */ hid -> ux_host_class_hid_class = command -> ux_host_class_command_class_ptr; /* Store the interface container into the HID class instance. */ hid -> ux_host_class_hid_interface = interface; /* Store the device container into the HID class instance. */ hid -> ux_host_class_hid_device = interface -> ux_interface_configuration -> ux_configuration_device; /* This instance of the device must also be stored in the interface container. */ interface -> ux_interface_class_instance = (VOID *) hid; /* Create this class instance. */ _ux_host_stack_class_instance_create(command -> ux_host_class_command_class_ptr, (VOID *) hid); #if defined(UX_HOST_STANDALONE) /* Set class tasks function. */ hid -> ux_host_class_hid_class -> ux_host_class_task_function = _ux_host_class_hid_tasks_run; /* Set activate state to first step. */ hid -> ux_host_class_hid_enum_state = UX_STATE_WAIT; status = UX_SUCCESS; return(status);/* ... */ #else /* Configure the HID. */ status = _ux_host_class_hid_configure(hid); /* If configure is done success, goes on. */ if (status == UX_SUCCESS) { /* Get the HID descriptor and parse it. */ status = _ux_host_class_hid_descriptor_parse(hid); }if (status == UX_SUCCESS) { ... } /* If HID descriptor parse is done success, goes on. */ if (status == UX_SUCCESS) { /* Search the HID interrupt endpoint but do not start it. */ status = _ux_host_class_hid_interrupt_endpoint_search(hid); }if (status == UX_SUCCESS) { ... } /* If HID interrupt endpoint is found, goes on. */ if (status == UX_SUCCESS) { /* Create the semaphore to protect multiple threads from accessing the same storage instance. *//* ... */ status = _ux_host_semaphore_create(&hid -> ux_host_class_hid_semaphore, "ux_host_class_hid_semaphore", 1); if (status == UX_SUCCESS) { /* If all is fine, try to locate the HID client for this HID device. */ _ux_host_class_hid_client_search(hid); /* Mark the HID class as live now. */ hid -> ux_host_class_hid_state = UX_HOST_CLASS_INSTANCE_LIVE; /* We may need to inform the application if a function has been programmed in the system structure. */ if (_ux_system_host -> ux_system_host_change_function != UX_NULL) { /* Call system change function. */ _ux_system_host -> ux_system_host_change_function(UX_DEVICE_INSERTION, hid -> ux_host_class_hid_class, (VOID *) hid); }if (_ux_system_host -> ux_system_host_change_function != UX_NULL) { ... } /* If trace is enabled, insert this event into the trace buffer. */ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_HID_ACTIVATE, hid, 0, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0) /* If trace is enabled, register this object. */ UX_TRACE_OBJECT_REGISTER(UX_TRACE_HOST_OBJECT_TYPE_INTERFACE, hid, 0, 0, 0) /* Return completion code. */ return(status); }if (status == UX_SUCCESS) { ... } else { status = UX_SEMAPHORE_ERROR; }else { ... } }if (status == UX_SUCCESS) { ... } /* Clean interrupt endpoint. */ if (hid -> ux_host_class_hid_interrupt_endpoint && hid -> ux_host_class_hid_interrupt_endpoint -> ux_endpoint_transfer_request.ux_transfer_request_data_pointer) _ux_utility_memory_free(hid -> ux_host_class_hid_interrupt_endpoint -> ux_endpoint_transfer_request.ux_transfer_request_data_pointer); /* Clean instance. */ _ux_host_class_hid_instance_clean(hid); /* Error, destroy the class instance and return error code. */ _ux_host_stack_class_instance_destroy(hid -> ux_host_class_hid_class, (VOID *) hid); /* Unmount instance. */ interface -> ux_interface_class_instance = UX_NULL; /* Free instance. */ _ux_utility_memory_free(hid); /* Return error code. */ return(status); /* ... */ #endif }{ ... }