projekty/Source/example1/src/WD.c

Go to the documentation of this file.
00001 /*
00002  * $Id: WD.c,v 1.00 2005/08/01 14:14:00 BorisK Exp $
00003  *
00004  * Copyright (C) 2005 ONTRACK s.r.o.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA    
00019  * 02111-1307, USA.
00020  *
00021  * [1] ARM-based Microcontroller LPC2119/2129/2194/2292/9994, "Preliminary User Manual", February 03, 2004, Philips
00022  * Written by Boris Kralik <kralikbo@yahoo.com>, 2005
00023  *
00024  */
00025 #ifndef WD_C
00026 #define WD_C
00027 
00028 #include        "WD.h"
00029 
00030 #if 1
00031 /***********************************************************************************
00032         Name:           WD_interrupt
00033         Description:    WatchDog interrupt routines
00034         Parameters:     void
00035         Return:         void
00036 ************************************************************************************/
00037 void
00038 WD_interrupt(void)
00039 {
00040         disableIRQ();
00041         #if 1
00042                 UARTWriteStr("\n\rWD_interrupt:0x%X",WD_WDTV);
00043         #endif
00044         VICVectAddr = 0;       // Acknowledge Interrupt
00045         enableIRQ();
00046 }
00047 #endif
00048 /***********************************************************************************
00049         Name:           WD_Stop - Stop WD
00050         Description:    ...
00051         Parameters:     void
00052         Return:         void
00053 ************************************************************************************/
00054 void WD_Stop(void)
00055 {
00056         disableIRQ();
00057         WD_WDMOD        &=      0xE;
00058         WD_WDFEED       =       0xAA;
00059         WD_WDFEED       =       0x55;                   //WD Feed Register
00060         wdTime=0;
00061         VICIntEnable    &=      (~VIC_WDT);
00062 #if 1
00063         printf("\n\rWD_Stop");
00064 #endif
00065         enableIRQ();
00066 }
00067 /***********************************************************************************
00068         Name:           WD_Start - Start WD
00069         Description:    ...
00070         Parameters:     void
00071         Return:         void
00072 ************************************************************************************/
00073 void WD_Start(void)
00074 {
00075         WD_WDMOD        |=      (1 << 1);
00076         WD_WDFEED       =       0xAA;
00077         WD_WDFEED       =       0x55;                   //WD Feed Register
00078         if (wdTime != 0)
00079                 WD_WDTC         =       wdTime;         //time out value
00080 #if 1
00081         printf("\n\rWD_Start:0x%X",(unsigned int)wdTime);
00082 #endif
00083 }
00084 /***********************************************************************************
00085         Name:           WD_Init
00086         Description:    ...
00087         Parameters:     time
00088         Return:         void
00089         Set WatchDog to Address 0
00090 ************************************************************************************/
00091 void WD_Init(uint32_t   time)
00092 {
00093         disableIRQ();
00094         wdTime          =       time;
00095         WD_WDMOD        =       ((1 << 0)|(1 << 1));    //WD enabled, WDRESET - operate with the watchdog interrupt and WDRESET
00096         WD_WDTC         =       wdTime;         //time out value
00097 #if 1
00098         VICVectAddr0    =       (unsigned long)WD_interrupt;
00099         VICVectCntl0    =       VIC_ENABLE | VIC_WDT;
00100 #endif
00101         WD_WDFEED       =       0xAA;
00102         WD_WDFEED       =       0x55;                   //WD Feed Register
00103         #if 0
00104                 UARTWriteStr("\n\rWD_Init");
00105         #endif
00106         enableIRQ();
00107 }
00108 void WD_reset(char *chRemark)
00109 {
00110         WD_WDTC         =       wdTime;
00111         WD_WDMOD        =       ((1 << 0)|(1 << 1));    //WD enabled, WDRESET - operate with the watchdog interrupt and WDRESET
00112         WD_WDFEED       =       0xAA;
00113         WD_WDFEED       =       0x55;                   //WD Feed Register
00114         printf("\n\rWD.c:%s",chRemark);
00115 }
00116 
00117 void WD_Reset(void)
00118 {
00119         if (wdTime == 0) return;
00120 #if 1
00121         WD_WDTC         =       wdTime;
00122         WD_WDMOD        =       ((1 << 0)|(1 << 1));    //WD enabled, WDRESET - operate with the watchdog interrupt and WDRESET
00123         WD_WDFEED       =       0xAA;
00124         WD_WDFEED       =       0x55;                   //WD Feed Register
00125         #if 0
00126                 UARTWriteStr("\n\rWD_Reset");
00127         #endif
00128 #endif
00129 }
00130 
00131 #endif

Generated on Fri Sep 21 13:41:54 2007 for example1 by  doxygen 1.4.7