[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Branch on presence of sleep mode bits for XMEGAs as well
From: |
Senthil Kumar Selvaraj |
Subject: |
[avr-libc-dev] Branch on presence of sleep mode bits for XMEGAs as well |
Date: |
Thu, 20 Nov 2014 13:14:36 +0530 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
This patch detects presence of SLEEP_SMODE<n>_bm bit definition and
defines set_sleep_mode accordingly, for XMEGA devices. Previously, the
code assumed that all xmegas have 3 bits - this patch removes that
assumption and generalizes it work with devices that have fewer bits.
Committed as rev #2458.
Regards
Senthil
2014-11-20 Senthil Kumar Selvaraj <address@hidden>
* include/avr/sleep.h (set_sleep_mode): Branch on presence of
SLEEP_SMODE<n>_bm for xmegas.
Index: include/avr/sleep.h
===================================================================
--- include/avr/sleep.h (revision 2457)
+++ include/avr/sleep.h (working copy)
@@ -180,8 +180,9 @@
EMCUCR = ((EMCUCR & ~_BV(SM0)) | ((mode) == SLEEP_MODE_PWR_SAVE ||
(mode) == SLEEP_MODE_EXT_STANDBY ? _BV(SM0) : 0)); \
} while(0)
-/* All xmegas work the same way */
+/* For xmegas, check presence of SLEEP_SMODE<n>_bm and define set_sleep_mode
accordingly. */
#elif defined(__AVR_XMEGA__)
+#if defined(SLEEP_SMODE2_bm)
#define set_sleep_mode(mode) \
do { \
@@ -188,6 +189,23 @@
_SLEEP_CONTROL_REG = ((_SLEEP_CONTROL_REG & ~(SLEEP_SMODE2_bm |
SLEEP_SMODE1_bm | SLEEP_SMODE0_bm)) | (mode)); \
} while(0)
+#elif defined(SLEEP_SMODE1_bm)
+
+ #define set_sleep_mode(mode) \
+ do { \
+ _SLEEP_CONTROL_REG = ((_SLEEP_CONTROL_REG & ~(SLEEP_SMODE1_bm |
SLEEP_SMODE0_bm)) | (mode)); \
+ } while(0)
+
+#else
+
+ #define set_sleep_mode(mode) \
+ do { \
+ _SLEEP_CONTROL_REG = ((_SLEEP_CONTROL_REG & ~( SLEEP_SMODE0_bm)) |
(mode)); \
+ } while(0)
+
+
+#endif /* #if defined(SLEEP_SMODE2_bm) */
+
/* For everything else, check for presence of SM<n> and define set_sleep_mode
accordingly. */
#else
#if defined(SM2)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] Branch on presence of sleep mode bits for XMEGAs as well,
Senthil Kumar Selvaraj <=