[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2422] bug #39049: Add clock_prescale_set and get func
From: |
Pitchumani |
Subject: |
[avr-libc-commit] [2422] bug #39049: Add clock_prescale_set and get function/ macro for tiny 4/5/9/10/20 and 40 devices |
Date: |
Tue, 29 Apr 2014 10:33:24 +0000 |
Revision: 2422
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2422
Author: pitchumani
Date: 2014-04-29 10:33:23 +0000 (Tue, 29 Apr 2014)
Log Message:
-----------
bug #39049: Add clock_prescale_set and get function/ macro for tiny 4/5/9/10/20
and 40 devices
Ticket Links:
------------
http://savannah.gnu.org/bugs/?39049
Modified Paths:
--------------
trunk/avr-libc/ChangeLog
trunk/avr-libc/NEWS
trunk/avr-libc/include/avr/power.h
Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog 2014-04-29 06:21:42 UTC (rev 2421)
+++ trunk/avr-libc/ChangeLog 2014-04-29 10:33:23 UTC (rev 2422)
@@ -1,5 +1,11 @@
2014-04-29 Senthil Kumar Selvaraj <address@hidden>
+ Fix for bug #39049: Clock prescaler set and get are missing for TINY
arch
+ * include/avr/power.h: Add clock_prescale_set and get function/macro
for
+ tiny 4, 5, 9, 10, 20 and 40 devices.
+
+2014-04-29 Senthil Kumar Selvaraj <address@hidden>
+
Fix for bug #40206: incorrect SP init in startup code for xmegas
* crt1/gcrt1.S: write to SPL and then SPH for xmega SP initialization
Modified: trunk/avr-libc/NEWS
===================================================================
--- trunk/avr-libc/NEWS 2014-04-29 06:21:42 UTC (rev 2421)
+++ trunk/avr-libc/NEWS 2014-04-29 10:33:23 UTC (rev 2422)
@@ -16,6 +16,7 @@
[#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
+ [#39049] Clock prescaler set and get are missing for TINY architecture
[#39783] CRC missing definitions and incorrect power macros for xmega D3
[#40003] Integer type promotion leads to inefficent code in wdt.h
[#40206] incorrect SP init in startup code for xmegas
Modified: trunk/avr-libc/include/avr/power.h
===================================================================
--- trunk/avr-libc/include/avr/power.h 2014-04-29 06:21:42 UTC (rev 2421)
+++ trunk/avr-libc/include/avr/power.h 2014-04-29 10:33:23 UTC (rev 2422)
@@ -2754,6 +2754,47 @@
}
}
+#elif defined(__AVR_ATtiny4__) \
+|| defined(__AVR_ATtiny5__) \
+|| defined(__AVR_ATtiny9__) \
+|| defined(__AVR_ATtiny10__) \
+|| defined(__AVR_ATtiny20__) \
+|| defined(__AVR_ATtiny40__) \
+
+typedef enum
+{
+ clock_div_1 = 0,
+ clock_div_2 = 1,
+ clock_div_4 = 2,
+ clock_div_8 = 3,
+ clock_div_16 = 4,
+ clock_div_32 = 5,
+ clock_div_64 = 6,
+ clock_div_128 = 7,
+ clock_div_256 = 8
+} clock_div_t;
+
+static __inline__ void clock_prescale_set(clock_div_t)
__attribute__((__always_inline__));
+
+void clock_prescale_set(clock_div_t __x)
+{
+ uint8_t __tmp = 0xD8;
+ __asm__ __volatile__ (
+ "in __tmp_reg__,__SREG__" "\n\t"
+ "cli" "\n\t"
+ "out %1, %0" "\n\t"
+ "out %2, %3" "\n\t"
+ "out __SREG__, __tmp_reg__"
+ : /* no outputs */
+ : "d" (__tmp),
+ "I" (_SFR_IO_ADDR(CCP)),
+ "I" (_SFR_IO_ADDR(CLKPSR)),
+ "d" (__x)
+ : "r16");
+}
+
+#define clock_prescale_get() (clock_div_t)(CLKPSR &
(uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
+
#endif
#endif /* _AVR_POWER_H_ */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2422] bug #39049: Add clock_prescale_set and get function/ macro for tiny 4/5/9/10/20 and 40 devices,
Pitchumani <=