X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=blobdiff_plain;f=tos%2Fchips%2Frf2xx%2Frf230%2FRF230DriverHwAckP.nc;h=790e79ed9dff0df02328d912c874f6b5de74d01d;hp=2bd762d394f8d32be60f8275c273157bd1ffff83;hb=3c311f1b2729f43a356b02542a7001db623395e1;hpb=d30405c532321fd306f685545094c57132123e94 diff --git a/tos/chips/rf2xx/rf230/RF230DriverHwAckP.nc b/tos/chips/rf2xx/rf230/RF230DriverHwAckP.nc index 2bd762d3..790e79ed 100644 --- a/tos/chips/rf2xx/rf230/RF230DriverHwAckP.nc +++ b/tos/chips/rf2xx/rf230/RF230DriverHwAckP.nc @@ -186,8 +186,11 @@ implementation PLL_CALIBRATION_TIME = (uint16_t)(180 * RADIO_ALARM_MICROSEC), CCA_REQUEST_TIME = (uint16_t)(140 * RADIO_ALARM_MICROSEC), - TX_SFD_DELAY = (uint16_t)((128 + 5*32 + 16) * RADIO_ALARM_MICROSEC), - RX_SFD_DELAY = (uint16_t)((16 + 32) * RADIO_ALARM_MICROSEC), + // 8 undocumented delay, 128 for CSMA, 16 for delay, 5*32 for preamble and SFD + TX_SFD_DELAY = (uint16_t)((8 + 128 + 16 + 5*32) * RADIO_ALARM_MICROSEC), + + // 32 for frame length, 16 for delay + RX_SFD_DELAY = (uint16_t)((32 + 16) * RADIO_ALARM_MICROSEC), }; tasklet_async event void RadioAlarm.fired() @@ -689,7 +692,18 @@ tasklet_async command uint8_t RadioState.getChannel() if( crcValid && call PacketTimeStamp.isValid(rxMsg) ) { uint32_t time32 = call PacketTimeStamp.timestamp(rxMsg); - time32 -= RX_SFD_DELAY + (length << (RADIO_ALARM_MILLI_EXP - 5)); + length = getHeader(rxMsg)->length; + +/* + * If you hate floating point arithmetics and do not care of up to 400 microsecond time stamping errors, + * then define RF230_HWACK_SLOPPY_TIMESTAMP, which will be significantly faster. + */ +#ifdef RF230_HWACK_SLOPPY_TIMESTAMP + time32 -= (uint16_t)(RX_SFD_DELAY) + ((uint16_t)(length) << (RADIO_ALARM_MILLI_EXP - 5)); +#else + time32 -= (uint16_t)(RX_SFD_DELAY) + (uint16_t)(32.0 * RADIO_ALARM_MICROSEC * (uint16_t)length); +#endif + call PacketTimeStamp.set(rxMsg, time32); }