From 67aa9e858909d8ec9acb2b6f4354bc85f9cacb2c Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 23 Oct 2007 21:27:57 +0000 Subject: [PATCH] Made initialization function return a pointer to the MAC driver structure, to make initialization nicer --- core/net/mac/nullmac.c | 20 +++++++++++--------- core/net/mac/xmac.c | 30 ++++++++++++++++-------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/core/net/mac/nullmac.c b/core/net/mac/nullmac.c index 14163dbba..c9f2b26f1 100644 --- a/core/net/mac/nullmac.c +++ b/core/net/mac/nullmac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: nullmac.c,v 1.3 2007/05/25 08:07:15 adamdunkels Exp $ + * $Id: nullmac.c,v 1.4 2007/10/23 21:27:57 adamdunkels Exp $ */ /** @@ -84,14 +84,6 @@ off(void) return radio->off(); } /*---------------------------------------------------------------------------*/ -void -nullmac_init(const struct radio_driver *d) -{ - radio = d; - radio->set_receive_function(input); - radio->on(); -} -/*---------------------------------------------------------------------------*/ const struct mac_driver nullmac_driver = { send, read, @@ -99,3 +91,13 @@ const struct mac_driver nullmac_driver = { on, off, }; +/*---------------------------------------------------------------------------*/ +const struct mac_driver * +nullmac_init(const struct radio_driver *d) +{ + radio = d; + radio->set_receive_function(input); + radio->on(); + return &nullmac_driver; +} +/*---------------------------------------------------------------------------*/ diff --git a/core/net/mac/xmac.c b/core/net/mac/xmac.c index 38a9c710d..f1dbd2bb3 100644 --- a/core/net/mac/xmac.c +++ b/core/net/mac/xmac.c @@ -30,7 +30,7 @@ * * This file is part of the Contiki operating system. * - * $Id: xmac.c,v 1.7 2007/08/30 14:39:18 matsutsuka Exp $ + * $Id: xmac.c,v 1.8 2007/10/23 21:27:57 adamdunkels Exp $ */ /** @@ -426,19 +426,6 @@ read(void) return 0; } /*---------------------------------------------------------------------------*/ -void -xmac_init(const struct radio_driver *d) -{ - radio_is_on = 0; - should_be_awake = 0; - PT_INIT(&pt); - rtimer_set(&rt, RTIMER_NOW() + OFF_TIME, 1, - (void (*)(struct rtimer *, void *))powercycle, NULL); - - radio = d; - radio->set_receive_function(input); -} -/*---------------------------------------------------------------------------*/ static int on(void) { @@ -459,3 +446,18 @@ const struct mac_driver xmac_driver = on, off }; +/*---------------------------------------------------------------------------*/ +const struct mac_driver * +xmac_init(const struct radio_driver *d) +{ + radio_is_on = 0; + should_be_awake = 0; + PT_INIT(&pt); + rtimer_set(&rt, RTIMER_NOW() + OFF_TIME, 1, + (void (*)(struct rtimer *, void *))powercycle, NULL); + + radio = d; + radio->set_receive_function(input); + return &xmac_driver; +} +/*---------------------------------------------------------------------------*/