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

📄 wd.c

📁 TDK 6521 SOC 芯片 DEMO程序
💻 C
字号:
/***************************************************************************
 * This code and information is provided "as is" without warranty of any   *
 * kind, either expressed or implied, including but not limited to the     *
 * implied warranties of merchantability and/or fitness for a particular   *
 * purpose.                                                                *
 *                                                                         *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 ***************************************************************************/
//**************************************************************************
//  DESCRIPTION: 71M652x POWER METER - software watchdogs.
//  The idea is that all the software watchdogs have to be reset
//  before the hardware watchdog is reset.  A watchdog test
//  runs from the 1-second interrupt from the RTC, so it works right
//  even in brownout mode, which runs with a 32KHz clock.
//  If the watchdog software is disabled, the watchdog is defeated
//  by continually resetting it, every one second in the rtc interrupt.
//
//  Software watchdogs can be individually enabled by defining them
//  in wd.h; note that currently only the main loop and periodic interrupts
//  (main.c, tmr0.c, tmr1.c, ce.c) have code to reset watchdogs.
// 
//  AUTHOR:  RGV
//
//  HISTORY: See end of file.
//**************************************************************************
//  File: wd.c
//
#include "options.h"
#if WATCHDOG // if no software watchdog, it's reset in ce.c's rtc interrupt
#include "irq.h"
#include "wd.h"

/*** External functions used by this module ***/
// None.

/*** External variables used within this module ***/
// None.

/*** Public functions declared within this module ***/
// see wd.h

/*** Public variables declared within this module ***/
// None.

/*** Private functions declared within this module ***/
// None.

/*** Private variables declared within this module ***/
static volatile uint_fast8_t wd_resets;
static uint_fast8_t wd_resets_needed;

//============================================================================//
//  software watchdogs.
//

// The following routine MUST be used, or watchdog resets
// can be lost when interrupts overwrite the variable "wd_resets"
#pragma save
void wd_reset (uint8_t set) small reentrant
{
    // Do this as fast as possible
    IRQ_DEFINES;
    IRQ_DISABLE();            // Begin critical section, disable ALL interrupts.
    wd_resets |= set;         // Record that the watchdog was reset
    if ((wd_resets_needed & wd_resets) == wd_resets_needed)
    {                         // Expected events occurred.
        wd_resets = 0;        // Clear the record of watchdog resets.
        RESET_WD();           // Reset the hardware watchdog.
    }
    IRQ_ENABLE();             // End critical section
}
#pragma restore


void wd_destroy (uint8_t clear)
{
    irq_disable ();           // Begin critical section, disable ALL interrupts.
    wd_resets_needed &= ~clear; // These watchdogs will not be tested.
    irq_enable ();            // critical section done
}

void wd_create (uint8_t set)
{
    irq_disable ();           // Begin critical section, disable ALL interrupts.
    wd_resets_needed |= set;  // These watchdogs will be tested.
    irq_enable ();            // critical section done
}

#endif // WATCHDOG.
/***************************************************************************
 * $Log: wd.c,v $
 * Revision 1.6  2006/09/09 01:16:07  gmikef
 * *** empty log message ***
 *
 * Revision 1.5  2006/06/30 17:29:31  tvander
 * Fixed absolute register access in reentrant code
 *
 * Revision 1.4  2006/03/06 03:43:14  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.2  2005/11/29 01:28:31  tvander
 * Software watchdogs actually work now.
 * Automatically enable software watchdogs by defining constant in wd.h
 * Optimized software watchdogs so they work faster.
 * Reset the watchdog is reset as soon as the enabling software watchdog is reset.
 * Removed the software watchdog test routine.
 *
 * Revision 1.1  2005/10/08 04:41:33  tvander
 * Fixed priority inversion.
 * Rewrote watchdog to work in brownout, but of course it doesn't work.
 * Watchdog can now be defeated by clearing watchdog option to 0.
 * Reorganized watt hour modules (at last!).
 * Disabled reading of STATUS in 6521_cli because the CE's status is always SAG.
 * Tested with 6521_CLI; measurements seem to work.
 * Fixed other builds.
 *
 * Revision 1.7  2005/10/06 20:51:51  tvander
 * Added brownout mode
 *
 * Revision 1.6  2005/09/22 23:45:25  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.5  2005/08/23 02:11:23  gmikef
 * *** empty log message ***
 *
 * Revision 1.4  2005/08/11 18:10:25  tvander
 * *** empty log message ***
 *
 * Revision 1.3  2005/08/10 02:05:17  gmikef
 * *** empty log message ***
 *
 * Revision 1.2  2005/05/06 16:40:35  tvander
 * Build errors fixed
 *
 * Revision 1.1  2005/04/30 02:21:57  gmikef
 * *** empty log message ***
 *
 * Revision 1.7  2005/04/30 00:18:47  gmikef
 * *** empty log message ***
 *
 * Revision 1.6  2005/04/29 01:27:16  gmikef
 * *** empty log message ***
 *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 * this program is fully protected by the United States copyright          *
 * laws and is the property of Teridian Semiconductor Corporation.         *
 ***************************************************************************/
// events.c

⌨️ 快捷键说明

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