⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usbtcdnet2280interrupt.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 4 页
字号:
/* usbTcdNET2280Interrupt.c - defines modules for interrupt handling *//* Copyright 2004 Wind River Systems, Inc. *//*Modification history--------------------01i,30sep04,pdg  DMA testing fixes01h,29sep04,ami  Mips related Changes01g,23sep04,pdg  Fix for short packet handling and not losing a setup                 interrupt.01f,22sep04,pdg  Fix for setting the address01e,21sep04,pdg  Full speed testing fixes01d,20sep04,ami  NET2280 tested for High Speed01c,17sep04,ami  After Control, Interrupt IN and Bulk OUT Testing   01b,08sep04,ami  Code Review Comments Incorporated01a,03sep04,ami Written*//*DESCRIPTIONThis file implements the interrupt related functionalities of TCD(Target Controller Driver) for the Netchip NET2280INCLUDE FILES: usb/usbPlatform.h, usb/ossLib.h, usb/usb.h,               usb/target/usbHalCommon.h, usb/target/usbTcd.h               drv/usb/target/usbNET2280.h,               drv/usb/target/usbNET2280Tcd.h,               drv/usb/target/usbTcdNET2280Debug.h               usb/target/usbPeriphInstr.h*//* includes */#include "usb/usbPlatform.h"#include "usb/ossLib.h"#include "usb/usb.h"#include "usb/target/usbHalCommon.h"#include "usb/target/usbTcd.h"#include "drv/usb/target/usbNET2280.h"#include "drv/usb/target/usbNET2280Tcd.h"#include "drv/usb/target/usbTcdNET2280Debug.h"#include "usb/target/usbPeriphInstr.h"/********************************************************************************* usbTcdNET2280Isr - isr of NET2280 TCD** This is the ISR for the NET2280 TCD.** RETURNS: N/A** ERRNO:*   none** \NOMANUAL*/LOCAL VOID usbTcdNET2280Isr    (    pUSB_TCD_NET2280_TARGET	pTarget		/* ISR Parameters */    )    {    UINT32	data32 = 0 ;			/* temporary register */    /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_INTERRUPT,    "usbTcdNET2280Isr entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280Isr: Entered...\n",0,0,0,0,0,0);    if ( pTarget == NULL )        {        USB_NET2280_ERROR("usbTcdNET2280Isr : Bad Parameters...\n",0,0,0,0,0,0);        return;        }    /* Disable the Interrupts. Reset bit 31 of PCIIRQENB1 register */    data32 = NET2280_CFG_READ (pTarget, NET2280_PCIIRQENB1_REG);    data32 &= ~NET2280_XIRQENB1_INTEN;    NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB1_REG, data32);    /* Call the HAL ISR */    (*pTarget->usbHalIsr)(pTarget->usbHalIsrParam);    /* Enable the Interrupts. Set bit 31 of PCIIRQENB1 register */    data32 = NET2280_CFG_READ (pTarget, NET2280_PCIIRQENB1_REG);    data32 |= NET2280_XIRQENB1_INTEN;    NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB1_REG, data32);    USB_NET2280_DEBUG ("usbTcdNET2280Isr: Exiting...\n",0,0,0,0,0,0);    return;    }/********************************************************************************* usbTcdNET2280FncInterruptStatusGet - to get the interrupt status** This function returns the interrupt status i.e whether the reset interrupt,* suspend interrupt, resume interrupt, disconnect interrupt or endpoint* related interrupt is pending. It also carries out the handling of certain* interrpts which are not intimated to the HAL.** RETURNS: OK or ERROR, if the interrupt status is not retrieved successfully** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM.* Bad Parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncInterruptStatusGet    (    pTRB_INTERRUPT_STATUS_GET_CLEAR pTrb	/* TRB to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    UINT32	data32 = 0;			/* temporary variable */    UINT8	i = 0;#ifdef NET2280_DMA_SUPPORTED    UINT32	tempData = 0;			/* Temporary variable */#endif    /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_INTERRUPT,    "usbTcdNET2280FncInterruptStatusGet entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncInterruptStatusGet: Entered...\n",    0,0,0,0,0,0);    /* Validate Parameters */    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||        (pHeader->handle == NULL))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT(USB_TCD_NET2280_INTERRUPT,        "usbTcdNET2280FncInterruptStatusGet exiting: Bad Parameter Received...",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncInterruptStatusGet: \        Bad Parameters...\n",0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_BAD_PARAM);        }    pTarget =  (pUSB_TCD_NET2280_TARGET) pHeader->handle;    /* Reset uInterruptStatus */    pTrb->uInterruptStatus = 0;    /*     * Read IRQSTAT0 register to determine the whether any endpoint related     * interrupts have occured     */    data32 = NET2280_CFG_READ (pTarget, NET2280_IRQSTAT0_REG);    /* Mask the unwanted interrupts */    data32 &= NET2280_CFG_READ(pTarget,NET2280_PCIIRQENB0_REG);      /* If bit 7 is set, setup interrupt has occured */    if ((data32 & NET2280_IRQENB0_SETUP) != 0)        {        /* To store the value of interruptEnable register */        UINT32 intEnableValue = 0;        USB_NET2280_DEBUG ("usbTcdNET2280FncInterruptStatusGet: Setup Interrupt\        ...\n",0,0,0,0,0,0);        /* WindView Instrumentation */        USB_TCD_LOG_EVENT(USB_TCD_NET2280_INTERRUPT,        "usbTcdNET2280FncInterruptStatusGet: Setup Event Occured...",        USB_TCD_NET2280_WV_FILTER);        pTarget->setupIntPending = TRUE;        /*         * Disable the setup interrupt, till we handle the setup. This will         * be enabled in the endpoint interrupt status clear.         */        intEnableValue = NET2280_CFG_READ(pTarget,NET2280_PCIIRQENB0_REG);        intEnableValue &= ~NET2280_IRQENB0_SETUP;        NET2280_CFG_WRITE (pTarget,NET2280_PCIIRQENB0_REG, intEnableValue);        /* Set the endpoint interrupt mask value */        pTrb->uInterruptStatus |= USBTCD_ENDPOINT_INTERRUPT_MASK;        }    /* Check if any endpoint specific interrupts have occured */     if ((data32 & NET2280_IRQENB0_EPMASK) != 0)         {        /* If bits 0:6 are set, endpoint related interrupt has occured */        for (i = NET2280_ENDPT_0_OUT; i <= NET2280_ENDPT_F; i++)            {            if ((data32 & NET2280_IRQENB0_EP(i)) != 0)                { 	        UINT32	dataEpStat = 0;                 /* set bit 4 if TRB :: uInterruptStatus */                pTrb->uInterruptStatus |= USBTCD_ENDPOINT_INTERRUPT_MASK;                /*                 * Read the EP_STAT regsiter for the endpoint and determine the                  * type of interrupt that has occured                 */                dataEpStat = NET2280_CFG_READ (pTarget,                              NET2280_EP_STAT_OFFSET(i));                /*                 * If the endpoint is not NET2280_ENDPT_0, update endptIntPending and                  * clear the particular bit in EP_STAT regsiter,                 * else determine the type of interrupt on endpoint 0, update                  * endptIntPending accordingle and clear the EP_STAT register                 */                 if (i != NET2280_ENDPT_0_OUT)                  {                                 pTarget->endptIntPending |= (1 << i);                  /* Clear the EP_STAT register */                  dataEpStat = (NET2280_EP_STAT_DPT | NET2280_EP_STAT_DPR |                                                      NET2280_EP_STAT_SPOD);                  NET2280_CFG_WRITE (pTarget,  NET2280_EP_STAT_OFFSET(i),                                    dataEpStat);                                                 }                   else                                       {                    if ((dataEpStat & NET2280_EP_STAT_DPT) != 0)                        {                        /*                          * Check if the address is to be set. If this                         * condition succeeds, then the data packet                         * transmitted interrupt has occured on the                         * status stage completion of the setAddress                         * standard request. So we write to OURADDR register                         * to set the new address.                         */                        if (pTarget->addressTobeSet != 0)                            {                                                       NET2280_CFG_WRITE(pTarget, NET2280_OURADDR_REG,                                              pTarget->addressTobeSet);                                                       /* Reset the addressTobeSet value */                            pTarget->addressTobeSet = 0;                            }                         /* Control In Interrupt. Set bit 7 of endptIntPending */                         pTarget->endptIntPending |= (1 << NET2280_ENDPT_0_IN);                        /* Clear the EP_STAT regsiter */                        NET2280_CFG_WRITE (pTarget,  NET2280_EP_STAT_OFFSET(i),                                    NET2280_EP_STAT_DPT);                        }                    if ((dataEpStat & NET2280_EP_STAT_DPR) != 0)                        {                        if (pTarget->setupIntPending == FALSE)                            {                            /* Clear the EP_STAT regsiter */                            NET2280_CFG_WRITE (pTarget,  NET2280_EP_STAT_OFFSET(i),                                                dataEpStat & NET2280_EP_STAT_DPR);                            }                        else                            {                            UINT32 dataTemp = 0;                              dataTemp = NET2280_CFG_READ (pTarget,                                                    NET2280_EP_IRQENB_OFFSET(i));                            dataTemp &= ~NET2280_EP_STAT_DPR;                            NET2280_CFG_WRITE(pTarget,                                          NET2280_EP_IRQENB_OFFSET(i),dataTemp);                                                      }                        /*                         * Disable the control status interrupt. We enable this in                          * usbTcdNET2280FncCopyDataToEpbuf, when the callback calls this                          * function for status stage. This ensures that we have handled                          * Data OUT stage before handling the Control Status stage                         */                                                          dataEpStat = NET2280_CFG_READ (pTarget,                                                        NET2280_PCIIRQENB1_REG);                        dataEpStat &= ~NET2280_XIRQENB1_CS;                        NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB1_REG,                                            dataEpStat);                                                    		pTarget->statusINPending = TRUE;	                        /* Control Out Interrupt. Set bit 0 of endptIntPending */                        pTarget->endptIntPending |= (1 << NET2280_ENDPT_0_OUT);                        }                    }                }            }    	}    /* Read IRQSTAT1 register */    data32 = NET2280_CFG_READ (pTarget, NET2280_IRQSTAT1_REG);    /* Mask the unwanted interrupts */    data32 &= NET2280_CFG_READ(pTarget,NET2280_PCIIRQENB1_REG );    /* reset interrupt */    if ((data32 & NET2280_IRQENB1_RPRESET) != 0)        {        USB_NET2280_DEBUG ("usbTcdNET2280FncInterruptStatusGet: Reset Interrupt\        ...\n",0,0,0,0,0,0);        /* WindView Instrumentation */        USB_TCD_LOG_EVENT(USB_TCD_NET2280_INTERRUPT,        "usbTcdNET2280FncInterruptStatusGet: Reset Event Occured...",        USB_TCD_NET2280_WV_FILTER);    	/* set bit 1 of TRB :: uInterruptStatus */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -