[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/telosb
.platform, NONE, 1.1.2.1 DS2411.nc, NONE, 1.1.2.1 DS2411C.nc,
NONE, 1.1.2.1 DS2411M.nc, NONE, 1.1.2.1 DS2411Pin.nc, NONE,
1.1.2.1 DS2411PinC.nc, NONE, 1.1.2.1 DS2411PinM.nc, NONE,
1.1.2.1 README.DS2411, NONE, 1.1.2.1 README_TOOLCHAIN, NONE,
1.1.2.1 build-mspgcc, NONE, 1.3.2.1 hardware.h, NONE, 1.8.2.1
Kristin Wright
kristinwright at users.sourceforge.net
Thu Nov 11 05:43:32 PST 2004
Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/telosb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8305/beta/platform/telosb
Added Files:
Tag: tos-1-1-8-candidate
.platform DS2411.nc DS2411C.nc DS2411M.nc DS2411Pin.nc
DS2411PinC.nc DS2411PinM.nc README.DS2411 README_TOOLCHAIN
build-mspgcc hardware.h
Log Message:
merge with trunk using the tos-1-1-8-postbugfix trunk snapshot
--- NEW FILE: .platform ---
@opts = ();
@commonplatforms = ("telos","msp430");
--- NEW FILE: DS2411.nc ---
//$Id: DS2411.nc,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
/* "Copyright (c) 2000-2003 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."
*/
//@author Cory Sharp <cssharp at eecs.berkeley.edu>
interface DS2411
{
command result_t init();
command void copy_id( uint8_t* id ); // 6 bytes
command uint8_t get_id_byte( uint8_t index );
command uint8_t get_family();
command uint8_t get_crc();
command bool is_crc_okay();
}
--- NEW FILE: DS2411C.nc ---
//$Id: DS2411C.nc,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
/* "Copyright (c) 2000-2003 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."
*/
//@author Cory Sharp <cssharp at eecs.berkeley.edu>
configuration DS2411C
{
provides interface DS2411;
}
implementation
{
components DS2411M, DS2411PinC;
DS2411 = DS2411M;
DS2411M.DS2411Pin -> DS2411PinC.DS2411Pin;
}
--- NEW FILE: DS2411M.nc ---
//$Id: DS2411M.nc,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
/* "Copyright (c) 2000-2003 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."
*/
//@author Cory Sharp <cssharp at eecs.berkeley.edu>
/*
The 1-wire timings suggested by the DS2411 data sheet are incorrect,
incomplete, or unclear. The timings provided the app note 522 work:
http://www.maxim-ic.com/appnotes.cfm/appnote_number/522
*/
module DS2411M
{
provides interface DS2411;
uses interface DS2411Pin;
}
implementation
{
uint8_t m_id[8];
enum
{
STD_A = 6,
STD_B = 64,
STD_C = 60,
STD_D = 10,
STD_E = 9,
STD_F = 55,
STD_G = 0,
STD_H = 480,
STD_I = 90,
STD_J = 220,
};
void init_pins()
{
TOSH_MAKE_ONEWIRE_INPUT();
TOSH_CLR_ONEWIRE_PIN();
}
bool reset() // >= 960us
{
int present;
call DS2411Pin.output_low();
TOSH_uwait(STD_H); //t_RSTL
call DS2411Pin.prepare_read();
TOSH_uwait(STD_I); //t_MSP
present = call DS2411Pin.read();
TOSH_uwait(STD_J); //t_REC
return (present == 0);
}
void write_bit_one() // >= 70us
{
call DS2411Pin.output_low();
TOSH_uwait(STD_A); //t_W1L
call DS2411Pin.output_high();
TOSH_uwait(STD_B); //t_SLOT - t_W1L
}
void write_bit_zero() // >= 70us
{
call DS2411Pin.output_low();
TOSH_uwait(STD_C); //t_W0L
call DS2411Pin.output_high();
TOSH_uwait(STD_D); //t_SLOT - t_W0L
}
void write_bit( int is_one ) // >= 70us
{
if(is_one)
write_bit_one();
else
write_bit_zero();
}
bool read_bit() // >= 70us
{
int bit;
call DS2411Pin.output_low();
TOSH_uwait(STD_A); //t_RL
call DS2411Pin.prepare_read();
TOSH_uwait(STD_E); //near-max t_MSR
bit = call DS2411Pin.read();
TOSH_uwait(STD_F); //t_REC
return bit;
}
void write_byte( uint8_t byte ) // >= 560us
{
uint8_t bit;
for( bit=0x01; bit!=0; bit<<=1 )
write_bit( byte & bit );
}
uint8_t read_byte() // >= 560us
{
uint8_t byte = 0;
uint8_t bit;
for( bit=0x01; bit!=0; bit<<=1 )
{
if( read_bit() )
byte |= bit;
}
return byte;
}
uint8_t crc8_byte( uint8_t crc, uint8_t byte )
{
int i;
crc ^= byte;
for( i=0; i<8; i++ )
{
if( crc & 1 )
crc = (crc >> 1) ^ 0x8c;
else
crc >>= 1;
}
return crc;
}
uint8_t crc8_bytes( uint8_t crc, uint8_t* bytes, uint8_t len )
{
uint8_t* end = bytes+len;
while( bytes != end )
crc = crc8_byte( crc, *bytes++ );
return crc;
}
command result_t DS2411.init() // >= 6000us
{
int retry = 5;
uint8_t id[8];
bzero( m_id, 8 );
call DS2411Pin.init();
while( retry-- > 0 )
{
int crc = 0;
if( reset() )
{
uint8_t* byte;
write_byte(0x33); //read rom
for( byte=id+7; byte!=id-1; byte-- )
crc = crc8_byte( crc, *byte=read_byte() );
if( crc == 0 )
{
memcpy( m_id, id, 8 );
return SUCCESS;
}
}
}
return FAIL;
}
command uint8_t DS2411.get_id_byte( uint8_t index )
{
return (index < 6) ? m_id[index+1] : 0;
}
command void DS2411.copy_id( uint8_t* id )
{
memcpy( id, m_id+1, 6 );
}
command uint8_t DS2411.get_family()
{
return m_id[7];
}
command uint8_t DS2411.get_crc()
{
return m_id[0];
}
uint8_t calc_crc()
{
return crc8_bytes( 0, m_id+1, 7 );
}
command bool DS2411.is_crc_okay()
{
return (call DS2411.get_crc() == calc_crc());
}
}
--- NEW FILE: DS2411Pin.nc ---
//$Id: DS2411Pin.nc,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
/* "Copyright (c) 2000-2003 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."
*/
//@author Cory Sharp <cssharp at eecs.berkeley.edu>
interface DS2411Pin
{
command void init();
command void output_low();
command void output_high();
command void prepare_read();
command uint8_t read(); //zero=0, nonzero=1
}
--- NEW FILE: DS2411PinC.nc ---
//$Id: DS2411PinC.nc,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
/* "Copyright (c) 2000-2003 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."
*/
//@author Cory Sharp <cssharp at eecs.berkeley.edu>
configuration DS2411PinC
{
provides interface DS2411Pin;
}
implementation
{
components DS2411PinM, MSP430GeneralIOC;
DS2411Pin = DS2411PinM;
DS2411PinM.MSP430Pin -> MSP430GeneralIOC.Port24;
}
--- NEW FILE: DS2411PinM.nc ---
//$Id: DS2411PinM.nc,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
/* "Copyright (c) 2000-2003 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."
*/
//@author Cory Sharp <cssharp at eecs.berkeley.edu>
module DS2411PinM
{
provides interface DS2411Pin;
uses interface MSP430GeneralIO as MSP430Pin;
}
implementation
{
command void DS2411Pin.init()
{
call MSP430Pin.selectIOFunc();
call MSP430Pin.makeInput();
call MSP430Pin.setLow();
}
command void DS2411Pin.output_low()
{
call MSP430Pin.makeOutput();
}
command void DS2411Pin.output_high()
{
call MSP430Pin.makeInput();
}
command void DS2411Pin.prepare_read()
{
call MSP430Pin.makeInput();
}
command uint8_t DS2411Pin.read()
{
return call MSP430Pin.getRaw();
}
}
--- NEW FILE: README.DS2411 ---
$Id: README.DS2411,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
README for DS2411
Author/Contact: tinyos-help at millennium.berkeley.edu
@author Cory Sharp <cssharp at eecs.berkeley.edu>
Description:
The DS2411 is a serial ID that provides a distinct, unique 48-bit number.
It is intended to be used in conjunction with a 16-bit IEEE OUI to produce
a unique 64-bit mote identifier number.
The DS2411 uses the 1-Wire protocol. This module has been abstracted to
live in the to-exist tos/chips/ heirarchy. The following interfaces,
configuration, and implementation files are intended to live in
tos/chips/:
DS2411.nc
DS2411C.nc
DS2411M.nc
DS2411Pin.nc
DS2411 defines the interface to the chip, and DS2411M implements the
(hopefully) platform-independent chip-logic. DS2411Pin defines a semantic
interface for iteracting with the DS2411 hardware IO pin. DS2411C in part
wires to the DS2411PinC configuration presumably provided by the platform.
The following configuration and module files must be provided by the
platform:
DS2411PinC.nc
DS2411PinM.nc
DS2411PinC and DS2411PinM implement the basic hardware semantics for
interacting with the DS2411 at the pin level. The more complex DS2411
logic is built given this minimal platform specific implementation.
--- NEW FILE: README_TOOLCHAIN ---
Creating the MSP430 toolchain for the MSP430F161x series of microcontrollers
============================================================================
Joe Polastre <tinyos-help at mail.millennium.berkeley.edu>
$Id: README_TOOLCHAIN,v 1.1.2.1 2004/11/11 13:43:29 kristinwright Exp $
Throughout this document, you will need a place where you intend to store
the MSP430 compiled toolchain (gcc, as, ld, etc). This path is typically
/usr/local/msp430, although it may be any path you choose. Any place in
this document where /usr/local/msp430 is used, change it to the path that
you would like all of the compiled files to exist.
After the release of binutils-1.15, f1611 support was added.
Download the most recent weekly snapshot of binutils from:
ftp://sources.redhat.com/pub/binutils/snapshots/binutils.weekly.tar.bz2
The weekly snapshot was verified on 2004-10-19.
First configure, build and install binutils.
The following commands will unpack the source code
$ tar --bzip2 -xf binutils.weekly.tar.bz2
$ cd binutils-yymmdd (where yymmdd is the date of the snapshot)
Now, for nesC to correctly compile, instruct the assembler to not use
the $ character:
$ perl -i.orig -pe 's/define (LEX_DOLLAR) 0/undef $1/' gas/config/tc-msp430.h
The following commands configure binutils as a cross assembly package,
build, and install it:
$ ./configure --target=msp430 --prefix=/usr/local/msp430
$ make
$ su
$ make install
Next, ensure the directory in which you installed the binutils binary
files is included in your "PATH" variable. The next stage will require
the MSP430 binutils to be functional, when the MSP430 library is compiled.
Download GCC version 3.2.3. It is important that version 3.2.3 is used,
as it most fully supports the MSP430 toolchain.
http://ftp.gnu.org/gnu/gcc/gcc-3.2.3/gcc-core-3.2.3.tar.gz
After downloading:
$ tar --bzip2 -xf gcc-core-3.2.3.tar.bz2
You must now download the MSP430 extensions to the GCC toolchain. They
can be retreived from the mspgcc sourceforge CVS server:
$ cvs -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/mspgcc login
(hit ENTER at the prompt for a password)
$ cvs -z3 -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/mspgcc co gcc
After retreiving the gcc files, perform the following commands to put them
in the extract gcc source directory and create the compiler:
$ cp -a gcc/gcc-3.3/* gcc-3.2.3
$ cd gcc-3.2.3
$ ./configure --target=msp430 --prefix=/usr/local/msp430
$ make
$ su
$ make install
Download msp430-libc from the mspgcc sourceforge CVS server:
$ cvs -z3 -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/mspgcc co msp430-libc
$ cd msp430-libc/src
If you specified something other than "/usr/local/msp430" as the prefix,
when building binutils and GCC, you will need to edit the Makefile.
Change "/usr/local/msp430" to the installation directory you are
actually using. The use the following commands to build and install
the library:
$ make
$ su
$ make install
After this step, all of the sources need to use the f1611 microcontroller
have been completed. Make sure that the directory where all the binaries
are stored, such as /usr/local/msp430/bin, is in your PATH environment
variable.
--- NEW FILE: build-mspgcc ---
#!/bin/bash
#$Id: build-mspgcc,v 1.3.2.1 2004/11/11 13:43:29 kristinwright Exp $
#@author Cory Sharp <cssharp at eecs.berkeley.edu>
OPT="$1"
if [ x$OPT = x ]
then
cat <<"EOF"
usage: build-mspgcc install
$Id: build-mspgcc,v 1.3.2.1 2004/11/11 13:43:29 kristinwright Exp $
build-mspgcc downloads, extracts, builds, and installs binutils, gcc,
and libc for the TI MSP430 microcontroller. As root, run:
./build-mspgcc install
The default installation directory is /opt/msp430. Change this by
setting the environment variable INSTALL_DIR before compiling and
installing:
INSTALL_DIR=/usr/local/msp430 ./build-mspgcc install
All other build options are unsupported.
Unsupported usage: build-mspgcc [command] (package)
commands: get, extract, build, install
packages: MSPGCC_CVS, BINUTILS, GCC, LIBC
environment variables:
INSTALL_DIR
USE_GCC=3.2 or 3.3
- currently 3.3 does not include msp430 1611 support
EOF
exit 0
fi
[ $OPT = get ] && OPT_NUM=1
[ $OPT = extract ] && OPT_NUM=2
[ $OPT = build ] && OPT_NUM=3
[ $OPT = install ] && OPT_NUM=4
[ x$OPT_NUM = x ] && echo "invalid option" && exit 1
PACKAGE="$2"
START_DIR=$PWD
: ${ARCHIVE_DIR:=archive}
: ${BUILD_DIR:=build}
: ${INSTALL_DIR:=/opt/msp430}
# {package}_URL will by default derive
# {package}_ARCHIVE for the tarball, and
# {package}_DIR for the source directory extracted from the tarball
# which can be overridden just by specifying the variable.
# Each package can specify following Bash functions
# {package}_get
# {package}_extact
# {package}_build
# {package}_install
# which take on defaults defined below if unspecified.
BINUTILS_URL="ftp://sources.redhat.com/pub/binutils/snapshots/binutils.weekly.tar.bz2"
GCC32_URL="ftp://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-3.2.3/gcc-core-3.2.3.tar.bz2"
GCC33_URL="ftp://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-3.3.5/gcc-core-3.3.5.tar.bz2"
MSPGCC_CVS_ARCHIVE=mspgcc-cvs.tar.gz
LIBC_ARCHIVE="$MSPGCC_CVS_ARCHIVE"
LIBC_DIR="mspgcc-cvs/msp430-libc/src"
GCC_URL="$GCC32_URL"
[ x$USE_GCC = x3.3 ] && GCC_URL="$GCC33_URL"
### --- binutils
BINUTILS_build() {
perl -i.orig -pe 's/define (LEX_DOLLAR) 0/undef $1/' gas/config/tc-msp430.h || exit 1
./configure --target=msp430 --prefix=$INSTALL_DIR || exit 1
make || exit 1
}
### --- gcc
GCC_build() {
BUILD_BASE="`cd "$START_DIR"; cd "$BUILD_DIR"; echo "$PWD"`"
if [ x$USE_GCC = x3.3 ]
then
cp -a "$BUILD_BASE"/mspgcc-cvs/gcc/gcc-3.4/* .
else
cp -a "$BUILD_BASE"/mspgcc-cvs/gcc/gcc-3.3/* .
fi
GCC_SRCDIR="$PWD"
GCC_OBJDIR="$PWD-obj"
[ -d "$GCC_OBJDIR" ] || mkdir -p "$GCC_OBJDIR"
cd "$GCC_OBJDIR"
"$GCC_SRCDIR"/configure --target=msp430 --prefix="$INSTALL_DIR"
make || exit 1
cd "$GCC_SRCDIR"
}
GCC_install() {
GCC_SRCDIR="$PWD"
GCC_OBJDIR="$PWD-obj"
cd "$GCC_OBJDIR"
make install || exit 1
cd "$GCC_SRCDIR"
}
### --- mspgcc cvs
MSPGCC_CVS_get() {
cd $ARCHIVE_DIR
mkdir -p mspgcc-cvs
cd mspgcc-cvs
if [ -f $HOME/.cvspass ] && grep -q -F ':pserver:anonymous at cvs.sf.net:' $HOME/.cvspass
then
:
else
echo
echo "*** Logging into SourceForge for anonymous CVS access."
echo "*** Press ENTER when prompted for a password."
echo
cvs -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/mspgcc login
fi
cvs -z3 -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/mspgcc export -D now gcc msp430-libc
cd $START_DIR
cd $ARCHIVE_DIR
tar cfvz $MSPGCC_CVS_ARCHIVE mspgcc-cvs
rm -rf mspgcc-cvs
cd $START_DIR
}
MSPGCC_CVS_build() {
true
}
MSPGCC_CVS_install() {
true
}
### --- libc cvs
LIBC_get() {
MSPGCC_CVS_get
}
LIBC_build() {
[ -d msp1 ] || mkdir msp1
[ -d msp2 ] || mkdir msp2
perl -i.orig -pe 's{^(prefix\s*=\s*)(.*)}{${1}'"$INSTALL_DIR"'}' Makefile
make || exit 1
}
### --- defaults for get, extract, build, install
default_get() {
get_url "$1" "$2" || exit 1
}
default_extract() {
extract_tarx "$1" "$2" || exit 1
}
default_build() {
make || exit 1
}
default_install() {
make install || exit 1
}
### ---
### ---
### ---
is_dir_in_path() {
perl -e '@p=split /:/, $ENV{PATH}; @g=grep { $_ eq "'"$1"'" } @p; exit (@g?0:1);'
}
get_url() {
wget "$1" -O "$2"
}
tar_compress_opt() {
[ ${1##*gz}x == x ] && echo z && return
[ ${1##*bz2}x == x ] && echo j && return
}
tar_topdir() {
tar -tv`tar_compress_opt $1`f "$1" 2>/dev/null \
| perl -e 'print $1 if <> =~ /^(?:\S+\s+){5}([^\/\n]+)/'
}
extract_tarx() {
[ -d "$2" ] || mkdir -p "$2"
tar -xv`tar_compress_opt $1`f "$1" -C "$2"
}
get_pkg_function() {
type "${1}_$2" >/dev/null 2>/dev/null && echo "${1}_$2" && return
echo "default_$2"
}
process_package() {
PKG="$1"
echo
echo "processing $PKG"
### get
if [ $OPT_NUM -ge 1 ]
then
eval PKG_URL="\$${PKG}_URL"
eval PKG_ARCHIVE="\$${PKG}_ARCHIVE"
[ x"$PKG_ARCHIVE" = x ] && PKG_ARCHIVE="${PKG_URL##*/}"
[ -d "$ARCHIVE_DIR" ] || mkdir -p "$ARCHIVE_DIR" || exit 1
WORK_FILE="$ARCHIVE_DIR/$PKG_ARCHIVE"
if [ -f "$WORK_FILE" ]
then
echo "download $PKG: found $WORK_FILE, skipping download"
else
echo "download $PKG: downloading $WORK_FILE"
eval `get_pkg_function $PKG get` "$PKG_URL" "$WORK_FILE"
fi
fi
### extract
if [ $OPT_NUM -ge 2 ]
then
eval PKG_DIR="\$${PKG}_DIR"
[ x"$PKG_DIR" = x ] && PKG_DIR=`tar_topdir "$WORK_FILE"`
[ -d "$BUILD_DIR" ] || mkdir -p "$BUILD_DIR" || exit 1
WORK_DIR="$BUILD_DIR/$PKG_DIR"
if [ -d "$WORK_DIR" ]
then
echo "found $WORK_DIR, skipping decompress"
else
echo "decompressing $WORK_FILE to $WORK_DIR"
eval `get_pkg_function $PKG extract` "$WORK_FILE" "$BUILD_DIR"
fi
fi
### build
if [ $OPT_NUM -ge 3 ]
then
BUILD_COMPLETE="$WORK_DIR/build-complete"
if [ -f "$BUILD_COMPLETE" ]
then
echo "found $BUILD_COMPLETE, skipping build"
else
echo "building $PKG"
cd "$WORK_DIR"
eval `get_pkg_function $PKG build`
cd "$START_DIR"
touch "$BUILD_COMPLETE"
fi
fi
### install
if [ $OPT_NUM -ge 4 ]
then
echo "installing $PKG"
cd "$WORK_DIR"
eval `get_pkg_function $PKG install`
cd "$START_DIR"
fi
}
### ---
export PATH="$INSTALL_DIR/bin:$PATH"
if [ x$PACKAGE = x ]
then
process_package MSPGCC_CVS
process_package BINUTILS
process_package GCC
process_package LIBC
else
process_package $PACKAGE
fi
--- NEW FILE: hardware.h ---
#ifndef _H_hardware_h
#define _H_hardware_h
#include "msp430hardware.h"
#include "MSP430ADC12.h"
#include "CC2420Const.h"
#include "AM.h"
// LEDs
TOSH_ASSIGN_PIN(RED_LED, 5, 4);
TOSH_ASSIGN_PIN(GREEN_LED, 5, 5);
TOSH_ASSIGN_PIN(YELLOW_LED, 5, 6);
// CC2420 RADIO #defines
TOSH_ASSIGN_PIN(RADIO_CSN, 4, 2);
TOSH_ASSIGN_PIN(RADIO_VREF, 4, 5);
TOSH_ASSIGN_PIN(RADIO_RESET, 4, 6);
TOSH_ASSIGN_PIN(RADIO_FIFOP, 1, 0);
TOSH_ASSIGN_PIN(RADIO_SFD, 4, 1);
TOSH_ASSIGN_PIN(RADIO_GIO0, 1, 3);
TOSH_ASSIGN_PIN(RADIO_FIFO, 1, 3);
TOSH_ASSIGN_PIN(RADIO_GIO1, 1, 4);
TOSH_ASSIGN_PIN(RADIO_CCA, 1, 4);
TOSH_ASSIGN_PIN(CC_FIFOP, 1, 0);
TOSH_ASSIGN_PIN(CC_FIFO, 1, 3);
TOSH_ASSIGN_PIN(CC_SFD, 4, 1);
TOSH_ASSIGN_PIN(CC_VREN, 4, 5);
TOSH_ASSIGN_PIN(CC_RSTN, 4, 6);
// UART pins
TOSH_ASSIGN_PIN(SOMI0, 3, 2);
TOSH_ASSIGN_PIN(SIMO0, 3, 1);
TOSH_ASSIGN_PIN(UCLK0, 3, 3);
TOSH_ASSIGN_PIN(UTXD0, 3, 4);
TOSH_ASSIGN_PIN(URXD0, 3, 5);
TOSH_ASSIGN_PIN(UTXD1, 3, 6);
TOSH_ASSIGN_PIN(URXD1, 3, 7);
TOSH_ASSIGN_PIN(UCLK1, 5, 3);
TOSH_ASSIGN_PIN(SOMI1, 5, 2);
TOSH_ASSIGN_PIN(SIMO1, 5, 1);
// ADC
TOSH_ASSIGN_PIN(ADC0, 6, 0);
TOSH_ASSIGN_PIN(ADC1, 6, 1);
TOSH_ASSIGN_PIN(ADC2, 6, 2);
TOSH_ASSIGN_PIN(ADC3, 6, 3);
// HUMIDITY
TOSH_ASSIGN_PIN(HUM_SDA, 1, 5);
TOSH_ASSIGN_PIN(HUM_SCL, 1, 6);
TOSH_ASSIGN_PIN(HUM_PWR, 1, 7);
// GIO pins
TOSH_ASSIGN_PIN(GIO0, 2, 0);
TOSH_ASSIGN_PIN(GIO1, 2, 1);
TOSH_ASSIGN_PIN(GIO2, 2, 3);
TOSH_ASSIGN_PIN(GIO3, 2, 6);
// 1-Wire
TOSH_ASSIGN_PIN(ONEWIRE, 2, 4);
void HUMIDITY_MAKE_CLOCK_OUTPUT() { TOSH_MAKE_HUM_SCL_OUTPUT(); }
void HUMIDITY_MAKE_CLOCK_INPUT() { TOSH_MAKE_HUM_SCL_INPUT(); }
void HUMIDITY_CLEAR_CLOCK() { TOSH_CLR_HUM_SCL_PIN(); }
void HUMIDITY_SET_CLOCK() { TOSH_SET_HUM_SCL_PIN(); }
void HUMIDITY_MAKE_DATA_OUTPUT() { TOSH_MAKE_HUM_SDA_OUTPUT(); }
void HUMIDITY_MAKE_DATA_INPUT() { TOSH_MAKE_HUM_SDA_INPUT(); }
void HUMIDITY_CLEAR_DATA() { TOSH_CLR_HUM_SDA_PIN(); }
void HUMIDITY_SET_DATA() { TOSH_SET_HUM_SDA_PIN(); }
char HUMIDITY_GET_DATA() { return TOSH_READ_HUM_SDA_PIN(); }
#define HUMIDITY_TIMEOUT_MS 30
#define HUMIDITY_TIMEOUT_TRIES 20
enum {
// Sensirion Humidity addresses and commands
TOSH_HUMIDITY_ADDR = 5,
TOSH_HUMIDTEMP_ADDR = 3,
TOSH_HUMIDITY_RESET = 0x1E
};
// FLASH
TOSH_ASSIGN_PIN(FLASH_PWR, 4, 3);
TOSH_ASSIGN_PIN(FLASH_CS, 4, 4);
TOSH_ASSIGN_PIN(FLASH_HOLD, 4, 7);
// PROGRAMMING PINS (tri-state)
//TOSH_ASSIGN_PIN(TCK, );
TOSH_ASSIGN_PIN(PROG_RX, 1, 1);
TOSH_ASSIGN_PIN(PROG_TX, 2, 2);
// send a bit via bit-banging to the flash
void TOSH_FLASH_M25P_DP_bit(bool set) {
if (set)
TOSH_SET_SIMO0_PIN();
else
TOSH_CLR_SIMO0_PIN();
TOSH_SET_UCLK0_PIN();
TOSH_CLR_UCLK0_PIN();
}
// put the flash into deep sleep mode
// important to do this by default
void TOSH_FLASH_M25P_DP() {
// SIMO0, UCLK0
TOSH_MAKE_SIMO0_OUTPUT();
TOSH_MAKE_UCLK0_OUTPUT();
TOSH_MAKE_FLASH_HOLD_OUTPUT();
TOSH_MAKE_FLASH_CS_OUTPUT();
TOSH_SET_FLASH_HOLD_PIN();
TOSH_SET_FLASH_CS_PIN();
TOSH_wait();
// initiate sequence;
TOSH_CLR_FLASH_CS_PIN();
TOSH_CLR_UCLK0_PIN();
TOSH_FLASH_M25P_DP_bit(TRUE); // 0
TOSH_FLASH_M25P_DP_bit(FALSE); // 1
TOSH_FLASH_M25P_DP_bit(TRUE); // 2
TOSH_FLASH_M25P_DP_bit(TRUE); // 3
TOSH_FLASH_M25P_DP_bit(TRUE); // 4
TOSH_FLASH_M25P_DP_bit(FALSE); // 5
TOSH_FLASH_M25P_DP_bit(FALSE); // 6
TOSH_FLASH_M25P_DP_bit(TRUE); // 7
TOSH_SET_FLASH_CS_PIN();
TOSH_SET_SIMO0_PIN();
TOSH_MAKE_SIMO0_INPUT();
TOSH_MAKE_UCLK0_INPUT();
TOSH_CLR_FLASH_HOLD_PIN();
}
// need to undef atomic inside header files or nesC ignores the directive
#undef atomic
void TOSH_SET_PIN_DIRECTIONS(void)
{
// reset all of the ports to be input and using i/o functionality
atomic
{
P1SEL = 0;
P2SEL = 0;
P3SEL = 0;
P4SEL = 0;
P5SEL = 0;
P6SEL = 0;
P1DIR = 0;
P2DIR = 0;
P3DIR = 0;
P4DIR = 0;
P5DIR = 0;
P6DIR = 0;
P1IE = 0;
P2IE = 0;
//{ MSP430REG_NORACE2(p,P1IE); p=0; }
//{ MSP430REG_NORACE2(p,P2IE); p=0; }
//LEDS
TOSH_SET_RED_LED_PIN();
TOSH_SET_GREEN_LED_PIN();
TOSH_SET_YELLOW_LED_PIN();
TOSH_MAKE_RED_LED_OUTPUT();
TOSH_MAKE_GREEN_LED_OUTPUT();
TOSH_MAKE_YELLOW_LED_OUTPUT();
//1-Wire PINS
TOSH_SET_ONEWIRE_PIN();
TOSH_MAKE_ONEWIRE_OUTPUT();
//RADIO PINS
//CC2420 pins
TOSH_SET_RADIO_RESET_PIN();
TOSH_MAKE_RADIO_RESET_OUTPUT();
TOSH_CLR_RADIO_VREF_PIN();
TOSH_MAKE_RADIO_VREF_OUTPUT();
TOSH_SET_RADIO_CSN_PIN();
TOSH_MAKE_RADIO_CSN_OUTPUT();
//FLASH PINS
TOSH_MAKE_FLASH_PWR_OUTPUT();
TOSH_SET_FLASH_PWR_PIN();
TOSH_MAKE_FLASH_CS_OUTPUT();
TOSH_SET_FLASH_CS_PIN();
TOSH_MAKE_FLASH_HOLD_OUTPUT();
TOSH_CLR_FLASH_HOLD_PIN();
//Put the flash in deep sleep state
TOSH_FLASH_M25P_DP();
//HUMIDITY PINS
TOSH_MAKE_HUM_SCL_OUTPUT();
TOSH_MAKE_HUM_SDA_OUTPUT();
TOSH_MAKE_HUM_PWR_OUTPUT();
TOSH_CLR_HUM_SCL_PIN();
TOSH_CLR_HUM_SDA_PIN();
TOSH_CLR_HUM_PWR_PIN();
}//atomic
}
#ifndef SENSORBOARD_H
#define SENSORBOARD_H
enum {
TOSH_ADC_PORTMAPSIZE = 4 // default board has no sensors hooked up
};
enum
{
TOSH_ACTUAL_ADC_PAR_PORT = ASSOCIATE_ADC_CHANNEL(
INPUT_CHANNEL_A4, REFERENCE_VREFplus_AVss, REFVOLT_LEVEL_1_5
),
TOSH_ACTUAL_ADC_TSR_PORT = ASSOCIATE_ADC_CHANNEL(
INPUT_CHANNEL_A5, REFERENCE_VREFplus_AVss, REFVOLT_LEVEL_1_5
),
};
enum
{
TOS_ADC_PAR_PORT,
TOS_ADC_TSR_PORT,
TOS_ADC_INTERNAL_TEMP_PORT,
TOS_ADC_INTERNAL_VOLTAGE_PORT
};
#endif // SENSORBOARD_H
#endif // _H_hardware_h
More information about the Tinyos-beta-commits
mailing list