Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

wdt.h

00001 /* Copyright (c) 2002, Marek Michalkiewicz
00002    All rights reserved.
00003 
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions are met:
00006 
00007    * Redistributions of source code must retain the above copyright
00008      notice, this list of conditions and the following disclaimer.
00009    * Redistributions in binary form must reproduce the above copyright
00010      notice, this list of conditions and the following disclaimer in
00011      the documentation and/or other materials provided with the
00012      distribution.
00013 
00014   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00015   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00018   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00019   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00020   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00021   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00022   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00023   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00024   POSSIBILITY OF SUCH DAMAGE. */
00025 
00026 /*
00027    avr/wdt.h - macros for AVR watchdog timer
00028  */
00029 
00030 #ifndef _AVR_WDT_H_
00031 #define _AVR_WDT_H_
00032 
00033 #include <avr/io.h>
00034 
00035 #define wdt_reset() __asm__ __volatile__ ("wdr")
00036 
00037 #define _wdt_write(value)                               \
00038         __asm__ __volatile__ (                          \
00039                 "in __tmp_reg__,__SREG__" "\n\t"        \
00040                 "cli" "\n\t"                            \
00041                 "wdr" "\n\t"                            \
00042                 "out %0,%1" "\n\t"                      \
00043                 "out __SREG__,__tmp_reg__" "\n\t"       \
00044                 "out %0,%2"                             \
00045                 : /* no outputs */                      \
00046                 : "I" (_SFR_IO_ADDR(WDTCR)),            \
00047                   "r" (0x18),/* _BV(WDCE) | _BV(WDE) */ \
00048                   "r" ((unsigned char)(value))          \
00049                 : "r0"                                  \
00050         )
00051 
00052 #define wdt_enable(timeout) _wdt_write((timeout) | _BV(WDE))
00053 
00054 #define wdt_disable() _wdt_write(0)
00055 
00056 #endif /* _AVR_WDT_H_ */

Generated on Thu Jan 30 22:30:53 2003 for EduNet by doxygen1.2.18