/** * @brief USB_OTG_HandleSessionRequest_ISR * Initiating the Session Request Protocol * @param None * @retval : status */ static uint32_t USB_OTG_HandleSessionRequest_ISR(USB_OTG_CORE_HANDLE *pdev) { USB_OTG_GINTSTS_TypeDef gintsts; USB_OTG_GOTGCTL_TypeDef gotgctl; gotgctl.d32 = 0; gintsts.d32 = 0; gotgctl.d32 = USB_OTG_READ_REG32( &pdev->regs.GREGS->GOTGCTL ); if (USB_OTG_IsDeviceMode(pdev) && (gotgctl.b.bsesvld)) { } else if (gotgctl.b.asesvld) { } /* Clear interrupt */ gintsts.d32 = 0; gintsts.b.sessreqintr = 1; USB_OTG_WRITE_REG32 (&pdev->regs.GREGS->GINTSTS, gintsts.d32); return 1; }
/** * @brief STM32_USBF_OTG_ISR_Handler * handles all USB Interrupts * @param pdev: device instance * @retval status */ uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev) { USB_OTG_GINTSTS_TypeDef gintr_status; uint32_t retval = 0; if (USB_OTG_IsDeviceMode(pdev)) /* ensure that we are in device mode */ { gintr_status.d32 = USB_OTG_ReadCoreItr(pdev); if (!gintr_status.d32) /* avoid spurious interrupt */ { return 0; } if (gintr_status.b.outepintr) { retval |= DCD_HandleOutEP_ISR(pdev); } if (gintr_status.b.inepint) { retval |= DCD_HandleInEP_ISR(pdev); } if (gintr_status.b.modemismatch) { USB_OTG_GINTSTS_TypeDef gintsts; /* Clear interrupt */ gintsts.d32 = 0; gintsts.b.modemismatch = 1; USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32); } if (gintr_status.b.wkupintr) { retval |= DCD_HandleResume_ISR(pdev); } if (gintr_status.b.usbsuspend) { retval |= DCD_HandleUSBSuspend_ISR(pdev); } if (gintr_status.b.sofintr) { retval |= DCD_HandleSof_ISR(pdev); } if (gintr_status.b.rxstsqlvl) { retval |= DCD_HandleRxStatusQueueLevel_ISR(pdev); } if (gintr_status.b.usbreset) { retval |= DCD_HandleUsbReset_ISR(pdev); } if (gintr_status.b.enumdone) { retval |= DCD_HandleEnumDone_ISR(pdev); } if (gintr_status.b.incomplisoin) { retval |= DCD_IsoINIncomplete_ISR(pdev); } if (gintr_status.b.incomplisoout) { retval |= DCD_IsoOUTIncomplete_ISR(pdev); } #ifdef VBUS_SENSING_ENABLED if (gintr_status.b.sessreqintr) { retval |= DCD_SessionRequest_ISR(pdev); } if (gintr_status.b.otgintr) { retval |= DCD_OTG_ISR(pdev); } #endif } return retval; }
/** * @brief USB_OTG_HandleOTG_ISR * handles the OTG Interrupts * @param None * @retval : status */ static uint32_t USB_OTG_HandleOTG_ISR(USB_OTG_CORE_HANDLE *pdev) { USB_OTG_GOTGINT_TypeDef gotgint; USB_OTG_GOTGCTL_TypeDef gotgctl; gotgint.d32 = 0; gotgctl.d32 = 0; gotgint.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GOTGINT); gotgctl.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GOTGCTL); if (gotgint.b.sesenddet) { gotgctl.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GOTGCTL); if (USB_OTG_IsDeviceMode(pdev)) { } else if (USB_OTG_IsHostMode(pdev)) { } } /* ----> SRP SUCCESS or FAILURE INTERRUPT <---- */ if (gotgint.b.sesreqsucstschng) { gotgctl.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GOTGCTL); if (gotgctl.b.sesreqscs) /* Session request success */ { if (USB_OTG_IsDeviceMode(pdev)) { } /* Clear Session Request */ gotgctl.d32 = 0; gotgctl.b.sesreq = 1; USB_OTG_MODIFY_REG32(&pdev->regs.GREGS->GOTGCTL, gotgctl.d32, 0); } else /* Session request failure */ { if (USB_OTG_IsDeviceMode(pdev)) { } } } /* ----> HNP SUCCESS or FAILURE INTERRUPT <---- */ if (gotgint.b.hstnegsucstschng) { gotgctl.d32 = USB_OTG_READ_REG32(&pdev->regs.GREGS->GOTGCTL); if (gotgctl.b.hstnegscs) /* Host negotiation success */ { if (USB_OTG_IsHostMode(pdev)) /* The core AUTOMATICALLY sets the Host mode */ { } } else /* Host negotiation failure */ { } gotgint.b.hstnegsucstschng = 1; /* Ack "Host Negotiation Success Status Change" interrupt. */ } /* ----> HOST NEGOTIATION DETECTED INTERRUPT <---- */ if (gotgint.b.hstnegdet) { if (USB_OTG_IsDeviceMode(pdev)) /* The core AUTOMATICALLY sets the Host mode */ { } else { } } if (gotgint.b.adevtoutchng) {} if (gotgint.b.debdone) { USB_OTG_ResetPort(pdev); } /* Clear OTG INT */ USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GOTGINT, gotgint.d32); return 1; }