openpcd/firmware/src/os/wdt.c @ master
1 | 1413b9c0 | (no author) | /* AT91SAM7 Watch Dog Timer code for OpenPCD / OpenPICC
|
---|---|---|---|
2 | * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
|
||
3 | 32985a29 | laforge | *
|
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 | 1413b9c0 | (no author) | */
|
19 | |||
20 | 48afc6a1 | laforge | #include <lib_AT91SAM7.h>
|
21 | #include <AT91SAM7.h>
|
||
22 | |||
23 | #include <os/dbgu.h>
|
||
24 | bfff30bf | laforge | #include <os/system_irq.h>
|
25 | 48afc6a1 | laforge | |
26 | 4c0cf591 | Harald Welte | #define WDT_WDD 0xFF
|
27 | #define WDT_WDV 0xFF
|
||
28 | |||
29 | d10804d3 | meri | #ifdef WDT_DEBUG
|
30 | #undef WDT_DEBUG
|
||
31 | #endif/*WDT_DEBUG*/ |
||
32 | 4c0cf591 | Harald Welte | |
33 | 373c172a | Harald Welte | static void wdt_irq(uint32_t sr) |
34 | 1413b9c0 | (no author) | {
|
35 | 4c0cf591 | Harald Welte | if (sr & 1) |
36 | 82cb631b | Min Xu | AT91F_DBGU_Frame("================> WATCHDOG EXPIRED !!!!!\n\r"); |
37 | 4c0cf591 | Harald Welte | if (sr & 2) |
38 | 82cb631b | Min Xu | AT91F_DBGU_Frame("================> WATCHDOG ERROR !!!!!\n\r"); |
39 | 1413b9c0 | (no author) | }
|
40 | |||
41 | 48afc6a1 | laforge | void wdt_restart(void) |
42 | {
|
||
43 | AT91F_WDTRestart(AT91C_BASE_WDTC); |
||
44 | }
|
||
45 | |||
46 | 1413b9c0 | (no author) | void wdt_init(void) |
47 | {
|
||
48 | bfff30bf | laforge | sysirq_register(AT91SAM7_SYSIRQ_WDT, &wdt_irq); |
49 | 1413b9c0 | (no author) | #ifdef WDT_DEBUG
|
50 | 4c0cf591 | Harald Welte | AT91F_WDTSetMode(AT91C_BASE_WDTC, (WDT_WDD << 16) | |
51 | 1413b9c0 | (no author) | AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | |
52 | 4c0cf591 | Harald Welte | AT91C_WDTC_WDFIEN | WDT_WDV); |
53 | 1413b9c0 | (no author) | #else
|
54 | 4c0cf591 | Harald Welte | AT91F_WDTSetMode(AT91C_BASE_WDTC, (WDT_WDD << 16) | |
55 | AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT | |
||
56 | AT91C_WDTC_WDRSTEN | WDT_WDV); |
||
57 | 1413b9c0 | (no author) | #endif
|
58 | }
|