?? wdt.c
字號:
/*****************************************************************************
* wdt.c: Watchdog C file for NXP LPC17xx Family Microprocessors
*
* Copyright(C) 2009, NXP Semiconductor
* All rights reserved.
*
* History
* 2009.05.27 ver 1.00 Prelimnary version, first Release
*
*****************************************************************************/
#include "LPC17xx.h"
#define WDEN 0x00000001
#define WDRESET 0x00000002
#define WDTOF 0x00000004
#define WDINT 0x00000008
#define WDT_FEED_VALUE 0X00FF//0x003FFFFF
volatile uint32_t wdt_counter;
/*****************************************************************************
** Function name: WDT_IRQHandler
**
** Descriptions: Watchdog timer interrupt handler
**
** parameters: None
** Returned value: None
**
*****************************************************************************/
void WDT_IRQHandler(void)
{
LPC_WDT->WDMOD &= ~WDTOF; /* clear the time-out terrupt flag */
wdt_counter++;
return;
}
/*****************************************************************************
** 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.
**
*****************************************************************************/
void WDTInit( void )
{
wdt_counter = 0;
NVIC_EnableIRQ(WDT_IRQn);
LPC_WDT->WDTC = WDT_FEED_VALUE; /* once WDEN is set, the WDT will start after feeding */
LPC_WDT->WDMOD = WDEN;
LPC_WDT->WDFEED = 0xAA; /* Feeding sequence */
LPC_WDT->WDFEED = 0x55;
// return( TRUE );
}
/*****************************************************************************
** Function name: WDTFeed
**
** Descriptions: Feed watchdog timer to prevent it from timeout
**
** parameters: None
** Returned value: None
**
*****************************************************************************/
void WDTFeed( void )
{
LPC_WDT->WDFEED = 0xAA; /* Feeding sequence */
LPC_WDT->WDFEED = 0x55;
return;
}
/******************************************************************************
** End Of File
******************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -