openpcd/firmware/src/os/wdt.c @ master
1 |
/* AT91SAM7 Watch Dog Timer code for OpenPCD / OpenPICC
|
---|---|
2 |
* (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
|
3 |
*
|
4 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* it under the terms of the GNU General Public License as published by
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* (at your option) any later version.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17 |
*
|
18 |
*/
|
19 |
|
20 |
#include <lib_AT91SAM7.h>
|
21 |
#include <AT91SAM7.h>
|
22 |
|
23 |
#include <os/dbgu.h>
|
24 |
#include <os/system_irq.h>
|
25 |
|
26 |
#define WDT_WDD 0xFF
|
27 |
#define WDT_WDV 0xFF
|
28 |
|
29 |
#ifdef WDT_DEBUG
|
30 |
#undef WDT_DEBUG
|
31 |
#endif/*WDT_DEBUG*/ |
32 |
|
33 |
static void wdt_irq(uint32_t sr) |
34 |
{
|
35 |
if (sr & 1) |
36 |
AT91F_DBGU_Frame("================> WATCHDOG EXPIRED !!!!!\n\r"); |
37 |
if (sr & 2) |
38 |
AT91F_DBGU_Frame("================> WATCHDOG ERROR !!!!!\n\r"); |
39 |
}
|
40 |
|
41 |
void wdt_restart(void) |
42 |
{
|
43 |
AT91F_WDTRestart(AT91C_BASE_WDTC); |
44 |
}
|
45 |
|
46 |
void wdt_init(void) |
47 |
{
|
48 |
sysirq_register(AT91SAM7_SYSIRQ_WDT, &wdt_irq); |
49 |
#ifdef WDT_DEBUG
|
50 |
AT91F_WDTSetMode(AT91C_BASE_WDTC, (WDT_WDD << 16) | |
51 |
AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | |
52 |
AT91C_WDTC_WDFIEN | WDT_WDV); |
53 |
#else
|
54 |
AT91F_WDTSetMode(AT91C_BASE_WDTC, (WDT_WDD << 16) | |
55 |
AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | |
56 |
AT91C_WDTC_WDRSTEN | WDT_WDV); |
57 |
#endif
|
58 |
}
|