[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2423] bug #37103: Add wdt_enable and wdt_disable macr
From: |
Pitchumani |
Subject: |
[avr-libc-commit] [2423] bug #37103: Add wdt_enable and wdt_disable macros for ATtiny4/5/9/10 /20/40 devices |
Date: |
Tue, 29 Apr 2014 12:51:45 +0000 |
Revision: 2423
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2423
Author: pitchumani
Date: 2014-04-29 12:51:45 +0000 (Tue, 29 Apr 2014)
Log Message:
-----------
bug #37103: Add wdt_enable and wdt_disable macros for ATtiny4/5/9/10/20/40
devices
Ticket Links:
------------
http://savannah.gnu.org/bugs/?37103
Modified Paths:
--------------
trunk/avr-libc/ChangeLog
trunk/avr-libc/NEWS
trunk/avr-libc/include/avr/wdt.h
Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog 2014-04-29 10:33:23 UTC (rev 2422)
+++ trunk/avr-libc/ChangeLog 2014-04-29 12:51:45 UTC (rev 2423)
@@ -1,3 +1,9 @@
+2014-04-29 George Thomas <address@hidden>
+
+ Fix for bug #37103: ATtiny5/9/10/20/40 watchdog can't be enabled
+ * include/avr/wdt.h: Add wdt_enable and wdt_disable macros for tiny 4,5,
+ 9,10,20 and 40 devices.
+
2014-04-29 Senthil Kumar Selvaraj <address@hidden>
Fix for bug #39049: Clock prescaler set and get are missing for TINY
arch
Modified: trunk/avr-libc/NEWS
===================================================================
--- trunk/avr-libc/NEWS 2014-04-29 10:33:23 UTC (rev 2422)
+++ trunk/avr-libc/NEWS 2014-04-29 12:51:45 UTC (rev 2423)
@@ -13,6 +13,7 @@
[#36410] avr/boot.h: poisoned SPMCR for ATmega128
[#36454] string.h: Error for long long in C90
[#36581] avr-libc: pgmspace.h is not ANSI compliant
+ [#37103] ATtiny5/9/10/20/40 watchdog can't be enabled
[#37778] _MemoryBarrier() in cpufunc.h error on compile
[#38135] Install a dummy stdfix-avrlibc.h
[#38516] Missing TWI and UCSR1D definitions for ATmega16/32 U4
Modified: trunk/avr-libc/include/avr/wdt.h
===================================================================
--- trunk/avr-libc/include/avr/wdt.h 2014-04-29 10:33:23 UTC (rev 2422)
+++ trunk/avr-libc/include/avr/wdt.h 2014-04-29 12:51:45 UTC (rev 2423)
@@ -107,8 +107,10 @@
#if defined(WDTCSR)
# define _WD_CONTROL_REG WDTCSR
+#elif defined(WDTCR)
+# define _WD_CONTROL_REG WDTCR
#else
-# define _WD_CONTROL_REG WDTCR
+# define _WD_CONTROL_REG WDT
#endif
#if defined(WDTOE)
@@ -353,6 +355,51 @@
)
+#elif defined(__AVR_ATtiny4__) \
+|| defined(__AVR_ATtiny5__) \
+|| defined(__AVR_ATtiny9__) \
+|| defined(__AVR_ATtiny10__) \
+|| defined(__AVR_ATtiny20__) \
+|| defined(__AVR_ATtiny40__)
+
+#define wdt_enable(value) \
+__asm__ __volatile__ ( \
+ "in __tmp_reg__,__SREG__" "\n\t" \
+ "cli" "\n\t" \
+ "wdr" "\n\t" \
+ "out %[CCPADDRESS],%[SIGNATURE]" "\n\t" \
+ "out %[WDTREG],%[WDVALUE]" "\n\t" \
+ "out __SREG__,__tmp_reg__" "\n\t" \
+ : /* no outputs */ \
+ : [CCPADDRESS] "I" (_SFR_IO_ADDR(CCP)), \
+ [SIGNATURE] "r" ((uint8_t)0xD8), \
+ [WDTREG] "I" (_SFR_IO_ADDR(_WD_CONTROL_REG)), \
+ [WDVALUE] "r" ((uint8_t)((value & 0x08 ? _WD_PS3_MASK : 0x00) \
+ | _BV(WDE) | value)) \
+ : "r16" \
+)
+
+#define wdt_disable() \
+do { \
+uint8_t temp_wd; \
+__asm__ __volatile__ ( \
+ "in __tmp_reg__,__SREG__" "\n\t" \
+ "cli" "\n\t" \
+ "wdr" "\n\t" \
+ "out %[CCPADDRESS],%[SIGNATURE]" "\n\t" \
+ "in %[TEMP_WD],%[WDTREG]" "\n\t" \
+ "cbr %[TEMP_WD],%[WDVALUE]" "\n\t" \
+ "out %[WDTREG],%[TEMP_WD]" "\n\t" \
+ "out __SREG__,__tmp_reg__" "\n\t" \
+ : /*no output */ \
+ : [CCPADDRESS] "I" (_SFR_IO_ADDR(CCP)), \
+ [SIGNATURE] "r" ((uint8_t)0xD8), \
+ [WDTREG] "I" (_SFR_IO_ADDR(_WD_CONTROL_REG)), \
+ [TEMP_WD] "d" (temp_wd), \
+ [WDVALUE] "I" (1 << WDE) \
+ : "r16" \
+); \
+}while(0)
#else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2423] bug #37103: Add wdt_enable and wdt_disable macros for ATtiny4/5/9/10 /20/40 devices,
Pitchumani <=