[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/diku/sensinode/tos/platform/micro4/radio
HALCC2420C.nc, NONE, 1.1 HPLCC2420M.nc, NONE,
1.1 SimpleMacC.nc, NONE, 1.1 cc2420.h, NONE, 1.1 SimpleMac.nc,
NONE, 1.1 SimpleMacM.nc, NONE, 1.1 hplcc2420.h, NONE,
1.1 HALCC2420M.nc, NONE, 1.1 HPLCC2420Status.nc, NONE,
1.1 HALCC2420.nc, NONE, 1.1 packet.h, NONE, 1.1
Marcus Chang
marcus_chang at users.sourceforge.net
Thu Mar 15 07:40:15 PDT 2007
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/diku/sensinode/apps/DataCollector
FIFOBufferManagerM.nc, NONE, 1.1 StatisticsM.nc, NONE,
1.1 Compression.nc, NONE, 1.1 DatasetManagerM.nc, NONE,
1.1 FlashManagerReader.nc, NONE, 1.1 StatisticsReader.nc, NONE,
1.1 ProtocolStarter.nc, NONE, 1.1 CompressionM.nc, NONE,
1.1 FIFOBufferManager.nc, NONE, 1.1 ConnectionM.nc, NONE,
1.1 BufferManager.nc, NONE, 1.1 Connection.nc, NONE,
1.1 FlashManagerC.nc, NONE, 1.1 DatasetManager.nc, NONE,
1.1 Statistics.nc, NONE, 1.1 config.h, NONE,
1.1 FlashManagerM.nc, NONE, 1.1 ProtocolC.nc, NONE,
1.1 SamplingC.nc, NONE, 1.1 BufferManager.h, NONE,
1.1 FlashManagerWriter.nc, NONE, 1.1 StatisticsC.nc, NONE,
1.1 ProtocolM.nc, NONE, 1.1 BufferManagerM.nc, NONE,
1.1 SamplingM.nc, NONE, 1.1 DatasetManager.h, NONE,
1.1 CompressionC.nc, NONE, 1.1 ConnectionC.nc, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/diku/sensinode/tools/make
micro4.target, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/diku/sensinode/tos/platform/micro4/radio
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30685/sensinode/tos/platform/micro4/radio
Added Files:
HALCC2420C.nc HPLCC2420M.nc SimpleMacC.nc cc2420.h
SimpleMac.nc SimpleMacM.nc hplcc2420.h HALCC2420M.nc
HPLCC2420Status.nc HALCC2420.nc packet.h
Log Message:
* Sensinode Micro.4 platform support
* Hoghtrob Data Collection Application
--- NEW FILE: HALCC2420C.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
configuration HALCC2420C {
provides {
interface HALCC2420;
interface StdControl;
}
uses {
interface StdOut;
}
}
implementation {
components HALCC2420M, HPLCC2420M, MSP430InterruptC, HPLSpiM,
BusArbitrationC, HPL1wireM;
StdControl = HALCC2420M.HALCC2420Control;
HALCC2420 = HALCC2420M.HALCC2420;
StdOut = HALCC2420M.StdOut;
HALCC2420M.Spi -> HPLSpiM.Spi;
HALCC2420M.MSP430Interrupt -> MSP430InterruptC.Port17;
HALCC2420M.HPLCC2420Control -> HPLCC2420M.HPLCC2420Control;
HALCC2420M.HPLCC2420 -> HPLCC2420M.HPLCC2420;
HALCC2420M.HPLCC2420RAM -> HPLCC2420M.HPLCC2420RAM;
HALCC2420M.HPLCC2420FIFO -> HPLCC2420M.HPLCC2420FIFO;
HALCC2420M.HPLCC2420Status -> HPLCC2420M.HPLCC2420Status;
HALCC2420M.BusArbitration -> BusArbitrationC.BusArbitration[unique("BusArbitration")];
HALCC2420M.HPL1wire -> HPL1wireM.HPL1wire;
HPLCC2420M.Spi -> HPLSpiM.Spi;
}
--- NEW FILE: HPLCC2420M.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
module HPLCC2420M {
provides {
interface HPLCC2420;
interface HPLCC2420RAM;
interface HPLCC2420FIFO;
interface HPLCC2420Status;
interface StdControl as HPLCC2420Control;
}
uses {
interface Spi;
}
}
implementation {
void cc2420_select()
{
TOSH_SET_RADIO_CSN_PIN();
}
void cc2420_unselect()
{
TOSH_CLR_RADIO_CSN_PIN();
}
/*********************************************************************
*
* HPLCC2420Control interface
*
********************************************************************/
command result_t HPLCC2420Control.init()
{
/* Taken from CC2420_INIT in NanoStack's rf.c */
P5DIR &= ~0x70;
P1DIR &= ~0x80;
P5SEL &= ~0x70;
P1SEL &= ~0x80;
return SUCCESS;
}
command result_t HPLCC2420Control.start()
{
return SUCCESS;
}
command result_t HPLCC2420Control.stop()
{
return SUCCESS;
}
/**
* Zero out the reserved bits since they can be either 0 or 1.
* This allows the use of "if !cmd(x)" in the radio stack
*/
uint8_t adjustStatusByte(uint8_t status) {
return status & 0x7E;
}
async command uint8_t HPLCC2420.cmd(uint8_t addr)
{
uint8_t value;
cc2420_select();
value = call Spi.write(addr);
cc2420_unselect();
return value;
}
async command uint8_t HPLCC2420.write(uint8_t reg, uint16_t data)
{
uint8_t res;
cc2420_select();
res = call Spi.write(reg & 0x3F);
call Spi.write(data >> 8);
call Spi.write(data);
cc2420_unselect();
return adjustStatusByte(res);
}
async command uint16_t HPLCC2420.read(uint8_t reg)
{
uint16_t value;
cc2420_select();
call Spi.write((uint8_t) reg | 0x40);
value = call Spi.write(0);
value <<= 8;
value |= (uint16_t)call Spi.write(0);
cc2420_unselect();
return value;
}
/*********************************************************************
*
* HPLCC2420RAM interface
*
********************************************************************/
norace uint8_t rxramlen;
norace uint16_t rxramaddr;
norace uint8_t* rxrambuf;
task void signalRAMRd() {
signal HPLCC2420RAM.readDone(rxramaddr, rxramlen, rxrambuf);
}
async command result_t HPLCC2420RAM.read(uint16_t addr, uint8_t _length, uint8_t* buffer) {
uint8_t i = 0;
atomic {
rxramaddr = addr;
rxramlen = _length;
rxrambuf = buffer;
}
cc2420_select();
call Spi.write((rxramaddr & 0x7F) | 0x80);
call Spi.write(((rxramaddr >> 1) & 0xC0) | 0x20);
for (i = 0 ; i < rxramlen; i++) {
buffer[i] = call Spi.write(0);
}
cc2420_unselect();
return post signalRAMRd();
}
norace uint8_t* rambuf;
norace uint8_t ramlen;
norace uint16_t ramaddr;
task void signalRAMWr() {
signal HPLCC2420RAM.writeDone(ramaddr, ramlen, rambuf);
}
async command result_t HPLCC2420RAM.write(uint16_t addr, uint8_t _length, uint8_t* buffer) {
uint8_t i;
atomic {
ramaddr = addr;
ramlen = _length;
rambuf = buffer;
}
cc2420_select();
call Spi.write((ramaddr & 0x7F) | 0x80);
call Spi.write(((ramaddr >> 1) & 0xC0));
for (i = 0; i < ramlen; i++) {
call Spi.write(rambuf[i]);
}
cc2420_unselect();
return post signalRAMWr();
}
default async event result_t HPLCC2420RAM.readDone(uint16_t addr,
uint8_t _length,
uint8_t *data)
{
return SUCCESS;
}
default async event result_t HPLCC2420RAM.writeDone(uint16_t addr,
uint8_t _length,
uint8_t *data)
{
return SUCCESS;
}
/*********************************************************************
*
* HPLCC2420FIFO
*
********************************************************************/
norace uint8_t rxlen;
norace uint8_t* rxbuf;
task void signalRXFIFO() {
uint8_t _rxlen;
uint8_t* _rxbuf;
atomic {
_rxlen = rxlen;
_rxbuf = rxbuf;
}
signal HPLCC2420FIFO.RXFIFODone(_rxlen, _rxbuf);
}
async command result_t HPLCC2420FIFO.readRXFIFO(uint8_t length,
uint8_t *data)
{
uint8_t i;
cc2420_select();
rxbuf = data;
call Spi.write(CC_REG_RXFIFO | 0x40);
rxlen = call Spi.write(0) & 0x7F;
if (rxlen > 0) {
rxbuf[0] = rxlen;
rxlen++;
if (rxlen > length) rxlen = length;
for (i = 1 ; i < rxlen; i++) {
rxbuf[i] = call Spi.write(0);
}
}
cc2420_unselect();
return post signalRXFIFO();
}
norace uint8_t txlen;
norace uint8_t* txbuf;
task void signalTXFIFO() {
uint8_t _txlen;
uint8_t* _txbuf;
atomic {
_txlen = txlen;
_txbuf = txbuf;
}
signal HPLCC2420FIFO.TXFIFODone(_txlen, _txbuf);
}
async command result_t HPLCC2420FIFO.writeTXFIFO(uint8_t length, uint8_t *data)
{
uint8_t i;
atomic {
txlen = length;
txbuf = data;
}
cc2420_select();
call Spi.write(CC_REG_TXFIFO);
call Spi.write(txlen);
for (i = 1; i < txlen; i++) {
call Spi.write(txbuf[i]);
}
/* Release the radio */
cc2420_unselect();
return post signalTXFIFO();
}
default async event result_t HPLCC2420FIFO.RXFIFODone(uint8_t _length,
uint8_t *data)
{
return SUCCESS;
}
default async event result_t HPLCC2420FIFO.TXFIFODone(uint8_t _length,
uint8_t *data) {
return SUCCESS;
}
/*********************************************************************
*
* HPLCC2420Status
*
********************************************************************/
async command bool HPLCC2420Status.FIFO()
{
return P5IN & (1 << 5);
}
async command bool HPLCC2420Status.FIFOP()
{
return P5IN & (1 << 6);
}
async command bool HPLCC2420Status.CCA()
{
return P5IN & (1 << 4);
}
async command bool HPLCC2420Status.SFD()
{
return P1IN & (1 << 7);
}
}
--- NEW FILE: SimpleMacC.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
configuration SimpleMacC {
provides {
interface StdControl;
interface SimpleMac;
}
uses {
interface StdOut;
}
}
implementation {
components SimpleMacM, HALCC2420C, LocalTimeMicroC;//, StdNullC;
StdControl = SimpleMacM;
SimpleMac = SimpleMacM;
StdOut = HALCC2420C.StdOut;
StdOut = SimpleMacM.StdOut;
//HALCC2420C.StdOut -> StdNullC;
SimpleMacM.HALCC2420 -> HALCC2420C.HALCC2420;
SimpleMacM.HALCC2420Control -> HALCC2420C.StdControl;
}
--- NEW FILE: cc2420.h ---
enum cc2420_defaults {
CC2420_DEFAULT_CHANNEL = 17, // IEEE channel 11-26
CC2420_DEFAULT_POWER = 100, // Power in procent
};
enum cc2420_error_codes {
// FAIL = 0,
// SUCCESS = 1,
CC2420_ERROR_CCA = 0x02,
CC2420_ERROR_TX = 0x03,
};
--- NEW FILE: SimpleMac.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
includes packet;
interface SimpleMac
{
/**
* sendPacket will perform a CCA, put the device into transmit mode,
* send the packet and return. If the SPI bus is not free or CCA
* fails, the sending of the packet is delayed. The contents
* of packet_t must not be changed after the call to sendPacket.
*
* @param packet_t * packet The packet that should be sent.
* @return result_t If the packet was queued for sending successfully.
*/
command result_t sendPacket(packet_t *packet);
/**
* sendPacketDone is signaled when a packet have been sent successfully.
*
* @param packet_t *packet The packet that have been sent.
* @param result_t result If the packet was sent successfully.
*/
event void sendPacketDone(packet_t *packet, result_t result);
/**
* receivedPacket is signalled when the radio have received a full
* packet. The function must return a free packet_t to the radio
* stack. This can be the same packet that have been signaled
*
* @param packet_t *packet The received packet
* @return packet_t* A free packet
*/
event packet_t *receivedPacket(packet_t *packet);
command result_t setChannel(uint8_t channel);
command result_t setTransmitPower(uint8_t power);
command result_t setAddress(mac_addr_t *addr);
command const mac_addr_t * getAddress();
command const ieee_mac_addr_t * getExtAddress();
command result_t rxEnable();
command result_t rxDisable();
command result_t addressFilterEnable();
command result_t addressFilterDisable();
command result_t setPanAddress(mac_addr_t *addr);
command const mac_addr_t * getPanAddress();
}
--- NEW FILE: SimpleMacM.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
module SimpleMacM {
provides {
interface SimpleMac;
interface StdControl as SimpleMacControl;
}
uses {
interface HALCC2420;
interface StdControl as HALCC2420Control;
interface StdOut;
}
}
implementation {
packet_t receivedPacket;
packet_t * receivedPacketPtr;
const mac_addr_t * shortAddress;
/*************************************************************************************************
*** StdControl
**************************************************************************************************/
task void initTask();
/**********************************************************************
* Init
*********************************************************************/
command result_t SimpleMacControl.init()
{
call HALCC2420Control.init();
post initTask();
receivedPacketPtr = &receivedPacket;
return SUCCESS;
}
task void initTask()
{
shortAddress = call HALCC2420.getAddress();
}
/**********************************************************************
* Start/Stop
*********************************************************************/
command result_t SimpleMacControl.start()
{
return call HALCC2420Control.start();
}
command result_t SimpleMacControl.stop()
{
return call HALCC2420Control.stop();
}
/*************************************************************************************************
*** Transmit related
**************************************************************************************************/
/**********************************************************************
* sendPacket
*********************************************************************/
uint8_t transmitbuffer[128];
packet_t * sendPacketPtr;
command result_t SimpleMac.sendPacket(packet_t * packet)
{
uint8_t i, length;
atomic sendPacketPtr = packet;
/* Repack from packet_t to uint8_t array */
length = packet->length;
transmitbuffer[0] = length;
/* use beacon packets to circumvent 802.15.4 addressing */
/* set bit 0-2 low in FCF to indicate beacon packet */
/* the last 13 bits can be used at leisure */
transmitbuffer[1] = (packet->fcf & 0x00F8); // set bit 0-2 low to indicate beacon packet
transmitbuffer[2] = (packet->fcf >> 8);
transmitbuffer[3] = packet->data_seq_no;
transmitbuffer[4] = (packet->dest & 0x00FF);
transmitbuffer[5] = (packet->dest >> 8);
transmitbuffer[6] = *shortAddress & 0x00FF; // (transmitPacketPtr->src & 0x00FF);
transmitbuffer[7] = *shortAddress >> 8; // (transmitPacketPtr->src >> 8);
for (i = 8; i < length - 1; i++)
{
transmitbuffer[i] = packet->data[i - 8];
}
transmitbuffer[length - 1] = 0; // transmitPacketPtr->fcs.rssi;
transmitbuffer[length] = 0; // transmitPacketPtr->fcs.correlation;
return call HALCC2420.sendPacket(transmitbuffer);
}
result_t sendPacketResult;
task void signalSendPacketDone()
{
result_t tmp;
atomic tmp = sendPacketResult;
signal SimpleMac.sendPacketDone(sendPacketPtr, tmp);
}
async event void HALCC2420.sendPacketDone(uint8_t * packet, result_t result)
{
atomic sendPacketResult = result;
post signalSendPacketDone();
}
/**********************************************************************
* setChannel
*********************************************************************/
command result_t SimpleMac.setChannel(uint8_t channel)
{
return call HALCC2420.setChannel(channel);
}
/**********************************************************************
* setTransmitPower
*********************************************************************/
command result_t SimpleMac.setTransmitPower(uint8_t power)
{
return call HALCC2420.setTransmitPower(power);
}
/**********************************************************************
* rxEnable
*********************************************************************/
command result_t SimpleMac.rxEnable()
{
return call HALCC2420.rxEnable();
}
/**********************************************************************
* rxDisable
*********************************************************************/
command result_t SimpleMac.rxDisable()
{
return call HALCC2420.rxDisable();
}
/*************************************************************************************************
*** Receive related
**************************************************************************************************/
event uint8_t * HALCC2420.receivedPacket(uint8_t * packet)
{
uint8_t length, i;
uint16_t tmp;
/* Repack from uint8_t array to packet_t */
length = packet[0];
receivedPacketPtr->length = length;
tmp = packet[2];
tmp = (tmp << 8) + packet[1];
receivedPacketPtr->fcf = tmp;
receivedPacketPtr->data_seq_no = packet[3];
tmp = packet[5];
tmp = (tmp << 8) + packet[4];
receivedPacketPtr->dest = tmp;
tmp = packet[7];
tmp = (tmp << 8) + packet[6];
receivedPacketPtr->src = tmp;
for (i = 8; i < length - 1; i++)
{
receivedPacketPtr->data[i - 8] = packet[i];
}
receivedPacketPtr->fcs.rssi = packet[length - 1];
receivedPacketPtr->fcs.correlation = packet[length];
receivedPacketPtr = signal SimpleMac.receivedPacket(receivedPacketPtr);
return packet;
}
/*************************************************************************************************
*** Adressing
**************************************************************************************************/
/**********************************************************************
* setShortAddress
*********************************************************************/
command result_t SimpleMac.setAddress(mac_addr_t *addr)
{
return call HALCC2420.setAddress(addr);
}
/**********************************************************************
* getShortAddress
*********************************************************************/
command const mac_addr_t * SimpleMac.getAddress()
{
return call HALCC2420.getAddress();
}
/**********************************************************************
* setPANAddress
*********************************************************************/
command result_t SimpleMac.setPanAddress(mac_addr_t *addr)
{
return call HALCC2420.setPanAddress(addr);
}
/**********************************************************************
* getShortAddress
*********************************************************************/
command const mac_addr_t * SimpleMac.getPanAddress()
{
return call HALCC2420.getPanAddress();
}
/**********************************************************************
* getExtAddress
*********************************************************************/
command const ieee_mac_addr_t * SimpleMac.getExtAddress()
{
return call HALCC2420.getExtAddress();
}
/**********************************************************************
* Hardware Address Filtering
*********************************************************************/
command result_t SimpleMac.addressFilterEnable()
{
return call HALCC2420.addressFilterEnable();
}
command result_t SimpleMac.addressFilterDisable()
{
return call HALCC2420.addressFilterDisable();
}
/*************************************************************************************************
** StdOut
*************************************************************************************************/
async event result_t StdOut.get(uint8_t data) {
return SUCCESS;
}
}
--- NEW FILE: hplcc2420.h ---
typedef enum
{
CC_REG_SNOP =0x00,
CC_REG_SXOSCON =0x01,
CC_REG_STXCAL =0x02,
CC_REG_SRXON =0x03,
CC_REG_STXON =0x04,
CC_REG_STXONCCA =0x05,
CC_REG_SRFOFF =0x06,
CC_REG_SXOSCOFF =0x07,
CC_REG_SFLUSHRX =0x08,
CC_REG_SFLUSHTX =0x09,
CC_REG_SACK =0x0A,
CC_REG_SACKPEND =0x0B,
CC_REG_SRXDEC =0x0C,
CC_REG_STXENC =0x0D,
CC_REG_SAES =0x0E,
CC_REG_MAIN =0x10,
CC_REG_MDMCTRL0 =0x11,
CC_REG_MDMCTRL1 =0x12,
CC_REG_RSSI =0x13,
CC_REG_SYNCWORD =0x14,
CC_REG_TXCTRL =0x15,
CC_REG_RXCTRL0 =0x16,
CC_REG_RXCTRL1 =0x17,
CC_REG_FSCTRL =0x18,
CC_REG_SECCTRL0 =0x19,
CC_REG_SECCTRL1 =0x1A,
CC_REG_BATTMON =0x1B,
CC_REG_IOCFG0 =0x1C,
CC_REG_IOCFG1 =0x1D,
CC_REG_MANFIDL =0x1E,
CC_REG_MANFIDH =0x1F,
CC_REG_FSMTC =0x20,
CC_REG_MANAND =0x21,
CC_REG_MANOR =0x22,
CC_REG_AGCCTRL =0x23,
CC_REG_AGCTST0 =0x24,
CC_REG_AGCTST1 =0x25,
CC_REG_AGCTST2 =0x26,
CC_REG_FSTST0 =0x27,
CC_REG_FSTST1 =0x28,
CC_REG_FSTST2 =0x29,
CC_REG_FSTST3 =0x2A,
CC_REG_RXBPFTST =0x2B,
CC_REG_FSMSTATE =0x2C,
CC_REG_ADCTST =0x2D,
CC_REG_DACTST =0x2E,
CC_REG_TOPTST =0x2F,
CC_REG_RESERVED =0x30,
CC_REG_TXFIFO =0x3E,
CC_REG_RXFIFO =0x3F
}cc2420_reg_t;
typedef enum
{
CC_ADDR_TXFIFO =0x000,
CC_ADDR_RXFIFO =0x080,
CC_ADDR_KEY0 =0x100,
CC_ADDR_RXNONCE =0x110,
CC_ADDR_SABUF =0x120,
CC_ADDR_KEY1 =0x130,
CC_ADDR_TXNONCE =0x140,
CC_ADDR_CBCSTATE =0x150,
CC_ADDR_IEEEADDR =0x160,
CC_ADDR_PANID =0x168,
CC_ADDR_SHORTADDR =0x16A
}cc2420_addr_t;
/*#define CC2420_RSSI_VALID 0x80
#define CC2420_TX_ACTIVE 0x40*/
/*MDMCTRL0 bits*/
#define CC2420_MC0_RESERVED_FRAME_MODE 0x2000
#define CC2420_MC0_PAN_COORDINATOR 0x1000
#define CC2420_MC0_ADDR_DECODE 0x0800
#define CC2420_MC0_CCA_HYST_MASK 0x0700
#define CC2420_MC0_CCA_MODE_MASK 0x00C0
#define CC2420_MC0_CCA_MODE_RSSI 0x0040
#define CC2420_MC0_CCA_MODE_802154 0x0080
#define CC2420_MC0_CCA_MODE_BOTH 0x00C0
#define CC2420_MC0_AUTOCRC 0x0020
#define CC2420_MC0_AUTOACK 0x0010
#define CC2420_MC0_PREAMB_LEN_MASK 0x000F
/*MDMCTRL1 bits*/
#define CC2420_MC1_CORR_THR_MASK 0x07C0
#define CC2420_MC1_DEMOD_AVG_MODE 0x0020
#define CC2420_MC1_MODULATION_MODE 0x0010
#define CC2420_MC1_TX_MODE_MASK 0x000C
#define CC2420_MC1_TX_MODE_BUFFERED 0x0000
#define CC2420_MC1_TX_MODE_SERIAL 0x0001
#define CC2420_MC1_TX_MODE_LOOP 0x0002
#define CC2420_MC1_RX_MODE_MASK 0x0003
#define CC2420_MC1_RX_MODE_BUFFERED 0x0000
#define CC2420_MC1_RX_MODE_SERIAL 0x0001
#define CC2420_MC1_RX_MODE_LOOP 0x0002
#define TXCTRL_INIT 0xA0FF
/* Status byte */
#define CC2420_XOSC16M_STABLE 0x40
#define CC2420_TX_UNDERFLOW 0x20
#define CC2420_ENC_BUSY 0x10
#define CC2420_TX_ACTIVE 0x08
#define CC2420_LOCK 0x04
#define CC2420_RSSI_VALID 0x02
typedef enum
{
CCA_HYST_0DB = 0x00,
CCA_HYST_1DB = 0x01,
CCA_HYST_2DB = 0x02,
CCA_HYST_3DB = 0x03,
CCA_HYST_4DB = 0x04,
CCA_HYST_5DB = 0x05,
CCA_HYST_6DB = 0x06,
CCA_HYST_7DB = 0x07,
} cca_hyst_db_t;
typedef enum
{
LEADING_ZERO_BYTES_1 = 0x00,
LEADING_ZERO_BYTES_2 = 0x01,
LEADING_ZERO_BYTES_3 = 0x02,
LEADING_ZERO_BYTES_4 = 0x03,
LEADING_ZERO_BYTES_5 = 0x04,
LEADING_ZERO_BYTES_6 = 0x05,
LEADING_ZERO_BYTES_7 = 0x06,
LEADING_ZERO_BYTES_8 = 0x07,
LEADING_ZERO_BYTES_9 = 0x08,
LEADING_ZERO_BYTES_10 = 0x09,
LEADING_ZERO_BYTES_11 = 0x0A,
LEADING_ZERO_BYTES_12 = 0x0B,
LEADING_ZERO_BYTES_13 = 0x0C,
LEADING_ZERO_BYTES_14 = 0x0D,
LEADING_ZERO_BYTES_15 = 0x0E,
LEADING_ZERO_BYTES_16 = 0x0F,
} preamble_length_t;
typedef struct
{
preamble_length_t preamble_length : 4;
bool autoack : 1;
bool autocrc : 1;
uint8_t cca_mode : 2;
cca_hyst_db_t cca_hyst : 3;
bool adr_decode : 1;
bool pan_coordinator : 1;
bool reserved_frame_mode : 1;
uint8_t reserved : 2;
} MDMCTRL0_t;
--- NEW FILE: HALCC2420M.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
[...1490 lines suppressed...]
*********************************************************************/
async event result_t HPLCC2420RAM.writeDone(uint16_t addr, uint8_t length, uint8_t* buf)
{
return SUCCESS;
}
async event result_t HPLCC2420RAM.readDone(uint16_t addr, uint8_t length, uint8_t* buf)
{
return SUCCESS;
}
/**********************************************************************
* StdOut
*********************************************************************/
async event result_t StdOut.get(uint8_t data)
{
return SUCCESS;
}
}
--- NEW FILE: HPLCC2420Status.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
interface HPLCC2420Status {
/**
* FIFO retrieves the status of the FIFO pin.
*
* @return bool True if the FIFO pin is high
*/
async command bool FIFO();
/**
* FIFOP retrieves the status of the FIFOP pin.
*
* @return bool True if the FIFOP pin is high
*/
async command bool FIFOP();
/**
* CCA retrieves the status of the CCA pin.
*
* @return bool True if the CCA pin is high
*/
async command bool CCA();
/**
* SFD retrieves the status of the SFD pin.
*
* @return bool True if the SFD pin is high
*/
async command bool SFD();
}
--- NEW FILE: HALCC2420.nc ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
includes cc2420;
interface HALCC2420
{
/**
* sendPacket will perform a CCA, put the device into transmit mode,
* send the packet and return. If the SPI bus is not free or CCA
* fails, the sending of the packet is delayed. The contents
* of the packet must not be changed after the call to sendPacket.
*
* @param uint8_t * packet The packet that should be sent.
* @return result_t If the packet was queued for sending successfully.
*/
command result_t sendPacket(uint8_t * packet);
/**
* sendPacketDone is signaled when a packet have been sent successfully.
*
* @param packet_t *packet The packet that have been sent.
* @param result_t result If the packet was sent successfully.
*/
async event void sendPacketDone(uint8_t * packet, result_t result);
/**
* receivedPacket is signalled when the radio have received a full
* packet. The function must return a free uint8_t * to the radio
* stack. This can be the same packet that have been signaled
*
* @param uint8_t *packet The received packet
* @return uint8_t* A free packet
*/
event uint8_t * receivedPacket(uint8_t * packet);
command result_t setChannel(uint8_t channel);
command result_t setTransmitPower(uint8_t power);
command result_t setAddress(mac_addr_t *addr);
command const mac_addr_t * getAddress();
command const ieee_mac_addr_t * getExtAddress();
command result_t rxEnable();
command result_t rxDisable();
command result_t addressFilterEnable();
command result_t addressFilterDisable();
command result_t setPanAddress(mac_addr_t *addr);
command const mac_addr_t * getPanAddress();
}
--- NEW FILE: packet.h ---
/*
Copyright (C) 2004 Klaus S. Madsen <klaussm at diku.dk>
Copyright (C) 2006 Marcus Chang <marcus at diku.dk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PACKET_H
#define PACKET_H
#define PACKET_MAX_PAYLOAD 122
typedef uint16_t mac_addr_t;
typedef uint8_t ieee_mac_addr_t[8];
/* Frame types */
enum fcf_stuff {
FCF_FT_BEACON = 0x0000,
FCF_FT_DATA = 0x0001,
FCF_FT_ACK = 0x0002,
FCF_FT_MAC_COMMAND = 0x0003,
FCF_FT_MASK = 0x0007,
/* Frame Control Field bits */
FCF_SECENC = 0x0008,
FCF_FRAMEPENDING = 0x0010,
FCF_ACKREQ = 0x0020,
FCF_INTRAPAN = 0x0040,
/* Addressing modes */
FCF_DST_NO_ADDR = 0x0000,
FCF_DST_SHORT_ADDR = 0x0800,
FCF_DST_LONG_ADDR = 0x0C00,
FCF_DST_ADDR_MASK = 0x0C00,
FCF_SRC_NO_ADDR = 0x0000,
FCF_SRC_SHORT_ADDR = 0x8000,
FCF_SRC_LONG_ADDR = 0xC000,
FCF_SRC_ADDR_MASK = 0xC000,
FCS_CRC_OK_MASK = 0x80,
FCS_CORRELATION_MASK = 0x7F,
};
struct packet
{
uint8_t length;
uint16_t fcf;
uint8_t data_seq_no;
mac_addr_t dest;
mac_addr_t src;
uint8_t data[PACKET_MAX_PAYLOAD - 2 * sizeof(mac_addr_t)];
union {
struct {
int8_t rssi;
uint8_t correlation;
};
uint16_t crc;
} fcs;
#ifdef __i386__
} __attribute__ ((packed));
#else
};
#endif
typedef struct packet packet_t;
#endif
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/diku/sensinode/apps/DataCollector
FIFOBufferManagerM.nc, NONE, 1.1 StatisticsM.nc, NONE,
1.1 Compression.nc, NONE, 1.1 DatasetManagerM.nc, NONE,
1.1 FlashManagerReader.nc, NONE, 1.1 StatisticsReader.nc, NONE,
1.1 ProtocolStarter.nc, NONE, 1.1 CompressionM.nc, NONE,
1.1 FIFOBufferManager.nc, NONE, 1.1 ConnectionM.nc, NONE,
1.1 BufferManager.nc, NONE, 1.1 Connection.nc, NONE,
1.1 FlashManagerC.nc, NONE, 1.1 DatasetManager.nc, NONE,
1.1 Statistics.nc, NONE, 1.1 config.h, NONE,
1.1 FlashManagerM.nc, NONE, 1.1 ProtocolC.nc, NONE,
1.1 SamplingC.nc, NONE, 1.1 BufferManager.h, NONE,
1.1 FlashManagerWriter.nc, NONE, 1.1 StatisticsC.nc, NONE,
1.1 ProtocolM.nc, NONE, 1.1 BufferManagerM.nc, NONE,
1.1 SamplingM.nc, NONE, 1.1 DatasetManager.h, NONE,
1.1 CompressionC.nc, NONE, 1.1 ConnectionC.nc, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/diku/sensinode/tools/make
micro4.target, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list