From 181213124bc2c30efa2988339c1f6e9f8559d5aa Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 2 Feb 2010 23:28:58 +0000 Subject: [PATCH] Added a configuration option for setting the MAC channel check rate (which must be a power of two). The configuration is independent of the MAC protocol. --- core/net/mac/cxmac.c | 4 ++-- core/net/mac/lpp.c | 4 ++-- core/net/mac/mac.h | 13 ++++++++++++- core/net/mac/xmac.c | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/net/mac/cxmac.c b/core/net/mac/cxmac.c index a5f20e119..281614ddd 100644 --- a/core/net/mac/cxmac.c +++ b/core/net/mac/cxmac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: cxmac.c,v 1.6 2010/02/02 16:33:07 adamdunkels Exp $ + * $Id: cxmac.c,v 1.7 2010/02/02 23:28:58 adamdunkels Exp $ */ /** @@ -114,7 +114,7 @@ struct cxmac_hdr { #ifdef CXMAC_CONF_OFF_TIME #define DEFAULT_OFF_TIME (CXMAC_CONF_OFF_TIME) #else -#define DEFAULT_OFF_TIME (RTIMER_ARCH_SECOND / 4 - DEFAULT_ON_TIME) +#define DEFAULT_OFF_TIME (RTIMER_ARCH_SECOND / MAC_CHANNEL_CHECK_RATE - DEFAULT_ON_TIME) #endif #define DEFAULT_PERIOD (DEFAULT_OFF_TIME + DEFAULT_ON_TIME) diff --git a/core/net/mac/lpp.c b/core/net/mac/lpp.c index 52b71b55e..2c681111a 100644 --- a/core/net/mac/lpp.c +++ b/core/net/mac/lpp.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: lpp.c,v 1.29 2010/01/25 11:43:32 adamdunkels Exp $ + * $Id: lpp.c,v 1.30 2010/02/02 23:28:58 adamdunkels Exp $ */ /** @@ -90,7 +90,7 @@ #ifdef LPP_CONF_OFF_TIME #define OFF_TIME LPP_CONF_OFF_TIME #else -#define OFF_TIME (CLOCK_SECOND / 2 - LISTEN_TIME) +#define OFF_TIME (CLOCK_SECOND / MAC_CHANNEL_CHECK_RATE - LISTEN_TIME) #endif /* LPP_CONF_OFF_TIME */ #define PACKET_LIFETIME (LISTEN_TIME + OFF_TIME) diff --git a/core/net/mac/mac.h b/core/net/mac/mac.h index 684290661..43527bd4f 100644 --- a/core/net/mac/mac.h +++ b/core/net/mac/mac.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: mac.h,v 1.8 2010/01/25 11:43:32 adamdunkels Exp $ + * $Id: mac.h,v 1.9 2010/02/02 23:28:58 adamdunkels Exp $ */ /** @@ -90,4 +90,15 @@ enum { MAC_TX_ERR_FATAL, }; +#ifdef MAC_CONF_CHANNEL_CHECK_RATE +#define MAC_CHANNEL_CHECK_RATE MAC_CONF_CHANNEL_CHECK_RATE +#else /* MAC_CHANNEL_CHECK_RATE */ +#define MAC_CHANNEL_CHECK_RATE 4 +#endif /* MAC_CHANNEL_CHECK_RATE */ + +#if (MAC_CHANNEL_CHECK_RATE & (MAC_CHANNEL_CHECK_RATE - 1)) != 0 +#error MAC_CONF_CHANNEL_CHECK_RATE must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...). +#error Change MAC_CONF_CHANNEL_CHECK_RATE in contiki-conf.h or in your Makefile. +#endif + #endif /* __MAC_H__ */ diff --git a/core/net/mac/xmac.c b/core/net/mac/xmac.c index 102df223d..eb9374a62 100644 --- a/core/net/mac/xmac.c +++ b/core/net/mac/xmac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: xmac.c,v 1.50 2010/01/28 13:40:47 adamdunkels Exp $ + * $Id: xmac.c,v 1.51 2010/02/02 23:28:58 adamdunkels Exp $ */ /** @@ -114,7 +114,7 @@ struct xmac_hdr { #ifdef XMAC_CONF_OFF_TIME #define DEFAULT_OFF_TIME (XMAC_CONF_OFF_TIME) #else -#define DEFAULT_OFF_TIME (RTIMER_ARCH_SECOND / 4 - DEFAULT_ON_TIME) +#define DEFAULT_OFF_TIME (RTIMER_ARCH_SECOND / MAC_CHANNEL_CHECK_RATE - DEFAULT_ON_TIME) #endif #define DEFAULT_PERIOD (DEFAULT_OFF_TIME + DEFAULT_ON_TIME)