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

📄 wdt.c

📁 NXP LPC2378 WDT Demo
💻 C
字号:
/*****************************************************************************
 *   wdt.c:  Watchdog C file for NXP LPC23xx/24xx Family Microprocessors
 *
 *   Copyright(C) 2006, NXP Semiconductor
 *   All rights reserved.
 *
 *   History
 *   2006.07.20  ver 1.00    Prelimnary version, first Release
 *
*****************************************************************************/
#include "LPC23xx.h"                        /* LPC23xx/24xx definitions */
#include "type.h"
#include "irq.h"
#include "timer.h"
#include "wdt.h"

void __swi(0) IRQDisable (void);
void __swi(1) IRQEnable (void);
void __swi(2) FIQDisable (void);
void __swi(3) FIQEnable (void);

//void __swi(0) IntEnable (void); 
//void __swi(1) IntDisable (void); 


volatile DWORD wdt_counter;

/*****************************************************************************
** Function name:		WDTHandler
**
** Descriptions:		Watchdog timer interrupt handler
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
void WDTHandler(void) __irq 
{
  WDMOD &= ~WDTOF;		/* clear the time-out terrupt flag */		  
  IENABLE;			/* handles nested interrupt */
  wdt_counter++;
  IDISABLE;
  VICVectAddr = 0;		/* Acknowledge Interrupt */
}

/*****************************************************************************
** Function name:		WDTInit
**
** Descriptions:		Initialize watchdog timer, install the
**				watchdog timer interrupt handler
**
** parameters:			None
** Returned value:		true or false, return false if the VIC table
**				is full and WDT interrupt handler can be
**				installed.
** 
*****************************************************************************/
DWORD WDTInit( void )
{
  wdt_counter = 0;
  if ( install_irq( WDT_INT, (void *)WDTHandler, HIGHEST_PRIORITY ) == FALSE )
  {
	return (FALSE);
  }

  WDTC = WDT_FEED_VALUE;	/* once WDEN is set, the WDT will start after feeding */
//  WDMOD = WDEN | WDRESET;
  WDMOD = WDEN;

  WDFEED = 0xAA;		/* Feeding sequence */
  WDFEED = 0x55;    
  return( TRUE );
}

/*****************************************************************************
** Function name:		WDTFeed
**
** Descriptions:		Feed watchdog timer to prevent it from timeout
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
void WDTFeed( void )
{
  IRQDisable();
  FIQDisable();

  WDFEED = 0xAA;		/* Feeding sequence */
  WDFEED = 0x55;
 
  FIQEnable();
  IRQEnable();
  //IntEnable();

  return;
}

/******************************************************************************
**                            End Of File
******************************************************************************/

⌨️ 快捷键说明

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