From c475ae95adff4b3da3bfb5b1b5fffd332fde7aee Mon Sep 17 00:00:00 2001 From: rincon Date: Wed, 18 Apr 2007 22:19:33 +0000 Subject: [PATCH] Removal - this stack has become the default. --- tos/chips/cc2420_lpl/AlarmMultiplexC.nc | 57 -- tos/chips/cc2420_lpl/CC2420.h | 321 ---------- tos/chips/cc2420_lpl/CC2420ActiveMessageC.nc | 88 --- tos/chips/cc2420_lpl/CC2420ActiveMessageP.nc | 188 ------ tos/chips/cc2420_lpl/CC2420Cca.nc | 46 -- tos/chips/cc2420_lpl/CC2420Config.nc | 73 --- tos/chips/cc2420_lpl/CC2420ControlC.nc | 93 --- tos/chips/cc2420_lpl/CC2420ControlP.nc | 286 --------- tos/chips/cc2420_lpl/CC2420CsmaC.nc | 88 --- tos/chips/cc2420_lpl/CC2420CsmaP.nc | 233 ------- tos/chips/cc2420_lpl/CC2420DutyCycle.h | 63 -- tos/chips/cc2420_lpl/CC2420DutyCycle.nc | 57 -- tos/chips/cc2420_lpl/CC2420DutyCycleC.nc | 80 --- tos/chips/cc2420_lpl/CC2420DutyCycleP.nc | 286 --------- tos/chips/cc2420_lpl/CC2420Fifo.nc | 93 --- .../cc2420_lpl/CC2420LowPowerListening.h | 66 -- .../cc2420_lpl/CC2420LowPowerListeningC.nc | 83 --- .../cc2420_lpl/CC2420LowPowerListeningP.nc | 505 --------------- tos/chips/cc2420_lpl/CC2420LplDummyP.nc | 84 --- tos/chips/cc2420_lpl/CC2420Packet.nc | 71 --- tos/chips/cc2420_lpl/CC2420PacketC.nc | 86 --- tos/chips/cc2420_lpl/CC2420Power.nc | 99 --- tos/chips/cc2420_lpl/CC2420Ram.nc | 65 -- tos/chips/cc2420_lpl/CC2420Receive.nc | 64 -- tos/chips/cc2420_lpl/CC2420ReceiveC.nc | 73 --- tos/chips/cc2420_lpl/CC2420ReceiveP.nc | 287 --------- tos/chips/cc2420_lpl/CC2420Register.nc | 57 -- tos/chips/cc2420_lpl/CC2420SpiC.nc | 115 ---- tos/chips/cc2420_lpl/CC2420SpiImplP.nc | 233 ------- tos/chips/cc2420_lpl/CC2420SpiP.nc | 64 -- tos/chips/cc2420_lpl/CC2420Strobe.nc | 47 -- tos/chips/cc2420_lpl/CC2420Transmit.nc | 99 --- tos/chips/cc2420_lpl/CC2420TransmitC.nc | 96 --- tos/chips/cc2420_lpl/CC2420TransmitP.nc | 575 ------------------ tos/chips/cc2420_lpl/IEEE802154.h | 61 -- tos/chips/cc2420_lpl/LowPowerListening.nc | 129 ---- 36 files changed, 5011 deletions(-) delete mode 100644 tos/chips/cc2420_lpl/AlarmMultiplexC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420.h delete mode 100644 tos/chips/cc2420_lpl/CC2420ActiveMessageC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420ActiveMessageP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Cca.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Config.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420ControlC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420ControlP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420CsmaC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420CsmaP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420DutyCycle.h delete mode 100644 tos/chips/cc2420_lpl/CC2420DutyCycle.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420DutyCycleC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420DutyCycleP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Fifo.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420LowPowerListening.h delete mode 100644 tos/chips/cc2420_lpl/CC2420LowPowerListeningC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420LowPowerListeningP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420LplDummyP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Packet.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420PacketC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Power.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Ram.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Receive.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420ReceiveC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420ReceiveP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Register.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420SpiC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420SpiImplP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420SpiP.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Strobe.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420Transmit.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420TransmitC.nc delete mode 100644 tos/chips/cc2420_lpl/CC2420TransmitP.nc delete mode 100644 tos/chips/cc2420_lpl/IEEE802154.h delete mode 100644 tos/chips/cc2420_lpl/LowPowerListening.nc diff --git a/tos/chips/cc2420_lpl/AlarmMultiplexC.nc b/tos/chips/cc2420_lpl/AlarmMultiplexC.nc deleted file mode 100644 index 38a54b26..00000000 --- a/tos/chips/cc2420_lpl/AlarmMultiplexC.nc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * A component that multiplexes the use of an alarm. The assumption is - * that its use is mutually exclusive and users check whether the - * events are for them. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include - -configuration AlarmMultiplexC { - - provides interface Init; - provides interface Alarm as Alarm32khz32; - -} - -implementation { - - components new HplCC2420AlarmC() as Alarm; - - Init = Alarm; - Alarm32khz32 = Alarm; - -} diff --git a/tos/chips/cc2420_lpl/CC2420.h b/tos/chips/cc2420_lpl/CC2420.h deleted file mode 100644 index 6b0847ad..00000000 --- a/tos/chips/cc2420_lpl/CC2420.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#ifndef __CC2420_H__ -#define __CC2420_H__ - -//#include "message.h" - -typedef uint8_t cc2420_status_t; - -typedef nx_struct cc2420_header_t { - nxle_uint8_t length; - nxle_uint16_t fcf; - nxle_uint8_t dsn; - nxle_uint16_t destpan; - nxle_uint16_t dest; - nxle_uint16_t src; - nxle_uint8_t type; -} cc2420_header_t; - -typedef nx_struct cc2420_footer_t { -} cc2420_footer_t; - -typedef nx_struct cc2420_metadata_t { - nx_uint8_t tx_power; - nx_uint8_t rssi; - nx_uint8_t lqi; - nx_bool crc; - nx_bool ack; - nx_uint16_t time; - nx_uint16_t rxInterval; -} cc2420_metadata_t; - -typedef nx_struct cc2420_packet_t { - cc2420_header_t packet; - nx_uint8_t data[]; -} cc2420_packet_t; - -#ifndef TOSH_DATA_LENGTH -#define TOSH_DATA_LENGTH 28 -#endif - -#ifndef CC2420_DEF_CHANNEL -#define CC2420_DEF_CHANNEL 26 -#endif - -#ifndef CC2420_DEF_RFPOWER -#define CC2420_DEF_RFPOWER 31 -#endif - -enum { - // size of the header not including the length byte - MAC_HEADER_SIZE = sizeof( cc2420_header_t ) - 1, - // size of the footer (FCS field) - MAC_FOOTER_SIZE = sizeof( uint16_t ), - // MDU - MAC_PACKET_SIZE = MAC_HEADER_SIZE + TOSH_DATA_LENGTH + MAC_FOOTER_SIZE, -}; - -enum cc2420_enums { - CC2420_TIME_ACK_TURNAROUND = 7, // jiffies - CC2420_TIME_VREN = 20, // jiffies - CC2420_TIME_SYMBOL = 2, // 2 symbols / jiffy - CC2420_BACKOFF_PERIOD = ( 20 / CC2420_TIME_SYMBOL ), // symbols - CC2420_MIN_BACKOFF = ( 20 / CC2420_TIME_SYMBOL ), // platform specific? - CC2420_ACK_WAIT_DELAY = 128, // jiffies -}; - -enum cc2420_status_enums { - CC2420_STATUS_RSSI_VALID = 1 << 1, - CC2420_STATUS_LOCK = 1 << 2, - CC2420_STATUS_TX_ACTIVE = 1 << 3, - CC2420_STATUS_ENC_BUSY = 1 << 4, - CC2420_STATUS_TX_UNDERFLOW = 1 << 5, - CC2420_STATUS_XOSC16M_STABLE = 1 << 6, -}; - -enum cc2420_config_reg_enums { - CC2420_SNOP = 0x00, - CC2420_SXOSCON = 0x01, - CC2420_STXCAL = 0x02, - CC2420_SRXON = 0x03, - CC2420_STXON = 0x04, - CC2420_STXONCCA = 0x05, - CC2420_SRFOFF = 0x06, - CC2420_SXOSCOFF = 0x07, - CC2420_SFLUSHRX = 0x08, - CC2420_SFLUSHTX = 0x09, - CC2420_SACK = 0x0a, - CC2420_SACKPEND = 0x0b, - CC2420_SRXDEC = 0x0c, - CC2420_SRXENC = 0x0d, - CC2420_SAES = 0x0e, - CC2420_MAIN = 0x10, - CC2420_MDMCTRL0 = 0x11, - CC2420_MDMCTRL1 = 0x12, - CC2420_RSSI = 0x13, - CC2420_SYNCWORD = 0x14, - CC2420_TXCTRL = 0x15, - CC2420_RXCTRL0 = 0x16, - CC2420_RXCTRL1 = 0x17, - CC2420_FSCTRL = 0x18, - CC2420_SECCTRL0 = 0x19, - CC2420_SECCTRL1 = 0x1a, - CC2420_BATTMON = 0x1b, - CC2420_IOCFG0 = 0x1c, - CC2420_IOCFG1 = 0x1d, - CC2420_MANFIDL = 0x1e, - CC2420_MANFIDH = 0x1f, - CC2420_FSMTC = 0x20, - CC2420_MANAND = 0x21, - CC2420_MANOR = 0x22, - CC2420_AGCCTRL = 0x23, - CC2420_AGCTST0 = 0x24, - CC2420_AGCTST1 = 0x25, - CC2420_AGCTST2 = 0x26, - CC2420_FSTST0 = 0x27, - CC2420_FSTST1 = 0x28, - CC2420_FSTST2 = 0x29, - CC2420_FSTST3 = 0x2a, - CC2420_RXBPFTST = 0x2b, - CC2420_FMSTATE = 0x2c, - CC2420_ADCTST = 0x2d, - CC2420_DACTST = 0x2e, - CC2420_TOPTST = 0x2f, - CC2420_TXFIFO = 0x3e, - CC2420_RXFIFO = 0x3f, -}; - -enum cc2420_ram_addr_enums { - CC2420_RAM_TXFIFO = 0x000, - CC2420_RAM_RXFIFO = 0x080, - CC2420_RAM_KEY0 = 0x100, - CC2420_RAM_RXNONCE = 0x110, - CC2420_RAM_SABUF = 0x120, - CC2420_RAM_KEY1 = 0x130, - CC2420_RAM_TXNONCE = 0x140, - CC2420_RAM_CBCSTATE = 0x150, - CC2420_RAM_IEEEADR = 0x160, - CC2420_RAM_PANID = 0x168, - CC2420_RAM_SHORTADR = 0x16a, -}; - -enum cc2420_nonce_enums { - CC2420_NONCE_BLOCK_COUNTER = 0, - CC2420_NONCE_KEY_SEQ_COUNTER = 2, - CC2420_NONCE_FRAME_COUNTER = 3, - CC2420_NONCE_SOURCE_ADDRESS = 7, - CC2420_NONCE_FLAGS = 15, -}; - -enum cc2420_main_enums { - CC2420_MAIN_RESETn = 15, - CC2420_MAIN_ENC_RESETn = 14, - CC2420_MAIN_DEMOD_RESETn = 13, - CC2420_MAIN_MOD_RESETn = 12, - CC2420_MAIN_FS_RESETn = 11, - CC2420_MAIN_XOSC16M_BYPASS = 0, -}; - -enum cc2420_mdmctrl0_enums { - CC2420_MDMCTRL0_RESERVED_FRAME_MODE = 13, - CC2420_MDMCTRL0_PAN_COORDINATOR = 12, - CC2420_MDMCTRL0_ADR_DECODE = 11, - CC2420_MDMCTRL0_CCA_HYST = 8, - CC2420_MDMCTRL0_CCA_MOD = 6, - CC2420_MDMCTRL0_AUTOCRC = 5, - CC2420_MDMCTRL0_AUTOACK = 4, - CC2420_MDMCTRL0_PREAMBLE_LENGTH = 0, -}; - -enum cc2420_mdmctrl1_enums { - CC2420_MDMCTRL1_CORR_THR = 6, - CC2420_MDMCTRL1_DEMOD_AVG_MODE = 5, - CC2420_MDMCTRL1_MODULATION_MODE = 4, - CC2420_MDMCTRL1_TX_MODE = 2, - CC2420_MDMCTRL1_RX_MODE = 0, -}; - -enum cc2420_rssi_enums { - CC2420_RSSI_CCA_THR = 8, - CC2420_RSSI_RSSI_VAL = 0, -}; - -enum cc2420_syncword_enums { - CC2420_SYNCWORD_SYNCWORD = 0, -}; - -enum cc2420_txctrl_enums { - CC2420_TXCTRL_TXMIXBUF_CUR = 14, - CC2420_TXCTRL_TX_TURNAROUND = 13, - CC2420_TXCTRL_TXMIX_CAP_ARRAY = 11, - CC2420_TXCTRL_TXMIX_CURRENT = 9, - CC2420_TXCTRL_PA_CURRENT = 6, - CC2420_TXCTRL_RESERVED = 5, - CC2420_TXCTRL_PA_LEVEL = 0, -}; - -enum cc2420_rxctrl0_enums { - CC2420_RXCTRL0_RXMIXBUF_CUR = 12, - CC2420_RXCTRL0_HIGH_LNA_GAIN = 10, - CC2420_RXCTRL0_MED_LNA_GAIN = 8, - CC2420_RXCTRL0_LOW_LNA_GAIN = 6, - CC2420_RXCTRL0_HIGH_LNA_CURRENT = 4, - CC2420_RXCTRL0_MED_LNA_CURRENT = 2, - CC2420_RXCTRL0_LOW_LNA_CURRENT = 0, -}; - -enum cc2420_rxctrl1_enums { - CC2420_RXCTRL1_RXBPF_LOCUR = 13, - CC2420_RXCTRL1_RXBPF_MIDCUR = 12, - CC2420_RXCTRL1_LOW_LOWGAIN = 11, - CC2420_RXCTRL1_MED_LOWGAIN = 10, - CC2420_RXCTRL1_HIGH_HGM = 9, - CC2420_RXCTRL1_MED_HGM = 8, - CC2420_RXCTRL1_LNA_CAP_ARRAY = 6, - CC2420_RXCTRL1_RXMIX_TAIL = 4, - CC2420_RXCTRL1_RXMIX_VCM = 2, - CC2420_RXCTRL1_RXMIX_CURRENT = 0, -}; - -enum cc2420_rsctrl_enums { - CC2420_FSCTRL_LOCK_THR = 14, - CC2420_FSCTRL_CAL_DONE = 13, - CC2420_FSCTRL_CAL_RUNNING = 12, - CC2420_FSCTRL_LOCK_LENGTH = 11, - CC2420_FSCTRL_LOCK_STATUS = 10, - CC2420_FSCTRL_FREQ = 0, -}; - -enum cc2420_secctrl0_enums { - CC2420_SECCTRL0_RXFIFO_PROTECTION = 9, - CC2420_SECCTRL0_SEC_CBC_HEAD = 8, - CC2420_SECCTRL0_SEC_SAKEYSEL = 7, - CC2420_SECCTRL0_SEC_TXKEYSEL = 6, - CC2420_SECCTRL0_SEC_RXKEYSEL = 5, - CC2420_SECCTRL0_SEC_M = 2, - CC2420_SECCTRL0_SEC_MODE = 0, -}; - -enum cc2420_secctrl1_enums { - CC2420_SECCTRL1_SEC_TXL = 8, - CC2420_SECCTRL1_SEC_RXL = 0, -}; - -enum cc2420_battmon_enums { - CC2420_BATTMON_BATT_OK = 6, - CC2420_BATTMON_BATTMON_EN = 5, - CC2420_BATTMON_BATTMON_VOLTAGE = 0, -}; - -enum cc2420_iocfg0_enums { - CC2420_IOCFG0_BCN_ACCEPT = 11, - CC2420_IOCFG0_FIFO_POLARITY = 10, - CC2420_IOCFG0_FIFOP_POLARITY = 9, - CC2420_IOCFG0_SFD_POLARITY = 8, - CC2420_IOCFG0_CCA_POLARITY = 7, - CC2420_IOCFG0_FIFOP_THR = 0, -}; - -enum cc2420_iocfg1_enums { - CC2420_IOCFG1_HSSD_SRC = 10, - CC2420_IOCFG1_SFDMUX = 5, - CC2420_IOCFG1_CCAMUX = 0, -}; - -enum cc2420_manfidl_enums { - CC2420_MANFIDL_PARTNUM = 12, - CC2420_MANFIDL_MANFID = 0, -}; - -enum cc2420_manfidh_enums { - CC2420_MANFIDH_VERSION = 12, - CC2420_MANFIDH_PARTNUM = 0, -}; - -enum cc2420_fsmtc_enums { - CC2420_FSMTC_TC_RXCHAIN2RX = 13, - CC2420_FSMTC_TC_SWITCH2TX = 10, - CC2420_FSMTC_TC_PAON2TX = 6, - CC2420_FSMTC_TC_TXEND2SWITCH = 3, - CC2420_FSMTC_TC_TXEND2PAOFF = 0, -}; - -enum cc2420_sfdmux_enums { - CC2420_SFDMUX_SFD = 0, - CC2420_SFDMUX_XOSC16M_STABLE = 24, -}; - -#endif diff --git a/tos/chips/cc2420_lpl/CC2420ActiveMessageC.nc b/tos/chips/cc2420_lpl/CC2420ActiveMessageC.nc deleted file mode 100644 index ec264f19..00000000 --- a/tos/chips/cc2420_lpl/CC2420ActiveMessageC.nc +++ /dev/null @@ -1,88 +0,0 @@ -/* tab:4 - * "Copyright (c) 2005 Stanford University. All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose, without fee, and without written - * agreement is hereby granted, provided that the above copyright - * notice, the following two paragraphs and the author appear in all - * copies of this software. - * - * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE - * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY - * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, - * ENHANCEMENTS, OR MODIFICATIONS." - */ - -/** - * The Active Message layer for the CC2420 radio. This configuration - * just layers the AM dispatch (CC2420ActiveMessageM) on top of the - * underlying CC2420 radio packet (CC2420CsmaRadioC), which is - * inherently an AM packet (acknowledgements based on AM destination - * addr and group). Note that snooping may not work, due to CC2420 - * early packet rejection if acknowledgements are enabled. - * - * @author Philip Levis - * @version $Revision$ $Date$ - */ - -#include "CC2420.h" - -configuration CC2420ActiveMessageC { - provides { - interface SplitControl; - interface AMSend[am_id_t id]; - interface Receive[am_id_t id]; - interface Receive as Snoop[am_id_t id]; - interface AMPacket; - interface Packet; - interface CC2420Packet; - interface PacketAcknowledgements; - interface CsmaBackoff[am_id_t amId]; - interface LowPowerListening; - } -} -implementation { - - components CC2420ActiveMessageP as AM; - components CC2420CsmaC as Radio; - components ActiveMessageAddressC as Address; - - CsmaBackoff = Radio; - Packet = AM; - AMSend = AM; - Receive = AM.Receive; - Snoop = AM.Snoop; - AMPacket = AM; - -#ifdef LOW_POWER_LISTENING - components CC2420LowPowerListeningC as Lpl; - LowPowerListening = Lpl; - AM.SubSend -> Lpl.Send; - AM.SubReceive -> Lpl.Receive; - SplitControl = Lpl; - -#else - components CC2420LplDummyP; - LowPowerListening = CC2420LplDummyP; - AM.SubSend -> Radio.Send; - AM.SubReceive -> Radio.Receive; - SplitControl = Radio; -#endif - - AM.amAddress -> Address; - Radio.AMPacket -> AM; - - components CC2420PacketC; - CC2420Packet = CC2420PacketC; - PacketAcknowledgements = CC2420PacketC; - - -} diff --git a/tos/chips/cc2420_lpl/CC2420ActiveMessageP.nc b/tos/chips/cc2420_lpl/CC2420ActiveMessageP.nc deleted file mode 100644 index 7cae4499..00000000 --- a/tos/chips/cc2420_lpl/CC2420ActiveMessageP.nc +++ /dev/null @@ -1,188 +0,0 @@ -/* tab:4 - * "Copyright (c) 2005 Stanford University. All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose, without fee, and without written - * agreement is hereby granted, provided that the above copyright - * notice, the following two paragraphs and the author appear in all - * copies of this software. - * - * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE - * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY - * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, - * ENHANCEMENTS, OR MODIFICATIONS." - */ - - -/** - * Active message implementation on top of the CC2420 radio. This - * implementation uses the 16-bit addressing mode of 802.15.4: the - * only additional byte it adds is the AM id byte, as the first byte - * of the data payload. - * - * @author Philip Levis - * @version $Revision$ $Date$ - */ - -module CC2420ActiveMessageP { - provides { - interface AMSend[am_id_t id]; - interface Receive[am_id_t id]; - interface Receive as Snoop[am_id_t id]; - interface AMPacket; - interface Packet; - } - uses { - interface Send as SubSend; - interface Receive as SubReceive; - command am_addr_t amAddress(); - } -} -implementation { - - enum { - CC2420_SIZE = MAC_HEADER_SIZE + MAC_FOOTER_SIZE, - }; - - cc2420_header_t* getHeader( message_t* msg ) { - return (cc2420_header_t*)( msg->data - sizeof(cc2420_header_t) ); - } - - command error_t AMSend.send[am_id_t id](am_addr_t addr, - message_t* msg, - uint8_t len) { - cc2420_header_t* header = getHeader( msg ); - header->type = id; - header->dest = addr; - header->destpan = TOS_AM_GROUP; - - return call SubSend.send( msg, len + CC2420_SIZE ); - } - - command error_t AMSend.cancel[am_id_t id](message_t* msg) { - return call SubSend.cancel(msg); - } - - command uint8_t AMSend.maxPayloadLength[am_id_t id]() { - return call Packet.maxPayloadLength(); - } - - command void* AMSend.getPayload[am_id_t id](message_t* m) { - return call Packet.getPayload(m, NULL); - } - - command void* Receive.getPayload[am_id_t id](message_t* m, uint8_t* len) { - return call Packet.getPayload(m, len); - } - - command uint8_t Receive.payloadLength[am_id_t id](message_t* m) { - return call Packet.payloadLength(m); - } - - command void* Snoop.getPayload[am_id_t id](message_t* m, uint8_t* len) { - return call Packet.getPayload(m, len); - } - - command uint8_t Snoop.payloadLength[am_id_t id](message_t* m) { - return call Packet.payloadLength(m); - } - - event void SubSend.sendDone(message_t* msg, error_t result) { - signal AMSend.sendDone[call AMPacket.type(msg)](msg, result); - } - - /* Receiving a packet */ - - event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) { - if (call AMPacket.isForMe(msg)) { - return signal Receive.receive[call AMPacket.type(msg)](msg, payload, len - CC2420_SIZE); - } - else { - return signal Snoop.receive[call AMPacket.type(msg)](msg, payload, len - CC2420_SIZE); - } - } - - command am_addr_t AMPacket.address() { - return call amAddress(); - } - - command am_addr_t AMPacket.destination(message_t* amsg) { - cc2420_header_t* header = getHeader(amsg); - return header->dest; - } - - command am_addr_t AMPacket.source(message_t* amsg) { - cc2420_header_t* header = getHeader(amsg); - return header->src; - } - - command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) { - cc2420_header_t* header = getHeader(amsg); - header->dest = addr; - } - - command void AMPacket.setSource(message_t* amsg, am_addr_t addr) { - cc2420_header_t* header = getHeader(amsg); - header->src = addr; - } - - command bool AMPacket.isForMe(message_t* amsg) { - return (call AMPacket.destination(amsg) == call AMPacket.address() || - call AMPacket.destination(amsg) == AM_BROADCAST_ADDR); - } - - command am_id_t AMPacket.type(message_t* amsg) { - cc2420_header_t* header = getHeader(amsg); - return header->type; - } - - command void AMPacket.setType(message_t* amsg, am_id_t type) { - cc2420_header_t* header = getHeader(amsg); - header->type = type; - } - - default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { - return msg; - } - - default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { - return msg; - } - - default event void AMSend.sendDone[uint8_t id](message_t* msg, error_t err) { - return; - } - - - command void Packet.clear(message_t* msg) {} - - command uint8_t Packet.payloadLength(message_t* msg) { - return getHeader(msg)->length - CC2420_SIZE; - } - - - command void Packet.setPayloadLength(message_t* msg, uint8_t len) { - getHeader(msg)->length = len + CC2420_SIZE; - } - - command uint8_t Packet.maxPayloadLength() { - return TOSH_DATA_LENGTH; - } - - command void* Packet.getPayload(message_t* msg, uint8_t* len) { - if (len != NULL) { - *len = call Packet.payloadLength(msg); - } - return msg->data; - } - - -} diff --git a/tos/chips/cc2420_lpl/CC2420Cca.nc b/tos/chips/cc2420_lpl/CC2420Cca.nc deleted file mode 100644 index 58e75f35..00000000 --- a/tos/chips/cc2420_lpl/CC2420Cca.nc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Interface to obtain a CCA reading from the CC2420 radio - * to determine if a neighbor is transmitting - * @author David Moss - */ - -interface CC2420Cca { - - /** - * @return TRUE if the CCA pin shows a clear channel - */ - command bool isChannelClear(); - -} - diff --git a/tos/chips/cc2420_lpl/CC2420Config.nc b/tos/chips/cc2420_lpl/CC2420Config.nc deleted file mode 100644 index f9bd2e7e..00000000 --- a/tos/chips/cc2420_lpl/CC2420Config.nc +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * An HAL abstraction of the ChipCon CC2420 radio. This abstraction - * deals specifically with radio configurations. All get() and set() - * commands are single-phase. After setting some values, a call to - * sync() is required for the changes to propagate to the cc2420 - * hardware chip. This interface allows setting multiple parameters - * before calling sync(). - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -interface CC2420Config { - - /** - * Sync configuration changes with the radio hardware. This only - * applies to set commands below. - * - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - command error_t sync(); - event void syncDone( error_t error ); - - /** - * Change the channel of the radio. - */ - command uint8_t getChannel(); - command void setChannel( uint8_t channel ); - - /** - * Change the short address of the radio. - */ - command uint16_t getShortAddr(); - command void setShortAddr( uint16_t address ); - - /** - * Change the PAN address of the radio. - */ - command uint16_t getPanAddr(); - command void setPanAddr( uint16_t address ); - -} diff --git a/tos/chips/cc2420_lpl/CC2420ControlC.nc b/tos/chips/cc2420_lpl/CC2420ControlC.nc deleted file mode 100644 index 8457c80e..00000000 --- a/tos/chips/cc2420_lpl/CC2420ControlC.nc +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Implementation for configuring a ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include "CC2420.h" -#include "IEEE802154.h" - -configuration CC2420ControlC { - - provides interface Init; - provides interface Resource; - provides interface CC2420Config; - provides interface CC2420Power; - - uses interface AMPacket; - -} - -implementation { - - components CC2420ControlP; - Init = CC2420ControlP; - Resource = CC2420ControlP; - CC2420Config = CC2420ControlP; - CC2420Power = CC2420ControlP; - AMPacket = CC2420ControlP; - - components AlarmMultiplexC as Alarm; - CC2420ControlP.StartupTimer -> Alarm; - - components HplCC2420PinsC as Pins; - CC2420ControlP.CSN -> Pins.CSN; - CC2420ControlP.RSTN -> Pins.RSTN; - CC2420ControlP.VREN -> Pins.VREN; - - components HplCC2420InterruptsC as Interrupts; - CC2420ControlP.InterruptCCA -> Interrupts.InterruptCCA; - - components new CC2420SpiC() as Spi; - CC2420ControlP.SpiResource -> Spi; - CC2420ControlP.SRXON -> Spi.SRXON; - CC2420ControlP.SRFOFF -> Spi.SRFOFF; - CC2420ControlP.SXOSCON -> Spi.SXOSCON; - CC2420ControlP.SXOSCOFF -> Spi.SXOSCOFF; - CC2420ControlP.FSCTRL -> Spi.FSCTRL; - CC2420ControlP.IOCFG0 -> Spi.IOCFG0; - CC2420ControlP.IOCFG1 -> Spi.IOCFG1; - CC2420ControlP.MDMCTRL0 -> Spi.MDMCTRL0; - CC2420ControlP.MDMCTRL1 -> Spi.MDMCTRL1; - CC2420ControlP.PANID -> Spi.PANID; - - components new CC2420SpiC() as SyncSpiC; - CC2420ControlP.SyncResource -> SyncSpiC; - - components LedsC as Leds; - CC2420ControlP.Leds -> Leds; - -} - diff --git a/tos/chips/cc2420_lpl/CC2420ControlP.nc b/tos/chips/cc2420_lpl/CC2420ControlP.nc deleted file mode 100644 index ca1084a4..00000000 --- a/tos/chips/cc2420_lpl/CC2420ControlP.nc +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include "Timer.h" - -module CC2420ControlP { - - provides interface Init; - provides interface Resource; - provides interface CC2420Config; - provides interface CC2420Power; - - uses interface Alarm as StartupTimer; - uses interface GeneralIO as CSN; - uses interface GeneralIO as RSTN; - uses interface GeneralIO as VREN; - uses interface GpioInterrupt as InterruptCCA; - - uses interface Resource as SpiResource; - uses interface CC2420Ram as PANID; - uses interface CC2420Register as FSCTRL; - uses interface CC2420Register as IOCFG0; - uses interface CC2420Register as IOCFG1; - uses interface CC2420Register as MDMCTRL0; - uses interface CC2420Register as MDMCTRL1; - uses interface CC2420Strobe as SRXON; - uses interface CC2420Strobe as SRFOFF; - uses interface CC2420Strobe as SXOSCOFF; - uses interface CC2420Strobe as SXOSCON; - uses interface AMPacket; - - uses interface Resource as SyncResource; - - uses interface Leds; - -} - -implementation { - - typedef enum { - S_VREG_STOPPED, - S_VREG_STARTING, - S_VREG_STARTED, - S_XOSC_STARTING, - S_XOSC_STARTED, - } cc2420_control_state_t; - - uint8_t m_channel = CC2420_DEF_CHANNEL; - uint8_t m_tx_power = CC2420_DEF_RFPOWER; - uint16_t m_pan = TOS_AM_GROUP; - uint16_t m_short_addr; - bool m_sync_busy; - task void syncDone_task(); - - norace cc2420_control_state_t m_state = S_VREG_STOPPED; - - command error_t Init.init() { - call CSN.makeOutput(); - call RSTN.makeOutput(); - call VREN.makeOutput(); - m_short_addr = call AMPacket.address(); - return SUCCESS; - } - - async command error_t Resource.immediateRequest() { - error_t error = call SpiResource.immediateRequest(); - if ( error == SUCCESS ) - call CSN.clr(); - return error; - } - - async command error_t Resource.request() { - return call SpiResource.request(); - } - - async command uint8_t Resource.isOwner() { - return call SpiResource.isOwner(); - } - - async command error_t Resource.release() { - atomic { - call CSN.set(); - return call SpiResource.release(); - } - } - - event void SpiResource.granted() { - call CSN.clr(); - signal Resource.granted(); - } - - async command error_t CC2420Power.startVReg() { - atomic { - if ( m_state != S_VREG_STOPPED ) - return FAIL; - m_state = S_VREG_STARTING; - } - call VREN.set(); - call StartupTimer.start( CC2420_TIME_VREN ); - return SUCCESS; - } - - async event void StartupTimer.fired() { - if ( m_state == S_VREG_STARTING ) { - m_state = S_VREG_STARTED; - call RSTN.clr(); - call RSTN.set(); - signal CC2420Power.startVRegDone(); - } - } - - async command error_t CC2420Power.stopVReg() { - m_state = S_VREG_STOPPED; - call RSTN.clr(); - call VREN.clr(); - call RSTN.set(); - return SUCCESS; - } - - async command error_t CC2420Power.startOscillator() { - atomic { - if ( m_state != S_VREG_STARTED ) - return FAIL; - - m_state = S_XOSC_STARTING; - call IOCFG1.write( CC2420_SFDMUX_XOSC16M_STABLE << - CC2420_IOCFG1_CCAMUX ); - call InterruptCCA.enableRisingEdge(); - call SXOSCON.strobe(); - call IOCFG0.write( ( 1 << CC2420_IOCFG0_FIFOP_POLARITY ) | - ( 127 << CC2420_IOCFG0_FIFOP_THR ) ); - call FSCTRL.write( ( 1 << CC2420_FSCTRL_LOCK_THR ) | - ( ( (m_channel - 11)*5+357 ) - << CC2420_FSCTRL_FREQ ) ); - call MDMCTRL0.write( ( 1 << CC2420_MDMCTRL0_RESERVED_FRAME_MODE ) | - ( 1 << CC2420_MDMCTRL0_ADR_DECODE ) | - ( 2 << CC2420_MDMCTRL0_CCA_HYST ) | - ( 3 << CC2420_MDMCTRL0_CCA_MOD ) | - ( 1 << CC2420_MDMCTRL0_AUTOCRC ) | - ( 1 << CC2420_MDMCTRL0_AUTOACK ) | - ( 2 << CC2420_MDMCTRL0_PREAMBLE_LENGTH ) ); - } - return SUCCESS; - } - - async event void InterruptCCA.fired() { - nxle_uint16_t id[ 2 ]; - m_state = S_XOSC_STARTED; - id[ 0 ] = m_pan; - id[ 1 ] = m_short_addr; - call InterruptCCA.disable(); - call IOCFG1.write( 0 ); - call PANID.write( 0, (uint8_t*)&id, 4 ); - call CSN.set(); - call CSN.clr(); - signal CC2420Power.startOscillatorDone(); - } - - async command error_t CC2420Power.stopOscillator() { - atomic { - if ( m_state != S_XOSC_STARTED ) - return FAIL; - m_state = S_VREG_STARTED; - call SXOSCOFF.strobe(); - } - return SUCCESS; - } - - async command error_t CC2420Power.rxOn() { - atomic { - if ( m_state != S_XOSC_STARTED ) - return FAIL; - call SRXON.strobe(); - } - return SUCCESS; - } - - async command error_t CC2420Power.rfOff() { - atomic { - if ( m_state != S_XOSC_STARTED ) - return FAIL; - call SRFOFF.strobe(); - } - return SUCCESS; - } - - command uint8_t CC2420Config.getChannel() { - atomic return m_channel; - } - - command void CC2420Config.setChannel( uint8_t channel ) { - atomic m_channel = channel; - } - - command uint16_t CC2420Config.getShortAddr() { - atomic return m_short_addr; - } - - command void CC2420Config.setShortAddr( uint16_t addr ) { - atomic m_short_addr = addr; - } - - command uint16_t CC2420Config.getPanAddr() { - return m_pan; - } - - command void CC2420Config.setPanAddr( uint16_t pan ) { - atomic m_pan = pan; - } - - command error_t CC2420Config.sync() { - atomic { - if ( m_sync_busy ) - return FAIL; - m_sync_busy = TRUE; - if ( m_state == S_XOSC_STARTED ) - call SyncResource.request(); - else - post syncDone_task(); - } - return SUCCESS; - } - - event void SyncResource.granted() { - - nxle_uint16_t id[ 2 ]; - uint8_t channel; - - atomic { - channel = m_channel; - id[ 0 ] = m_pan; - id[ 1 ] = m_short_addr; - } - - call CSN.clr(); - call FSCTRL.write( ( 1 << CC2420_FSCTRL_LOCK_THR ) | - ( ( (channel - 11)*5+357 ) << CC2420_FSCTRL_FREQ ) ); - call PANID.write( 0, (uint8_t*)id, sizeof( id ) ); - call CSN.set(); - call SyncResource.release(); - - post syncDone_task(); - - } - - task void syncDone_task() { - atomic m_sync_busy = FALSE; - signal CC2420Config.syncDone( SUCCESS ); - } - - default event void CC2420Config.syncDone( error_t error ) {} - -} diff --git a/tos/chips/cc2420_lpl/CC2420CsmaC.nc b/tos/chips/cc2420_lpl/CC2420CsmaC.nc deleted file mode 100644 index 8743b4c8..00000000 --- a/tos/chips/cc2420_lpl/CC2420CsmaC.nc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Basic implementation of a CSMA MAC for the ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include "CC2420.h" -#include "IEEE802154.h" - -configuration CC2420CsmaC { - - provides interface SplitControl; - provides interface Send; - provides interface Receive; - provides interface CsmaBackoff[am_id_t amId]; - - uses interface AMPacket; - -} - -implementation { - - components CC2420CsmaP as CsmaP; - - CsmaBackoff = CsmaP; - SplitControl = CsmaP; - Send = CsmaP; - AMPacket = CsmaP; - - components CC2420ControlC; - AMPacket = CC2420ControlC; - CsmaP.Resource -> CC2420ControlC; - CsmaP.CC2420Power -> CC2420ControlC; - - components CC2420TransmitC; - - CsmaP.SubControl -> CC2420TransmitC; - CsmaP.CC2420Transmit -> CC2420TransmitC; - CsmaP.SubBackoff -> CC2420TransmitC; - - components CC2420ReceiveC; - Receive = CC2420ReceiveC; - CsmaP.SubControl -> CC2420ReceiveC; - - components RandomC; - CsmaP.Random -> RandomC; - - components LedsC as Leds; - CsmaP.Leds -> Leds; - - components MainC; - MainC.SoftwareInit -> CsmaP; - MainC.SoftwareInit -> CC2420ControlC; - MainC.SoftwareInit -> CC2420TransmitC; - MainC.SoftwareInit -> CC2420ReceiveC; -} diff --git a/tos/chips/cc2420_lpl/CC2420CsmaP.nc b/tos/chips/cc2420_lpl/CC2420CsmaP.nc deleted file mode 100644 index 9911f5a0..00000000 --- a/tos/chips/cc2420_lpl/CC2420CsmaP.nc +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -module CC2420CsmaP { - - provides interface Init; - provides interface SplitControl; - provides interface Send; - provides interface CsmaBackoff[am_id_t amId]; - - uses interface Resource; - uses interface CC2420Power; - uses interface AsyncStdControl as SubControl; - uses interface CC2420Transmit; - uses interface CsmaBackoff as SubBackoff; - uses interface Random; - uses interface AMPacket; - uses interface Leds; - -} - -implementation { - - enum { - S_PREINIT, - S_STOPPED, - S_STARTING, - S_STARTED, - S_STOPPING, - S_TRANSMIT, - }; - - message_t* m_msg; - uint8_t m_state = S_PREINIT; - uint8_t m_dsn; - error_t sendErr = SUCCESS; - - task void startDone_task(); - task void stopDone_task(); - task void sendDone_task(); - - cc2420_header_t* getHeader( message_t* msg ) { - return (cc2420_header_t*)( msg->data - sizeof( cc2420_header_t ) ); - } - - cc2420_metadata_t* getMetadata( message_t* msg ) { - return (cc2420_metadata_t*)msg->metadata; - } - - command error_t Init.init() { - - if ( m_state != S_PREINIT ) - return FAIL; - - m_state = S_STOPPED; - - return SUCCESS; - - } - - command error_t SplitControl.start() { - - if ( m_state != S_STOPPED ) - return FAIL; - - m_state = S_STARTING; - - m_dsn = call Random.rand16(); - call CC2420Power.startVReg(); - - return SUCCESS; - - } - - async event void CC2420Power.startVRegDone() { - call Resource.request(); - } - - event void Resource.granted() { - call CC2420Power.startOscillator(); - } - - async event void CC2420Power.startOscillatorDone() { - call SubControl.start(); - call CC2420Power.rxOn(); - call Resource.release(); - post startDone_task(); - } - - task void startDone_task() { - m_state = S_STARTED; - signal SplitControl.startDone( SUCCESS ); - } - - command error_t SplitControl.stop() { - - if ( m_state != S_STARTED ) - return FAIL; - - m_state = S_STOPPING; - - call SubControl.stop(); - call CC2420Power.stopVReg(); - post stopDone_task(); - - return SUCCESS; - - } - - task void stopDone_task() { - m_state = S_STOPPED; - signal SplitControl.stopDone( SUCCESS ); - } - - command error_t Send.cancel( message_t* p_msg ) { - return FAIL; - } - - command error_t Send.send( message_t* p_msg, uint8_t len ) { - - cc2420_header_t* header = getHeader( p_msg ); - cc2420_metadata_t* metadata = getMetadata( p_msg ); - - atomic { - if ( m_state != S_STARTED ) - return FAIL; - m_state = S_TRANSMIT; - m_msg = p_msg; - header->dsn = ++m_dsn; - } - - header->length = len; - header->fcf &= 1 << IEEE154_FCF_ACK_REQ; - header->fcf |= ( ( IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE ) | - ( 1 << IEEE154_FCF_INTRAPAN ) | - ( IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE ) | - ( IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE ) ); - header->src = call AMPacket.address(); - metadata->ack = FALSE; - metadata->rssi = 0; - metadata->lqi = 0; - metadata->time = 0; - - call CC2420Transmit.sendCCA( m_msg ); - - return SUCCESS; - - } - - command void* Send.getPayload(message_t* m) { - return m->data; - } - - command uint8_t Send.maxPayloadLength() { - return TOSH_DATA_LENGTH; - } - - async event uint16_t SubBackoff.initial( message_t* msg ) { - return signal CsmaBackoff.initial[((cc2420_header_t*)(msg->data - - sizeof(cc2420_header_t)))->type](msg); - } - - async event uint16_t SubBackoff.congestion( message_t* msg ) { - return signal CsmaBackoff.congestion[((cc2420_header_t*)(msg->data - - sizeof(cc2420_header_t)))->type](msg); - } - - async event void CC2420Transmit.sendDone( message_t* p_msg, error_t err ) { - atomic sendErr = err; - post sendDone_task(); - } - - task void sendDone_task() { - error_t packetErr; - atomic packetErr = sendErr; - m_state = S_STARTED; - signal Send.sendDone( m_msg, packetErr ); - } - - - /***************** Defaults ***************/ - default async event uint16_t CsmaBackoff.initial[am_id_t amId]( - message_t *m) { - return ( call Random.rand16() % (0x1F * CC2420_BACKOFF_PERIOD) - + CC2420_MIN_BACKOFF); - } - - default async event uint16_t CsmaBackoff.congestion[am_id_t amId]( - message_t *m) { - return ( call Random.rand16() % (0x7 * CC2420_BACKOFF_PERIOD) - + CC2420_MIN_BACKOFF); - } - - default event void SplitControl.startDone(error_t error) { - } - - default event void SplitControl.stopDone(error_t error) { - } -} - diff --git a/tos/chips/cc2420_lpl/CC2420DutyCycle.h b/tos/chips/cc2420_lpl/CC2420DutyCycle.h deleted file mode 100644 index 4d38e4a4..00000000 --- a/tos/chips/cc2420_lpl/CC2420DutyCycle.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author David Moss - */ - -#ifndef CC2420DUTYCYCLE_H -#define CC2420DUTYCYCLE_H - -/** - * Default duty period is 0, which is "always on" - */ -#ifndef DEFAULT_DUTY_PERIOD -#define DEFAULT_DUTY_PERIOD 0 -#endif - -/** - * This is a measured value of the time the radio is actually on (5.8 ms) - * We round this up to 6 ms for erring on the side of better performance ratios - */ -#ifndef DUTY_ON_TIME -#define DUTY_ON_TIME 6 // TODO re-measure -#endif - -/** - * The maximum number of CCA checks performed on each wakeup. - * If there are too few, the receiver may wake up between messages - * and not detect the transmitter. - */ -#ifndef MAX_LPL_CCA_CHECKS -#define MAX_LPL_CCA_CHECKS 100 -#endif - -#endif diff --git a/tos/chips/cc2420_lpl/CC2420DutyCycle.nc b/tos/chips/cc2420_lpl/CC2420DutyCycle.nc deleted file mode 100644 index 785cf6d0..00000000 --- a/tos/chips/cc2420_lpl/CC2420DutyCycle.nc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Manage the CC2420's duty cycle and power - * @author David Moss - */ - -interface CC2420DutyCycle { - - /** - * Set the sleep interval, in binary milliseconds - * @param sleepIntervalMs the sleep interval in [ms] - */ - command void setSleepInterval(uint16_t sleepIntervalMs); - - /** - * @return the sleep interval in [ms] - */ - command uint16_t getSleepInterval(); - - /** - * A transmitter was detected. You must now take action to - * turn the radio off when the transaction is complete. - */ - event void detected(); - -} - diff --git a/tos/chips/cc2420_lpl/CC2420DutyCycleC.nc b/tos/chips/cc2420_lpl/CC2420DutyCycleC.nc deleted file mode 100644 index c118bcdf..00000000 --- a/tos/chips/cc2420_lpl/CC2420DutyCycleC.nc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Use this component to duty cycle the radio. When a message is heard, - * disable DutyCycling. - * - * @author David Moss dmm@rincon.com - */ - -#include "CC2420DutyCycle.h" - -configuration CC2420DutyCycleC { - provides { - interface CC2420DutyCycle; - interface SplitControl; - interface State as SplitControlState; - } -} - -implementation { - components MainC, - CC2420DutyCycleP, - CC2420TransmitC, - CC2420CsmaC, - LedsC, - new StateC() as RadioPowerStateC, - new StateC() as DutyCycleStateC, - new StateC() as CheckStateC, - new StateC() as SplitControlStateC, - new TimerMilliC() as OnTimerC, - new TimerMilliC() as CheckTimerC, - RandomC; - - CC2420DutyCycle = CC2420DutyCycleP; - SplitControl = CC2420DutyCycleP; - SplitControlState = SplitControlStateC; - - MainC.SoftwareInit -> CC2420DutyCycleP; - - CC2420DutyCycleP.Random -> RandomC; - CC2420DutyCycleP.CC2420Cca -> CC2420TransmitC; - CC2420DutyCycleP.SubControl -> CC2420CsmaC; - CC2420DutyCycleP.RadioPowerState -> RadioPowerStateC; - CC2420DutyCycleP.DutyCycleState -> DutyCycleStateC; - CC2420DutyCycleP.SplitControlState -> SplitControlStateC; - CC2420DutyCycleP.CheckState -> CheckStateC; - CC2420DutyCycleP.OnTimer -> OnTimerC; - CC2420DutyCycleP.Leds -> LedsC; -} - - diff --git a/tos/chips/cc2420_lpl/CC2420DutyCycleP.nc b/tos/chips/cc2420_lpl/CC2420DutyCycleP.nc deleted file mode 100644 index 14891660..00000000 --- a/tos/chips/cc2420_lpl/CC2420DutyCycleP.nc +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Module to duty cycle the radio on and off, performing CCA receive checks. - * When a carrier is sensed, this will leave the radio on. It is then up - * to higher layers to turn the radio off again. Once the radio is turned - * off, this module will automatically continue duty cycling and looking for - * a modulated signal. - * - * @author David Moss - */ - -#include "CC2420DutyCycle.h" - -module CC2420DutyCycleP { - provides { - interface CC2420DutyCycle; - interface Init; - interface SplitControl; - } - - uses { - interface Timer as OnTimer; - interface SplitControl as SubControl; - interface State as RadioPowerState; - interface State as DutyCycleState; - interface State as SplitControlState; - interface State as CheckState; - interface Leds; - interface CC2420Cca; - interface Random; - } -} - -implementation { - - /** The current period of the duty cycle, equivalent of wakeup interval */ - uint16_t sleepInterval; - - /** The number of times the CCA has been sampled in this wakeup period */ - uint8_t ccaChecks; - - /** - * Radio Power, Check State, and Duty Cycling State - */ - enum { - S_OFF, // off by default - S_ON, - }; - - - /***************** Prototypes ****************/ - task void stopRadio(); - task void startRadio(); - task void getCca(); - - /***************** Init Commands ****************/ - command error_t Init.init() { - sleepInterval = DEFAULT_DUTY_PERIOD; - return SUCCESS; - } - - /***************** CC2420DutyCycle Commands ****************/ - /** - * Set the sleep interval, in binary milliseconds - * @param sleepIntervalMs the sleep interval in [ms] - */ - command void CC2420DutyCycle.setSleepInterval(uint16_t sleepIntervalMs) { - sleepInterval = sleepIntervalMs; - - if(sleepInterval == 0 && call DutyCycleState.getState() == S_ON) { - call DutyCycleState.forceState(S_OFF); - call CheckState.toIdle(); - - /* - * Leave the radio on permanently if sleepInterval == 0 and the radio is - * supposed to be enabled - */ - if(call RadioPowerState.getState() == S_OFF) { - call SubControl.start(); - } - } - } - - /** - * @return the sleep interval in [ms] - */ - command uint16_t CC2420DutyCycle.getSleepInterval() { - return sleepInterval; - } - - /***************** SplitControl Commands ****************/ - command error_t SplitControl.start() { - call SplitControlState.forceState(S_ON); - - if(sleepInterval > 0) { - // Begin duty cycling - call DutyCycleState.forceState(S_ON); - call CheckState.toIdle(); - post stopRadio(); - signal SplitControl.startDone(SUCCESS); - - } else { - call DutyCycleState.forceState(S_OFF); - call CheckState.toIdle(); - - /* - * Leave the radio on permanently if sleepInterval == 0 and the radio is - * supposed to be enabled - */ - if(call RadioPowerState.getState() == S_OFF) { - call SubControl.start(); - // Here, SplitControl.startDone is signaled on SubControl.startDone - - } else { - // Radio is already on - signal SplitControl.startDone(SUCCESS); - } - } - - return SUCCESS; - } - - command error_t SplitControl.stop() { - call SplitControlState.forceState(S_OFF); - call DutyCycleState.forceState(S_OFF); - call CheckState.toIdle(); - return call SubControl.stop(); - - /* - * SubControl.stopDone signals SplitControl.stopDone when - * DutyCycleState is S_OFF - */ - } - - /***************** Timer Events ****************/ - event void OnTimer.fired() { - if(call DutyCycleState.getState() == S_ON) { - if(call RadioPowerState.getState() == S_OFF) { - call CheckState.forceState(S_ON); - ccaChecks = 0; - - /* - * The MicaZ, running on an external oscillator I think, and - * returning the microcontroller out of a sleep state to immediately - * perform an ADC conversion, sucks. The first ADC conversion out - * of a sleep state lasts about a second. We don't want the radio - * on that long. Like the CC1000 RSSI pulse check implementation - * done in the Rincon CC1000Radio stack, we will perform - * a single ADC conversion and then flip on the radio to check - * the channel. - */ - post getCca(); - - } else { - // Someone else turned on the radio, try again in awhile - call OnTimer.startOneShot(sleepInterval); - } - } - } - - /***************** SubControl Events ****************/ - event void SubControl.startDone(error_t error) { - if(call DutyCycleState.getState() == S_ON && error) { - // My responsibility to try again - post startRadio(); - return; - } - - call RadioPowerState.forceState(S_ON); - //call Leds.led2On(); - - if(call DutyCycleState.getState() == S_ON) { - if(call CheckState.getState() == S_ON) { - post getCca(); - } - - } else { - // Must have turned the radio on manually - signal SplitControl.startDone(SUCCESS); - } - } - - event void SubControl.stopDone(error_t error) { - if(error && call DutyCycleState.getState() == S_ON) { - // My responsibility to try again - post stopRadio(); - return; - } - - call RadioPowerState.forceState(S_OFF); - //call Leds.led2Off(); - - if(call DutyCycleState.getState() == S_ON) { - call OnTimer.startOneShot(sleepInterval); - - } else { - // Must have turned off the radio manually - signal SplitControl.stopDone(error); - } - - } - - - /***************** Tasks ****************/ - task void stopRadio() { - if(call DutyCycleState.getState() == S_ON) { - if(call SubControl.stop() != SUCCESS) { - // Already stopped? - call OnTimer.startOneShot(sleepInterval); - } - } - } - - task void startRadio() { - if(call DutyCycleState.getState() == S_ON) { - if(call SubControl.start() != SUCCESS) { - post startRadio(); - } - } - } - - - task void getCca() { - if(call DutyCycleState.getState() == S_ON) { - - ccaChecks++; - if(ccaChecks == 1) { - // Microcontroller is ready, turn on the radio and sample a few times - post startRadio(); - return; - } - - if(!call CC2420Cca.isChannelClear()) { - signal CC2420DutyCycle.detected(); - // Leave the radio on for upper layers to perform some transaction - - } else { - if(ccaChecks <= MAX_LPL_CCA_CHECKS) { - post getCca(); - return; - - } else { - call CheckState.toIdle(); - post stopRadio(); - } - } - } - } - - /**************** Defaults ****************/ - default event void CC2420DutyCycle.detected() { - } - -} - - diff --git a/tos/chips/cc2420_lpl/CC2420Fifo.nc b/tos/chips/cc2420_lpl/CC2420Fifo.nc deleted file mode 100644 index ba4d6538..00000000 --- a/tos/chips/cc2420_lpl/CC2420Fifo.nc +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * HAL abstraction for accessing the FIFO registers of a ChipCon - * CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -interface CC2420Fifo { - - /** - * Start reading from the FIFO. The readDone event will - * be signalled upon completion. - * - * @param data a pointer to the receive buffer. - * @param length number of bytes to read. - * @return status byte returned when sending the last address byte - * of the SPI transaction. - */ - async command cc2420_status_t beginRead( uint8_t* data, uint8_t length ); - - /** - * Continue reading from the FIFO without having to send the address - * byte again. The readDone event will be signalled - * upon completion. - * - * @param data a pointer to the receive buffer. - * @param length number of bytes to read. - * @return SUCCESS always. - */ - async command error_t continueRead( uint8_t* data, uint8_t length ); - - /** - * Signals the completion of a read operation. - * - * @param data a pointer to the receive buffer. - * @param length number of bytes read. - * @param error notification of how the operation went - */ - async event void readDone( uint8_t* data, uint8_t length, error_t error ); - - /** - * Start writing the FIFO. The writeDone event will be - * signalled upon completion. - * - * @param data a pointer to the send buffer. - * @param length number of bytes to write. - * @return status byte returned when sending the last address byte - * of the SPI transaction. - */ - async command cc2420_status_t write( uint8_t* data, uint8_t length ); - - /** - * Signals the completion of a write operation. - * - * @param data a pointer to the send buffer. - * @param length number of bytes written. - * @param error notification of how the operation went - */ - async event void writeDone( uint8_t* data, uint8_t length, error_t error ); - -} diff --git a/tos/chips/cc2420_lpl/CC2420LowPowerListening.h b/tos/chips/cc2420_lpl/CC2420LowPowerListening.h deleted file mode 100644 index ae6d0e70..00000000 --- a/tos/chips/cc2420_lpl/CC2420LowPowerListening.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - - /** - * @author David Moss - */ -#ifndef CC2420LOWPOWERLISTENING_H -#define CC2420LOWPOWERLISTENING_H - -#include "CC2420DutyCycle.h" - -/** - * The default duty period is usually 0, which is the equivalent of - * ONE_MESSAGE (below), which tells the node to transmit the message - * one time without expecting receiver duty cycling. - */ -#ifndef DEFAULT_TRANSMIT_PERIOD -#define DEFAULT_TRANSMIT_PERIOD DEFAULT_DUTY_PERIOD -#endif - -/** - * Amount of time, in milliseconds, to keep the radio on after - * a successful receive addressed to this node - */ -#ifndef DELAY_AFTER_RECEIVE -#define DELAY_AFTER_RECEIVE 50 -#endif - -/** - * Value used to indicate the message being sent should be transmitted - * one time - */ -#ifndef ONE_MESSAGE -#define ONE_MESSAGE 0 -#endif - -#endif - diff --git a/tos/chips/cc2420_lpl/CC2420LowPowerListeningC.nc b/tos/chips/cc2420_lpl/CC2420LowPowerListeningC.nc deleted file mode 100644 index 1bdfa379..00000000 --- a/tos/chips/cc2420_lpl/CC2420LowPowerListeningC.nc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Low Power Listening for the CC2420 - * @author David Moss - */ - -#include "CC2420LowPowerListening.h" - -configuration CC2420LowPowerListeningC { - provides { - interface LowPowerListening; - interface Send; - interface Receive; - interface SplitControl; - } -} - -implementation { - components MainC, - CC2420LowPowerListeningP, - CC2420DutyCycleC, - CC2420ActiveMessageC, - CC2420CsmaC, - CC2420TransmitC, - RandomC, - new StateC() as SendStateC, - new StateC() as RadioStateC, - new TimerMilliC() as OffTimerC, - new TimerMilliC() as SendDoneTimerC; - - LowPowerListening = CC2420LowPowerListeningP; - Send = CC2420LowPowerListeningP; - Receive = CC2420LowPowerListeningP; - SplitControl = CC2420DutyCycleC; - - MainC.SoftwareInit -> CC2420LowPowerListeningP; - - CC2420LowPowerListeningP.Random -> RandomC; - CC2420LowPowerListeningP.SendState -> SendStateC; - CC2420LowPowerListeningP.RadioState -> RadioStateC; - CC2420LowPowerListeningP.SplitControlState -> CC2420DutyCycleC; - CC2420LowPowerListeningP.OffTimer -> OffTimerC; - CC2420LowPowerListeningP.SendDoneTimer -> SendDoneTimerC; - CC2420LowPowerListeningP.CC2420DutyCycle -> CC2420DutyCycleC; - CC2420LowPowerListeningP.SubSend -> CC2420CsmaC; - CC2420LowPowerListeningP.Resend -> CC2420TransmitC; - CC2420LowPowerListeningP.SubReceive -> CC2420CsmaC; - CC2420LowPowerListeningP.SubControl -> CC2420CsmaC; - CC2420LowPowerListeningP.PacketAcknowledgements -> CC2420ActiveMessageC; - CC2420LowPowerListeningP.AMPacket -> CC2420ActiveMessageC; - -} - diff --git a/tos/chips/cc2420_lpl/CC2420LowPowerListeningP.nc b/tos/chips/cc2420_lpl/CC2420LowPowerListeningP.nc deleted file mode 100644 index 51b405ef..00000000 --- a/tos/chips/cc2420_lpl/CC2420LowPowerListeningP.nc +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Low Power Listening for the CC2420 - * - * @author David Moss - */ - -#include "CC2420LowPowerListening.h" - -module CC2420LowPowerListeningP { - provides { - interface Init; - interface LowPowerListening; - interface Send; - interface Receive; - } - - uses { - interface Leds; - interface Send as SubSend; - interface CC2420Transmit as Resend; - interface Receive as SubReceive; - interface AMPacket; - interface SplitControl as SubControl; - interface CC2420DutyCycle; - interface PacketAcknowledgements; - interface State as SendState; - interface State as RadioState; - interface State as SplitControlState; - interface Random; - interface Timer as OffTimer; - interface Timer as SendDoneTimer; - } -} - -implementation { - - /** The message currently being sent */ - message_t *currentSendMsg; - - /** The length of the current send message */ - uint8_t currentSendLen; - - /** TRUE if the radio is duty cycling and not always on */ - bool dutyCycling; - - /** Tx DSN to ensure multiple transmitted messages get across only once */ - uint8_t txDsn; - - /** The last received broadcast DSN. TODO is this the best way? */ - uint8_t lastRxDsn; - - /** - * Radio State - */ - enum { - S_OFF, - S_ON, - }; - - /** - * Send States - */ - enum { - S_IDLE, - S_SENDING, - }; - - - /***************** Prototypes ***************/ - task void send(); - task void resend(); - task void startRadio(); - task void stopRadio(); - - void startOffTimer(); - cc2420_header_t *getHeader(message_t *msg); - cc2420_metadata_t *getMetadata(message_t* msg); - uint16_t getActualDutyCycle(uint16_t dutyCycle); - void signalDone(error_t error); - - /***************** Init Commands ***************/ - command error_t Init.init() { - txDsn = call Random.rand16(); - dutyCycling = FALSE; - return SUCCESS; - } - - /***************** LowPowerListening Commands ***************/ - /** - * Set this this node's radio sleep interval, in milliseconds. - * Once every interval, the node will sleep and perform an Rx check - * on the radio. Setting the sleep interval to 0 will keep the radio - * always on. - * - * This is the equivalent of setting the local duty cycle rate. - * - * @param sleepIntervalMs the length of this node's Rx check interval, in [ms] - */ - command void LowPowerListening.setLocalSleepInterval( - uint16_t sleepIntervalMs) { - call CC2420DutyCycle.setSleepInterval(sleepIntervalMs); - } - - /** - * @return the local node's sleep interval, in [ms] - */ - command uint16_t LowPowerListening.getLocalSleepInterval() { - return call CC2420DutyCycle.getSleepInterval(); - } - - /** - * Set this node's radio duty cycle rate, in units of [percentage*100]. - * For example, to get a 0.05% duty cycle, - * - * call LowPowerListening.setDutyCycle(5); // or equivalently... - * call LowPowerListening.setDutyCycle(00005); // for better readability? - * - * - * For a 100% duty cycle (always on), - * - * call LowPowerListening.setDutyCycle(10000); - * - * - * This is the equivalent of setting the local sleep interval explicitly. - * - * @param dutyCycle The duty cycle percentage, in units of [percentage*100] - */ - command void LowPowerListening.setLocalDutyCycle(uint16_t dutyCycle) { - call CC2420DutyCycle.setSleepInterval( - call LowPowerListening.dutyCycleToSleepInterval(dutyCycle)); - } - - /** - * @return this node's radio duty cycle rate, in units of [percentage*100] - */ - command uint16_t LowPowerListening.getLocalDutyCycle() { - return call LowPowerListening.sleepIntervalToDutyCycle( - call CC2420DutyCycle.getSleepInterval()); - } - - - /** - * Configure this outgoing message so it can be transmitted to a neighbor mote - * with the specified Rx sleep interval. - * @param msg Pointer to the message that will be sent - * @param sleepInterval The receiving node's sleep interval, in [ms] - */ - command void LowPowerListening.setRxSleepInterval(message_t *msg, - uint16_t sleepIntervalMs) { - getMetadata(msg)->rxInterval = sleepIntervalMs; - } - - /** - * @return the destination node's sleep interval configured in this message - */ - command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg) { - return getMetadata(msg)->rxInterval; - } - - /** - * Configure this outgoing message so it can be transmitted to a neighbor mote - * with the specified Rx duty cycle rate. - * Duty cycle is in units of [percentage*100], i.e. 0.25% duty cycle = 25. - * - * @param msg Pointer to the message that will be sent - * @param dutyCycle The duty cycle of the receiving mote, in units of - * [percentage*100] - */ - command void LowPowerListening.setRxDutyCycle(message_t *msg, - uint16_t dutyCycle) { - getMetadata(msg)->rxInterval = - call LowPowerListening.dutyCycleToSleepInterval(dutyCycle); - } - - - /** - * @return the destination node's duty cycle configured in this message - * in units of [percentage*100] - */ - command uint16_t LowPowerListening.getRxDutyCycle(message_t *msg) { - return call LowPowerListening.sleepIntervalToDutyCycle( - getMetadata(msg)->rxInterval); - } - - /** - * Convert a duty cycle, in units of [percentage*100], to - * the sleep interval of the mote in milliseconds - * @param dutyCycle The duty cycle in units of [percentage*100] - * @return The equivalent sleep interval, in units of [ms] - */ - command uint16_t LowPowerListening.dutyCycleToSleepInterval( - uint16_t dutyCycle) { - dutyCycle = getActualDutyCycle(dutyCycle); - - if(dutyCycle == 10000) { - return 0; - } - - return (DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle; - } - - /** - * Convert a sleep interval, in units of [ms], to a duty cycle - * in units of [percentage*100] - * @param sleepInterval The sleep interval in units of [ms] - * @return The duty cycle in units of [percentage*100] - */ - command uint16_t LowPowerListening.sleepIntervalToDutyCycle( - uint16_t sleepInterval) { - if(sleepInterval == 0) { - return 10000; - } - - return getActualDutyCycle((DUTY_ON_TIME * 10000) - / (sleepInterval + DUTY_ON_TIME)); - } - - - /***************** Send Commands ***************/ - /** - * Each call to this send command gives the message a single - * DSN that does not change for every copy of the message - * sent out. For messages that are not acknowledged, such as - * a broadcast address message, the receiving end does not - * signal receive() more than once for that message. - */ - command error_t Send.send(message_t *msg, uint8_t len) { - if(call SplitControlState.getState() == S_OFF) { - // Everything is off right now, start SplitControl and try again - return EOFF; - } - - if(call SendState.requestState(S_SENDING) == SUCCESS) { - currentSendMsg = msg; - currentSendLen = len; - (getHeader(msg))->dsn = ++txDsn; - - // In case our off timer is running... - call OffTimer.stop(); - - if(call RadioState.getState() == S_ON) { - if(call LowPowerListening.getRxSleepInterval(currentSendMsg) - > ONE_MESSAGE) { - // Send it repetitively within our transmit window - call PacketAcknowledgements.requestAck(currentSendMsg); - call SendDoneTimer.startOneShot( - call LowPowerListening.getRxSleepInterval(currentSendMsg) * 2); - } - - post send(); - - } else { - post startRadio(); - } - - return SUCCESS; - } - - return FAIL; - } - - command error_t Send.cancel(message_t *msg) { - if(currentSendMsg == msg) { - call SendState.toIdle(); - return SUCCESS; - } - - return FAIL; - } - - - command uint8_t Send.maxPayloadLength() { - return call SubSend.maxPayloadLength(); - } - - command void *Send.getPayload(message_t* msg) { - return call SubSend.getPayload(msg); - } - - /***************** Receive Commands ***************/ - command void *Receive.getPayload(message_t* msg, uint8_t* len) { - return call SubReceive.getPayload(msg, len); - } - - command uint8_t Receive.payloadLength(message_t* msg) { - return call SubReceive.payloadLength(msg); - } - - - /***************** DutyCycle Events ***************/ - /** - * A transmitter was detected. You must now take action to - * turn the radio off when the transaction is complete. - */ - event void CC2420DutyCycle.detected() { - // At this point, the duty cycling has been disabled temporary - // and it will be this component's job to turn the radio back off - - startOffTimer(); - } - - - /***************** SubControl Events ***************/ - event void SubControl.startDone(error_t error) { - if(!error) { - call RadioState.forceState(S_ON); - - if(call SendState.getState() == S_SENDING) { - if(call LowPowerListening.getRxSleepInterval(currentSendMsg) - > ONE_MESSAGE) { - // Send it repetitively within our transmit window - call PacketAcknowledgements.requestAck(currentSendMsg); - call SendDoneTimer.startOneShot( - call LowPowerListening.getRxSleepInterval(currentSendMsg) * 2); - } - - post send(); - } - } - } - - event void SubControl.stopDone(error_t error) { - if(!error) { - call RadioState.forceState(S_OFF); - - if(call SendState.getState() == S_SENDING) { - // We're in the middle of sending a message; start the radio back up - post startRadio(); - } - } - } - - /***************** SubSend Events ***************/ - event void SubSend.sendDone(message_t* msg, error_t error) { - if(call SendState.getState() == S_SENDING - && call SendDoneTimer.isRunning()) { - if(call PacketAcknowledgements.wasAcked(msg)) { - signalDone(error); - - } else { - post resend(); - } - - return; - } - - signalDone(error); - } - - /***************** SubReceive Events ***************/ - /** - * If the received message is new, we signal the receive event and - * start the off timer. If the last message we received had the same - * DSN as this message, then the chances are pretty good - * that this message should be ignored, especially if the destination address - * as the broadcast address - * - * TODO - * What happens if a unicast Tx doesn't get Rx's ack, and resends that - * message? - */ - event message_t *SubReceive.receive(message_t* msg, void* payload, - uint8_t len) { - - if((getHeader(msg))->dsn == lastRxDsn - && call AMPacket.destination(msg) == AM_BROADCAST_ADDR) { - // Already got this broadcast message. - // TODO should we do something similar with unicast messages? - return msg; - - } else { - lastRxDsn = (getHeader(msg))->dsn; - startOffTimer(); - return signal Receive.receive(msg, payload, len); - } - } - - /***************** Timer Events ****************/ - event void OffTimer.fired() { - /* - * Only stop the radio if the radio is supposed to be off permanently - * or if the duty cycle is on and our sleep interval is not 0 - */ - if(call SplitControlState.getState() == S_OFF - || (call CC2420DutyCycle.getSleepInterval() > 0 - && call SplitControlState.getState() == S_ON)) { - post stopRadio(); - } - } - - /** - * When this timer is running, that means we're sending repeating messages - * to a node that is receive check duty cycling. - */ - event void SendDoneTimer.fired() { - if(call SendState.getState() == S_SENDING) { - // The next time SubSend.sendDone is signaled, send is complete. - call SendState.toIdle(); - } - } - - /***************** Resend Events ****************/ - /** - * Signal that a message has been sent - * - * @param p_msg message to send. - * @param error notifaction of how the operation went. - */ - async event void Resend.sendDone( message_t* p_msg, error_t error ) { - // This is actually caught by SubSend.sendDone - } - - - /***************** Tasks ***************/ - task void send() { - if(call SubSend.send(currentSendMsg, currentSendLen) != SUCCESS) { - post send(); - } - } - - task void resend() { - // Resend the last message without CCA checks. - if(call Resend.resend() != SUCCESS) { - post resend(); - } - } - - task void startRadio() { - if(call SubControl.start() != SUCCESS) { - post startRadio(); - } - } - - task void stopRadio() { - if(call SubControl.stop() != SUCCESS) { - post stopRadio(); - } - } - - /***************** Functions ***************/ - void startOffTimer() { - call OffTimer.startOneShot(DELAY_AFTER_RECEIVE); - } - - /** - * Check the bounds on a given duty cycle - * We're never over 100%, and we're never at 0% - */ - uint16_t getActualDutyCycle(uint16_t dutyCycle) { - if(dutyCycle > 10000) { - return 10000; - } else if(dutyCycle == 0) { - return 1; - } - - return dutyCycle; - } - - cc2420_header_t *getHeader(message_t *msg) { - return (cc2420_header_t *)(msg->data - sizeof( cc2420_header_t )); - } - - cc2420_metadata_t *getMetadata(message_t* msg) { - return (cc2420_metadata_t*)msg->metadata; - } - - void signalDone(error_t error) { - call SendState.toIdle(); - startOffTimer(); - signal Send.sendDone(currentSendMsg, error); - currentSendMsg = NULL; - } -} - diff --git a/tos/chips/cc2420_lpl/CC2420LplDummyP.nc b/tos/chips/cc2420_lpl/CC2420LplDummyP.nc deleted file mode 100644 index 63f5c26f..00000000 --- a/tos/chips/cc2420_lpl/CC2420LplDummyP.nc +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Dummy low power listening interface used when LowPowerListening is not - * compiled in with the application. - * Sleep interval is always 0, and duty cycle is always 100% - * @author David Moss - */ - -module CC2420LplDummyP { - provides { - interface LowPowerListening; - } -} - -implementation { - - command void LowPowerListening.setLocalSleepInterval(uint16_t sleepIntervalMs) { - } - - command uint16_t LowPowerListening.getLocalSleepInterval() { - return 0; - } - - command void LowPowerListening.setLocalDutyCycle(uint16_t dutyCycle) { - } - - command uint16_t LowPowerListening.getLocalDutyCycle() { - return 10000; - } - - command void LowPowerListening.setRxSleepInterval(message_t *msg, uint16_t sleepIntervalMs) { - } - - command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg) { - return 0; - } - - command void LowPowerListening.setRxDutyCycle(message_t *msg, uint16_t dutyCycle) { - } - - command uint16_t LowPowerListening.getRxDutyCycle(message_t *msg) { - return 10000; - } - - command uint16_t LowPowerListening.dutyCycleToSleepInterval(uint16_t dutyCycle) { - return 0; - } - - command uint16_t LowPowerListening.sleepIntervalToDutyCycle(uint16_t sleepInterval) { - return 10000; - } - -} - diff --git a/tos/chips/cc2420_lpl/CC2420Packet.nc b/tos/chips/cc2420_lpl/CC2420Packet.nc deleted file mode 100644 index 5eee2aef..00000000 --- a/tos/chips/cc2420_lpl/CC2420Packet.nc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -interface CC2420Packet { - - /** - * Get transmission power setting for current packet. - * - * @param the message - */ - async command uint8_t getPower( message_t* p_msg ); - - /** - * Set transmission power for a given packet. Valid ranges are - * between 0 and 31. - * - * @param p_msg the message. - * @param power transmission power. - */ - async command void setPower( message_t* p_msg, uint8_t power ); - - /** - * Get rssi value for a given packet. For received packets, it is - * the received signal strength when receiving that packet. For sent - * packets, it is the received signal strength of the ack if an ack - * was received. - */ - async command int8_t getRssi( message_t* p_msg ); - - /** - * Get lqi value for a given packet. For received packets, it is the - * link quality indicator value when receiving that packet. For sent - * packets, it is the link quality indicator value of the ack if an - * ack was received. - */ - async command uint8_t getLqi( message_t* p_msg ); - -} diff --git a/tos/chips/cc2420_lpl/CC2420PacketC.nc b/tos/chips/cc2420_lpl/CC2420PacketC.nc deleted file mode 100644 index 84c5ceb2..00000000 --- a/tos/chips/cc2420_lpl/CC2420PacketC.nc +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -module CC2420PacketC { - - provides interface CC2420Packet; - provides interface PacketAcknowledgements as Acks; - -} - -implementation { - - cc2420_header_t* getHeader( message_t* msg ) { - return (cc2420_header_t*)( msg->data - sizeof( cc2420_header_t ) ); - } - - cc2420_metadata_t* getMetadata( message_t* msg ) { - return (cc2420_metadata_t*)msg->metadata; - } - - async command error_t Acks.requestAck( message_t* p_msg ) { - getHeader( p_msg )->fcf |= 1 << IEEE154_FCF_ACK_REQ; - return SUCCESS; - } - - async command error_t Acks.noAck( message_t* p_msg ) { - getHeader( p_msg )->fcf &= ~(1 << IEEE154_FCF_ACK_REQ); - return SUCCESS; - } - - async command bool Acks.wasAcked( message_t* p_msg ) { - return getMetadata( p_msg )->ack; - } - - async command void CC2420Packet.setPower( message_t* p_msg, uint8_t power ) { - if ( power > 31 ) - power = 31; - getMetadata( p_msg )->tx_power = power; - } - - async command uint8_t CC2420Packet.getPower( message_t* p_msg ) { - return getMetadata( p_msg )->tx_power; - } - - async command int8_t CC2420Packet.getRssi( message_t* p_msg ) { - return getMetadata( p_msg )->rssi; - } - - async command error_t CC2420Packet.getLqi( message_t* p_msg ) { - return getMetadata( p_msg )->lqi; - } - -} diff --git a/tos/chips/cc2420_lpl/CC2420Power.nc b/tos/chips/cc2420_lpl/CC2420Power.nc deleted file mode 100644 index 0fcfedf9..00000000 --- a/tos/chips/cc2420_lpl/CC2420Power.nc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * An HAL abstraction of the ChipCon CC2420 radio. This abstraction - * deals specifically with radio power operations (e.g. voltage - * regulator, oscillator, etc). However, it does not include - * transmission power, see the CC2420Config interface. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -interface CC2420Power { - - /** - * Start the voltage regulator on the CC2420. On SUCCESS, - * startVReg() will be signalled when the voltage - * regulator is fully on. - * - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t startVReg(); - - /** - * Signals that the voltage regulator has been started. - */ - async event void startVRegDone(); - - /** - * Stop the voltage regulator immediately. - * - * @return SUCCESS always - */ - async command error_t stopVReg(); - - /** - * Start the oscillator. On SUCCESS, startOscillator - * will be signalled when the oscillator has been started. - * - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t startOscillator(); - - /** - * Signals that the oscillator has been started. - */ - async event void startOscillatorDone(); - - /** - * Stop the oscillator. - * - * @return SUCCESS if the oscillator was stopped, FAIL otherwise. - */ - async command error_t stopOscillator(); - - /** - * Enable RX. - * - * @return SUCCESS if receive mode has been enabled, FAIL otherwise. - */ - async command error_t rxOn(); - - /** - * Disable RX. - * - * @return SUCCESS if receive mode has been disabled, FAIL otherwise. - */ - async command error_t rfOff(); - -} diff --git a/tos/chips/cc2420_lpl/CC2420Ram.nc b/tos/chips/cc2420_lpl/CC2420Ram.nc deleted file mode 100644 index fce50282..00000000 --- a/tos/chips/cc2420_lpl/CC2420Ram.nc +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * HAL abstraction for accessing theRAM of a ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include "CC2420.h" - -interface CC2420Ram { - - /** - * Read data from a RAM. This operation is sychronous. - * - * @param offset within the field. - * @param data a pointer to the receive buffer. - * @param length number of bytes to read. - * @return status byte returned when sending the last byte - * of the SPI transaction. - */ - async command cc2420_status_t read( uint8_t offset, uint8_t* data, uint8_t length ); - - /** - * Write data to RAM. This operation is sychronous. - * - * @param offset within the field. - * @param data a pointer to the send buffer. - * @param length number of bytes to write. - * @return status byte returned when sending the last address byte - * of the SPI transaction. - */ - async command cc2420_status_t write( uint8_t offset, uint8_t* data, uint8_t length ); - -} diff --git a/tos/chips/cc2420_lpl/CC2420Receive.nc b/tos/chips/cc2420_lpl/CC2420Receive.nc deleted file mode 100644 index 47cb15dc..00000000 --- a/tos/chips/cc2420_lpl/CC2420Receive.nc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Low-level abstraction of the receive path implementation for the - * ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -interface CC2420Receive { - - /** - * Notification that an SFD capture has occured. - * - * @param time at which the capture happened. - */ - async command void sfd( uint16_t time ); - - /** - * Notification that the packet has been dropped by the radio - * (e.g. due to address rejection). - */ - async command void sfd_dropped(); - - /** - * Signals that a message has been received. - * - * @param type of the message received. - * @param message pointer to message received. - */ - async event void receive( uint8_t type, message_t* message ); - -} - diff --git a/tos/chips/cc2420_lpl/CC2420ReceiveC.nc b/tos/chips/cc2420_lpl/CC2420ReceiveC.nc deleted file mode 100644 index f9b1b715..00000000 --- a/tos/chips/cc2420_lpl/CC2420ReceiveC.nc +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Implementation of the receive path for the ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -configuration CC2420ReceiveC { - - provides interface Init; - provides interface AsyncStdControl; - provides interface CC2420Receive; - provides interface Receive; - -} - -implementation { - - components CC2420ReceiveP; - components new CC2420SpiC() as Spi; - - components HplCC2420PinsC as Pins; - components HplCC2420InterruptsC as InterruptsC; - - components LedsC as Leds; - CC2420ReceiveP.Leds -> Leds; - - Init = CC2420ReceiveP; - AsyncStdControl = CC2420ReceiveP; - CC2420Receive = CC2420ReceiveP; - Receive = CC2420ReceiveP; - - CC2420ReceiveP.CSN -> Pins.CSN; - CC2420ReceiveP.FIFO -> Pins.FIFO; - CC2420ReceiveP.FIFOP -> Pins.FIFOP; - CC2420ReceiveP.InterruptFIFOP -> InterruptsC.InterruptFIFOP; - - CC2420ReceiveP.SpiResource -> Spi; - CC2420ReceiveP.RXFIFO -> Spi.RXFIFO; - CC2420ReceiveP.SFLUSHRX -> Spi.SFLUSHRX; - -} diff --git a/tos/chips/cc2420_lpl/CC2420ReceiveP.nc b/tos/chips/cc2420_lpl/CC2420ReceiveP.nc deleted file mode 100644 index f7f59aa5..00000000 --- a/tos/chips/cc2420_lpl/CC2420ReceiveP.nc +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -module CC2420ReceiveP { - - provides interface Init; - provides interface AsyncStdControl; - provides interface CC2420Receive; - provides interface Receive; - - uses interface GeneralIO as CSN; - uses interface GeneralIO as FIFO; - uses interface GeneralIO as FIFOP; - uses interface GpioInterrupt as InterruptFIFOP; - - uses interface Resource as SpiResource; - uses interface CC2420Fifo as RXFIFO; - uses interface CC2420Strobe as SACK; - uses interface CC2420Strobe as SFLUSHRX; - - uses interface Leds; - -} - -implementation { - - typedef enum { - S_STOPPED, - S_STARTED, - S_RX_HEADER, - S_RX_PAYLOAD, - } cc2420_receive_state_t; - - enum { - RXFIFO_SIZE = 128, - TIMESTAMP_QUEUE_SIZE = 8, - }; - - uint16_t m_timestamp_queue[ TIMESTAMP_QUEUE_SIZE ]; - uint8_t m_timestamp_head, m_timestamp_size; - uint8_t m_missed_packets; - - bool fallingEdgeEnabled; - - norace uint8_t m_bytes_left; - norace message_t* m_p_rx_buf; - - message_t m_rx_buf; - cc2420_receive_state_t m_state; - - void beginReceive(); - void receive(); - void waitForNextPacket(); - task void receiveDone_task(); - - cc2420_header_t* getHeader( message_t* msg ) { - return (cc2420_header_t*)( msg->data - sizeof( cc2420_header_t ) ); - } - - cc2420_metadata_t* getMetadata( message_t* msg ) { - return (cc2420_metadata_t*)msg->metadata; - } - - command error_t Init.init() { - fallingEdgeEnabled = FALSE; - m_p_rx_buf = &m_rx_buf; - return SUCCESS; - } - - void reset_state() { - m_bytes_left = RXFIFO_SIZE; - m_timestamp_head = m_timestamp_size = 0; - m_missed_packets = 0; - } - - async command error_t AsyncStdControl.start() { - atomic { - reset_state(); - m_state = S_STARTED; - - // MicaZ's don't like to re-enable the falling edge - if(!fallingEdgeEnabled) { - call InterruptFIFOP.enableFallingEdge(); - fallingEdgeEnabled = TRUE; - } - } - return SUCCESS; - } - - async command error_t AsyncStdControl.stop() { - atomic { - m_state = S_STOPPED; - // MicaZ's don't like to re-enable the falling edge - //call InterruptFIFOP.disable(); - } - return SUCCESS; - } - - async command void CC2420Receive.sfd( uint16_t time ) { - if ( m_timestamp_size < TIMESTAMP_QUEUE_SIZE ) { - uint8_t tail = ( ( m_timestamp_head + m_timestamp_size ) % - TIMESTAMP_QUEUE_SIZE ); - m_timestamp_queue[ tail ] = time; - m_timestamp_size++; - } - } - - async command void CC2420Receive.sfd_dropped() { - if ( m_timestamp_size ) - m_timestamp_size--; - } - - async event void InterruptFIFOP.fired() { - if ( m_state == S_STARTED ) - beginReceive(); - else - m_missed_packets++; - } - - void beginReceive() { - m_state = S_RX_HEADER; - if ( call SpiResource.immediateRequest() == SUCCESS ) - receive(); - else - call SpiResource.request(); - } - - event void SpiResource.granted() { - receive(); - } - - void receive() { - call CSN.clr(); - call RXFIFO.beginRead( (uint8_t*)getHeader( m_p_rx_buf ), 1 ); - } - - async event void RXFIFO.readDone( uint8_t* rx_buf, uint8_t rx_len, - error_t error ) { - - cc2420_header_t* header = getHeader( m_p_rx_buf ); - cc2420_metadata_t* metadata = getMetadata( m_p_rx_buf ); - uint8_t* buf = (uint8_t*)header; - uint8_t length = buf[ 0 ]; - - switch( m_state ) { - - case S_RX_HEADER: - m_state = S_RX_PAYLOAD; - if ( length + 1 > m_bytes_left ) { - reset_state(); - call CSN.set(); - call CSN.clr(); - call SFLUSHRX.strobe(); - call SFLUSHRX.strobe(); - call CSN.set(); - call SpiResource.release(); - waitForNextPacket(); - } - else { - if ( !call FIFO.get() && !call FIFOP.get() ) - m_bytes_left -= length + 1; - call RXFIFO.continueRead( (length <= MAC_PACKET_SIZE) ? buf + 1 : NULL, - length ); - } - break; - - case S_RX_PAYLOAD: - - call CSN.set(); - call SpiResource.release(); - - if ( m_timestamp_size ) { - if ( length > 10 ) { - metadata->time = m_timestamp_queue[ m_timestamp_head ]; - m_timestamp_head = ( m_timestamp_head + 1 ) % TIMESTAMP_QUEUE_SIZE; - m_timestamp_size--; - } - } - else { - metadata->time = 0xffff; - } - - // pass packet up if crc is good - if ( ( buf[ length ] >> 7 ) && rx_buf ) { - uint8_t type = ( header->fcf >> IEEE154_FCF_FRAME_TYPE ) & 7; - signal CC2420Receive.receive( type, m_p_rx_buf ); - if ( type == IEEE154_TYPE_DATA ) { - post receiveDone_task(); - return; - } - } - - waitForNextPacket(); - break; - - default: - call CSN.set(); - call SpiResource.release(); - break; - - } - - } - - task void receiveDone_task() { - - cc2420_header_t* header = getHeader( m_p_rx_buf ); - cc2420_metadata_t* metadata = getMetadata( m_p_rx_buf ); - uint8_t* buf = (uint8_t*)header; - uint8_t length = buf[ 0 ]; - - metadata->crc = buf[ length ] >> 7; - metadata->rssi = buf[ length - 1 ]; - metadata->lqi = buf[ length ] & 0x7f; - m_p_rx_buf = signal Receive.receive( m_p_rx_buf, m_p_rx_buf->data, - length ); - - waitForNextPacket(); - - } - - void waitForNextPacket() { - - atomic { - if ( m_state == S_STOPPED ) - return; - - if ( ( m_missed_packets && call FIFO.get() ) || !call FIFOP.get() ) { - if ( m_missed_packets ) - m_missed_packets--; - beginReceive(); - } - else { - m_state = S_STARTED; - m_missed_packets = 0; - } - } - - } - - command void* Receive.getPayload(message_t* m, uint8_t* len) { - if (len != NULL) { - *len = TOSH_DATA_LENGTH; - } - return m->data; - } - - command uint8_t Receive.payloadLength(message_t* m) { - uint8_t* buf = (uint8_t*)getHeader( m_p_rx_buf ); - return buf[0]; - } - - async event void RXFIFO.writeDone( uint8_t* tx_buf, uint8_t tx_len, error_t error ) {} -} diff --git a/tos/chips/cc2420_lpl/CC2420Register.nc b/tos/chips/cc2420_lpl/CC2420Register.nc deleted file mode 100644 index 5a95aee0..00000000 --- a/tos/chips/cc2420_lpl/CC2420Register.nc +++ /dev/null @@ -1,57 +0,0 @@ -/* tab:4 - * "Copyright (c) 2005 Stanford University. All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose, without fee, and without written - * agreement is hereby granted, provided that the above copyright - * notice, the following two paragraphs and the author appear in all - * copies of this software. - * - * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE - * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY - * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, - * ENHANCEMENTS, OR MODIFICATIONS." - * - */ - -/** - * Interface representing one of the Read/Write registers on the - * CC2420 radio. The return values (when appropriate) refer to the - * status byte returned on the CC2420 SO pin. A full list of RW - * registers can be found on page 61 of the CC2420 datasheet (rev - * 1.2). Page 25 of the same document describes the protocol for - * interacting with these registers over the CC2420 SPI bus. - * - * @author Philip Levis - * @version $Revision$ $Date$ - */ - -#include "CC2420.h" - -interface CC2420Register { - - /** - * Read a 16-bit data word from the register. - * - * @param data pointer to place the register value. - * @return status byte from the read. - */ - async command cc2420_status_t read(uint16_t* data); - - /** - * Write a 16-bit data word to the register. - * - * @param data value to write to register. - * @return status byte from the write. - */ - async command cc2420_status_t write(uint16_t data); - -} diff --git a/tos/chips/cc2420_lpl/CC2420SpiC.nc b/tos/chips/cc2420_lpl/CC2420SpiC.nc deleted file mode 100644 index 7e35a93b..00000000 --- a/tos/chips/cc2420_lpl/CC2420SpiC.nc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Implementation of basic SPI primitives for the ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -generic configuration CC2420SpiC() { - - provides interface Resource; - - // commands - provides interface CC2420Strobe as SFLUSHRX; - provides interface CC2420Strobe as SFLUSHTX; - provides interface CC2420Strobe as SNOP; - provides interface CC2420Strobe as SRXON; - provides interface CC2420Strobe as SRFOFF; - provides interface CC2420Strobe as STXON; - provides interface CC2420Strobe as STXONCCA; - provides interface CC2420Strobe as SXOSCON; - provides interface CC2420Strobe as SXOSCOFF; - - // registers - provides interface CC2420Register as FSCTRL; - provides interface CC2420Register as IOCFG0; - provides interface CC2420Register as IOCFG1; - provides interface CC2420Register as MDMCTRL0; - provides interface CC2420Register as MDMCTRL1; - provides interface CC2420Register as TXCTRL; - - // ram - provides interface CC2420Ram as IEEEADR; - provides interface CC2420Ram as PANID; - provides interface CC2420Ram as SHORTADR; - provides interface CC2420Ram as TXFIFO_RAM; - - // fifos - provides interface CC2420Fifo as RXFIFO; - provides interface CC2420Fifo as TXFIFO; - -} - -implementation { - - enum { - CLIENT_ID = unique( "CC2420Spi.Resource" ), - }; - - components HplCC2420PinsC as Pins; - components CC2420SpiP as Spi; - - Resource = Spi.Resource[ CLIENT_ID ]; - - // commands - SFLUSHRX = Spi.Strobe[ CC2420_SFLUSHRX ]; - SFLUSHTX = Spi.Strobe[ CC2420_SFLUSHTX ]; - SNOP = Spi.Strobe[ CC2420_SNOP ]; - SRXON = Spi.Strobe[ CC2420_SRXON ]; - SRFOFF = Spi.Strobe[ CC2420_SRFOFF ]; - STXON = Spi.Strobe[ CC2420_STXON ]; - STXONCCA = Spi.Strobe[ CC2420_STXONCCA ]; - SXOSCON = Spi.Strobe[ CC2420_SXOSCON ]; - SXOSCOFF = Spi.Strobe[ CC2420_SXOSCOFF ]; - - // registers - FSCTRL = Spi.Reg[ CC2420_FSCTRL ]; - IOCFG0 = Spi.Reg[ CC2420_IOCFG0 ]; - IOCFG1 = Spi.Reg[ CC2420_IOCFG1 ]; - MDMCTRL0 = Spi.Reg[ CC2420_MDMCTRL0 ]; - MDMCTRL1 = Spi.Reg[ CC2420_MDMCTRL1 ]; - TXCTRL = Spi.Reg[ CC2420_TXCTRL ]; - - // ram - IEEEADR = Spi.Ram[ CC2420_RAM_IEEEADR ]; - PANID = Spi.Ram[ CC2420_RAM_PANID ]; - SHORTADR = Spi.Ram[ CC2420_RAM_SHORTADR ]; - TXFIFO_RAM = Spi.Ram[ CC2420_RAM_TXFIFO ]; - - // fifos - RXFIFO = Spi.Fifo[ CC2420_RXFIFO ]; - TXFIFO = Spi.Fifo[ CC2420_TXFIFO ]; - -} - diff --git a/tos/chips/cc2420_lpl/CC2420SpiImplP.nc b/tos/chips/cc2420_lpl/CC2420SpiImplP.nc deleted file mode 100644 index 75adec49..00000000 --- a/tos/chips/cc2420_lpl/CC2420SpiImplP.nc +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -module CC2420SpiImplP { - - provides interface Resource[ uint8_t id ]; - provides interface CC2420Fifo as Fifo[ uint8_t id ]; - provides interface CC2420Ram as Ram[ uint16_t id ]; - provides interface CC2420Register as Reg[ uint8_t id ]; - provides interface CC2420Strobe as Strobe[ uint8_t id ]; - - uses interface Resource as SpiResource; - uses interface SpiByte; - uses interface SpiPacket; - uses interface Leds; - -} - -implementation { - - enum { - RESOURCE_COUNT = uniqueCount( "CC2420Spi.Resource" ), - NO_HOLDER = 0xff, - }; - - norace uint16_t m_addr; - bool m_resource_busy = FALSE; - uint8_t m_requests = 0; - uint8_t m_holder = NO_HOLDER; - - default event void Resource.granted[ uint8_t id ]() { - } - - async command error_t Resource.request[ uint8_t id ]() { - atomic { - if ( m_resource_busy ) - m_requests |= 1 << id; - else { - m_holder = id; - m_resource_busy = TRUE; - call SpiResource.request(); - } - } - return SUCCESS; - } - - async command error_t Resource.immediateRequest[ uint8_t id ]() { - error_t error; - atomic { - if ( m_resource_busy ) - return EBUSY; - error = call SpiResource.immediateRequest(); - if ( error == SUCCESS ) { - m_holder = id; - m_resource_busy = TRUE; - } - } - return error; - } - - async command error_t Resource.release[ uint8_t id ]() { - uint8_t i; - atomic { - if ( m_holder != id ) - return FAIL; - m_holder = NO_HOLDER; - call SpiResource.release(); - if ( !m_requests ) { - m_resource_busy = FALSE; - } - else { - for ( i = m_holder + 1; ; i++ ) { - if ( i >= RESOURCE_COUNT ) - i = 0; - if ( m_requests & ( 1 << i ) ) { - m_holder = i; - m_requests &= ~( 1 << i ); - call SpiResource.request(); - return SUCCESS; - } - } - } - return SUCCESS; - } - } - - async command uint8_t Resource.isOwner[ uint8_t id ]() { - atomic return m_holder == id; - } - - event void SpiResource.granted() { - uint8_t holder; - atomic holder = m_holder; - signal Resource.granted[ holder ](); - } - - async command cc2420_status_t Fifo.beginRead[ uint8_t addr ]( uint8_t* data, - uint8_t len ) { - - cc2420_status_t status; - - m_addr = addr | 0x40; - - status = call SpiByte.write( m_addr ); - call Fifo.continueRead[ addr ]( data, len ); - - return status; - - } - - async command error_t Fifo.continueRead[ uint8_t addr ]( uint8_t* data, - uint8_t len ) { - call SpiPacket.send( NULL, data, len ); - return SUCCESS; - } - - async command cc2420_status_t Fifo.write[ uint8_t addr ]( uint8_t* data, - uint8_t len ) { - - uint8_t status; - - m_addr = addr; - - status = call SpiByte.write( m_addr ); - call SpiPacket.send( data, NULL, len ); - - return status; - - } - - async command cc2420_status_t Ram.read[ uint16_t addr ]( uint8_t offset, - uint8_t* data, - uint8_t len ) { - - cc2420_status_t status; - - addr += offset; - - call SpiByte.write( addr | 0x80 ); - status = call SpiByte.write( ( ( addr >> 1 ) & 0xc0 ) | 0x20 ); - for ( ; len; len-- ) - *data++ = call SpiByte.write( 0 ); - - return status; - - } - - async event void SpiPacket.sendDone( uint8_t* tx_buf, uint8_t* rx_buf, - uint16_t len, error_t error ) { - if ( m_addr & 0x40 ) - signal Fifo.readDone[ m_addr & ~0x40 ]( rx_buf, len, error ); - else - signal Fifo.writeDone[ m_addr ]( tx_buf, len, error ); - } - - async command cc2420_status_t Ram.write[ uint16_t addr ]( uint8_t offset, - uint8_t* data, - uint8_t len ) { - - cc2420_status_t status = 0; - - addr += offset; - - call SpiByte.write( addr | 0x80 ); - call SpiByte.write( ( addr >> 1 ) & 0xc0 ); - for ( ; len; len-- ) - status = call SpiByte.write( *data++ ); - - return status; - - } - - async command cc2420_status_t Reg.read[ uint8_t addr ]( uint16_t* data ) { - - cc2420_status_t status; - - status = call SpiByte.write( addr | 0x40 ); - *data = (uint16_t)call SpiByte.write( 0 ) << 8; - *data |= call SpiByte.write( 0 ); - - return status; - - } - - async command cc2420_status_t Reg.write[ uint8_t addr ]( uint16_t data ) { - - call SpiByte.write( addr ); - call SpiByte.write( data >> 8 ); - return call SpiByte.write( data & 0xff ); - - } - - async command cc2420_status_t Strobe.strobe[ uint8_t addr ]() { - return call SpiByte.write( addr ); - } - - default async event void Fifo.readDone[ uint8_t addr ]( uint8_t* rx_buf, uint8_t rx_len, error_t error ) {} - default async event void Fifo.writeDone[ uint8_t addr ]( uint8_t* tx_buf, uint8_t tx_len, error_t error ) {} - -} diff --git a/tos/chips/cc2420_lpl/CC2420SpiP.nc b/tos/chips/cc2420_lpl/CC2420SpiP.nc deleted file mode 100644 index dd7d4d46..00000000 --- a/tos/chips/cc2420_lpl/CC2420SpiP.nc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -configuration CC2420SpiP { - - provides interface Resource[ uint8_t id ]; - provides interface CC2420Fifo as Fifo[ uint8_t id ]; - provides interface CC2420Ram as Ram[ uint16_t id ]; - provides interface CC2420Register as Reg[ uint8_t id ]; - provides interface CC2420Strobe as Strobe[ uint8_t id ]; - -} - -implementation { - - components CC2420SpiImplP as SpiP; - Resource = SpiP; - Fifo = SpiP; - Ram = SpiP; - Reg = SpiP; - Strobe = SpiP; - - components new HplCC2420SpiC(); - SpiP.SpiResource -> HplCC2420SpiC; - SpiP.SpiByte -> HplCC2420SpiC; - SpiP.SpiPacket -> HplCC2420SpiC; - - components LedsC; - SpiP.Leds -> LedsC; - -} diff --git a/tos/chips/cc2420_lpl/CC2420Strobe.nc b/tos/chips/cc2420_lpl/CC2420Strobe.nc deleted file mode 100644 index ae7ae757..00000000 --- a/tos/chips/cc2420_lpl/CC2420Strobe.nc +++ /dev/null @@ -1,47 +0,0 @@ -/* tab:4 - * "Copyright (c) 2005 Stanford University. All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose, without fee, and without written - * agreement is hereby granted, provided that the above copyright - * notice, the following two paragraphs and the author appear in all - * copies of this software. - * - * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE - * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY - * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, - * ENHANCEMENTS, OR MODIFICATIONS." - * - */ - -/** - * Interface representing one of the CC2420 command strobe registers. - * Writing to one of these registers enacts a command on the CC2420, - * such as power-up, transmission, or clear a FIFO. - * - * @author Philip Levis - * @version $Revision$ $Date$ - */ - -#include "CC2420.h" - -interface CC2420Strobe { - - /** - * Send a command strobe to the register. The return value is the - * CC2420 status register. Table 5 on page 27 of the CC2420 - * datasheet (v1.2) describes the contents of this register. - * - * @return Status byte from the CC2420. - */ - async command cc2420_status_t strobe(); - -} diff --git a/tos/chips/cc2420_lpl/CC2420Transmit.nc b/tos/chips/cc2420_lpl/CC2420Transmit.nc deleted file mode 100644 index 0f887b25..00000000 --- a/tos/chips/cc2420_lpl/CC2420Transmit.nc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Low-level abstraction for the transmit path implementaiton of the - * ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -interface CC2420Transmit { - - /** - * Send a message with CCA enabled. - * - * @param p_msg message to send. - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t sendCCA( message_t* p_msg ); - - /** - * Send a message with CCA disabled. - * - * @param p_msg message to send. - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t send( message_t* p_msg ); - - /** - * Send the previous message again with CCA enabled. - * - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t resendCCA(); - - /** - * Send the previous message again with CCA disabled. - * - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t resend(); - - /** - * Cancel sending of the message. - * - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t cancel(); - - /** - * Signal that a message has been sent - * - * @param p_msg message to send. - * @param error notifaction of how the operation went. - */ - async event void sendDone( message_t* p_msg, error_t error ); - - /** - * Modify the contents of a packet. This command can only be used - * when an SFD capture event for the sending packet is signalled. - * - * @param offset in the message to start modifying. - * @param buf to data to write - * @param len of bytes to write - * @return SUCCESS if the request was accepted, FAIL otherwise. - */ - async command error_t modify( uint8_t offset, uint8_t* buf, uint8_t len ); - -} - diff --git a/tos/chips/cc2420_lpl/CC2420TransmitC.nc b/tos/chips/cc2420_lpl/CC2420TransmitC.nc deleted file mode 100644 index 442d282b..00000000 --- a/tos/chips/cc2420_lpl/CC2420TransmitC.nc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Implementation of the transmit path for the ChipCon CC2420 radio. - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include "IEEE802154.h" - -configuration CC2420TransmitC { - - provides { - interface Init; - interface AsyncStdControl; - interface CC2420Transmit; - interface CsmaBackoff; - interface RadioTimeStamping; - interface CC2420Cca; - } -} - -implementation { - - components CC2420TransmitP; - Init = Alarm; - Init = CC2420TransmitP; - AsyncStdControl = CC2420TransmitP; - CC2420Transmit = CC2420TransmitP; - CsmaBackoff = CC2420TransmitP; - RadioTimeStamping = CC2420TransmitP; - CC2420Cca = CC2420TransmitP; - - components AlarmMultiplexC as Alarm; - CC2420TransmitP.BackoffTimer -> Alarm; - -#ifdef PLATFORM_MICAZ - components new TimerMilliC() as WatchdogTimerC; - CC2420TransmitP.WatchdogTimer -> WatchdogTimerC; -#endif - - components HplCC2420PinsC as Pins; - CC2420TransmitP.CCA -> Pins.CCA; - CC2420TransmitP.CSN -> Pins.CSN; - CC2420TransmitP.SFD -> Pins.SFD; - - components HplCC2420InterruptsC as Interrupts; - CC2420TransmitP.CaptureSFD -> Interrupts.CaptureSFD; - - components new CC2420SpiC() as Spi; - CC2420TransmitP.SpiResource -> Spi; - CC2420TransmitP.SNOP -> Spi.SNOP; - CC2420TransmitP.STXON -> Spi.STXON; - CC2420TransmitP.STXONCCA -> Spi.STXONCCA; - CC2420TransmitP.SFLUSHTX -> Spi.SFLUSHTX; - CC2420TransmitP.TXCTRL -> Spi.TXCTRL; - CC2420TransmitP.TXFIFO -> Spi.TXFIFO; - CC2420TransmitP.TXFIFO_RAM -> Spi.TXFIFO_RAM; - - components CC2420ReceiveC; - CC2420TransmitP.CC2420Receive -> CC2420ReceiveC; - - components LedsC as Leds; - CC2420TransmitP.Leds -> Leds; - -} diff --git a/tos/chips/cc2420_lpl/CC2420TransmitP.nc b/tos/chips/cc2420_lpl/CC2420TransmitP.nc deleted file mode 100644 index 9aa7c13a..00000000 --- a/tos/chips/cc2420_lpl/CC2420TransmitP.nc +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#include "IEEE802154.h" - -module CC2420TransmitP { - - provides interface Init; - provides interface AsyncStdControl; - provides interface CC2420Transmit as Send; - provides interface CsmaBackoff; - provides interface RadioTimeStamping as TimeStamp; - provides interface CC2420Cca; - - uses interface Alarm as BackoffTimer; - -#ifdef PLATFORM_MICAZ - uses interface Timer as WatchdogTimer; -#endif - - uses interface GpioCapture as CaptureSFD; - uses interface GeneralIO as CCA; - uses interface GeneralIO as CSN; - uses interface GeneralIO as SFD; - - uses interface Resource as SpiResource; - uses interface CC2420Fifo as TXFIFO; - uses interface CC2420Ram as TXFIFO_RAM; - uses interface CC2420Register as TXCTRL; - uses interface CC2420Strobe as SNOP; - uses interface CC2420Strobe as STXON; - uses interface CC2420Strobe as STXONCCA; - uses interface CC2420Strobe as SFLUSHTX; - - uses interface CC2420Receive; - uses interface Leds; - -} - -implementation { - - typedef enum { - S_STOPPED, - S_STARTED, - S_LOAD, - S_SAMPLE_CCA, - S_SAMPLE_CCA_ONLY, - S_BEGIN_TRANSMIT, - S_SFD, - S_EFD, - S_ACK_WAIT, - S_CANCEL, - } cc2420_transmit_state_t; - - // This specifies how many jiffies the stack should wait after a - // TXACTIVE to receive an SFD interrupt before assuming something is - // wrong and aborting the send. There seems to be a condition - // on the micaZ where the SFD interrupt is never handled. - enum { - CC2420_ABORT_PERIOD = 320 - }; - - norace message_t* m_msg; - - norace bool m_cca; - - norace uint8_t m_tx_power; - - cc2420_transmit_state_t m_state = S_STOPPED; - - bool m_receiving = FALSE; - - uint16_t m_prev_time; - - - /***************** Prototypes ****************/ - void loadTXFIFO(); - void attemptSend(); - cc2420_header_t* getHeader( message_t* msg ); - cc2420_metadata_t* getMetadata( message_t* msg ); - void startBackoffTimer(uint16_t time); - void stopBackoffTimer(); - error_t acquireSpiResource(); - void releaseSpiResource(); - void signalDone(error_t err); - void congestionBackoff(); - error_t send( message_t* p_msg, bool cca ); - error_t resend( bool cca ); - -#ifdef PLATFORM_MICAZ - task void startWatchdogTimer(); - task void stopWatchdogTimer(); -#endif - - - /***************** Init Commands ****************/ - command error_t Init.init() { - call CCA.makeInput(); - call CSN.makeOutput(); - call SFD.makeInput(); - return SUCCESS; - } - - /***************** AsyncStdControl Commands ****************/ - async command error_t AsyncStdControl.start() { - atomic { - call CaptureSFD.captureRisingEdge(); - m_state = S_STARTED; - m_receiving = FALSE; - m_tx_power = 0; - } - return SUCCESS; - } - - async command error_t AsyncStdControl.stop() { - atomic { - m_state = S_STOPPED; - stopBackoffTimer(); - call CaptureSFD.disable(); - } - return SUCCESS; - } - - /***************** Send Commands ****************/ - async command error_t Send.sendCCA( message_t* p_msg ) { - return send( p_msg, TRUE ); - } - - async command error_t Send.send( message_t* p_msg ) { - return send( p_msg, FALSE ); - } - - async command error_t Send.resendCCA() { - return resend( TRUE ); - } - - async command error_t Send.resend() { - return resend( FALSE ); - } - - async command error_t Send.cancel() { - stopBackoffTimer(); - - atomic { - switch( m_state ) { - case S_LOAD: - m_state = S_CANCEL; - break; - - case S_SAMPLE_CCA: - case S_BEGIN_TRANSMIT: - m_state = S_STARTED; - break; - - default: - // cancel not allowed while radio is busy transmitting - return FAIL; - } - } - - return SUCCESS; - } - - async command error_t Send.modify( uint8_t offset, uint8_t* buf, - uint8_t len ) { - call CSN.clr(); - call TXFIFO_RAM.write( offset, buf, len ); - call CSN.set(); - return SUCCESS; - } - - /***************** CC2420Cca Commands ****************/ - /** - * @return TRUE if the CCA pin shows a clear channel - */ - command bool CC2420Cca.isChannelClear() { - return call CCA.get(); - } - - /***************** CaptureSFD Events ****************/ - async event void CaptureSFD.captured( uint16_t time ) { - - atomic { - switch( m_state ) { - - case S_SFD: - call CaptureSFD.captureFallingEdge(); - signal TimeStamp.transmittedSFD( time, m_msg ); - releaseSpiResource(); - stopBackoffTimer(); - m_state = S_EFD; - if ( ( ( getHeader( m_msg )->fcf >> IEEE154_FCF_FRAME_TYPE ) & 7 ) == - IEEE154_TYPE_DATA ) - getMetadata( m_msg )->time = time; - if ( call SFD.get() ) - break; - - case S_EFD: - call CaptureSFD.captureRisingEdge(); - if ( getHeader( m_msg )->fcf & ( 1 << IEEE154_FCF_ACK_REQ ) ) { - m_state = S_ACK_WAIT; - startBackoffTimer( CC2420_ACK_WAIT_DELAY ); - } - else { - signalDone(SUCCESS); - } - if ( !call SFD.get() ) - break; - - default: - if ( !m_receiving ) { - call CaptureSFD.captureFallingEdge(); - signal TimeStamp.receivedSFD( time ); - call CC2420Receive.sfd( time ); - m_receiving = TRUE; - m_prev_time = time; - if ( call SFD.get() ) - return; - } - if ( m_receiving ) { - call CaptureSFD.captureRisingEdge(); - m_receiving = FALSE; - if ( time - m_prev_time < 10 ) - call CC2420Receive.sfd_dropped(); - } - break; - - } - } - } - - /***************** CC2420Receive Events ****************/ - async event void CC2420Receive.receive( uint8_t type, message_t* ack_msg ) { - - if ( type == IEEE154_TYPE_ACK ) { - cc2420_header_t* ack_header = getHeader( ack_msg ); - cc2420_header_t* msg_header = getHeader( m_msg ); - cc2420_metadata_t* msg_metadata = getMetadata( m_msg ); - uint8_t* ack_buf = (uint8_t*)ack_header; - uint8_t length = ack_header->length; - - if ( m_state == S_ACK_WAIT && - msg_header->dsn == ack_header->dsn ) { - stopBackoffTimer(); - msg_metadata->ack = TRUE; - msg_metadata->rssi = ack_buf[ length - 1 ]; - msg_metadata->lqi = ack_buf[ length ] & 0x7f; - signalDone(SUCCESS); - } - } - } - - /***************** SpiResource Events ****************/ - event void SpiResource.granted() { - uint8_t cur_state; - - atomic { - cur_state = m_state; - } - - switch( cur_state ) { - case S_LOAD: - loadTXFIFO(); - break; - - case S_BEGIN_TRANSMIT: - attemptSend(); - break; - - default: - releaseSpiResource(); - break; - } - } - - /***************** TXFIFO Events ****************/ - async event void TXFIFO.readDone( uint8_t* tx_buf, uint8_t tx_len, - error_t error ) { - } - - - async event void TXFIFO.writeDone( uint8_t* tx_buf, uint8_t tx_len, - error_t error ) { - call CSN.set(); - - if ( m_state == S_CANCEL ) { - m_state = S_STARTED; - } - else if ( !m_cca ) { - m_state = S_BEGIN_TRANSMIT; - attemptSend(); - } - else { - releaseSpiResource(); - m_state = S_SAMPLE_CCA; - startBackoffTimer( signal CsmaBackoff.initial( m_msg ) + 1); - } - } - - /***************** Timer Events ****************/ - async event void BackoffTimer.fired() { - - atomic { - switch( m_state ) { - case S_SAMPLE_CCA : - // sample CCA and wait a little longer if free, just in case we - // sampled during the ack turn-around window - if ( call CCA.get() ) { - m_state = S_BEGIN_TRANSMIT; - startBackoffTimer( CC2420_TIME_ACK_TURNAROUND ); - } - else { - congestionBackoff(); - } - break; - - case S_BEGIN_TRANSMIT : - if ( acquireSpiResource() == SUCCESS ) - attemptSend(); - break; - - case S_ACK_WAIT : - signalDone( SUCCESS ); - break; - -#ifdef PLATFORM_MICAZ - case S_SFD: - // We didn't receive an SFD interrupt within CC2420_ABORT_PERIOD - // jiffies. Assume something is wrong. - call SFLUSHTX.strobe(); - call CaptureSFD.disable(); - call CaptureSFD.captureRisingEdge(); - signalDone( ERETRY ); - break; -#endif - default: - break; - } - } - } - - -#ifdef PLATFORM_MICAZ - event void WatchdogTimer.fired() { - atomic m_state = S_STARTED; - releaseSpiResource(); - signalDone(ERETRY); - } -#endif - - - /***************** Functions ****************/ - /** - * Send a message with or without CCA - */ - error_t send( message_t* p_msg, bool cca ) { - atomic { - if ( m_state != S_STARTED ) { - return FAIL; - } - - m_state = S_LOAD; - m_cca = cca; - m_msg = p_msg; - } - -#ifdef PLATFORM_MICAZ - post startWatchdogTimer(); -#endif - - if ( acquireSpiResource() == SUCCESS ) { - loadTXFIFO(); - } - // Else, we wait for the SpiResource.granted event.. - - return SUCCESS; - } - - /** - * Resend a message with or without CCA - */ - error_t resend( bool cca ) { - atomic { - if ( m_state != S_STARTED ) - return FAIL; - m_cca = cca; - m_state = cca ? S_SAMPLE_CCA : S_BEGIN_TRANSMIT; - } - -#ifdef PLATFORM_MICAZ - post startWatchdogTimer(); -#endif - - if ( m_cca ) { - startBackoffTimer( signal CsmaBackoff.initial( m_msg ) ); - } - else if ( acquireSpiResource() == SUCCESS ) { - attemptSend(); - } - - return SUCCESS; - } - - /** - * Attempt to send a message - */ - void attemptSend() { - uint8_t status; - bool congestion = TRUE; - - call CSN.clr(); - - status = m_cca ? call STXONCCA.strobe() : call STXON.strobe(); - if ( !( status & CC2420_STATUS_TX_ACTIVE ) ) { - status = call SNOP.strobe(); - if ( status & CC2420_STATUS_TX_ACTIVE ) - congestion = FALSE; - } - atomic m_state = congestion ? S_SAMPLE_CCA : S_SFD; - - call CSN.set(); - - if ( congestion ) { - releaseSpiResource(); - congestionBackoff(); - } -#ifdef PLATFORM_MICAZ - else { - startBackoffTimer(CC2420_ABORT_PERIOD); - } -#endif - } - - - /** - * Get the CC2420 message header - */ - cc2420_header_t* getHeader( message_t* msg ) { - return (cc2420_header_t*)( msg->data - sizeof( cc2420_header_t ) ); - } - - /** - * Get the CC2420 message metadata - */ - cc2420_metadata_t* getMetadata( message_t* msg ) { - return (cc2420_metadata_t*)msg->metadata; - } - -#ifdef PLATFORM_MICAZ - /** - * Start the watchdog timer - */ - task void startWatchdogTimer() { - call WatchdogTimer.startOneShot(50); - } - - /** - * Stop the watchdog timer - */ - task void stopWatchdogTimer() { - call WatchdogTimer.stop(); - } -#endif - - /** - * Start the backoff timer - */ - void startBackoffTimer(uint16_t time) { - call BackoffTimer.start(time); - } - - /** - * Stop the backoff timer - */ - void stopBackoffTimer() { - call BackoffTimer.stop(); - } - - /** - * Acquire the SPI bus resource immediately, or defer it till later - */ - error_t acquireSpiResource() { - error_t error = call SpiResource.immediateRequest(); - if ( error != SUCCESS ) { - call SpiResource.request(); - } - return error; - } - - /** - * Release the SPI resource - */ - void releaseSpiResource() { - call SpiResource.release(); - } - - /** - * Signal done - */ - void signalDone( error_t err ) { - atomic m_state = S_STARTED; - -#ifdef PLATFORM_MICAZ - post stopWatchdogTimer(); -#endif - - signal Send.sendDone( m_msg, err ); - } - - /** - * Congestion Backoff - */ - void congestionBackoff() { - atomic { - startBackoffTimer(signal CsmaBackoff.congestion( m_msg ) + 1); - } - } - - /** - * Load TX FIFO - */ - void loadTXFIFO() { - cc2420_header_t* header = getHeader( m_msg ); - uint8_t tx_power = getMetadata( m_msg )->tx_power; - - if ( !tx_power ) - tx_power = CC2420_DEF_RFPOWER; - call CSN.clr(); - if ( m_tx_power != tx_power ) - call TXCTRL.write( ( 2 << CC2420_TXCTRL_TXMIXBUF_CUR ) | - ( 3 << CC2420_TXCTRL_PA_CURRENT ) | - ( 1 << CC2420_TXCTRL_RESERVED ) | - ( tx_power << CC2420_TXCTRL_PA_LEVEL ) ); - m_tx_power = tx_power; - call TXFIFO.write( (uint8_t*)header, header->length - 1 ); - } - - /***************** Defaults ****************/ - default async event void TimeStamp.transmittedSFD( uint16_t time, message_t* p_msg ) {} - default async event void TimeStamp.receivedSFD( uint16_t time ) {} - -} diff --git a/tos/chips/cc2420_lpl/IEEE802154.h b/tos/chips/cc2420_lpl/IEEE802154.h deleted file mode 100644 index 65aab6f0..00000000 --- a/tos/chips/cc2420_lpl/IEEE802154.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2005-2006 Arch Rock Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - * - * @author Jonathan Hui - * @version $Revision$ $Date$ - */ - -#ifndef __IEEE802154_H__ -#define __IEEE802154_H__ - -enum ieee154_fcf_enums { - IEEE154_FCF_FRAME_TYPE = 0, - IEEE154_FCF_SECURITY_ENABLED = 3, - IEEE154_FCF_FRAME_PENDING = 4, - IEEE154_FCF_ACK_REQ = 5, - IEEE154_FCF_INTRAPAN = 6, - IEEE154_FCF_DEST_ADDR_MODE = 10, - IEEE154_FCF_SRC_ADDR_MODE = 14, -}; - -enum ieee154_fcf_type_enums { - IEEE154_TYPE_BEACON = 0, - IEEE154_TYPE_DATA = 1, - IEEE154_TYPE_ACK = 2, - IEEE154_TYPE_MAC_CMD = 3, -}; - -enum iee154_fcf_addr_mode_enums { - IEEE154_ADDR_NONE = 0, - IEEE154_ADDR_SHORT = 2, - IEEE154_ADDR_EXT = 3, -}; - -#endif diff --git a/tos/chips/cc2420_lpl/LowPowerListening.nc b/tos/chips/cc2420_lpl/LowPowerListening.nc deleted file mode 100644 index c8649c85..00000000 --- a/tos/chips/cc2420_lpl/LowPowerListening.nc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2005-2006 Rincon Research Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of the Arch Rock Corporation nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT 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 SUCH DAMAGE - */ - -/** - * Low Power Listening interface - * - * @author David Moss - * @author Jonathan Hui - */ - -interface LowPowerListening { - - /** - * Set this this node's radio sleep interval, in milliseconds. - * Once every interval, the node will sleep and perform an Rx check - * on the radio. Setting the sleep interval to 0 will keep the radio - * always on. - * - * This is the equivalent of setting the local duty cycle rate. - * - * @param sleepIntervalMs the length of this node's Rx check interval, in [ms] - */ - command void setLocalSleepInterval(uint16_t sleepIntervalMs); - - /** - * @return the local node's sleep interval, in [ms] - */ - command uint16_t getLocalSleepInterval(); - - /** - * Set this node's radio duty cycle rate, in units of [percentage*100]. - * For example, to get a 0.05% duty cycle, - * - * call LowPowerListening.setDutyCycle(5); // or equivalently... - * call LowPowerListening.setDutyCycle(00005); // for better readability? - * - * - * For a 100% duty cycle (always on), - * - * call LowPowerListening.setDutyCycle(10000); - * - * - * This is the equivalent of setting the local sleep interval explicitly. - * - * @param dutyCycle The duty cycle percentage, in units of [percentage*100] - */ - command void setLocalDutyCycle(uint16_t dutyCycle); - - /** - * @return this node's radio duty cycle rate, in units of [percentage*100] - */ - command uint16_t getLocalDutyCycle(); - - - /** - * Configure this outgoing message so it can be transmitted to a neighbor mote - * with the specified Rx sleep interval. - * @param msg Pointer to the message that will be sent - * @param sleepInterval The receiving node's sleep interval, in [ms] - */ - command void setRxSleepInterval(message_t *msg, uint16_t sleepIntervalMs); - - /** - * @return the destination node's sleep interval configured in this message - */ - command uint16_t getRxSleepInterval(message_t *msg); - - /** - * Configure this outgoing message so it can be transmitted to a neighbor mote - * with the specified Rx duty cycle rate. - * Duty cycle is in units of [percentage*100], i.e. 0.25% duty cycle = 25. - * - * @param msg Pointer to the message that will be sent - * @param dutyCycle The duty cycle of the receiving mote, in units of - * [percentage*100] - */ - command void setRxDutyCycle(message_t *msg, uint16_t dutyCycle); - - /** - * @return the destination node's duty cycle configured in this message - * in units of [percentage*100] - */ - command uint16_t getRxDutyCycle(message_t *msg); - - /** - * Convert a duty cycle, in units of [percentage*100], to - * the sleep interval of the mote in milliseconds - * @param dutyCycle The duty cycle in units of [percentage*100] - * @return The equivalent sleep interval, in units of [ms] - */ - command uint16_t dutyCycleToSleepInterval(uint16_t dutyCycle); - - /** - * Convert a sleep interval, in units of [ms], to a duty cycle - * in units of [percentage*100] - * @param sleepInterval The sleep interval in units of [ms] - * @return The duty cycle in units of [percentage*100] - */ - command uint16_t sleepIntervalToDutyCycle(uint16_t sleepInterval); - -} -- 2.39.2