Skip to content

Commit 7c5d351

Browse files
committed
Fix Channel Halt Interupt spaming
1 parent 1a82f91 commit 7c5d351

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/targets/TARGET_STM/USBHALHost_STM.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,12 @@ void USBHALHost::_usbisr(void)
439439
}
440440
}
441441

442+
442443
void USBHALHost::UsbIrqhandler()
443444
{
444445
#if ARC_USB_FULL_SIZE
445446
// fix from Lix Paulian : https://community.st.com/t5/stm32-mcus-products/stm32f4-stm32f7-usb-host-core-interrupt-flood/td-p/436225/page/4
446-
447-
// Enable USB_OTG_HCINT_NAK interrupts for CTRL and BULK on USB_OTG_GINTSTS_SOF (1ms)
447+
// Change to also stop flooding of channel halt interrupt
448448
uint32_t ch_num;
449449
HCD_HandleTypeDef* hhcd = (HCD_HandleTypeDef *)usb_hcca;
450450

@@ -454,24 +454,33 @@ void USBHALHost::UsbIrqhandler()
454454
{
455455
// workaround the interrupts flood issue: re-enable NAK interrupt
456456
USBx_HC(ch_num)->HCINTMSK |= USB_OTG_HCINT_NAK;
457+
458+
// workaround the interrupts flood issue: re-enable CHH interrupt
459+
USBx_HC(ch_num)->HCINTMSK |= USB_OTG_HCINT_CHH;
457460
}
458461
}
462+
459463

460464
HAL_HCD_IRQHandler((HCD_HandleTypeDef *)usb_hcca);
461465

462-
// Disable USB_OTG_HCINT_NAK interrupts for CTRL and BULK on USB_OTG_GINTSTS_HCINT
463466
if (__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_HCINT) && hhcd->Init.dma_enable == 0)
464467
{
465468
for (ch_num = 0; ch_num < hhcd->Init.Host_channels; ch_num++)
466469
{
467-
if (USBx_HC(ch_num)->HCINT & USB_OTG_HCINT_NAK)
470+
if ((hhcd->hc[ch_num].ep_type == EP_TYPE_CTRL) || (hhcd->hc[ch_num].ep_type == EP_TYPE_BULK))
468471
{
469-
if ((hhcd->hc[ch_num].ep_type == EP_TYPE_CTRL) || (hhcd->hc[ch_num].ep_type == EP_TYPE_BULK))
472+
if (USBx_HC(ch_num)->HCINT & USB_OTG_HCINT_NAK)
470473
{
471474
// workaround the interrupts flood issue: disable NAK interrupt
472475
USBx_HC(ch_num)->HCINTMSK &= ~USB_OTG_HCINT_NAK;
473476
}
474-
}
477+
478+
if (USBx_HC(ch_num)->HCINT & USB_OTG_HCINT_CHH)
479+
{
480+
// workaround the interrupts flood issue: disable CHH interrupt
481+
USBx_HC(ch_num)->HCINTMSK &= ~USB_OTG_HCINT_CHH;
482+
}
483+
}
475484
}
476485
}
477486
#else

0 commit comments

Comments
 (0)