[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/eyesIFX/byte_radio
UartManchPhyC.nc, NONE, 1.1.2.1 UartManchPhyP.nc, NONE,
1.1.2.1 RssiFixedThresholdCMC.nc, 1.1.2.4,
1.1.2.5 RssiFixedThresholdCMP.nc, 1.1.2.5, 1.1.2.6 UartPhyC.nc,
1.1.2.5, 1.1.2.6
Philipp Huppertz
phihup at users.sourceforge.net
Tue Sep 12 05:16:36 PDT 2006
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250
HplTda5250ConfigC.nc, 1.1.2.4, 1.1.2.5 HplTda5250ConfigP.nc,
1.1.2.5, 1.1.2.6 Tda5250ActiveMessageP.nc, 1.1.2.4,
1.1.2.5 tda5250_message.h, 1.1.2.4, 1.1.2.5
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/ctp CtpP.nc, 1.1.2.3, 1.1.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/eyesIFX/byte_radio
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11833/tos/platforms/eyesIFX/byte_radio
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
RssiFixedThresholdCMC.nc RssiFixedThresholdCMP.nc UartPhyC.nc
Added Files:
Tag: tinyos-2_0_devel-BRANCH
UartManchPhyC.nc UartManchPhyP.nc
Log Message:
- added Andreas Koepke's improvements and fixes to the tda5250 and /lib/byte_radio
- improved unconnected ASKNFSK pin handling/wireing on eyes
--- NEW FILE: UartManchPhyC.nc ---
/*
* Copyright (c) 2006, 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.
*
* - Description ---------------------------------------------------------
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1.2.1 $
* $Date: 2006/09/12 12:16:31 $
* @author: Philipp Huppertz <huppertz at tkn.tu-berlin.de>
* ========================================================================
*/
/**
* Configuration for the byte radio physical layer. Together with the
* PacketSerializerP the UartPhyP module turns byte streams into packets.
*
* @see PacketSerializerP
*
* @author Philipp Huppertz <huppertz at tkn.tu-berlin.de>
*/
configuration UartManchPhyC
{
provides{
interface PhyPacketTx;
interface RadioByteComm as SerializerRadioByteComm;
interface PhyPacketRx;
interface UartPhyControl;
}
uses {
interface RadioByteComm;
}
}
implementation
{
components
new Alarm32khzC() as RxByteTimer,
UartManchPhyP,
// PlatformLedsC,
MainC;
MainC.SoftwareInit -> UartManchPhyP;
PhyPacketRx = UartManchPhyP;
SerializerRadioByteComm = UartManchPhyP;
RadioByteComm = UartManchPhyP;
PhyPacketTx = UartManchPhyP;
UartPhyControl = UartManchPhyP;
UartManchPhyP.RxByteTimer -> RxByteTimer;
// PlatformLedsC.Led0 <- UartManchPhyP.Led0;
// PlatformLedsC.Led1 <- UartManchPhyP.Led1;
}
--- NEW FILE: UartManchPhyP.nc ---
/* -*- mode:c++; indent-tabs-mode: nil -*-
* Copyright (c) 2004, 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.
*
* - Description ---------------------------------------------------------
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1.2.1 $
* $Date: 2006/09/12 12:16:31 $
* @author: Kevin Klues (klues at tkn.tu-berlin.de)
* @author: Philipp Huppertz <huppertz at tkn.tu-berlin.de>
* ========================================================================
*/
#include "manchester.h"
/**
* Implementation of the physical layer for the eyesIFX byte radio.
* Together with the PacketSerializerP this module turns byte streams
* into packets.
*
* @author Kevin Klues <klues at tkn.tu-berlin.de>
* @author Philipp Huppertz <huppertz at tkn.tu-berlin.de>
*/
module UartManchPhyP {
provides {
interface Init;
interface PhyPacketTx;
interface RadioByteComm as SerializerRadioByteComm;
interface PhyPacketRx;
interface UartPhyControl;
}
uses {
interface RadioByteComm;
interface Alarm<T32khz, uint16_t> as RxByteTimer;
}
}
implementation
{
/* Module Definitions */
typedef enum {
STATE_PREAMBLE,
STATE_PREAMBLE_MANCHESTER,
STATE_SYNC,
STATE_SFD,
STATE_HEADER_DONE,
STATE_DATA_HIGH,
STATE_DATA_LOW,
STATE_FOOTER_START,
STATE_FOOTER_DONE
} phyState_t;
#define PREAMBLE_LENGTH 4
#define BYTE_TIME 18
#define PREAMBLE_BYTE 0x55
#define SYNC_BYTE 0xFF
#define SFD_BYTE 0x50
/** Module Global Variables */
phyState_t phyState; // Current Phy state State
uint16_t preambleCount;
uint16_t numPreambles; // Number of preambles to send before the packet
uint8_t byteTime; // max. time between two bytes
uint8_t bufByte;
/* Local Function Declarations */
void TransmitNextByte();
void ReceiveNextByte(uint8_t data);
/* Radio Init */
command error_t Init.init(){
atomic {
phyState = STATE_PREAMBLE;
numPreambles = PREAMBLE_LENGTH;
byteTime = BYTE_TIME;
}
return SUCCESS;
}
async command error_t UartPhyControl.setNumPreambles(uint16_t numPreambleBytes) {
atomic {
numPreambles = numPreambleBytes;
}
return SUCCESS;
}
command error_t UartPhyControl.setByteTimeout(uint8_t byteTimeout) {
if (call RxByteTimer.isRunning() == TRUE) {
return FAIL;
} else {
atomic byteTime = byteTimeout * 33;
return SUCCESS;
}
}
async command bool UartPhyControl.isBusy() {
return phyState != STATE_PREAMBLE;
}
void resetState() {
atomic {
call RxByteTimer.stop();
switch(phyState) {
case STATE_SYNC:
case STATE_SFD:
signal PhyPacketRx.recvHeaderDone(FAIL);
break;
case STATE_DATA_HIGH:
case STATE_DATA_LOW:
case STATE_FOOTER_START:
signal PhyPacketRx.recvFooterDone(FAIL);
break;
default:
break;
}
phyState = STATE_PREAMBLE;
}
}
async event void RxByteTimer.fired() {
// no bytes have arrived, so...
resetState();
}
async command void PhyPacketTx.sendHeader() {
atomic {
phyState = STATE_PREAMBLE;
preambleCount = numPreambles;
}
TransmitNextByte();
}
async command void SerializerRadioByteComm.txByte(uint8_t data) {
bufByte = data;
call RadioByteComm.txByte(manchesterEncodeNibble((bufByte & 0xf0) >> 4));
phyState = STATE_DATA_LOW;
}
async command bool SerializerRadioByteComm.isTxDone() {
return call RadioByteComm.isTxDone();
}
async command void PhyPacketTx.sendFooter() {
atomic phyState = STATE_FOOTER_START;
TransmitNextByte();
}
/* Radio Recv */
async command void PhyPacketRx.recvFooter() {
// currently there is no footer
// atomic phyState = STATE_FOOTER_START;
atomic {
phyState = STATE_PREAMBLE;
}
call RxByteTimer.stop();
signal PhyPacketRx.recvFooterDone(SUCCESS);
}
/* Tx Done */
async event void RadioByteComm.txByteReady(error_t error) {
if(error == SUCCESS) {
TransmitNextByte();
} else {
atomic {
signal SerializerRadioByteComm.txByteReady(error);
phyState = STATE_PREAMBLE;
}
}
}
void TransmitNextByte() {
atomic {
switch(phyState) {
case STATE_PREAMBLE:
if(preambleCount > 0) {
preambleCount--;
} else {
phyState = STATE_SYNC;
}
call RadioByteComm.txByte(PREAMBLE_BYTE);
break;
case STATE_SYNC:
phyState = STATE_SFD;
call RadioByteComm.txByte(SYNC_BYTE);
break;
case STATE_SFD:
phyState = STATE_HEADER_DONE;
call RadioByteComm.txByte(SFD_BYTE);
break;
case STATE_HEADER_DONE:
phyState = STATE_DATA_HIGH;
signal PhyPacketTx.sendHeaderDone();
break;
case STATE_DATA_HIGH:
signal SerializerRadioByteComm.txByteReady(SUCCESS);
break;
case STATE_DATA_LOW:
call RadioByteComm.txByte(manchesterEncodeNibble(bufByte & 0x0f));
phyState = STATE_DATA_HIGH;
break;
case STATE_FOOTER_START:
/* Pseudo-Footer: the MSP430 has two buffers: one for
* transmit, one to store the next byte to be transmitted,
* this footer fills the next-to-transmit buffer, to make
* sure that the last real byte is actually
* transmitted. The byte stored by this call may not be
* transmitted fully or not at all.
*/
phyState = STATE_FOOTER_DONE;
call RadioByteComm.txByte(manchesterEncodeNibble(bufByte & 0x0f));
break;
case STATE_FOOTER_DONE:
phyState = STATE_PREAMBLE;
signal PhyPacketTx.sendFooterDone();
break;
default:
break;
}
}
}
/* Rx Done */
async event void RadioByteComm.rxByteReady(uint8_t data) {
call RxByteTimer.start(byteTime);
ReceiveNextByte(data);
}
/* Receive the next Byte from the USART */
void ReceiveNextByte(uint8_t data) {
uint8_t decodedByte;
atomic {
switch(phyState) {
case STATE_SYNC:
if(data != PREAMBLE_BYTE) {
if (data == SFD_BYTE) {
signal PhyPacketRx.recvHeaderDone(SUCCESS);
phyState = STATE_DATA_HIGH;
} else {
phyState = STATE_SFD;
}
}
break;
case STATE_SFD:
if (data == SFD_BYTE) {
signal PhyPacketRx.recvHeaderDone(SUCCESS);
phyState = STATE_DATA_HIGH;
} else {
phyState = STATE_PREAMBLE;
}
break;
case STATE_PREAMBLE:
if(data == PREAMBLE_BYTE) {
phyState = STATE_SYNC;
}
else if(manchesterDecodeByte(data) != 0xff) {
phyState = STATE_PREAMBLE_MANCHESTER;
}
break;
case STATE_PREAMBLE_MANCHESTER:
if(data == PREAMBLE_BYTE) {
phyState = STATE_SYNC;
}
else if(manchesterDecodeByte(data) == 0xff) {
phyState = STATE_PREAMBLE;
}
break;
case STATE_DATA_HIGH:
decodedByte = manchesterDecodeByte(data);
if(decodedByte != 0xff) {
bufByte = decodedByte << 4;
phyState = STATE_DATA_LOW;
}
else {
resetState();
}
break;
case STATE_DATA_LOW:
decodedByte = manchesterDecodeByte(data);
if(decodedByte != 0xff) {
bufByte |= decodedByte;
phyState = STATE_DATA_HIGH;
signal SerializerRadioByteComm.rxByteReady(bufByte);
}
else {
resetState();
}
break;
// maybe there will be a time.... we will need this. but for now there is no footer
//case STATE_FOOTER_START:
//phyState = STATE_FOOTER_DONE;
//break;
//case STATE_FOOTER_DONE:
//phyState = STATE_NULL;
//signal PhyPacketRx.recvFooterDone(TRUE);
//break;
default:
break;
}
}
}
}
Index: RssiFixedThresholdCMC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMC.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** RssiFixedThresholdCMC.nc 3 Aug 2006 18:17:52 -0000 1.1.2.4
--- RssiFixedThresholdCMC.nc 12 Sep 2006 12:16:31 -0000 1.1.2.5
***************
*** 51,55 ****
RssiSensorVccC as Rssi,
new BatteryLevelSensorC() as Voltage,
- PlatformLedsC,
new TimerMilliC() as Timer,
MainC;
--- 51,54 ----
***************
*** 66,71 ****
ChannelMonitorData = RssiFixedThresholdCMP;
BatteryLevel = RssiFixedThresholdCMP;
! // RssiFixedThresholdCMP.Led3 -> PlatformLedsC.Led3;
! // RssiFixedThresholdCMP.Led2 -> PlatformLedsC.Led2;
RssiFixedThresholdCMP.Timer -> Timer;
}
--- 65,73 ----
ChannelMonitorData = RssiFixedThresholdCMP;
BatteryLevel = RssiFixedThresholdCMP;
!
! /* components PlatformLedsC;
! RssiFixedThresholdCMP.Led3 -> PlatformLedsC.Led3;
! RssiFixedThresholdCMP.Led2 -> PlatformLedsC.Led2;
! */
RssiFixedThresholdCMP.Timer -> Timer;
}
Index: RssiFixedThresholdCMP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/eyesIFX/byte_radio/RssiFixedThresholdCMP.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** RssiFixedThresholdCMP.nc 3 Aug 2006 18:17:52 -0000 1.1.2.5
--- RssiFixedThresholdCMP.nc 12 Sep 2006 12:16:31 -0000 1.1.2.6
***************
*** 58,63 ****
{
//#define CM_DEBUG // debug...
! /* Measure internal voltage every 5s */
! #define VOLTAGE_SAMPLE_INTERVALL 5000
/*
--- 58,63 ----
{
//#define CM_DEBUG // debug...
! /* Measure internal voltage every 20s */
! #define VOLTAGE_SAMPLE_INTERVALL 20000
/*
***************
*** 85,90 ****
#define THREE_SIGMA 145
! // 93 mV measured against 3V Vcc
! #define INITIAL_BUSY_DELTA 127
// 3000/2 mV measured against 2.5V Ref
--- 85,90 ----
#define THREE_SIGMA 145
! // 92 mV measured against 3V Vcc
! #define INITIAL_BUSY_DELTA 120
// 3000/2 mV measured against 2.5V Ref
***************
*** 150,158 ****
#endif
! int16_t computeSNR() {
uint32_t delta;
uint16_t snr;
- uint16_t r;
- atomic r = rssi;
if(r > noisefloor) {
delta = r - noisefloor;
--- 150,156 ----
#endif
! int16_t computeSNR(uint16_t r) {
uint32_t delta;
uint16_t snr;
if(r > noisefloor) {
delta = r - noisefloor;
***************
*** 246,250 ****
uint16_t bD;
if(result == SUCCESS) {
! nbl = data;
atomic bD = busyDelta;
d = batteryLevel - nbl;
--- 244,248 ----
uint16_t bD;
if(result == SUCCESS) {
! nbl = (data + batteryLevel)>>1;
atomic bD = busyDelta;
d = batteryLevel - nbl;
***************
*** 269,272 ****
--- 267,273 ----
if(res == SUCCESS) state = CCA;
}
+ else if(state == CCA) {
+ res = SUCCESS;
+ }
}
return res;
***************
*** 395,398 ****
--- 396,402 ----
if(res == SUCCESS) state = SNR;
}
+ else if(state == SNR) {
+ res = SUCCESS;
+ }
}
return res;
***************
*** 401,409 ****
task void SnrReadyTask() {
int16_t snr;
! snr = computeSNR();
! atomic state = IDLE;
! signal ChannelMonitorData.getSnrDone(snr);
}
default async event void ChannelMonitorData.getSnrDone(int16_t snr) {
}
--- 405,431 ----
task void SnrReadyTask() {
int16_t snr;
! state_t s;
! uint16_t r;
! atomic {
! r = rssi;
! s = state;
! if(state == SNR) state = IDLE;
! }
! if(s == SNR) {
! snr = computeSNR(r);
! signal ChannelMonitorData.getSnrDone(snr);
! }
}
+ async command uint16_t ChannelMonitorData.readSnr() {
+ uint16_t rval;
+ if(rssi > noisefloor) {
+ rval = (rssi-noisefloor)>>4;
+ } else {
+ rval = 3;
+ }
+ return rval;
+ }
+
default async event void ChannelMonitorData.getSnrDone(int16_t snr) {
}
Index: UartPhyC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/eyesIFX/byte_radio/UartPhyC.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** UartPhyC.nc 3 Aug 2006 18:17:52 -0000 1.1.2.5
--- UartPhyC.nc 12 Sep 2006 12:16:31 -0000 1.1.2.6
***************
*** 37,44 ****
/**
! * Configuration for the byte radio physical layer. Together with the
! * PacketSerializerP the UartPhyP module turns byte streams into packets.
! *
! * @see PacketSerializerP
*
* @author Philipp Huppertz <huppertz at tkn.tu-berlin.de>
--- 37,41 ----
/**
! * UartPhyC
*
* @author Philipp Huppertz <huppertz at tkn.tu-berlin.de>
***************
*** 48,51 ****
--- 45,49 ----
{
provides{
+ interface Init;
interface PhyPacketTx;
interface RadioByteComm as SerializerRadioByteComm;
***************
*** 61,68 ****
components
new Alarm32khzC() as RxByteTimer,
! UartPhyP,
! MainC;
! MainC.SoftwareInit -> UartPhyP;
PhyPacketRx = UartPhyP;
SerializerRadioByteComm = UartPhyP;
--- 59,65 ----
components
new Alarm32khzC() as RxByteTimer,
! UartPhyP;
! Init = UartPhyP;
PhyPacketRx = UartPhyP;
SerializerRadioByteComm = UartPhyP;
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250
HplTda5250ConfigC.nc, 1.1.2.4, 1.1.2.5 HplTda5250ConfigP.nc,
1.1.2.5, 1.1.2.6 Tda5250ActiveMessageP.nc, 1.1.2.4,
1.1.2.5 tda5250_message.h, 1.1.2.4, 1.1.2.5
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/ctp CtpP.nc, 1.1.2.3, 1.1.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list