-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathUSBHALHost_STM.cpp
606 lines (527 loc) · 19.8 KB
/
USBHALHost_STM.cpp
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
/* mbed USBHost Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef TARGET_STM
#if defined(TARGET_PORTENTA_H7) || defined(PORTENTA_H7_PINS)
#define USBx_BASE USB2_OTG_FS_PERIPH_BASE
#elif defined(TARGET_GIGA) || defined(GIGA_PINS)
#define USBx_BASE USB1_OTG_HS_PERIPH_BASE
#else
#define USBx_BASE USB1_OTG_HS_PERIPH_BASE
#endif
#include "mbed.h"
#include "USBHost/USBHALHost.h"
#include "USBHost/dbg.h"
#include "pinmap.h"
#include "mbed_chrono.h"
#include "USBHALHost_STM.h"
void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd)
{
USBHALHost_Private_t *priv = (USBHALHost_Private_t *)(hhcd->pData);
USBHALHost *obj = priv->inst;
void (USBHALHost::*func)(int hub, int port, bool lowSpeed, USBHostHub * hub_parent) = priv->deviceConnected;
(obj->*func)(0, 1, 0, NULL);
}
void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd)
{
USBHALHost_Private_t *priv = (USBHALHost_Private_t *)(hhcd->pData);
USBHALHost *obj = priv->inst;
void (USBHALHost::*func1)(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr) = priv->deviceDisconnected;
(obj->*func1)(0, 1, (USBHostHub *)NULL, 0);
}
int HAL_HCD_HC_GetDirection(HCD_HandleTypeDef *hhcd, uint8_t chnum)
{
/* useful for transmission */
return hhcd->hc[chnum].ep_is_in;
}
uint32_t HAL_HCD_HC_GetMaxPacket(HCD_HandleTypeDef *hhcd, uint8_t chnum)
{
/* useful for transmission */
return hhcd->hc[chnum].max_packet;
}
void HAL_HCD_EnableInt(HCD_HandleTypeDef *hhcd, uint8_t chnum)
{
USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
USBx_HOST->HAINTMSK |= (1 << chnum);
}
void HAL_HCD_DisableInt(HCD_HandleTypeDef *hhcd, uint8_t chnum)
{
USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
USBx_HOST->HAINTMSK &= ~(1 << chnum);
}
uint32_t HAL_HCD_HC_GetType(HCD_HandleTypeDef *hhcd, uint8_t chnum)
{
/* useful for transmission */
return hhcd->hc[chnum].ep_type;
}
// The urb_state parameter can be one of the following according to the ST documentation, but the explanations
// that follow are the result of an analysis of the ST HAL / LL source code, the Reference Manual for the
// STM32H747 microcontroller, and the source code of this library:
//
// - URB_ERROR = various serious errors that may be hard or impossible to recover from without pulling
// the thumb drive out and putting it back in again, but we will try
// - URB_IDLE = set by a call to HAL_HCD_HC_SubmitRequest(), but never used by this library
// - URB_NYET = never actually used by the ST HAL / LL at the time of writing, nor by this library
// - URB_STALL = a stall response from the device - but it is never handled by the library and will end up
// as a timeout at a higher layer, because of an ep_queue.get() timeout, which will activate
// error recovery indirectly
// - URB_DONE = the transfer completed normally without errors
// - URB_NOTREADY = a NAK, NYET, or not more than a couple of repeats of some of the errors that will
// become URB_ERROR if they repeat several times in a row
//
#if ARC_FS_OVER_HS
//
// In the underlying HAL code there are the following issues when running FS using the HS interface:
// This effects the GIGA as it has no external PHY which is required in order to run at HS.
//
// 1. Transmitting length larger then packetsize can cause future issues reading, the NAK nightmare.
// 2. Receiving multiple seperate packets can lead to lost data and the need to retry.
//
// So for transmitting we split the data into sizes of <= packet size and individually transfer them, only calling pPriv->transferCompleted() when all data is sent.
// For receiving we receive all the data and call pPriv->transferCompleted().
//
// If we get NAKS on the control OUT EPs we make sure that USB_OTG_HCCHAR_CHDIS ans USB_OTG_HCCHAR_CHENA are reset to the correct values.
//
void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *pHcd, uint8_t uChannel, HCD_URBStateTypeDef urbState)
{
USBHALHost_Private_t *pPriv = (USBHALHost_Private_t *)(pHcd->pData);
HCTD *pTransferDescriptor = (HCTD *)pPriv->addr[uChannel];
if (pTransferDescriptor)
{
uint32_t endpointType = pHcd->hc[uChannel].ep_type;
if ((endpointType == EP_TYPE_INTR))
{
// Disable the channel interrupt and retransfer below
// TOD: really this retransfer should be queued up and transfered on the SOF interupt based on interval from descriptor.
pTransferDescriptor->state = USB_TYPE_IDLE ;
HAL_HCD_DisableInt(pHcd, uChannel);
pTransferDescriptor->currBufPtr += HAL_HCD_HC_GetXferCount(pHcd, uChannel);
}
else if ((endpointType == EP_TYPE_BULK) || (endpointType == EP_TYPE_CTRL))
{
uint8_t uEpIsInput = pHcd->hc[uChannel].ep_is_in;
switch(urbState)
{
case URB_NOTREADY:
{
if(!uEpIsInput)
{
#if ARC_NO_RESUBMITREQUEST
// make sure that USB_OTG_HCCHAR_CHDIS and USB_OTG_HCCHAR_CHENA are reset to the correct values
uint32_t tmpreg;
tmpreg = USBx_HC(uChannel)->HCCHAR;
tmpreg &= ~USB_OTG_HCCHAR_CHDIS;
tmpreg |= USB_OTG_HCCHAR_CHENA;
USBx_HC(uChannel)->HCCHAR = tmpreg;
#else
// Submit the same request again, because the device wasn't ready to accept the last one
uint16_t uPacketSize = pHcd->hc[uChannel].max_packet;
uint16_t uTransferSize = (pTransferDescriptor->size > uPacketSize) ? uPacketSize : pTransferDescriptor->size;
HAL_HCD_HC_SubmitRequest(pHcd, uChannel, uEpIsInput, endpointType, !pTransferDescriptor->setup, (uint8_t *) pTransferDescriptor->currBufPtr, uTransferSize, 0);
HAL_HCD_EnableInt(pHcd, uChannel);
#endif
}
}
break;
case URB_DONE:
{
// first calculate how much we transferred, HAL metrics aonly work for IN EPs
uint16_t uPacketSize = pHcd->hc[uChannel].max_packet;
uint16_t uTransferredCount;
if(uEpIsInput)
uTransferredCount = HAL_HCD_HC_GetXferCount(pHcd, uChannel);
else
uTransferredCount = (pTransferDescriptor->size > uPacketSize) ? uPacketSize : pTransferDescriptor->size;
// update transfer descriptor
pTransferDescriptor->size -= uTransferredCount;
pTransferDescriptor->currBufPtr += uTransferredCount;
// if we are an OUT EP and there is still more data, send next packet
if(!uEpIsInput && pTransferDescriptor->size )
{
uint16_t uTransferSize = (pTransferDescriptor->size > uPacketSize) ? uPacketSize : pTransferDescriptor->size;
HAL_HCD_HC_SubmitRequest(pHcd, uChannel, uEpIsInput, endpointType, !pTransferDescriptor->setup, (uint8_t *) pTransferDescriptor->currBufPtr, uTransferSize, 0);
HAL_HCD_EnableInt(pHcd, uChannel);
}
else
{
// this will be handled below for USB_TYPE_IDLE
pTransferDescriptor->state = USB_TYPE_IDLE;
}
}
break;
case URB_ERROR:
{
// While USB_TYPE_ERROR in the endpoint state is used to activate error recovery, this value is actually never used.
// Going here will lead to a timeout at a higher layer, because of ep_queue.get() timeout, which will activate error
// recovery indirectly.
pTransferDescriptor->state = USB_TYPE_ERROR;
}
break;
default:
{
pTransferDescriptor->state = USB_TYPE_PROCESSING;
}
break;
}
}
if (pTransferDescriptor->state == USB_TYPE_IDLE)
{
// Call transferCompleted on correct object
void (USBHALHost::*func)(volatile uint32_t addr) = pPriv->transferCompleted;
(pPriv->inst->*func)(reinterpret_cast<std::uintptr_t>(pTransferDescriptor));
}
}
}
#elif ARC_USB_FULL_SIZE
void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *pHcd, uint8_t uChannel, HCD_URBStateTypeDef urbState)
{
USBHALHost_Private_t *pPriv = (USBHALHost_Private_t *)(pHcd->pData);
HCTD *pTransferDescriptor = (HCTD *)pPriv->addr[uChannel];
if (pTransferDescriptor)
{
constexpr uint32_t uRetryCount = 10;
uint32_t endpointType = pHcd->hc[uChannel].ep_type;
if ((endpointType == EP_TYPE_INTR))
{
// Disable the channel interrupt and retransfer below
pTransferDescriptor->state = USB_TYPE_IDLE ;
HAL_HCD_DisableInt(pHcd, uChannel);
}
else if ((endpointType == EP_TYPE_BULK) || (endpointType == EP_TYPE_CTRL))
{
switch(urbState)
{
case URB_NOTREADY:
{
// If we have transferred any data then disable retries
if(pHcd->hc[uChannel].xfer_count > 0)
pTransferDescriptor->retry = 0xffffffff; // Disable retries
else
{
// if the retry count is 0 then initialize downward counting retry
// otherwise decrement retry count
if(pTransferDescriptor->retry == 0)
pTransferDescriptor->retry = uRetryCount;
else
pTransferDescriptor->retry--;
}
// If our retry count has got down to 0 or we are an Ack then submit request again
if((pTransferDescriptor->retry == 0) || (pTransferDescriptor->size==0))
{
// initialize downward counting retry
pTransferDescriptor->retry = uRetryCount;
// resubmit the request.
HAL_HCD_HC_SubmitRequest(pHcd, uChannel, pHcd->hc[uChannel].ep_is_in, endpointType, !pTransferDescriptor->setup, (uint8_t *) pTransferDescriptor->currBufPtr, pTransferDescriptor->size, 0);
HAL_HCD_EnableInt(pHcd, uChannel);
}
}
break;
case URB_DONE:
{
// this will be handled below for USB_TYPE_IDLE
pTransferDescriptor->state = USB_TYPE_IDLE;
}
break;
case URB_ERROR:
{
// While USB_TYPE_ERROR in the endpoint state is used to activate error recovery, this value is actually never used.
// Going here will lead to a timeout at a higher layer, because of ep_queue.get() timeout, which will activate error
// recovery indirectly.
pTransferDescriptor->state = USB_TYPE_ERROR;
}
break;
default:
{
pTransferDescriptor->state = USB_TYPE_PROCESSING;
}
break;
}
}
if (pTransferDescriptor->state == USB_TYPE_IDLE)
{
// Disable retrues
pTransferDescriptor->retry = 0;
// Update transfer descriptor buffer pointer
pTransferDescriptor->currBufPtr += HAL_HCD_HC_GetXferCount(pHcd, uChannel);
// Call transferCompleted on correct object
void (USBHALHost::*func)(volatile uint32_t addr) = pPriv->transferCompleted;
(pPriv->inst->*func)(reinterpret_cast<std::uintptr_t>(pTransferDescriptor));
}
}
}
#else
void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state)
{
USBHALHost_Private_t *priv = (USBHALHost_Private_t *)(hhcd->pData);
USBHALHost *obj = priv->inst;
void (USBHALHost::*func)(volatile uint32_t addr) = priv->transferCompleted;
uint32_t addr = priv->addr[chnum];
uint32_t max_size = HAL_HCD_HC_GetMaxPacket(hhcd, chnum);
uint32_t type = HAL_HCD_HC_GetType(hhcd, chnum);
uint32_t dir = HAL_HCD_HC_GetDirection(hhcd, chnum);
uint32_t length;
if ((addr != 0)) {
HCTD *td = (HCTD *)addr;
if ((type == EP_TYPE_BULK) || (type == EP_TYPE_CTRL)) {
switch (urb_state) {
case URB_DONE:
#if defined(MAX_NOTREADY_RETRY)
td->retry = 0;
#endif
if (td->size > max_size) {
/* enqueue another request */
td->currBufPtr += max_size;
td->size -= max_size;
length = td->size <= max_size ? td->size : max_size;
HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir, type, !td->setup, (uint8_t *) td->currBufPtr, length, 0);
HAL_HCD_EnableInt(hhcd, chnum);
return;
}
break;
case URB_NOTREADY:
#if defined(MAX_NOTREADY_RETRY)
if (td->retry < MAX_NOTREADY_RETRY) {
td->retry++;
#endif
// Submit the same request again, because the device wasn't ready to accept the last one
length = td->size <= max_size ? td->size : max_size;
HAL_HCD_HC_SubmitRequest(hhcd, chnum, dir, type, !td->setup, (uint8_t *) td->currBufPtr, length, 0);
HAL_HCD_EnableInt(hhcd, chnum);
return;
#if defined(MAX_NOTREADY_RETRY)
} else {
// MAX_NOTREADY_RETRY reached, so stop trying to resend and instead wait for a timeout at a higher layer
}
#endif
break;
}
}
if ((type == EP_TYPE_INTR)) {
/* reply a packet of length NULL, this will be analyze in call back
* for mouse or hub */
td->state = USB_TYPE_IDLE ;
HAL_HCD_DisableInt(hhcd, chnum);
} else {
if (urb_state == URB_DONE) {
td->state = USB_TYPE_IDLE;
}
else if (urb_state == URB_ERROR) {
// While USB_TYPE_ERROR in the endpoint state is used to activate error recovery, this value is actually never used.
// Going here will lead to a timeout at a higher layer, because of ep_queue.get() timeout, which will activate error
// recovery indirectly.
td->state = USB_TYPE_ERROR;
} else {
td->state = USB_TYPE_PROCESSING;
}
}
if (td->state == USB_TYPE_IDLE) {
td->currBufPtr += HAL_HCD_HC_GetXferCount(hhcd, chnum);
(obj->*func)(addr);
}
} else {
if (urb_state != 0) {
//USB_DBG_EVENT("spurious %d %d", chnum, urb_state);
}
}
}
#endif
USBHALHost *USBHALHost::instHost;
#if defined(TARGET_OPTA)
#include <usb_phy_api.h>
#include <Wire.h>
#endif
void USBHALHost::init()
{
#if defined(TARGET_OPTA)
get_usb_phy()->deinit();
Wire1.begin();
// reset FUSB registers
Wire1.beginTransmission(0x21);
Wire1.write(0x5);
Wire1.write(0x1);
Wire1.endTransmission();
Wire1.beginTransmission(0x21);
Wire1.write(0x5);
Wire1.write(0x0);
Wire1.endTransmission();
delay(100);
// setup port as SRC
Wire1.beginTransmission(0x21);
Wire1.write(0x2);
Wire1.write(0x3);
Wire1.endTransmission();
// enable interrupts
Wire1.beginTransmission(0x21);
Wire1.write(0x3);
Wire1.write(1 << 1);
Wire1.endTransmission();
#endif
NVIC_DisableIRQ(USBHAL_IRQn);
NVIC_SetVector(USBHAL_IRQn, (uint32_t)(_usbisr));
HAL_HCD_Init((HCD_HandleTypeDef *) usb_hcca);
control_disable = 0;
HAL_HCD_Start((HCD_HandleTypeDef *) usb_hcca);
NVIC_EnableIRQ(USBHAL_IRQn);
usb_vbus(1);
}
uint32_t USBHALHost::controlHeadED()
{
return 0xffffffff;
}
uint32_t USBHALHost::bulkHeadED()
{
return 0xffffffff;
}
uint32_t USBHALHost::interruptHeadED()
{
return 0xffffffff;
}
void USBHALHost::updateBulkHeadED(uint32_t addr)
{
}
void USBHALHost::updateControlHeadED(uint32_t addr)
{
}
void USBHALHost::updateInterruptHeadED(uint32_t addr)
{
}
void USBHALHost::enableList(ENDPOINT_TYPE type)
{
/* react when the 3 lists are requested to be disabled */
if (type == CONTROL_ENDPOINT) {
control_disable--;
if (control_disable == 0) {
NVIC_EnableIRQ(USBHAL_IRQn);
} else {
//printf("reent\n");
}
}
}
bool USBHALHost::disableList(ENDPOINT_TYPE type)
{
if (type == CONTROL_ENDPOINT) {
NVIC_DisableIRQ(USBHAL_IRQn);
control_disable++;
if (control_disable > 1) {
//printf("disable reentrance !!!\n");
}
return true;
}
return false;
}
void USBHALHost::memInit()
{
usb_hcca = (volatile HCD_HandleTypeDef *)usb_buf;
usb_edBuf = usb_buf + HCCA_SIZE;
usb_tdBuf = usb_buf + HCCA_SIZE + (MAX_ENDPOINT * ED_SIZE);
/* init channel */
memset((void *)usb_buf, 0, TOTAL_SIZE);
for (int i = 0; i < MAX_ENDPOINT; i++) {
HCED *hced = (HCED *)(usb_edBuf + i * ED_SIZE);
hced->ch_num = i;
hced->hhcd = (HCCA *) usb_hcca;
}
}
volatile uint8_t *USBHALHost::getED()
{
for (int i = 0; i < MAX_ENDPOINT; i++) {
if (!edBufAlloc[i]) {
edBufAlloc[i] = true;
return (volatile uint8_t *)(usb_edBuf + i * ED_SIZE);
}
}
perror("Could not allocate ED\r\n");
return NULL; //Could not alloc ED
}
volatile uint8_t *USBHALHost::getTD()
{
int i;
for (i = 0; i < MAX_TD; i++) {
if (!tdBufAlloc[i]) {
tdBufAlloc[i] = true;
return (volatile uint8_t *)(usb_tdBuf + i * TD_SIZE);
}
}
perror("Could not allocate TD\r\n");
return NULL; //Could not alloc TD
}
void USBHALHost::freeED(volatile uint8_t *ed)
{
int i;
i = (ed - usb_edBuf) / ED_SIZE;
edBufAlloc[i] = false;
}
void USBHALHost::freeTD(volatile uint8_t *td)
{
int i;
i = (td - usb_tdBuf) / TD_SIZE;
tdBufAlloc[i] = false;
}
using namespace mbed::chrono_literals;
void USBHALHost::resetRootHub()
{
// Initiate port reset
rtos::ThisThread::sleep_for(200);
HAL_HCD_ResetPort((HCD_HandleTypeDef *)usb_hcca);
}
void USBHALHost::_usbisr(void)
{
if (instHost) {
instHost->UsbIrqhandler();
}
}
void USBHALHost::UsbIrqhandler()
{
#if ARC_USB_FULL_SIZE || ARC_FS_OVER_HS
// fix from Lix Paulian : https://community.st.com/t5/stm32-mcus-products/stm32f4-stm32f7-usb-host-core-interrupt-flood/td-p/436225/page/4
// Change to also stop flooding of channel halt interrupt
uint32_t ch_num;
HCD_HandleTypeDef* hhcd = (HCD_HandleTypeDef *)usb_hcca;
if (__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_SOF) && hhcd->Init.dma_enable == 0)
{
for (ch_num = 0; ch_num < hhcd->Init.Host_channels; ch_num++)
{
// workaround the interrupts flood issue: re-enable NAK interrupt
USBx_HC(ch_num)->HCINTMSK |= USB_OTG_HCINT_NAK;
// workaround the interrupts flood issue: re-enable CHH interrupt
if(hhcd->hc[ch_num].ep_type == EP_TYPE_CTRL)
USBx_HC(ch_num)->HCINTMSK |= USB_OTG_HCINT_CHH;
}
}
HAL_HCD_IRQHandler((HCD_HandleTypeDef *)usb_hcca);
if (__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_HCINT) && hhcd->Init.dma_enable == 0)
{
for (ch_num = 0; ch_num < hhcd->Init.Host_channels; ch_num++)
{
if ((hhcd->hc[ch_num].ep_type == EP_TYPE_CTRL) || (hhcd->hc[ch_num].ep_type == EP_TYPE_BULK))
{
if (USBx_HC(ch_num)->HCINT & USB_OTG_HCINT_NAK)
{
// workaround the interrupts flood issue: disable NAK interrupt
USBx_HC(ch_num)->HCINTMSK &= ~USB_OTG_HCINT_NAK;
}
if ((USBx_HC(ch_num)->HCINT & USB_OTG_HCINT_CHH) && (hhcd->hc[ch_num].ep_type == EP_TYPE_CTRL))
{
// workaround the interrupts flood issue: disable CHH interrupt
USBx_HC(ch_num)->HCINTMSK &= ~USB_OTG_HCINT_CHH;
}
}
}
}
#else
HAL_HCD_IRQHandler((HCD_HandleTypeDef *)usb_hcca);
#endif
}
#endif