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

📄 syswdog.c

📁 au1500开发的应用程序
💻 C
字号:
/* sysWdog.c - hardware watchdog driver */

/* Copyright 2002-2004 Founder Communications, Inc. */

/*
modification history
--------------------
01a,17mar05,fhchen  written
*/

/*
DESCRIPTION

This file provides routines to control hardware watchdog on V100R001CPE
board. MAX706s and MAX6369 are used together. Timeout value can be
adjusted by jumper. GPIO207 and nRESETIN are connected.

A dedicated high priority task is spawned to feed the watchdog. To use
this module, simple call sysWdgStart, and all is going.

NOTE:
- sysWdgEnable and sysWdgDisable not supported.

TODO:
- add GPIO207 initialization? 

*/

/* includes */

#include <vxWorks.h>
#include <taskLib.h>
#include "sysWdog.h"
#include "config.h"

#ifdef INCLUDE_EXTERNAL_WATCHDOG 

/* locals */

LOCAL UINT32 interval = 0;

/***********************************************************************
*
* wdgFeedIntervalSet - set feeding interval
*
* RETURNS: N/A
*/

void wdgFeedIntervalSet(UINT32 newInterval)
    {
    interval = newInterval;
    }

/***********************************************************************
*
* wdgFeedIntervalGet - get feeding interval
*
* RETURNS: interval currently used
*/

UINT32 wdgFeedIntervalGet(void)
    {
    return (interval);
    }

/***********************************************************************
*
* sysWdgEnable - enable watchdog
*
* This routine enable the hardware watchdog. If enable/disable is not 
* supported, it returns ERROR, and this can be safely ignored.
*
* RETURNS: OK, or ERROR if enable function not supported by hardware.
*/

STATUS sysWdgEnable(void)
    {
    return (ERROR);
    }

/***********************************************************************
*
* sysWdgDisable - disable watchdog
*
* This routine disable the hardware watchdog, if enable/disable is not 
* supported, it returns ERROR, and this can be safely ignored.
*
* RETURNS: OK, or ERROR if disable function not supported by hardware.
*/

STATUS sysWdgDisable (void)
    {
    return (ERROR);
    }

/***********************************************************************
*
* sysWdgStart - start hardware watchdog related facility
*
* This routine enable the watchdog and then start the feeder. 
* 
* NOTE:
* - Currently the feeder is a task.
*
* RETURNS: OK, or ERROR if taskSpawn failed.
*/

STATUS sysWdgStart(void)
    {
    
    /* set feeding interval */

    wdgFeedIntervalSet(WDG_TIMEOUT);
    
    /* enable the hardware watchdog */

    sysWdgEnable();
    
    /* start the feeder */

    return (taskSpawn(WDG_TASK_NAME, WDG_TASK_PRIO, VX_UNBREAKABLE,
                      WDG_TASK_STACK_SIZE, (FUNCPTR)wdgTaskEntry,
                      0,0,0,0,0,0,0,0,0, 0));
    
    }

/***********************************************************************
*
* wdgTaskEntry - entry point for watchdog feeding task
*
* There are various ways to feeding hardware watchdog, using a dedicated
* task may be the best one.
*
* RETURNS: N/A
*/

void wdgTaskEntry(void)
    {
       
    UINT32 delay;

    for(;;)
        {
        /* get delay value */

        delay  = (interval < WDG_TIMEOUT) ? (interval) : (WDG_TIMEOUT - 10);

        /* feeding the watchdog */
        
        sysWdgFeed();
     
        /* sleep for a while */
        
        taskDelay(delay);
        
        }
    }
	
#endif /* INCLUDE_EXTERNAL_WATCHDOG */

⌨️ 快捷键说明

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