From: mmaroti Date: Sun, 29 Nov 2009 07:37:10 +0000 (+0000) Subject: move the energy detection to a better place so we can measure the energy of ack frames X-Git-Tag: rc_6_tinyos_2_1_1~124 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=c520bf97bb3dea73573ff5919cf0e3158f7b5670 move the energy detection to a better place so we can measure the energy of ack frames --- diff --git a/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc b/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc index 1365e6a8..b8e7fbb0 100644 --- a/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc +++ b/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc @@ -689,6 +689,17 @@ implementation } #endif +#ifdef RF212_RSSI_ENERGY + if( irq & RF212_IRQ_TRX_END ) + { + if( irq == RF212_IRQ_TRX_END || + (irq == (RF212_IRQ_RX_START | RF212_IRQ_TRX_END) && cmd == CMD_NONE) ) + call PacketRSSI.set(rxMsg, readRegister(RF212_PHY_ED_LEVEL)); + else + call PacketRSSI.clear(rxMsg); + } +#endif + if( irq & RF212_IRQ_PLL_LOCK ) { if( cmd == CMD_TURNON || cmd == CMD_CHANNEL ) @@ -771,12 +782,7 @@ implementation else if( cmd == CMD_RECEIVE ) { ASSERT( state == STATE_RX_ON || state == STATE_PLL_ON_2_RX_ON ); -#ifdef RF212_RSSI_ENERGY - if( irq == RF212_IRQ_TRX_END ) - call PacketRSSI.set(rxMsg, readRegister(RF212_PHY_ED_LEVEL)); - else - call PacketRSSI.clear(rxMsg); -#endif + if( state == STATE_PLL_ON_2_RX_ON ) { ASSERT( (readRegister(RF212_TRX_STATUS) & RF212_TRX_STATUS_MASK) == RF212_PLL_ON ); diff --git a/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc b/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc index 65de3ca5..22c969cb 100644 --- a/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc +++ b/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc @@ -702,6 +702,17 @@ implementation } #endif +#ifdef RF230_RSSI_ENERGY + if( irq & RF230_IRQ_TRX_END ) + { + if( irq == RF230_IRQ_TRX_END || + (irq == (RF230_IRQ_RX_START | RF230_IRQ_TRX_END) && cmd == CMD_NONE) ) + call PacketRSSI.set(rxMsg, readRegister(RF230_PHY_ED_LEVEL)); + else + call PacketRSSI.clear(rxMsg); + } +#endif + if( irq & RF230_IRQ_PLL_LOCK ) { if( cmd == CMD_TURNON || cmd == CMD_CHANNEL ) @@ -784,12 +795,7 @@ implementation else if( cmd == CMD_RECEIVE ) { ASSERT( state == STATE_RX_ON || state == STATE_PLL_ON_2_RX_ON ); -#ifdef RF230_RSSI_ENERGY - if( irq == RF230_IRQ_TRX_END ) - call PacketRSSI.set(rxMsg, readRegister(RF230_PHY_ED_LEVEL)); - else - call PacketRSSI.clear(rxMsg); -#endif + if( state == STATE_PLL_ON_2_RX_ON ) { ASSERT( (readRegister(RF230_TRX_STATUS) & RF230_TRX_STATUS_MASK) == RF230_PLL_ON );