]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/rf230/RF230LayerP.nc
Proper MSP_BSL_FLAGS for telosa and telosb based platforms using TMI modular tos...
[tinyos-2.x.git] / tos / chips / rf230 / RF230LayerP.nc
index a6acb2b34ab2a77d90a33f066f50a207ce49bc99..4ba79fca8bf74f60d948f3f78c71a38f29e0186e 100644 (file)
@@ -150,11 +150,11 @@ implementation
 
        enum
        {
-               SLEEP_WAKEUP_TIME = (uint16_t)(880 * RF230_ALARM_MICROSEC),
-               CCA_REQUEST_TIME = (uint16_t)(140 * RF230_ALARM_MICROSEC),
+               SLEEP_WAKEUP_TIME = (uint16_t)(880 * RF230_ALARM_SEC / 1000000UL),
+               CCA_REQUEST_TIME = (uint16_t)(140 * RF230_ALARM_SEC / 1000000UL),
 
-               TX_SFD_DELAY = (uint16_t)(176 * RF230_ALARM_MICROSEC),
-               RX_SFD_DELAY = (uint16_t)(8 * RF230_ALARM_MICROSEC),
+               TX_SFD_DELAY = (uint16_t)(176 * RF230_ALARM_SEC / 1000000UL),
+               RX_SFD_DELAY = (uint16_t)(8 * RF230_ALARM_SEC / 1000000UL),
        };
 
        tasklet_async event void RadioAlarm.fired()
@@ -696,17 +696,15 @@ implementation
                                        if( irq == RF230_IRQ_RX_START )
                                        {
                                                temp = readRegister(RF230_PHY_RSSI) & RF230_RSSI_MASK;
-
                                                rssiBusy += temp - (rssiBusy >> 2);
-
-#ifdef RF230_RSSI_ENERGY
-                                               temp = readRegister(RF230_PHY_ED_LEVEL);
-#endif
-
+#ifndef RF230_RSSI_ENERGY
                                                call PacketRSSI.set(rxMsg, temp);
                                        }
                                        else
+                                       {
                                                call PacketRSSI.clear(rxMsg);
+#endif
+                                       }
 
                                        /*
                                         * The timestamp corresponds to the first event which could not
@@ -747,7 +745,12 @@ 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 );