[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/iris .platform,
NONE, 1.1 ActiveMessageC.nc, NONE, 1.1 MeasureClockC.nc, NONE,
1.1 MicaTimer.h, NONE, 1.1 platform.h, NONE,
1.1 platform_message.h, NONE, 1.1
Janos Sallai
sallai at users.sourceforge.net
Mon Nov 5 12:37:21 PST 2007
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/diagmsg Assert.h, NONE,
1.1 AssertC.nc, NONE, 1.1 AssertP.nc, NONE, 1.1 DiagMsg.nc,
NONE, 1.1 DiagMsg.txt, NONE, 1.1 DiagMsgC.nc, NONE,
1.1 DiagMsgM.nc, NONE, 1.1 NoDiagMsgC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/iris/chips/rf230
HplRF230.h, NONE, 1.1 HplRF230.nc, NONE, 1.1 HplRF230C.nc,
NONE, 1.1 HplRF230P.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/iris
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27584
Added Files:
.platform ActiveMessageC.nc MeasureClockC.nc MicaTimer.h
platform.h platform_message.h
Log Message:
platform support for the IRIS mote (atm1218 MCU and rf230 radio)
--- NEW FILE: .platform ---
#
# FILE: micaz/.platform
#
# Includes that should take precedence come first. Platforms come before
# chips because they may override files. These must be specified as
# @includes instead of -I's to @opts, otherwise the %T won't be processed
# by ncc.
#
# $Id: .platform,v 1.1 2007/11/05 20:37:17 sallai Exp $
#
push( @includes, qw(
%T/platforms/micaz
%T/platforms/mica
%T/platforms/iris/chips/rf230
%T/chips/rf230
%T/chips/cc2420 # for IEEE802154.h
%T/platforms/mica2/chips/at45db
%T/platforms/mica/chips/at45db
%T/chips/at45db
%T/chips/atm1281
%T/chips/atm1281/adc
%T/chips/atm1281/timer
%T/chips/atm128
%T/chips/atm128/adc
%T/chips/atm128/pins
%T/chips/atm128/spi
%T/chips/atm128/i2c
%T/chips/atm128/timer
%T/lib/timer
%T/lib/serial
%T/lib/power
%T/lib/diagmsg # for testing purposes
) );
@opts = qw(
-gcc=avr-gcc
-mmcu=atmega1281
-fnesc-target=avr
-fnesc-no-debug
-fnesc-scheduler=TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postTask
);
push @opts, "-mingw-gcc" if $cygwin;
--- NEW FILE: ActiveMessageC.nc ---
/*
* Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Author: Miklos Maroti
*/
configuration ActiveMessageC
{
provides
{
interface SplitControl;
interface AMSend[uint8_t id];
interface Receive[uint8_t id];
interface Receive as Snoop[uint8_t id];
interface Packet;
interface AMPacket;
interface PacketAcknowledgements as Acks;
}
}
implementation
{
components DefaultMacC as MAC;
SplitControl = MAC;
AMSend = MAC;
Receive = MAC.Receive;
Snoop = MAC.Snoop;
Packet = MAC;
AMPacket = MAC;
Acks = MAC;
// TODO: do these from PlatformC
// components RealMainP, HplRF230C, RF230DriverC;
// RealMainP.PlatformInit -> HplRF230C.PlatformInit;
// RealMainP.PlatformInit -> RF230DriverC.PlatformInit;
}
--- NEW FILE: MeasureClockC.nc ---
/*
* Copyright (c) 2006 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
* Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*/
#include <MicaTimer.h>
#include <scale.h>
/**
* Measure cpu clock frequency at boot time. Provides an Atm128Calibrate
* interface so that other components can adjust their calibration as
* needed.
*
* @author David Gay
* @author Janos Sallai
*/
module MeasureClockC {
provides {
/**
* This code MUST be called from PlatformP only, hence the exactlyonce.
*/
interface Init @exactlyonce();
interface Atm128Calibrate;
}
}
implementation
{
enum {
/* This is expected number of cycles per jiffy at the platform's
specified MHz. Assumes PLATFORM_MHZ == 1, 2, 4, 8 or 16. */
MAGIC = 488 / (16 / PLATFORM_MHZ)
};
uint16_t cycles;
command error_t Init.init() {
/* Measure clock cycles per Jiffy (1/32768s) */
/* This code doesn't use the HPL to avoid timing issues when compiling
with debugging on */
atomic
{
uint8_t now, wraps;
uint16_t start;
/* Setup timer2 to count 32 jiffies, and timer1 cpu cycles */
TCCR1B = 1 << CS10;
ASSR = 1 << AS2;
TCCR2B = 1 << CS21 | 1 << CS20;
/* Wait for 1s for counter to stablilize after power-up (yes, it
really does take that long). That's 122 wrap arounds of timer 1
at 8MHz. */
start = TCNT1;
for (wraps = MAGIC / 2; wraps; )
{
uint16_t next = TCNT1;
if (next < start)
wraps--;
start = next;
}
/* Wait for a TCNT0 change */
now = TCNT2;
while (TCNT2 == now) ;
/* Read cpu cycles and wait for next TCNT2 change */
start = TCNT1;
now = TCNT2;
while (TCNT2 == now) ;
cycles = TCNT1;
cycles = (cycles - start + 16) >> 5;
/* Reset to boot state */
ASSR = TCCR1B = TCCR2B = 0;
TCNT2 = 0;
TCNT1 = 0;
TIFR1 = TIFR2 = 0xff;
while (ASSR & (1 << TCN2UB | 1 << OCR2BUB | 1 << TCR2BUB))
;
}
return SUCCESS;
}
async command uint16_t Atm128Calibrate.cyclesPerJiffy() {
return cycles;
}
async command uint32_t Atm128Calibrate.calibrateMicro(uint32_t n) {
return scale32(n + MAGIC / 2, cycles, MAGIC);
}
async command uint32_t Atm128Calibrate.actualMicro(uint32_t n) {
return scale32(n + (cycles >> 1), MAGIC, cycles);
}
async command uint8_t Atm128Calibrate.adcPrescaler() {
/* This is also log2(cycles/3.05). But that's a pain to compute */
if (cycles >= 390)
return ATM128_ADC_PRESCALE_128;
if (cycles >= 195)
return ATM128_ADC_PRESCALE_64;
if (cycles >= 97)
return ATM128_ADC_PRESCALE_32;
if (cycles >= 48)
return ATM128_ADC_PRESCALE_16;
if (cycles >= 24)
return ATM128_ADC_PRESCALE_8;
if (cycles >= 12)
return ATM128_ADC_PRESCALE_4;
return ATM128_ADC_PRESCALE_2;
}
async command uint16_t Atm128Calibrate.baudrateRegister(uint32_t baudrate) {
// value is (cycles*32768) / (8*baudrate) - 1
return ((uint32_t)cycles << 12) / baudrate - 1;
}
}
--- NEW FILE: MicaTimer.h ---
// $Id: MicaTimer.h,v 1.1 2007/11/05 20:37:17 sallai Exp $
/*
* Copyright (c) 2005-2006 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
* Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*/
#ifndef MICATIMER_H
#define MICATIMER_H
/* This file defines the rates at which the mica family's atmega1281 timer 1
and 3 timers run at. The goal is to present the user with microsend and
32khz timers, but it may not be possible to run the timers at these rates
(because of the limited prescaler selection).
So TinyOS picks a prescaler (based on the selected processor MHz) for
each of these timers, and builds corresponding 16-bit alarms&counters
(AlarmOne16C, AlarmThree16C, CounterOne16C, CounterThree16C) over
hardware timers 1 and 3. TinyOS then divides these hardware timers by
the appropriate power of 2 to get approximate 32-bit 32kHz and 1MHz
alarms and counters (Alarm32khz32C, AlarmMicro32C, Counter32khz32C,
CounterMicro32C).
The constants and typedefs for all this configuration are defined here,
based on the value of the MHZ preprocessor symbol, which shoud approximate
the platform's MHZ rate.
Note that the timers thus obtained will not be exactly at 32768Hz or
1MHz, because the clock doesn't divide by a power of two to those
frequencies, and/or the clock frequency is not accurate. If you need
more accurate timing, you should use the calibration functions
offered by the Atm128Calibrate interface provided by PlatformC.
This file also defines EXT_STANDBY_T0_THRESHOLD, a threshold on
remaining time till the next timer 0 interrupt under which the mote
should sleep in ext standby rather than power save. This is only
important when not using the internal oscillator. Wake up from power
save takes 65536 cycles (6 cycles for ext standby), which is, e.g.,
~9.4ms at 7Mhz.
*/
#include <Timer.h>
#include <Atm128Timer.h>
/* Some types for the non-standard rates that mica timers might be running
at.
*/
typedef struct { } T64khz;
typedef struct { } T128khz;
typedef struct { } T2mhz;
typedef struct { } T4mhz;
/* TX is the typedef for the rate of timer X,
MICA_PRESCALER_X is the prescaler for timer X,
MICA_DIVIDER_X_FOR_Y_LOG2 is the number of bits to shift timer X by
to get rate Y,
counter_X_overflow_t is uint16_t if MICA_DIVIDER_X_FOR_Y_LOG2 is 0,
uint32_t otherwise.
*/
#if MHZ == 1
typedef T128khz TOne;
typedef TMicro TThree;
typedef uint32_t counter_one_overflow_t;
typedef uint16_t counter_three_overflow_t;
enum {
MICA_PRESCALER_ONE = ATM128_CLK16_DIVIDE_8,
MICA_DIVIDE_ONE_FOR_32KHZ_LOG2 = 2,
MICA_PRESCALER_THREE = ATM128_CLK16_NORMAL,
MICA_DIVIDE_THREE_FOR_MICRO_LOG2 = 0,
EXT_STANDBY_T0_THRESHOLD = 80,
};
#elif MHZ == 2
typedef T32khz TOne;
typedef T2mhz TThree;
typedef uint16_t counter_one_overflow_t;
typedef uint32_t counter_three_overflow_t;
enum {
MICA_PRESCALER_ONE = ATM128_CLK16_DIVIDE_64,
MICA_DIVIDE_ONE_FOR_32KHZ_LOG2 = 0,
MICA_PRESCALER_THREE = ATM128_CLK16_NORMAL,
MICA_DIVIDE_THREE_FOR_MICRO_LOG2 = 1,
EXT_STANDBY_T0_THRESHOLD = 40
};
#elif MHZ == 4
typedef T64khz TOne;
typedef T4mhz TThree;
typedef uint32_t counter_one_overflow_t;
typedef uint32_t counter_three_overflow_t;
enum {
MICA_PRESCALER_ONE = ATM128_CLK16_DIVIDE_64,
MICA_DIVIDE_ONE_FOR_32KHZ_LOG2 = 1,
MICA_PRESCALER_THREE = ATM128_CLK16_NORMAL,
MICA_DIVIDE_THREE_FOR_MICRO_LOG2 = 2,
EXT_STANDBY_T0_THRESHOLD = 24
};
#elif MHZ == 8
/*
typedef T32khz TOne;
typedef TMicro TThree;
typedef uint16_t counter_one_overflow_t;
typedef uint16_t counter_three_overflow_t;
enum {
MICA_PRESCALER_ONE = ATM128_CLK16_DIVIDE_256,
MICA_DIVIDE_ONE_FOR_32KHZ_LOG2 = 0,
MICA_PRESCALER_THREE = ATM128_CLK16_DIVIDE_8,
MICA_DIVIDE_THREE_FOR_MICRO_LOG2 = 0,
EXT_STANDBY_T0_THRESHOLD = 12
};
*/
// get a 1MHz (1 microsecond resolution) timer for debugging purposes
typedef TMilli TOne;
typedef TMicro TThree;
typedef uint32_t counter_one_overflow_t;
typedef uint16_t counter_three_overflow_t;
enum {
MICA_PRESCALER_ONE = ATM128_CLK16_DIVIDE_8,
MICA_DIVIDE_ONE_FOR_32KHZ_LOG2 = 5,
MICA_PRESCALER_THREE = ATM128_CLK16_DIVIDE_8,
MICA_DIVIDE_THREE_FOR_MICRO_LOG2 = 0,
EXT_STANDBY_T0_THRESHOLD = 12,
};
#else
#error "Unknown clock rate. MHZ must be defined to one of 1, 2, 4, or 8."
#endif
enum {
PLATFORM_MHZ = MHZ
};
#endif
--- NEW FILE: platform.h ---
--- NEW FILE: platform_message.h ---
/* $Id: platform_message.h,v 1.1 2007/11/05 20:37:17 sallai Exp $
* "Copyright (c) 2005 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
* Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*/
/**
* Defining the platform-independently named packet structures to be the
* chip-specific CC1000 packet structures.
*
* @author Philip Levis
* @date May 16 2005
* Revision: $Revision: 1.1 $
*/
#ifndef PLATFORM_MESSAGE_H
#define PLATFORM_MESSAGE_H
#include <DefaultMac.h>
#include <Serial.h>
typedef union message_header {
defaultmac_header_t rf230;
serial_header_t serial;
} message_header_t;
typedef union message_footer {
} message_footer_t;
typedef union message_metadata {
defaultmac_metadata_t rf230;
} message_metadata_t;
#endif
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/diagmsg Assert.h, NONE,
1.1 AssertC.nc, NONE, 1.1 AssertP.nc, NONE, 1.1 DiagMsg.nc,
NONE, 1.1 DiagMsg.txt, NONE, 1.1 DiagMsgC.nc, NONE,
1.1 DiagMsgM.nc, NONE, 1.1 NoDiagMsgC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/iris/chips/rf230
HplRF230.h, NONE, 1.1 HplRF230.nc, NONE, 1.1 HplRF230C.nc,
NONE, 1.1 HplRF230P.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list