Moved remotely
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@113 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* watchdog.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Watchdog funcitonality
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define WD_CLKSRC_APB (0x01)
|
||||
#define WD_CLKSRC_IRC_OSC (0x00)
|
||||
#define WD_EN (0x01)
|
||||
#define WD_RESET (0x02)
|
||||
#define WD_WTOF (0x04)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static INT16 WtofStatus = -1;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \brief Enable the watchdog */
|
||||
void watchdogEnable(
|
||||
UINT16 resetTime /**< Time in ms till watchdog will reset target when not fed in meantime */
|
||||
)
|
||||
{
|
||||
UINT32 prescaleFeedValue;
|
||||
|
||||
// Make sure the WD_WTOF is stored
|
||||
watchdogCausedReset();
|
||||
|
||||
// Internal RC oscilator runs on 4 Mhz, the prescale is calculated by:
|
||||
// 1 resetTime
|
||||
// ------------ * 4 * prescaleFeedValue = (-----------) (seconden)
|
||||
// 4.000.000 1000
|
||||
//
|
||||
//
|
||||
prescaleFeedValue = resetTime * 1000;
|
||||
WDTC = prescaleFeedValue; /* once WDEN is set, the WDT will start after feeding */
|
||||
WDMOD = WD_EN | WD_RESET;
|
||||
|
||||
WDFEED = 0xAA; /* Feeding sequence */
|
||||
WDFEED = 0x55;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Feed the watchdog in order to prevent a reset */
|
||||
void watchdogFeed()
|
||||
{
|
||||
WDFEED = 0xAA; /* Feeding sequence */
|
||||
WDFEED = 0x55;
|
||||
}
|
||||
|
||||
BOOLEAN watchdogCausedReset()
|
||||
{
|
||||
if ( WtofStatus < 0)
|
||||
{
|
||||
WtofStatus = ((WDMOD & WD_WTOF) == WD_WTOF ? 1 : 0);
|
||||
|
||||
// Clear bit
|
||||
WDMOD &= ~WD_WTOF;
|
||||
}
|
||||
|
||||
return (WtofStatus == 1 ? TRUE : FALSE);
|
||||
}
|
||||
Reference in New Issue
Block a user