From 5e81e42152dccc39b2b566079fb627b3cbdd2f5e Mon Sep 17 00:00:00 2001 From: Mark Burton Date: Sat, 1 Feb 2014 19:15:47 +0000 Subject: [PATCH] Now clears FIFO empty interrupt mask in DCD_WriteEmptyTxFifo() when transfer completes. This fixes a problem whereby outputting to the USB UART when the host is connected but the USB UART is not open would cause the interrupt handler to be called continuously so it would consume 100% of the CPU. --- .../FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c | 7 ++++++- .../FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/platform/stm32f2/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c b/src/platform/stm32f2/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c index 359d5699..89a6f12a 100644 --- a/src/platform/stm32f2/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c +++ b/src/platform/stm32f2/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c @@ -674,7 +674,12 @@ static uint32_t DCD_WriteEmptyTxFifo(USB_OTG_CORE_HANDLE *pdev, uint32_t epnum) ep->xfer_buff += len; ep->xfer_count += len; - + + if(ep->xfer_count >= ep->xfer_len) + { + uint32_t fifoemptymsk = 1 << ep->num; + USB_OTG_MODIFY_REG32(&pdev->regs.DREGS->DIEPEMPMSK, fifoemptymsk, 0); + } txstatus.d32 = USB_OTG_READ_REG32(&pdev->regs.INEP_REGS[epnum]->DTXFSTS); } diff --git a/src/platform/stm32f4/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c b/src/platform/stm32f4/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c index 359d5699..89a6f12a 100644 --- a/src/platform/stm32f4/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c +++ b/src/platform/stm32f4/FWLib/USB/STM32_USB_OTG_Driver/src/usb_dcd_int.c @@ -674,7 +674,12 @@ static uint32_t DCD_WriteEmptyTxFifo(USB_OTG_CORE_HANDLE *pdev, uint32_t epnum) ep->xfer_buff += len; ep->xfer_count += len; - + + if(ep->xfer_count >= ep->xfer_len) + { + uint32_t fifoemptymsk = 1 << ep->num; + USB_OTG_MODIFY_REG32(&pdev->regs.DREGS->DIEPEMPMSK, fifoemptymsk, 0); + } txstatus.d32 = USB_OTG_READ_REG32(&pdev->regs.INEP_REGS[epnum]->DTXFSTS); }