2 ******************************************************************************
4 * @author MCD Application Team
7 * @brief Host driver interrupt subroutines
8 ******************************************************************************
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
24 #include "usb_defines.h"
25 #include "usb_hcd_int.h"
27 #if defined (__CC_ARM) /*!< ARM Compiler */
29 #elif defined ( __ICCARM__ ) /*!< IAR Compiler */
31 #elif defined (__GNUC__) /*!< GNU Compiler */
32 #pragma GCC optimize ("O0")
33 #elif defined (__TASKING__) /*!< TASKING Compiler */
38 /** @addtogroup USB_OTG_DRIVER
42 /** @defgroup USB_HCD_INT
43 * @brief This file contains the interrupt subroutines for the Host mode.
48 /** @defgroup USB_HCD_INT_Private_Defines
56 /** @defgroup USB_HCD_INT_Private_TypesDefinitions
65 /** @defgroup USB_HCD_INT_Private_Macros
73 /** @defgroup USB_HCD_INT_Private_Variables
81 /** @defgroup USB_HCD_INT_Private_FunctionPrototypes
85 static uint32_t USB_OTG_USBH_handle_sof_ISR(USB_OTG_CORE_HANDLE *pdev);
86 static uint32_t USB_OTG_USBH_handle_port_ISR(USB_OTG_CORE_HANDLE *pdev);
87 static uint32_t USB_OTG_USBH_handle_hc_ISR (USB_OTG_CORE_HANDLE *pdev);
88 static uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev ,
90 static uint32_t USB_OTG_USBH_handle_hc_n_Out_ISR (USB_OTG_CORE_HANDLE *pdev ,
92 static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev);
93 static uint32_t USB_OTG_USBH_handle_nptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev);
94 static uint32_t USB_OTG_USBH_handle_ptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev);
95 static uint32_t USB_OTG_USBH_handle_Disconnect_ISR (USB_OTG_CORE_HANDLE *pdev);
96 static uint32_t USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (USB_OTG_CORE_HANDLE *pdev);
103 /** @defgroup USB_HCD_INT_Private_Functions
108 * @brief HOST_Handle_ISR
109 * This function handles all USB Host Interrupts
110 * @param pdev: Selected device
114 uint32_t USBH_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev)
116 USB_OTG_GINTSTS_TypeDef gintsts;
121 /* Check if HOST Mode */
122 if (USB_OTG_IsHostMode(pdev))
124 gintsts.d32 = USB_OTG_ReadCoreItr(pdev);
130 if (gintsts.b.sofintr)
132 retval |= USB_OTG_USBH_handle_sof_ISR (pdev);
135 if (gintsts.b.rxstsqlvl)
137 retval |= USB_OTG_USBH_handle_rx_qlvl_ISR (pdev);
140 if (gintsts.b.nptxfempty)
142 retval |= USB_OTG_USBH_handle_nptxfempty_ISR (pdev);
145 if (gintsts.b.ptxfempty)
147 retval |= USB_OTG_USBH_handle_ptxfempty_ISR (pdev);
150 if (gintsts.b.hcintr)
152 retval |= USB_OTG_USBH_handle_hc_ISR (pdev);
155 if (gintsts.b.portintr)
157 retval |= USB_OTG_USBH_handle_port_ISR (pdev);
160 if (gintsts.b.disconnect)
162 retval |= USB_OTG_USBH_handle_Disconnect_ISR (pdev);
166 if (gintsts.b.incomplisoout)
168 retval |= USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (pdev);
177 * @brief USB_OTG_USBH_handle_hc_ISR
178 * This function indicates that one or more host channels has a pending
179 * @param pdev: Selected device
182 static uint32_t USB_OTG_USBH_handle_hc_ISR (USB_OTG_CORE_HANDLE *pdev)
184 USB_OTG_HAINT_TypeDef haint;
185 USB_OTG_HCCHAR_TypeDef hcchar;
189 /* Clear appropriate bits in HCINTn to clear the interrupt bit in
192 haint.d32 = USB_OTG_ReadHostAllChannels_intr(pdev);
194 for (i = 0; i < pdev->cfg.host_channels ; i++)
196 if (haint.b.chint & (1 << i))
198 hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[i]->HCCHAR);
202 retval |= USB_OTG_USBH_handle_hc_n_In_ISR (pdev, i);
206 retval |= USB_OTG_USBH_handle_hc_n_Out_ISR (pdev, i);
215 * @brief USB_OTG_otg_hcd_handle_sof_intr
216 * Handles the start-of-frame interrupt in host mode.
217 * @param pdev: Selected device
220 static uint32_t USB_OTG_USBH_handle_sof_ISR (USB_OTG_CORE_HANDLE *pdev)
222 USB_OTG_GINTSTS_TypeDef gintsts;
226 /* Clear interrupt */
227 gintsts.b.sofintr = 1;
228 USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32);
234 * @brief USB_OTG_USBH_handle_Disconnect_ISR
235 * Handles disconnect event.
236 * @param pdev: Selected device
239 static uint32_t USB_OTG_USBH_handle_Disconnect_ISR (USB_OTG_CORE_HANDLE *pdev)
241 USB_OTG_GINTSTS_TypeDef gintsts;
243 pdev->host.ConnSts = 0;
246 pdev->host.port_cb->Disconnect(pdev);
248 /* Clear interrupt */
249 gintsts.b.disconnect = 1;
250 USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32);
256 * @brief USB_OTG_USBH_handle_nptxfempty_ISR
257 * Handles non periodic tx fifo empty.
258 * @param pdev: Selected device
261 static uint32_t USB_OTG_USBH_handle_nptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
263 USB_OTG_GINTMSK_TypeDef intmsk;
264 USB_OTG_HNPTXSTS_TypeDef hnptxsts;
265 uint16_t len_words , len;
267 hnptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->HNPTXSTS);
269 len_words = (pdev->host.hc[hnptxsts.b.chnum].xfer_len + 3) / 4;
271 while ((hnptxsts.b.nptxfspcavail > len_words)&&
272 (pdev->host.hc[hnptxsts.b.chnum].xfer_len != 0))
275 len = hnptxsts.b.nptxfspcavail * 4;
277 if (len > pdev->host.hc[hnptxsts.b.chnum].xfer_len)
280 len = pdev->host.hc[hnptxsts.b.chnum].xfer_len;
283 intmsk.b.nptxfempty = 1;
284 USB_OTG_MODIFY_REG32( &pdev->regs.GREGS->GINTMSK, intmsk.d32, 0);
287 len_words = (pdev->host.hc[hnptxsts.b.chnum].xfer_len + 3) / 4;
289 USB_OTG_WritePacket (pdev , pdev->host.hc[hnptxsts.b.chnum].xfer_buff, hnptxsts.b.chnum, len);
291 pdev->host.hc[hnptxsts.b.chnum].xfer_buff += len;
292 pdev->host.hc[hnptxsts.b.chnum].xfer_len -= len;
293 pdev->host.hc[hnptxsts.b.chnum].xfer_count += len;
295 hnptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->HNPTXSTS);
302 * @brief USB_OTG_USBH_handle_ptxfempty_ISR
303 * Handles periodic tx fifo empty
304 * @param pdev: Selected device
307 static uint32_t USB_OTG_USBH_handle_ptxfempty_ISR (USB_OTG_CORE_HANDLE *pdev)
309 USB_OTG_GINTMSK_TypeDef intmsk;
310 USB_OTG_HPTXSTS_TypeDef hptxsts;
311 uint16_t len_words , len;
313 hptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.HREGS->HPTXSTS);
315 len_words = (pdev->host.hc[hptxsts.b.chnum].xfer_len + 3) / 4;
317 while ((hptxsts.b.ptxfspcavail > len_words)&&
318 (pdev->host.hc[hptxsts.b.chnum].xfer_len != 0))
321 len = hptxsts.b.ptxfspcavail * 4;
323 if (len > pdev->host.hc[hptxsts.b.chnum].xfer_len)
325 len = pdev->host.hc[hptxsts.b.chnum].xfer_len;
328 intmsk.b.ptxfempty = 1;
329 USB_OTG_MODIFY_REG32( &pdev->regs.GREGS->GINTMSK, intmsk.d32, 0);
332 len_words = (pdev->host.hc[hptxsts.b.chnum].xfer_len + 3) / 4;
334 USB_OTG_WritePacket (pdev , pdev->host.hc[hptxsts.b.chnum].xfer_buff, hptxsts.b.chnum, len);
336 pdev->host.hc[hptxsts.b.chnum].xfer_buff += len;
337 pdev->host.hc[hptxsts.b.chnum].xfer_len -= len;
338 pdev->host.hc[hptxsts.b.chnum].xfer_count += len;
340 hptxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.HREGS->HPTXSTS);
347 * @brief USB_OTG_USBH_handle_port_ISR
348 * This function determines which interrupt conditions have occurred
349 * @param pdev: Selected device
352 static uint32_t USB_OTG_USBH_handle_port_ISR (USB_OTG_CORE_HANDLE *pdev)
354 USB_OTG_HPRT0_TypeDef hprt0;
355 USB_OTG_HPRT0_TypeDef hprt0_dup;
356 USB_OTG_HCFG_TypeDef hcfg;
357 uint32_t do_reset = 0;
364 hprt0.d32 = USB_OTG_READ_REG32(pdev->regs.HPRT0);
365 hprt0_dup.d32 = USB_OTG_READ_REG32(pdev->regs.HPRT0);
367 /* Clear the interrupt bits in GINTSTS */
369 hprt0_dup.b.prtena = 0;
370 hprt0_dup.b.prtconndet = 0;
371 hprt0_dup.b.prtenchng = 0;
372 hprt0_dup.b.prtovrcurrchng = 0;
374 /* Port Connect Detected */
375 if (hprt0.b.prtconndet)
377 pdev->host.port_cb->Connect(pdev);
378 hprt0_dup.b.prtconndet = 1;
383 /* Port Enable Changed */
384 if (hprt0.b.prtenchng)
386 hprt0_dup.b.prtenchng = 1;
387 if (hprt0.b.prtena == 1)
389 pdev->host.ConnSts = 1;
391 if ((hprt0.b.prtspd == HPRT0_PRTSPD_LOW_SPEED) ||
392 (hprt0.b.prtspd == HPRT0_PRTSPD_FULL_SPEED))
395 hcfg.d32 = USB_OTG_READ_REG32(&pdev->regs.HREGS->HCFG);
397 if (hprt0.b.prtspd == HPRT0_PRTSPD_LOW_SPEED)
399 USB_OTG_WRITE_REG32(&pdev->regs.HREGS->HFIR, 6000 );
400 if (hcfg.b.fslspclksel != HCFG_6_MHZ)
402 if(pdev->cfg.coreID == USB_OTG_FS_CORE_ID)
404 USB_OTG_InitFSLSPClkSel(pdev ,HCFG_6_MHZ );
412 USB_OTG_WRITE_REG32(&pdev->regs.HREGS->HFIR, 48000 );
413 if (hcfg.b.fslspclksel != HCFG_48_MHZ)
415 USB_OTG_InitFSLSPClkSel(pdev ,HCFG_48_MHZ );
426 /* Overcurrent Change Interrupt */
427 if (hprt0.b.prtovrcurrchng)
429 hprt0_dup.b.prtovrcurrchng = 1;
434 USB_OTG_ResetPort(pdev);
437 /* Clear Port Interrupts */
438 USB_OTG_WRITE_REG32(pdev->regs.HPRT0, hprt0_dup.d32);
444 * @brief USB_OTG_USBH_handle_hc_n_Out_ISR
445 * Handles interrupt for a specific Host Channel
446 * @param pdev: Selected device
447 * @param hc_num: Channel number
450 uint32_t USB_OTG_USBH_handle_hc_n_Out_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t num)
453 USB_OTG_HCINTn_TypeDef hcint;
454 USB_OTG_HCGINTMSK_TypeDef hcintmsk;
455 USB_OTG_HC_REGS *hcreg;
456 USB_OTG_HCCHAR_TypeDef hcchar;
458 hcreg = pdev->regs.HC_REGS[num];
459 hcint.d32 = USB_OTG_READ_REG32(&hcreg->HCINT);
460 hcintmsk.d32 = USB_OTG_READ_REG32(&hcreg->HCGINTMSK);
461 hcint.d32 = hcint.d32 & hcintmsk.d32;
463 hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[num]->HCCHAR);
467 CLEAR_HC_INT(hcreg ,ahberr);
468 UNMASK_HOST_INT_CHH (num);
470 else if (hcint.b.ack)
472 CLEAR_HC_INT(hcreg , ack);
475 else if (hcint.b.xfercompl)
477 pdev->host.ErrCnt[num] = 0;
478 UNMASK_HOST_INT_CHH (num);
479 USB_OTG_HC_Halt(pdev, num);
480 CLEAR_HC_INT(hcreg , xfercompl);
481 pdev->host.HC_Status[num] = HC_XFRC;
484 else if (hcint.b.stall)
486 CLEAR_HC_INT(hcreg , stall);
487 UNMASK_HOST_INT_CHH (num);
488 USB_OTG_HC_Halt(pdev, num);
489 pdev->host.HC_Status[num] = HC_STALL;
492 else if (hcint.b.nak)
494 pdev->host.ErrCnt[num] = 0;
495 UNMASK_HOST_INT_CHH (num);
496 USB_OTG_HC_Halt(pdev, num);
497 CLEAR_HC_INT(hcreg , nak);
498 pdev->host.HC_Status[num] = HC_NAK;
501 else if (hcint.b.xacterr)
503 UNMASK_HOST_INT_CHH (num);
504 USB_OTG_HC_Halt(pdev, num);
505 pdev->host.ErrCnt[num] ++;
506 pdev->host.HC_Status[num] = HC_XACTERR;
507 CLEAR_HC_INT(hcreg , xacterr);
509 else if (hcint.b.nyet)
511 pdev->host.ErrCnt[num] = 0;
512 UNMASK_HOST_INT_CHH (num);
513 USB_OTG_HC_Halt(pdev, num);
514 CLEAR_HC_INT(hcreg , nyet);
515 pdev->host.HC_Status[num] = HC_NYET;
517 else if (hcint.b.datatglerr)
520 UNMASK_HOST_INT_CHH (num);
521 USB_OTG_HC_Halt(pdev, num);
522 CLEAR_HC_INT(hcreg , nak);
523 pdev->host.HC_Status[num] = HC_DATATGLERR;
525 CLEAR_HC_INT(hcreg , datatglerr);
527 else if (hcint.b.chhltd)
529 MASK_HOST_INT_CHH (num);
531 if(pdev->host.HC_Status[num] == HC_XFRC)
533 pdev->host.URB_State[num] = URB_DONE;
535 if (hcchar.b.eptype == EP_TYPE_BULK)
537 pdev->host.hc[num].toggle_out ^= 1;
540 else if(pdev->host.HC_Status[num] == HC_NAK)
542 pdev->host.URB_State[num] = URB_NOTREADY;
544 else if(pdev->host.HC_Status[num] == HC_NYET)
546 if(pdev->host.hc[num].do_ping == 1)
548 USB_OTG_HC_DoPing(pdev, num);
550 pdev->host.URB_State[num] = URB_NOTREADY;
552 else if(pdev->host.HC_Status[num] == HC_STALL)
554 pdev->host.URB_State[num] = URB_STALL;
556 else if(pdev->host.HC_Status[num] == HC_XACTERR)
558 if (pdev->host.ErrCnt[num] == 3)
560 pdev->host.URB_State[num] = URB_ERROR;
561 pdev->host.ErrCnt[num] = 0;
564 CLEAR_HC_INT(hcreg , chhltd);
572 * @brief USB_OTG_USBH_handle_hc_n_In_ISR
573 * Handles interrupt for a specific Host Channel
574 * @param pdev: Selected device
575 * @param hc_num: Channel number
578 uint32_t USB_OTG_USBH_handle_hc_n_In_ISR (USB_OTG_CORE_HANDLE *pdev , uint32_t num)
580 USB_OTG_HCINTn_TypeDef hcint;
581 USB_OTG_HCGINTMSK_TypeDef hcintmsk;
582 USB_OTG_HCCHAR_TypeDef hcchar;
583 USB_OTG_HCTSIZn_TypeDef hctsiz;
584 USB_OTG_HC_REGS *hcreg;
587 hcreg = pdev->regs.HC_REGS[num];
588 hcint.d32 = USB_OTG_READ_REG32(&hcreg->HCINT);
589 hcintmsk.d32 = USB_OTG_READ_REG32(&hcreg->HCGINTMSK);
590 hcint.d32 = hcint.d32 & hcintmsk.d32;
591 hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[num]->HCCHAR);
597 CLEAR_HC_INT(hcreg ,ahberr);
598 UNMASK_HOST_INT_CHH (num);
600 else if (hcint.b.ack)
602 CLEAR_HC_INT(hcreg ,ack);
605 else if (hcint.b.stall)
607 UNMASK_HOST_INT_CHH (num);
608 pdev->host.HC_Status[num] = HC_STALL;
609 CLEAR_HC_INT(hcreg , nak); /* Clear the NAK Condition */
610 CLEAR_HC_INT(hcreg , stall); /* Clear the STALL Condition */
611 hcint.b.nak = 0; /* NOTE: When there is a 'stall', reset also nak,
612 else, the pdev->host.HC_Status = HC_STALL
613 will be overwritten by 'nak' in code below */
614 USB_OTG_HC_Halt(pdev, num);
616 else if (hcint.b.datatglerr)
619 UNMASK_HOST_INT_CHH (num);
620 USB_OTG_HC_Halt(pdev, num);
621 CLEAR_HC_INT(hcreg , nak);
622 pdev->host.HC_Status[num] = HC_DATATGLERR;
623 CLEAR_HC_INT(hcreg , datatglerr);
626 if (hcint.b.frmovrun)
628 UNMASK_HOST_INT_CHH (num);
629 USB_OTG_HC_Halt(pdev, num);
630 CLEAR_HC_INT(hcreg ,frmovrun);
633 else if (hcint.b.xfercompl)
636 if (pdev->cfg.dma_enable == 1)
638 hctsiz.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[num]->HCTSIZ);
639 pdev->host.XferCnt[num] = pdev->host.hc[num].xfer_len - hctsiz.b.xfersize;
642 pdev->host.HC_Status[num] = HC_XFRC;
643 pdev->host.ErrCnt [num]= 0;
644 CLEAR_HC_INT(hcreg , xfercompl);
646 if ((hcchar.b.eptype == EP_TYPE_CTRL)||
647 (hcchar.b.eptype == EP_TYPE_BULK))
649 UNMASK_HOST_INT_CHH (num);
650 USB_OTG_HC_Halt(pdev, num);
651 CLEAR_HC_INT(hcreg , nak);
652 pdev->host.hc[num].toggle_in ^= 1;
655 else if(hcchar.b.eptype == EP_TYPE_INTR)
658 USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[num]->HCCHAR, hcchar.d32);
659 pdev->host.URB_State[num] = URB_DONE;
663 else if (hcint.b.chhltd)
665 MASK_HOST_INT_CHH (num);
667 if(pdev->host.HC_Status[num] == HC_XFRC)
669 pdev->host.URB_State[num] = URB_DONE;
672 else if (pdev->host.HC_Status[num] == HC_STALL)
674 pdev->host.URB_State[num] = URB_STALL;
677 else if((pdev->host.HC_Status[num] == HC_XACTERR) ||
678 (pdev->host.HC_Status[num] == HC_DATATGLERR))
680 pdev->host.ErrCnt[num] = 0;
681 pdev->host.URB_State[num] = URB_ERROR;
684 else if(hcchar.b.eptype == EP_TYPE_INTR)
686 pdev->host.hc[num].toggle_in ^= 1;
689 CLEAR_HC_INT(hcreg , chhltd);
692 else if (hcint.b.xacterr)
694 UNMASK_HOST_INT_CHH (num);
695 pdev->host.ErrCnt[num] ++;
696 pdev->host.HC_Status[num] = HC_XACTERR;
697 USB_OTG_HC_Halt(pdev, num);
698 CLEAR_HC_INT(hcreg , xacterr);
701 else if (hcint.b.nak)
703 if(hcchar.b.eptype == EP_TYPE_INTR)
705 UNMASK_HOST_INT_CHH (num);
706 USB_OTG_HC_Halt(pdev, num);
707 CLEAR_HC_INT(hcreg , nak);
709 else if ((hcchar.b.eptype == EP_TYPE_CTRL)||
710 (hcchar.b.eptype == EP_TYPE_BULK))
712 /* re-activate the channel */
715 USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[num]->HCCHAR, hcchar.d32);
717 pdev->host.HC_Status[num] = HC_NAK;
726 * @brief USB_OTG_USBH_handle_rx_qlvl_ISR
727 * Handles the Rx Status Queue Level Interrupt
728 * @param pdev: Selected device
732 static uint32_t USB_OTG_USBH_handle_rx_qlvl_ISR (USB_OTG_CORE_HANDLE *pdev)
734 USB_OTG_GRXFSTS_TypeDef grxsts;
735 USB_OTG_GINTMSK_TypeDef intmsk;
736 USB_OTG_HCTSIZn_TypeDef hctsiz;
737 USB_OTG_HCCHAR_TypeDef hcchar;
738 __IO uint8_t channelnum =0;
741 /* Disable the Rx Status Queue Level interrupt */
743 intmsk.b.rxstsqlvl = 1;
744 USB_OTG_MODIFY_REG32( &pdev->regs.GREGS->GINTMSK, intmsk.d32, 0);
746 grxsts.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GRXSTSP);
747 channelnum = grxsts.b.chnum;
748 hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[channelnum]->HCCHAR);
750 switch (grxsts.b.pktsts)
752 case GRXSTS_PKTSTS_IN:
753 /* Read the data into the host buffer. */
754 if ((grxsts.b.bcnt > 0) && (pdev->host.hc[channelnum].xfer_buff != (void *)0))
757 USB_OTG_ReadPacket(pdev, pdev->host.hc[channelnum].xfer_buff, grxsts.b.bcnt);
758 /*manage multiple Xfer */
759 pdev->host.hc[grxsts.b.chnum].xfer_buff += grxsts.b.bcnt;
760 pdev->host.hc[grxsts.b.chnum].xfer_count += grxsts.b.bcnt;
763 count = pdev->host.hc[channelnum].xfer_count;
764 pdev->host.XferCnt[channelnum] = count;
766 hctsiz.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[channelnum]->HCTSIZ);
767 if(hctsiz.b.pktcnt > 0)
769 /* re-activate the channel when more packets are expected */
772 USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[channelnum]->HCCHAR, hcchar.d32);
777 case GRXSTS_PKTSTS_IN_XFER_COMP:
779 case GRXSTS_PKTSTS_DATA_TOGGLE_ERR:
780 case GRXSTS_PKTSTS_CH_HALTED:
785 /* Enable the Rx Status Queue Level interrupt */
786 intmsk.b.rxstsqlvl = 1;
787 USB_OTG_MODIFY_REG32(&pdev->regs.GREGS->GINTMSK, 0, intmsk.d32);
792 * @brief USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR
793 * Handles the incomplete Periodic transfer Interrupt
794 * @param pdev: Selected device
797 static uint32_t USB_OTG_USBH_handle_IncompletePeriodicXfer_ISR (USB_OTG_CORE_HANDLE *pdev)
800 USB_OTG_GINTSTS_TypeDef gintsts;
801 USB_OTG_HCCHAR_TypeDef hcchar;
806 hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[0]->HCCHAR);
809 USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[0]->HCCHAR, hcchar.d32);
812 /* Clear interrupt */
813 gintsts.b.incomplisoout = 1;
814 USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32);
831 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/