More updates for raven

This commit is contained in:
c_oflynn 2008-10-14 18:38:09 +00:00
parent a73ed65dac
commit 6e3ee0d917
2 changed files with 352 additions and 352 deletions

View file

@ -1,237 +1,237 @@
/* /*
* Copyright (c) 2008, Swedish Institute of Computer Science. * Copyright (c) 2008, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ieee-15-4-manager.c,v 1.1 2008/10/14 09:43:40 adamdunkels Exp $ * $Id: ieee-15-4-manager.c,v 1.2 2008/10/14 18:38:09 c_oflynn Exp $
*/ */
/** /**
* *
* \addtogroup rf230mac * \addtogroup rf230mac
* \{ * \{
*/ */
/** /**
* \file * \file
* \brief Interfaces the 802.15.4 MAC to upper network layers. * \brief Interfaces the 802.15.4 MAC to upper network layers.
* *
* \author * \author
* Mike Vidales <mavida404@gmail.com> * Mike Vidales <mavida404@gmail.com>
*/ */
#include "mac.h" #include "zmac.h"
#include "radio.h" #include "radio.h"
#include "ieee-15-4-manager.h" #include "ieee-15-4-manager.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
wake(void) wake(void)
{ {
/* Wake the radio. */ /* Wake the radio. */
return radio_leave_sleep_mode(); return radio_leave_sleep_mode();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
sleep(void) sleep(void)
{ {
/* Sleep the radio. */ /* Sleep the radio. */
return radio_enter_sleep_mode(); return radio_enter_sleep_mode();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_channel(int channel) set_channel(int channel)
{ {
/* Set the channel. */ /* Set the channel. */
phyCurrentChannel = channel; phyCurrentChannel = channel;
radio_set_operating_channel(phyCurrentChannel); radio_set_operating_channel(phyCurrentChannel);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_channel(void) get_channel(void)
{ {
/* Reads the current channel. */ /* Reads the current channel. */
phyCurrentChannel = radio_get_operating_channel(); phyCurrentChannel = radio_get_operating_channel();
return phyCurrentChannel; return phyCurrentChannel;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_dst_panid(int panid) set_dst_panid(int panid)
{ {
macDstPANId = panid; macDstPANId = panid;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_dst_panid(void) get_dst_panid(void)
{ {
return macDstPANId; return macDstPANId;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_src_panid(int panid) set_src_panid(int panid)
{ {
/* Writes the PAN_ID to the radio. */ /* Writes the PAN_ID to the radio. */
macSrcPANId = panid; macSrcPANId = panid;
radio_set_pan_id(macSrcPANId); radio_set_pan_id(macSrcPANId);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_src_panid(void) get_src_panid(void)
{ {
/* Gets the PAN_ID from the radio. */ /* Gets the PAN_ID from the radio. */
macSrcPANId = radio_get_pan_id(); macSrcPANId = radio_get_pan_id();
return macSrcPANId; return macSrcPANId;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_auto_mode(bool mode) set_auto_mode(bool mode)
{ {
autoModes = mode; autoModes = mode;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static bool static bool
get_auto_mode(void) get_auto_mode(void)
{ {
return autoModes; return autoModes;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_long_addr(uint64_t address) set_long_addr(uint64_t address)
{ {
/* Set the Long address in the radio. */ /* Set the Long address in the radio. */
macLongAddr = address; macLongAddr = address;
radio_set_extended_address((uint8_t *)&macLongAddr); radio_set_extended_address((uint8_t *)&macLongAddr);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint64_t static uint64_t
get_long_addr(void) get_long_addr(void)
{ {
/* Get the Long address from the radio. */ /* Get the Long address from the radio. */
radio_get_extended_address((uint8_t *)&macLongAddr); radio_get_extended_address((uint8_t *)&macLongAddr);
return macLongAddr; return macLongAddr;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_short_addr(int address) set_short_addr(int address)
{ {
/* Set the Short address in the radio. */ /* Set the Short address in the radio. */
macShortAddress = address; macShortAddress = address;
radio_set_short_address(macShortAddress); radio_set_short_address(macShortAddress);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_short_addr(void) get_short_addr(void)
{ {
/* Get the Short address from the radio. */ /* Get the Short address from the radio. */
macShortAddress = radio_get_short_address(); macShortAddress = radio_get_short_address();
return macShortAddress; return macShortAddress;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_iamcoord_bit(bool iamcoord) set_iamcoord_bit(bool iamcoord)
{ {
/** Set the iAmCoord bit. */ /** Set the iAmCoord bit. */
iAmCoord = iamcoord; iAmCoord = iamcoord;
radio_set_device_role(iAmCoord); radio_set_device_role(iAmCoord);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static bool static bool
get_iamcoord_bit(void) get_iamcoord_bit(void)
{ {
/** Get the iAmCoord bit. */ /** Get the iAmCoord bit. */
iAmCoord = radio_get_device_role(); iAmCoord = radio_get_device_role();
return iAmCoord; return iAmCoord;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_coord_long_addr(uint64_t address) set_coord_long_addr(uint64_t address)
{ {
macCoordExtendedAddress = address; macCoordExtendedAddress = address;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint64_t static uint64_t
get_coord_long_addr(void) get_coord_long_addr(void)
{ {
return macCoordExtendedAddress; return macCoordExtendedAddress;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_coord_short_addr(int address) set_coord_short_addr(int address)
{ {
macCoordShortAddress = address; macCoordShortAddress = address;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
get_coord_short_addr(void) get_coord_short_addr(void)
{ {
return macCoordShortAddress; return macCoordShortAddress;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_dest_long_addr(uint64_t address) set_dest_long_addr(uint64_t address)
{ {
macDestAddress = address; macDestAddress = address;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint64_t static uint64_t
get_dest_long_addr(void) get_dest_long_addr(void)
{ {
return macDestAddress; return macDestAddress;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** \brief initializes the 802.15.4 manager layer. /** \brief initializes the 802.15.4 manager layer.
* \param pieee_15_4_manager Pointer to \ref ieee_15_4_manager * \param pieee_15_4_manager Pointer to \ref ieee_15_4_manager
*/ */
void ieee_15_4_init(ieee_15_4_manager_t *pieee_15_4_manager) void ieee_15_4_init(ieee_15_4_manager_t *pieee_15_4_manager)
{ {
/* Initialize the IEEE 15.4 manager. */ /* Initialize the IEEE 15.4 manager. */
pieee_15_4_manager->wake = wake; pieee_15_4_manager->wake = wake;
pieee_15_4_manager->sleep = sleep; pieee_15_4_manager->sleep = sleep;
pieee_15_4_manager->set_channel = set_channel; pieee_15_4_manager->set_channel = set_channel;
pieee_15_4_manager->get_channel = get_channel; pieee_15_4_manager->get_channel = get_channel;
pieee_15_4_manager->set_dst_panid = set_dst_panid; pieee_15_4_manager->set_dst_panid = set_dst_panid;
pieee_15_4_manager->get_dst_panid = get_dst_panid; pieee_15_4_manager->get_dst_panid = get_dst_panid;
pieee_15_4_manager->set_src_panid = set_src_panid; pieee_15_4_manager->set_src_panid = set_src_panid;
pieee_15_4_manager->get_src_panid = get_src_panid; pieee_15_4_manager->get_src_panid = get_src_panid;
pieee_15_4_manager->set_auto_mode = set_auto_mode; pieee_15_4_manager->set_auto_mode = set_auto_mode;
pieee_15_4_manager->get_auto_mode = get_auto_mode; pieee_15_4_manager->get_auto_mode = get_auto_mode;
pieee_15_4_manager->set_long_addr = set_long_addr; pieee_15_4_manager->set_long_addr = set_long_addr;
pieee_15_4_manager->get_long_addr = get_long_addr; pieee_15_4_manager->get_long_addr = get_long_addr;
pieee_15_4_manager->set_short_addr = set_short_addr; pieee_15_4_manager->set_short_addr = set_short_addr;
pieee_15_4_manager->get_short_addr = get_short_addr; pieee_15_4_manager->get_short_addr = get_short_addr;
pieee_15_4_manager->set_iamcoord_bit = set_iamcoord_bit; pieee_15_4_manager->set_iamcoord_bit = set_iamcoord_bit;
pieee_15_4_manager->get_iamcoord_bit = get_iamcoord_bit; pieee_15_4_manager->get_iamcoord_bit = get_iamcoord_bit;
pieee_15_4_manager->set_coord_long_addr = set_coord_long_addr; pieee_15_4_manager->set_coord_long_addr = set_coord_long_addr;
pieee_15_4_manager->get_coord_long_addr = get_coord_long_addr; pieee_15_4_manager->get_coord_long_addr = get_coord_long_addr;
pieee_15_4_manager->set_coord_short_addr = set_coord_short_addr; pieee_15_4_manager->set_coord_short_addr = set_coord_short_addr;
pieee_15_4_manager->get_coord_short_addr = get_coord_short_addr; pieee_15_4_manager->get_coord_short_addr = get_coord_short_addr;
pieee_15_4_manager->set_dest_long_addr = set_dest_long_addr; pieee_15_4_manager->set_dest_long_addr = set_dest_long_addr;
pieee_15_4_manager->get_dest_long_addr = get_dest_long_addr; pieee_15_4_manager->get_dest_long_addr = get_dest_long_addr;
} }
/** \} */ /** \} */

View file

@ -1,115 +1,115 @@
/* /*
* Copyright (c) 2008, Swedish Institute of Computer Science. * Copyright (c) 2008, Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ieee-15-4-manager.h,v 1.1 2008/10/14 09:43:40 adamdunkels Exp $ * $Id: ieee-15-4-manager.h,v 1.2 2008/10/14 18:38:09 c_oflynn Exp $
*/ */
/** /**
* \addtogroup rf230mac * \addtogroup rf230mac
* \{ * \{
*/ */
/** /**
* \file * \file
* \brief Example glue code between the existing MAC code and the * \brief Example glue code between the existing MAC code and the
* Contiki mac interface * Contiki mac interface
* *
* \author * \author
* Mike Vidales <mavida404@gmail.com> * Mike Vidales <mavida404@gmail.com>
* *
* \ingroup ieee_15_4 * \ingroup ieee_15_4
* *
*/ */
#ifndef __IEEEMANAGER_H__ #ifndef __IEEEMANAGER_H__
#define __IEEEMANAGER_H__ #define __IEEEMANAGER_H__
/** \brief The interface structure for the 802.15.4 quasi-MAC. */ /** \brief The interface structure for the 802.15.4 quasi-MAC. */
typedef struct ieee_15_4_manager{ typedef struct ieee_15_4_manager{
/** Turn the MAC layer on. */ /** Turn the MAC layer on. */
int (* wake)(void); int (* wake)(void);
/** Turn the MAC layer off. */ /** Turn the MAC layer off. */
int (* sleep)(void); int (* sleep)(void);
/** Set the operating channel. */ /** Set the operating channel. */
void (* set_channel)(int channel); void (* set_channel)(int channel);
/** Get the operating channel. */ /** Get the operating channel. */
int (* get_channel)(void); int (* get_channel)(void);
/** Set the Destination PAN_ID. */ /** Set the Destination PAN_ID. */
void (* set_dst_panid)(int panid); void (* set_dst_panid)(int panid);
/** Get the Destination PAN_ID. */ /** Get the Destination PAN_ID. */
int (* get_dst_panid)(void); int (* get_dst_panid)(void);
/** Set the Source PAN_ID. */ /** Set the Source PAN_ID. */
void (* set_src_panid)(int panid); void (* set_src_panid)(int panid);
/** Get the Source PAN_ID. */ /** Get the Source PAN_ID. */
int (* get_src_panid)(void); int (* get_src_panid)(void);
/** Set the Automatic TRX modes. */ /** Set the Automatic TRX modes. */
void (* set_auto_mode)(bool mode); void (* set_auto_mode)(bool mode);
/** Get the current state of Automatic TRX modes. */ /** Get the current state of Automatic TRX modes. */
bool (* get_auto_mode)(void); bool (* get_auto_mode)(void);
/** Set the Long Address. */ /** Set the Long Address. */
void (* set_long_addr)(uint64_t address); void (* set_long_addr)(uint64_t address);
/** Get the Long Address. */ /** Get the Long Address. */
uint64_t (* get_long_addr)(void); uint64_t (* get_long_addr)(void);
/** Set the Short Address. */ /** Set the Short Address. */
void (* set_short_addr)(int address); void (* set_short_addr)(int address);
/** Get the short Address. */ /** Get the short Address. */
int (* get_short_addr)(void); int (* get_short_addr)(void);
/** Set the iAmCoord bit. */ /** Set the iAmCoord bit. */
void (* set_iamcoord_bit)(bool iamcoord); void (* set_iamcoord_bit)(bool iamcoord);
/** Get the iAmCoord bit. */ /** Get the iAmCoord bit. */
bool (* get_iamcoord_bit)(void); bool (* get_iamcoord_bit)(void);
/** Set the Coordinator Long address. */ /** Set the Coordinator Long address. */
void (* set_coord_long_addr)(uint64_t address); void (* set_coord_long_addr)(uint64_t address);
/** Get the Coordinator Long address. */ /** Get the Coordinator Long address. */
uint64_t (* get_coord_long_addr)(void); uint64_t (* get_coord_long_addr)(void);
/** Set the Coordinator Long address. */ /** Set the Coordinator Long address. */
void (* set_coord_short_addr)(int address); void (* set_coord_short_addr)(int address);
/** Get the Coordinator Long address. */ /** Get the Coordinator Long address. */
int (* get_coord_short_addr)(void); int (* get_coord_short_addr)(void);
/** Set the Destination address. */ /** Set the Destination address. */
void (* set_dest_long_addr)(uint64_t address); void (* set_dest_long_addr)(uint64_t address);
/** Get the Destination address. */ /** Get the Destination address. */
uint64_t (* get_dest_long_addr)(void); uint64_t (* get_dest_long_addr)(void);
} ieee_15_4_manager_t; } ieee_15_4_manager_t;
void ieee_15_4_init(struct ieee_15_4_manager *pieee_15_4_manager); void ieee_15_4_init(struct ieee_15_4_manager *pieee_15_4_manager);
#endif /* __IEEEMANAGER_H__ */ #endif /* __IEEEMANAGER_H__ */
/** \} */ /** \} */