[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/micaz/mac/tkn154 Makefile.include, NONE, 1.1 README.txt, NONE, 1.1 TKN154TimingP.nc, NONE, 1.1 TKN154_platform.h, NONE, 1.1 platform_message.h, NONE, 1.1
Jan-Hinrich Hauer
janhauer at users.sourceforge.net
Mon May 18 09:29:58 PDT 2009
Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/micaz/mac/tkn154
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20923/tos/platforms/micaz/mac/tkn154
Added Files:
Makefile.include README.txt TKN154TimingP.nc TKN154_platform.h
platform_message.h
Log Message:
added TKN15.4 "platform glue" code for micaz
--- NEW FILE: Makefile.include ---
CFLAGS += -I$(TOSDIR)/platforms/micaz/mac/tkn154 \
-I$(TOSDIR)/platforms/telosb/mac/tkn154 \
-I$(TOSDIR)/platforms/telosb/mac/tkn154/timer \
-I$(TOSDIR)/chips/cc2420_tkn154
--- NEW FILE: README.txt ---
This directory contains the TKN15.4 "platform glue" code for the micaz
platform. Like the telos platform, micaz uses the CC2420 radio and in order not
to maintain identical configuration files, the micaz platform pulls in (uses) some
files from the platform/telosb/mac/tkn154 directory. This includes the central
MAC configurations "Ieee802154BeaconEnabledC" and "Ieee802154NonBeaconEnabledC",
to which the next higher layer will wire to.
The ./Makefile.include file defines in which order the directories are parsed and
should be included by any micaz application.
More information on TKN15.4 can be found here:
tinyos-2.x/tos/lib/mac/tkn154/README.txt
--- NEW FILE: TKN154TimingP.nc ---
/*
* Copyright (c) 2008, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* extraification, 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 Technische Universitaet Berlin 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 COPYRIGHT
* OWNER OR 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.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2009/05/18 16:29:56 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
/**
* In slotted CSMA-CA frames must be sent on backoff boundaries (slot width:
* 320 us). The MicaZ platform lacks a clock with sufficient precision and
* accuracy, i.e. for slotted CSMA-CA the timing is *not* standard compliant
* (this code is experimental)
*/
#include "TKN154_platform.h"
module TKN154TimingP
{
provides interface CaptureTime;
provides interface ReliableWait;
provides interface ReferenceTime;
uses interface TimeCalc;
uses interface GetNow<bool> as CCA;
uses interface Alarm<T62500hz,uint32_t> as SymbolAlarm;
uses interface Leds;
}
implementation
{
enum {
S_WAIT_OFF,
S_WAIT_RX,
S_WAIT_TX,
S_WAIT_BACKOFF,
};
uint8_t m_state = S_WAIT_OFF;
async command error_t CaptureTime.convert(uint16_t time, ieee154_timestamp_t *localTime, int16_t offset)
{
// Timer1 is used for capturing, it is sourced by ACLK (32768Hz),
// we now need to convert the capture "time" into ieee154_timestamp_t.
// With the 32768Hz quartz we don't have enough precision anyway,
// so the code below generates a timestamp that is not accurate
uint16_t tcnt1, delta;
uint32_t now;
atomic {
tcnt1 = TCNT1;
now = call SymbolAlarm.getNow();
}
if (time < tcnt1)
delta = tcnt1 - time;
else
delta = ~(time - tcnt1) + 1;
*localTime = now - delta * 2 + offset; // one tick of Timer1 ~ two symbols
return SUCCESS;
}
async command bool ReliableWait.ccaOnBackoffBoundary(ieee154_timestamp_t *slot0)
{
// There is no point in trying
return (call CCA.getNow() ? 20: 0);
}
async command bool CaptureTime.isValidTimestamp(uint16_t risingSFDTime, uint16_t fallingSFDTime)
{
// smallest packet (ACK) takes
// length field (1) + MPDU (5) = 6 byte => 12 * 16 us = 192 us
return (fallingSFDTime - risingSFDTime) > 5;
}
async command void ReliableWait.waitRx(uint32_t t0, uint32_t dt)
{
if (m_state != S_WAIT_OFF){
ASSERT(0);
return;
}
m_state = S_WAIT_RX;
call SymbolAlarm.startAt(t0 - 16, dt); // subtract 12 symbols required for Rx calibration
}
async command void ReliableWait.waitTx(ieee154_timestamp_t *t0, uint32_t dt)
{
if (m_state != S_WAIT_OFF){
ASSERT(0);
return;
}
m_state = S_WAIT_TX;
call SymbolAlarm.startAt(*t0 - 16, dt); // subtract 12 symbols required for Tx calibration
}
async command void ReliableWait.waitBackoff(uint32_t dt)
{
if (m_state != S_WAIT_OFF){
ASSERT(0);
return;
}
m_state = S_WAIT_BACKOFF;
call SymbolAlarm.start(dt);
}
async event void SymbolAlarm.fired()
{
switch (m_state)
{
case S_WAIT_RX: m_state = S_WAIT_OFF; signal ReliableWait.waitRxDone(); break;
case S_WAIT_TX: m_state = S_WAIT_OFF; signal ReliableWait.waitTxDone(); break;
case S_WAIT_BACKOFF: m_state = S_WAIT_OFF; signal ReliableWait.waitBackoffDone(); break;
default: ASSERT(0); break;
}
}
async command void ReferenceTime.getNow(ieee154_timestamp_t* timestamp, uint16_t dt)
{
*timestamp = call SymbolAlarm.getNow() + dt;
}
async command uint32_t ReferenceTime.toLocalTime(const ieee154_timestamp_t* timestamp)
{
return *timestamp;
}
}
--- NEW FILE: TKN154_platform.h ---
/*
* Copyright (c) 2008, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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 COPYRIGHT
* OWNER OR 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.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2009/05/18 16:29:56 $
* @author Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
#ifndef __TKN154_platform_H
#define __TKN154_platform_H
/****************************************************
* The following constants define guard times on MicaZ.
* All values are in symbol time (1 symbol = 16 us)
*/
enum {
// the expected maximum time between calling a transmit() operation and
// the radio putting the first byte on the channel assuming no CSMA-CA
IEEE154_RADIO_TX_DELAY = 400,
// the expected maximum time between calling a receive() operation and the
// the radio actually being put in receive mode
IEEE154_RADIO_RX_DELAY = 400,
// defines at what time the MAC payload for a beacon frame is assembled before
// the next scheduled beacon transmission time; the value must be smaller than
// the beacon interval plus the time for preparing the Tx operation
BEACON_PAYLOAD_UPDATE_INTERVAL = 2500,
};
typedef uint32_t ieee154_timestamp_t;
#endif
--- NEW FILE: platform_message.h ---
#ifndef PLATFORM_MESSAGE_H
#define PLATFORM_MESSAGE_H
#include <Serial.h>
/* The following include pulls in the ieee154_header_t/ieee154_metadata_t definitions */
#include <TKN154_MAC.h>
/* TOSH_DATA_LENGTH should be the maximum length of the MAC payload */
#define TOSH_DATA_LENGTH IEEE154_aMaxMACPayloadSize
typedef union message_header {
ieee154_header_t ieee154;
serial_header_t serial;
} message_header_t;
typedef union TOSRadioFooter {
} message_footer_t;
typedef union TOSRadioMetadata {
ieee154_metadata_t ieee154;
} message_metadata_t;
#endif
More information about the Tinyos-2-commits
mailing list