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

📄 wdogav.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
STATUS wDogIntClear(void){    UINT8 *pIntStat;         if(wDogInitialized)        {        pIntStat = (UINT8 *) FPGA_WD_INTSTAT;            *pIntStat |= WDOG_INT_CLEAR_VALUE;	IO_SYNC;        *pIntStat |= WDOG_INT_CLEAR_VALUE;	IO_SYNC;	        if(wDogDebug)            {            logMsg("interrupt status Address: %x\n",                    (int)pIntStat,0,0,0,0,0);            }                     return OK;          }    else        {                    if(wDogDebug)            {            logMsg("Cannot clear interrupt. The watchdog has not"                     "been initialized.\n",0,0,0,0,0,0);            }                     return ERROR;        }              }/************************************************************ Function Name : wDogIntUnmask** Description   :*           Unmasks the Watchdog interrupt  **  Arguments    :*      void**  Return Value :*      STATUS OK    - if the watchdog interrupt has been masked*             ERROR - if the watchdog is locked**  Comments:*/ STATUS wDogIntUnmask(  int cpuId){    UINT8 *pIntStat;         if(!wDogLocked)        {	if (CPU_ID_0 == cpuId) 	    pIntStat = (UINT8 *) FPGA_CPU0_WD_INTMSK;	else	    pIntStat = (UINT8 *) FPGA_CPU1_WD_INTMSK;        *pIntStat |= WDOG_INT_MSK_VALUE;	IO_SYNC;		if (CPU_ID_0 == cpuId) 	    wDogCPU0IntMasked = FALSE;	else	    wDogCPU1IntMasked = FALSE;	        if(wDogDebug)            {            logMsg("Watchdog has been unmasked.\n"                    ,0,0,0,0,0,0);            }                     return OK;          }    else        {                    if(wDogDebug)            {            logMsg("The watchdog has not"                     "been unmasked.\n",0,0,0,0,0,0);            }                     return ERROR;        }              }/************************************************************ Function Name : wDogIntMask** Description   :*           Masks the Watchdog interrupt  **  Arguments    :*      void**  Return Value :*      STATUS OK    - if the watchdog interrupt has been masked*             ERROR - if the watchdog is locked**  Comments:*/ STATUS wDogIntMask(  int cpuId){    UINT8 *pIntStat;         if(!wDogLocked)        {	if (CPU_ID_0 == cpuId) 	    pIntStat = (UINT8 *) FPGA_CPU0_WD_INTMSK;	else	    pIntStat = (UINT8 *) FPGA_CPU1_WD_INTMSK;        *pIntStat &= ~WDOG_INT_MSK_VALUE;	IO_SYNC;		if (CPU_ID_0 == cpuId) 	    wDogCPU0IntMasked = TRUE;	else	    wDogCPU1IntMasked = TRUE;	        if(wDogDebug)            {            logMsg("Watchdog has been masked.\n"                    ,0,0,0,0,0,0);            }                     return OK;          }    else        {                    if(wDogDebug)            {            logMsg("The watchdog has not"                     "been masked.\n",0,0,0,0,0,0);            }                     return ERROR;        }              }#endif/************************************************************ Function Name : wDogAvInit** Description   :*          Sets the register pointer, initializes all variables*          performs a jumper check, and installs an interrupt*          service routine.**  Arguments    :*      VOIDFUNCPTR routine - routine to be called with the interrupt*      int arg -- parameter passed to the routine*      int mode -- user defined value (interrupt/reset)**  Return Value :*      STATUS - OK    if watchdog is initialized*             - ERROR if there is a null interrupt service*                        routine when the mode is set to *                        interrupt*                     if the watchdog has already been initialized*                     if jumper has not been installed*                     if the mode is neither interrupt or reset**  Comments:*      N/A*/ STATUS wDogAvInit(VOIDFUNCPTR routine, int arg, int mode){    if(wDogInitialized == TRUE)        {                    if(wDogDebug)            {            logMsg("Watchdog has already been initialized.\n"                ,0,0,0,0,0,0);            }                    return ERROR;        }    else        {        /* initialize all variables */#if !(defined(CCA_145)|| defined(CCA_146) || defined(CCA_149)|| defined(VME_183))        wDogJmprInstalled  = TRUE;#endif        wDogLocked         = FALSE;#if (defined(CCA_145)|| defined(CCA_146) || defined(CCA_149)|| defined(VME_183))	wDogEnabled        = FALSE;	wDogCPU0IntMasked  = FALSE;	wDogCPU1IntMasked  = FALSE;#endif        wDogIntEnabled     = ERROR;        wDogIntConnected   = ERROR;        wDogMode           = mode;        /* set register pointer */           if (CPU_ID_0 == sysProcId)            {            wDogAdrs = (UINT8 *)IOFPGA_WDA_ADRS_WDOG_AV;#if (defined(CCA_145)|| defined(CCA_146) || defined(CCA_149)|| defined(VME_183))            wDogInterrupt  = FPGA_WATCHDOG;#else	    wDogInterrupt  = FPGA_WATCHDOG0;#endif            }        else            {            wDogAdrs = (UINT8 *)IOFPGA_WDB_ADRS_WDOG_AV;#if (defined(CCA_145)|| defined(CCA_146) || defined(CCA_149)|| defined(VME_183))            wDogInterrupt  = FPGA_WATCHDOG;#else	    wDogInterrupt  = FPGA_WATCHDOG1;#endif            }#if !(defined(CCA_145)|| defined(CCA_146) || defined(CCA_149)|| defined(VME_183))        /* jumper check */            wDogJmprInstalled = wDogAvJmprChk();        if(wDogJmprInstalled)            {            return ERROR;            }#endif	        /* mode check */        if(WDOG_MODE_INTERRUPT == wDogMode)	{                            if(routine != NULL)	    {		wDogIntConnected = intConnect((void *)(wDogInterrupt), (VOIDFUNCPTR) routine, arg);                                if(ERROR==wDogIntConnected)		{                                            if(wDogDebug)		    {                        logMsg("Connected to the Interrupt Service routine.\n"                                ,0,0,0,0,0,0);		    }                                            return wDogIntConnected;		}	    }            else	    {                                    if(wDogDebug)		{                    logMsg("Interrupt Service routine is null. Watchdog not initialized.\n"                            ,0,0,0,0,0,0);		}                                    return ERROR;	    }	}        else if(wDogMode != WDOG_MODE_RESET)	{                            if(wDogDebug)	    {               logMsg("Failed to start the watchdog. Invalid mode.\n"                      ,0,0,0,0,0,0);	    }                           return ERROR;	}	        if(wDogDebug)	{            logMsg("Watchdog has been initialized.\n",0,0,0,0,0,0);	}    /* initialize semaphor to mutually exclusive, prevents a read or write task from     * becoming interrupted by a task with a higher priority doing the same action.     * this would cause data corruption     */    wDogSemId = semMCreate(SEM_DELETE_SAFE);    if(NULL == wDogSemId)    {        return ERROR;    }        wDogInitialized = TRUE;        return OK;    }}/************************************************************ Function Name : wDogAvStart** Description   :*          Checks the mode and enables interrupts or sets*          the reset bit in watchdog registers to effectively*          "start" handling of watchdog events.** Arguments    :*      void** Return Value :*      STATUS - OK    if watchdog has been started.*             - ERROR if the watchdog could not be initialized*                     if the watchdog interrupt could not be*                        enabled*                     if the mode is neither interrupt or reset** Comments:*      N/A*/#if (defined(CCA_145)|| defined(CCA_146) || defined(CCA_149)|| defined(VME_183))STATUS wDogAvStart(void){       /* check if the watchdog initialized */    if(wDogInitialized)    {            /* does the user want reset mode? */        if(WDOG_MODE_RESET == wDogMode)	{            wDogAvKick();	    wDogResetEnable();	    wDogEnable();            return OK;	}             else 	{	    /* does the user want interrupt mode? */	    if(WDOG_MODE_INTERRUPT == wDogMode)	    {		/* interrupt mode */		wDogResetDisable();		/* unmask CPU 0 interrupt at least */		if (CPU_ID_0 == sysProcId)		{		    wDogIntUnmask(CPU_ID_0);		}		else		{		    wDogIntUnmask(CPU_ID_1);		}		/* kick the watchdog before enabling it */		if (wDogAvMinGet() == 0) wDogAvKick();		/* start the watchdog */		wDogEnable();		/* enable the watchdog interrupt */		wDogIntEnabled = intEnable(wDogInterrupt);		if(wDogDebug)		{		    if(OK == wDogIntEnabled)			logMsg("Watchdog Enabled.\n"                            ,0,0,0,0,0,0);		    else		    {			logMsg("Watchdog Not Enabled.\n"                            ,0,0,0,0,0,0);		    }			}				wDogAvKick();		return wDogIntEnabled;	    }	    else /* user has input a wrong value for the mode */	    {		if(wDogDebug)		{		    logMsg("Failed to start the watchdog. Invalid mode.\n"			    ,0,0,0,0,0,0);		}   		return ERROR;	    }	}    }    else    {                    if(wDogDebug)            {            logMsg("Failed to start the watchdog. Watchdog not initialized.\n"                   ,0,0,0,0,0,0);            }                        return ERROR;        }        }#elseSTATUS wDogAvStart(void){    UINT8 *pAddress = wDogAdrs;        /* check if the watchdog initialized */    if(wDogInitialized)        {                    /* does the user want reset mode? */        if(WDOG_MODE_RESET == wDogMode)            {            wDogAvKick();                *pAddress |= WDOG_MODE_OFFSET;            return OK;            }                    /* does the user want interrupt mode? */                else if(WDOG_MODE_INTERRUPT == wDogMode)            {            wDogAvKick();            wDogIntEnabled = intEnable(wDogInterrupt);                        if(OK == wDogIntEnabled)                {                                    if(wDogDebug)                    {                    logMsg("Watchdog Enabled.\n"                            ,0,0,0,0,0,0);                    }                }            else                {                                    if(wDogDebug)                    {                    logMsg("Watchdog Not Enabled.\n"                            ,0,0,0,0,0,0);                    }                }                            return wDogIntEnabled;            }        /* user has input a wrong value for the mode */        else            {            if(wDogDebug)               {               logMsg("Failed to start the watchdog. Invalid mode.\n"                      ,0,0,0,0,0,0);               }                              return ERROR;            }        }    else        {                    if(wDogDebug)            {            logMsg("Failed to start the watchdog. Watchdog not initialized.\n"                   ,0,0,0,0,0,0);            }                        return ERROR;        }        }     #endif                                                                                                                                        

⌨️ 快捷键说明

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