From 9d072d5309c6db3894a3c8224fbf585242e6eb68 Mon Sep 17 00:00:00 2001 From: maralvira Date: Sun, 7 Nov 2010 14:21:06 +0000 Subject: [PATCH] Add macro to help compute TMR.ENBL values (useful when using #defined values to represent timers) --- cpu/mc1322x/lib/include/tmr.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpu/mc1322x/lib/include/tmr.h b/cpu/mc1322x/lib/include/tmr.h index a3b318dd5..5de31613a 100644 --- a/cpu/mc1322x/lib/include/tmr.h +++ b/cpu/mc1322x/lib/include/tmr.h @@ -30,7 +30,7 @@ * This file is part of libmc1322x: see http://mc1322x.devl.org * for details. * - * $Id: tmr.h,v 1.5 2010/11/07 14:19:17 maralvira Exp $ + * $Id: tmr.h,v 1.6 2010/11/07 14:21:06 maralvira Exp $ */ #ifndef TMR_H @@ -143,6 +143,12 @@ static volatile struct TMR_struct * const _TMR3 = (void *) (TMR3_BASE); #define TMR2 (*_TMR2) #define TMR3 (*_TMR3) +/* Used to compute which enable bit to set for a particular timer, e.g. + TMR0.ENBL |= TMR_ENABLE_BIT(TMR2); + Helpful when you're using macros to define timers +*/ +#define TMR_ENABLE_BIT(x) ((&(x) == &(TMR0)) ? 1 : (&(x) == &(TMR1)) ? 2 : (&(x) == &(TMR2)) ? 4 : (&(x) == &(TMR3)) ? 8 : 0) + #define TMR0_PIN GPIO_08 #define TMR1_PIN GPIO_09 #define TMR2_PIN GPIO_10