Made initialization function return a pointer to the MAC driver structure, to make initialization nicer
This commit is contained in:
parent
f638c628d7
commit
67aa9e8589
|
@ -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;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue