From f183c0aa6df9bbf16b9fb594bf8142adfc1e5d1b Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 11 Jun 2012 17:35:59 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4267 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/OTGv1/usb_lld.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'os/hal/platforms/STM32/OTGv1') diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c index fae5f500f..0f927cd85 100644 --- a/os/hal/platforms/STM32/OTGv1/usb_lld.c +++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c @@ -381,13 +381,6 @@ static void otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { usbp->epc[ep]->in_state->mode.linear.txbuf += n; } usbp->epc[ep]->in_state->txcnt += n; - /* TODO: Potential issue, txcnt can be less than txsize after the planned - number of packets have been received, better disable the interrupt - at the end of the transaction in otg_epin_handler().*/ - if (usbp->epc[ep]->in_state->txcnt >= usbp->epc[ep]->in_state->txsize) { - /* Transfer finished.*/ - OTG->DIEPEMPMSK &= ~DIEPEMPMSK_INEPTXFEM(ep); - } } /** @@ -401,20 +394,21 @@ static void otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { static void otg_epin_handler(USBDriver *usbp, usbep_t ep) { uint32_t epint = OTG->ie[ep].DIEPINT; - /* Resets all EP IRQ sources.*/ - OTG->ie[ep].DIEPINT = 0xFFFFFFFF; - + if (epint & DIEPINT_TOC) { + /* Timeouts not handled yet, not sure how to handle.*/ + OTG->ie[ep].DIEPINT = DIEPINT_TOC; + } if (epint & DIEPINT_XFRC) { /* Transmit transfer complete.*/ + OTG->ie[ep].DIEPINT = DIEPINT_XFRC; _usb_isr_invoke_in_cb(usbp, ep); + OTG->DIEPEMPMSK &= ~DIEPEMPMSK_INEPTXFEM(ep); } - if (epint & DIEPINT_TXFE) { + else if (epint & DIEPINT_TXFE) { /* TX FIFO empty or emptying.*/ + OTG->ie[ep].DIEPINT = DIEPINT_TXFE; otg_txfifo_handler(usbp, ep); } - if (epint & DIEPINT_TOC) { - /* Timeouts not handled yet, not sure how to handle.*/ - } } /** -- cgit v1.2.3