updated for latest mac driver structure
This commit is contained in:
parent
229d60d691
commit
e42d572f81
2 changed files with 17 additions and 14 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: tdma_mac.c,v 1.4 2008/02/24 22:10:30 adamdunkels Exp $
|
* $Id: tdma_mac.c,v 1.5 2008/11/12 12:42:41 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -102,7 +102,7 @@ transmitter(struct rtimer *t, void *ptr)
|
||||||
while(now > slot_start + SLOT_LENGTH - GUARD_PERIOD) {
|
while(now > slot_start + SLOT_LENGTH - GUARD_PERIOD) {
|
||||||
slot_start += PERIOD_LENGTH;
|
slot_start += PERIOD_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF("TIMER Rescheduling until %u\n", slot_start);
|
PRINTF("TIMER Rescheduling until %u\n", slot_start);
|
||||||
r = rtimer_set(&rtimer, slot_start, 1,
|
r = rtimer_set(&rtimer, slot_start, 1,
|
||||||
(void (*)(struct rtimer *, void *))transmitter, NULL);
|
(void (*)(struct rtimer *, void *))transmitter, NULL);
|
||||||
|
@ -143,7 +143,7 @@ transmitter(struct rtimer *t, void *ptr)
|
||||||
if(r) {
|
if(r) {
|
||||||
PRINTF("TIMER Error #2: %d\n", r);
|
PRINTF("TIMER Error #2: %d\n", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -152,7 +152,7 @@ send(void)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
id_counter++;
|
id_counter++;
|
||||||
|
|
||||||
/* Clean up already sent packets */
|
/* Clean up already sent packets */
|
||||||
while(lastqueued != nextsend) {
|
while(lastqueued != nextsend) {
|
||||||
PRINTF("BUFFER Cleaning up packet #%i\n", id[lastqueued]);
|
PRINTF("BUFFER Cleaning up packet #%i\n", id[lastqueued]);
|
||||||
|
@ -161,7 +161,7 @@ send(void)
|
||||||
|
|
||||||
lastqueued = (lastqueued + 1) % NUM_PACKETS;
|
lastqueued = (lastqueued + 1) % NUM_PACKETS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((freeslot + 1) % NUM_PACKETS == lastqueued) {
|
if((freeslot + 1) % NUM_PACKETS == lastqueued) {
|
||||||
PRINTF("BUFFER Buffer full, dropping packet #%i\n", (id_counter+1));
|
PRINTF("BUFFER Buffer full, dropping packet #%i\n", (id_counter+1));
|
||||||
return UIP_FW_DROPPED;
|
return UIP_FW_DROPPED;
|
||||||
|
@ -177,7 +177,7 @@ send(void)
|
||||||
PRINTF("BUFFER Wrote packet #%i to buffer \n", id[freeslot]);
|
PRINTF("BUFFER Wrote packet #%i to buffer \n", id[freeslot]);
|
||||||
|
|
||||||
freeslot = (freeslot + 1) % NUM_PACKETS;
|
freeslot = (freeslot + 1) % NUM_PACKETS;
|
||||||
|
|
||||||
if(!timer_on) {
|
if(!timer_on) {
|
||||||
PRINTF("TIMER Starting timer\n");
|
PRINTF("TIMER Starting timer\n");
|
||||||
r = rtimer_set(&rtimer, RTIMER_NOW() + RTIMER_SECOND, 1,
|
r = rtimer_set(&rtimer, RTIMER_NOW() + RTIMER_SECOND, 1,
|
||||||
|
@ -226,7 +226,7 @@ off(void)
|
||||||
return radio->off();
|
return radio->off();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
const struct mac_driver *
|
||||||
tdma_mac_init(const struct radio_driver *d)
|
tdma_mac_init(const struct radio_driver *d)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -237,12 +237,15 @@ tdma_mac_init(const struct radio_driver *d)
|
||||||
radio = d;
|
radio = d;
|
||||||
radio->set_receive_function(input);
|
radio->set_receive_function(input);
|
||||||
radio->on();
|
radio->on();
|
||||||
|
|
||||||
|
return &tdma_mac_driver;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct mac_driver tdma_mac_driver = {
|
const struct mac_driver tdma_mac_driver = {
|
||||||
send,
|
"TDMA MAC",
|
||||||
read,
|
send,
|
||||||
set_receive_function,
|
read,
|
||||||
on,
|
set_receive_function,
|
||||||
off,
|
on,
|
||||||
|
off,
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: tdma_mac.h,v 1.1 2007/08/31 13:42:22 fros4943 Exp $
|
* $Id: tdma_mac.h,v 1.2 2008/11/12 12:42:41 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TDMA_MAC_H__
|
#ifndef __TDMA_MAC_H__
|
||||||
|
@ -39,6 +39,6 @@
|
||||||
|
|
||||||
extern const struct mac_driver tdma_mac_driver;
|
extern const struct mac_driver tdma_mac_driver;
|
||||||
|
|
||||||
void tdma_mac_init(const struct radio_driver *r);
|
const struct mac_driver * tdma_mac_init(const struct radio_driver *r);
|
||||||
|
|
||||||
#endif /* __TDMA_MAC_H__ */
|
#endif /* __TDMA_MAC_H__ */
|
||||||
|
|
Loading…
Reference in a new issue