]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/rf230/RF230LayerP.nc
fix setChannel in SLEEP state
[tinyos-2.x.git] / tos / chips / rf230 / RF230LayerP.nc
index 6ce32074b642cb80ce06d6cf013dbb57437ffc67..4bdfb51257553ada0edb0647951767fea0d66e10 100644 (file)
@@ -60,8 +60,8 @@ module RF230LayerP
                interface PacketField<uint8_t> as PacketRSSI;
                interface PacketField<uint8_t> as PacketTimeSyncOffset;
 
-               interface PacketTimeStamp<TRF230, uint32_t>;
-               interface LocalTime<TRF230>;
+               interface PacketTimeStamp<TRadio, uint32_t>;
+               interface LocalTime<TRadio>;
 
                interface RF230Config;
                interface Tasklet;
@@ -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()
@@ -268,6 +268,11 @@ implementation
 
 /*----------------- CHANNEL -----------------*/
 
+       tasklet_async command uint8_t RadioState.getChannel()
+       {
+               return channel;
+       }
+
        tasklet_async command error_t RadioState.setChannel(uint8_t c)
        {
                c &= RF230_CHANNEL_MASK;
@@ -319,6 +324,9 @@ implementation
                        readRegister(RF230_IRQ_STATUS); // clear the interrupt register
                        call IRQ.captureRisingEdge();
 
+                       // setChannel was ignored in SLEEP because the SPI was not working, so do it here
+                       writeRegister(RF230_PHY_CC_CCA, RF230_CCA_MODE_VALUE | channel);
+
                        writeRegister(RF230_TRX_STATE, RF230_RX_ON);
                        state = STATE_TRX_OFF_2_RX_ON;
                }