Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define UX_SOURCE_CODE
#define UX_HCD_STM32_SOURCE_CODE
#include "ux_api.h"
#include "ux_hcd_stm32.h"
#include "ux_host_stack.h"
...
...
HAL_HCD_Connect_Callback(HCD_HandleTypeDef *)
...
...
HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *)
...
...
HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *, uint8_t, HCD_URBStateTypeDef)
...
HAL_HCD_SOF_Callback(HCD_HandleTypeDef *)
Files
loading (3/5)...
SourceVuSTM32 Libraries and Samplesusbxcommon/usbx_stm32_host_controllers/ux_hcd_stm32_callback.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* 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 */ /** */ /** STM32 Controller Driver */ /** */... /**************************************************************************/ /**************************************************************************/ /* Include necessary system files. */ #define UX_SOURCE_CODE #define UX_HCD_STM32_SOURCE_CODE #include "ux_api.h" #include "ux_hcd_stm32.h" #include "ux_host_stack.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* HAL_HCD_Connect_Callback PORTABLE C */ /* 6.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function handles callback from HAL driver. */ /* */ /* INPUT */ /* */ /* hhcd Pointer to HCD handle */ /* */ /* OUTPUT */ /* */ /* Completion Status */ /* */ /* CALLS */ /* */ /* _ux_utility_semaphore_put Put semaphore */ /* */ /* CALLED BY */ /* */ /* stm32 Controller Driver */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* */... /**************************************************************************/ void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) { UX_HCD *hcd; UX_HCD_STM32 *hcd_stm32; /* Get the pointer to the HCD & HCD_STM32. */ hcd = (UX_HCD*)hhcd -> pData; hcd_stm32 = (UX_HCD_STM32*)hcd -> ux_hcd_controller_hardware; /* Something happened on the root hub port. Signal it to the root hub thread. */ hcd -> ux_hcd_root_hub_signal[0]++; /* The controller has issued a ATTACH Root HUB signal. */ hcd_stm32 -> ux_hcd_stm32_controller_flag |= UX_HCD_STM32_CONTROLLER_FLAG_DEVICE_ATTACHED; hcd_stm32 -> ux_hcd_stm32_controller_flag &= ~UX_HCD_STM32_CONTROLLER_FLAG_DEVICE_DETACHED; /* Wake up the root hub thread. */ _ux_utility_semaphore_put(&_ux_system_host -> ux_system_host_enum_semaphore); }{ ... } ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* HAL_HCD_Disconnect_Callback PORTABLE C */ /* 6.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function handles callback from HAL driver. */ /* */ /* INPUT */ /* */ /* hhcd Pointer to HCD handle */ /* */ /* OUTPUT */ /* */ /* Completion Status */ /* */ /* CALLS */ /* */ /* _ux_utility_semaphore_put Put semaphore */ /* */ /* CALLED BY */ /* */ /* stm32 Controller Driver */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* */... /**************************************************************************/ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) { UX_HCD *hcd; UX_HCD_STM32 *hcd_stm32; /* Get the pointer to the HCD & HCD_STM32. */ hcd = (UX_HCD*)hhcd -> pData; hcd_stm32 = (UX_HCD_STM32*)hcd -> ux_hcd_controller_hardware; /* Something happened on the root hub port. Signal it to the root hub thread. */ hcd -> ux_hcd_root_hub_signal[0]++; /* The controller has issued a DETACH Root HUB signal. */ hcd_stm32 -> ux_hcd_stm32_controller_flag |= UX_HCD_STM32_CONTROLLER_FLAG_DEVICE_DETACHED; hcd_stm32 -> ux_hcd_stm32_controller_flag &= ~UX_HCD_STM32_CONTROLLER_FLAG_DEVICE_ATTACHED; /* Wake up the root hub thread. */ _ux_utility_semaphore_put(&_ux_system_host -> ux_system_host_enum_semaphore); }{ ... } ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* HAL_HCD_Disconnect_Callback PORTABLE C */ /* 6.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function handles callback from HAL driver. */ /* */ /* INPUT */ /* */ /* hhcd Pointer to HCD handle */ /* */ /* OUTPUT */ /* */ /* Completion Status */ /* */ /* CALLS */ /* */ /* _ux_utility_semaphore_put Put semaphore */ /* HAL_HCD_HC_SubmitRequest Submit request */ /* HAL_HCD_HC_Halt Halt channel */ /* HAL_HCD_HC_GetXferCount Get transfer count */ /* */ /* CALLED BY */ /* */ /* stm32 Controller Driver */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* */... /**************************************************************************/ void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) { UX_HCD *hcd; UX_HCD_STM32 *hcd_stm32; UX_HCD_STM32_ED *ed; UX_TRANSFER *transfer_request; /* Check the URB state. */ if (urb_state == URB_DONE || urb_state == URB_STALL || urb_state == URB_ERROR || urb_state == URB_NOTREADY) { /* Get the pointer to the HCD & HCD_STM32. */ hcd = (UX_HCD*)hhcd -> pData; hcd_stm32 = (UX_HCD_STM32*)hcd -> ux_hcd_controller_hardware; /* Check if driver is still valid. */ if (hcd_stm32 == UX_NULL) return; /* Load the ED for the channel. */ ed = hcd_stm32 -> ux_hcd_stm32_channels_ed[chnum]; /* Check if ED is still valid. */ if (ed == UX_NULL) { return; }if (ed == UX_NULL) { ... } /* Get transfer request. */ transfer_request = ed -> ux_stm32_ed_transfer_request; /* Check if ED is still valid. */ if (transfer_request == UX_NULL) { return; }if (transfer_request == UX_NULL) { ... } /* Check if URB state is not URB_NOTREADY. */ if (urb_state != URB_NOTREADY) { /* Handle URB states. */ switch (urb_state) { case URB_STALL: /* Set the completion code to stalled. */ transfer_request -> ux_transfer_request_completion_code = UX_TRANSFER_STALLED; break;case URB_STALL: case URB_DONE: /* Check the request direction. */ if ((((ed->ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) != UX_CONTROL_ENDPOINT) && (transfer_request -> ux_transfer_request_type & UX_REQUEST_DIRECTION) == UX_REQUEST_IN) { /* Get transfer size for receiving direction. */ transfer_request -> ux_transfer_request_actual_length = HAL_HCD_HC_GetXferCount(hcd_stm32 -> hcd_handle, ed -> ux_stm32_ed_channel); }if ((((ed->ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) != UX_CONTROL_ENDPOINT) && (transfer_request -> ux_transfer_request_type & UX_REQUEST_DIRECTION) == UX_REQUEST_IN) { ... } /* Check if the request is for bulk OUT or control OUT. */ if ((((ed -> ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) == UX_BULK_ENDPOINT || ((ed -> ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) == UX_CONTROL_ENDPOINT) && (transfer_request -> ux_transfer_request_type & UX_REQUEST_DIRECTION) == UX_REQUEST_OUT) { /* Update actual transfer length. */ transfer_request -> ux_transfer_request_actual_length += transfer_request -> ux_transfer_request_packet_length; /* Check if there is more data to send. */ if (transfer_request -> ux_transfer_request_requested_length > transfer_request -> ux_transfer_request_actual_length) { /* Adjust the transmit length. */ transfer_request -> ux_transfer_request_packet_length = UX_MIN(ed->ux_stm32_ed_endpoint->ux_endpoint_descriptor.wMaxPacketSize, transfer_request -> ux_transfer_request_requested_length - transfer_request -> ux_transfer_request_actual_length); /* Submit the transmit request. */ HAL_HCD_HC_SubmitRequest(hcd_stm32 -> hcd_handle, ed -> ux_stm32_ed_channel, 0, EP_TYPE_BULK, USBH_PID_DATA, transfer_request->ux_transfer_request_data_pointer + transfer_request -> ux_transfer_request_actual_length, transfer_request -> ux_transfer_request_packet_length, 0); return; }if (transfer_request -> ux_transfer_request_requested_length > transfer_request -> ux_transfer_request_actual_length) { ... } }if ((((ed -> ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) == UX_BULK_ENDPOINT || ((ed -> ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) == UX_CONTROL_ENDPOINT) && (transfer_request -> ux_transfer_request_type & UX_REQUEST_DIRECTION) == UX_REQUEST_OUT) { ... } /* Set the completion code to SUCCESS. */ transfer_request -> ux_transfer_request_completion_code = UX_SUCCESS; break;case URB_DONE: default: /* Set the completion code to transfer error. */ transfer_request -> ux_transfer_request_completion_code = UX_TRANSFER_ERROR;default }switch (urb_state) { ... } /* Move to next transfer. */ ed -> ux_stm32_ed_transfer_request = transfer_request -> ux_transfer_request_next_transfer_request; /* Invoke callback function. */ if (transfer_request -> ux_transfer_request_completion_function) transfer_request -> ux_transfer_request_completion_function(transfer_request); /* Wake up the transfer request thread. */ _ux_utility_semaphore_put(&transfer_request -> ux_transfer_request_semaphore); }if (urb_state != URB_NOTREADY) { ... } else { /* Handle URB_NOTREADY state here. */ /* Check if we need to retry the transfer by checking the status. */ if ((ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_SETUP) || (ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_DATA_OUT) || (ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_STATUS_OUT) || (ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_BULK_OUT)) { /* Submit the transmit request. */ HAL_HCD_HC_SubmitRequest(hcd_stm32 -> hcd_handle, ed -> ux_stm32_ed_channel, 0, ((ed -> ux_stm32_ed_endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE) == UX_BULK_ENDPOINT ? EP_TYPE_BULK : EP_TYPE_CTRL, ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_SETUP ? USBH_PID_SETUP : USBH_PID_DATA, transfer_request -> ux_transfer_request_data_pointer + transfer_request -> ux_transfer_request_actual_length, transfer_request -> ux_transfer_request_packet_length, 0); }if ((ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_SETUP) || (ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_DATA_OUT) || (ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_CONTROL_STATUS_OUT) || (ed -> ux_stm32_ed_status == UX_HCD_STM32_ED_STATUS_BULK_OUT)) { ... } }else { ... } }if (urb_state == URB_DONE || urb_state == URB_STALL || urb_state == URB_ERROR || urb_state == URB_NOTREADY) { ... } }{ ... } ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* HAL_HCD_SOF_Callback PORTABLE C */ /* 6.0 */ /* AUTHOR */ /* */ /* Chaoqiong Xiao, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function handles callback from HAL driver. */ /* */ /* INPUT */ /* */ /* hhcd Pointer to HCD handle */ /* */ /* OUTPUT */ /* */ /* Completion Status */ /* */ /* CALLS */ /* */ /* _ux_utility_semaphore_put Put semaphore */ /* */ /* CALLED BY */ /* */ /* stm32 Controller Driver */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ /* */... /**************************************************************************/ void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd) { UX_HCD *hcd; UX_HCD_STM32 *hcd_stm32; /* Get the pointer to the HCD & HCD_STM32. */ hcd = (UX_HCD*)hhcd -> pData; hcd_stm32 = (UX_HCD_STM32*)hcd -> ux_hcd_controller_hardware; if ((hcd_stm32 -> ux_hcd_stm32_controller_flag & UX_HCD_STM32_CONTROLLER_FLAG_SOF) == 0) { hcd_stm32 -> ux_hcd_stm32_controller_flag |= UX_HCD_STM32_CONTROLLER_FLAG_SOF; hcd -> ux_hcd_thread_signal++; /* Wake up the scheduler. */ _ux_utility_semaphore_put(&_ux_system_host -> ux_system_host_hcd_semaphore); }if ((hcd_stm32 -> ux_hcd_stm32_controller_flag & UX_HCD_STM32_CONTROLLER_FLAG_SOF) == 0) { ... } }{ ... }
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.