TSCH: use RTIMER_CLOCK_DIFF to compute estimated drift, fixing a bug that would occur on 16-bit rtimer platforms
This commit is contained in:
parent
5b5f07ba52
commit
bb5e5d5c6b
|
@ -737,7 +737,7 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t))
|
||||||
if(linkaddr_cmp(&destination_address, &linkaddr_node_addr)
|
if(linkaddr_cmp(&destination_address, &linkaddr_node_addr)
|
||||||
|| linkaddr_cmp(&destination_address, &linkaddr_null)) {
|
|| linkaddr_cmp(&destination_address, &linkaddr_null)) {
|
||||||
int do_nack = 0;
|
int do_nack = 0;
|
||||||
estimated_drift = ((int32_t)expected_rx_time - (int32_t)rx_start_time);
|
estimated_drift = RTIMER_CLOCK_DIFF(expected_rx_time, rx_start_time);
|
||||||
|
|
||||||
#if TSCH_TIMESYNC_REMOVE_JITTER
|
#if TSCH_TIMESYNC_REMOVE_JITTER
|
||||||
/* remove jitter due to measurement errors */
|
/* remove jitter due to measurement errors */
|
||||||
|
|
|
@ -55,10 +55,12 @@
|
||||||
|
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
|
|
||||||
#ifndef RTIMER_CLOCK_LT
|
#ifndef RTIMER_CLOCK_DIFF
|
||||||
typedef unsigned short rtimer_clock_t;
|
typedef unsigned short rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a,b) ((signed short)((a)-(b)))
|
||||||
#endif /* RTIMER_CLOCK_LT */
|
#endif /* RTIMER_CLOCK_DIFF */
|
||||||
|
|
||||||
|
#define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0)
|
||||||
|
|
||||||
#include "rtimer-arch.h"
|
#include "rtimer-arch.h"
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef uint32_t clock_time_t;
|
||||||
typedef uint16_t uip_stats_t;
|
typedef uint16_t uip_stats_t;
|
||||||
|
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
|
||||||
rtimer_clock_t rtimer_arch_now(void);
|
rtimer_clock_t rtimer_arch_now(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,8 +55,8 @@ typedef unsigned short uip_stats_t;
|
||||||
|
|
||||||
typedef uint32_t clock_time_t;
|
typedef uint32_t clock_time_t;
|
||||||
|
|
||||||
/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_LT is defined */
|
/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_DIFF is defined */
|
||||||
typedef unsigned long rtimer_clock_t;
|
typedef unsigned long rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a,b) ((signed long)((a)-(b)))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,10 +34,10 @@ typedef uint32_t uip_stats_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
||||||
* RTIMER_CLOCK_LT to override this
|
* RTIMER_CLOCK_DIFF to override this
|
||||||
*/
|
*/
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a,b) ((int32_t)((a)-(b)))
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -201,7 +201,7 @@ typedef unsigned short uip_stats_t;
|
||||||
#define CLOCK_CONF_SECOND 1000L
|
#define CLOCK_CONF_SECOND 1000L
|
||||||
typedef unsigned long clock_time_t;
|
typedef unsigned long clock_time_t;
|
||||||
typedef unsigned long rtimer_clock_t;
|
typedef unsigned long rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a,b) ((signed long)((a)-(b)))
|
||||||
|
|
||||||
#define AODV_COMPLIANCE
|
#define AODV_COMPLIANCE
|
||||||
#define AODV_NUM_RT_ENTRIES 32
|
#define AODV_NUM_RT_ENTRIES 32
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef unsigned long clock_time_t;
|
||||||
|
|
||||||
typedef uint64_t rtimer_clock_t;
|
typedef uint64_t rtimer_clock_t;
|
||||||
#define RTIMER_ARCH_SECOND 1024
|
#define RTIMER_ARCH_SECOND 1024
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((int64_t)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((int64_t)((a) - (b)))
|
||||||
|
|
||||||
/* We define the following macros and types otherwise Contiki does not
|
/* We define the following macros and types otherwise Contiki does not
|
||||||
* compile.
|
* compile.
|
||||||
|
|
|
@ -80,9 +80,9 @@
|
||||||
#define JN516X_EXTERNAL_CRYSTAL_OSCILLATOR (RTIMER_USE_32KHZ || JN516X_SLEEP_ENABLED)
|
#define JN516X_EXTERNAL_CRYSTAL_OSCILLATOR (RTIMER_USE_32KHZ || JN516X_SLEEP_ENABLED)
|
||||||
#endif /* JN516X_EXTERNAL_CRYSTAL_OSCILLATOR */
|
#endif /* JN516X_EXTERNAL_CRYSTAL_OSCILLATOR */
|
||||||
|
|
||||||
/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_LT is defined */
|
/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_DIFF is defined */
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
|
||||||
|
|
||||||
/* 8ms timer tick */
|
/* 8ms timer tick */
|
||||||
#define CLOCK_CONF_SECOND 125
|
#define CLOCK_CONF_SECOND 125
|
||||||
|
|
|
@ -87,7 +87,7 @@ typedef unsigned long clock_time_t;
|
||||||
|
|
||||||
typedef unsigned long rtimer_clock_t;
|
typedef unsigned long rtimer_clock_t;
|
||||||
|
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a,b) ((signed long)((a)-(b)))
|
||||||
|
|
||||||
#define LEDS_CONF_RED_PIN boardDescription->io->leds[1].gpioPin
|
#define LEDS_CONF_RED_PIN boardDescription->io->leds[1].gpioPin
|
||||||
#define LEDS_CONF_GREEN_PIN boardDescription->io->leds[0].gpioPin
|
#define LEDS_CONF_GREEN_PIN boardDescription->io->leds[0].gpioPin
|
||||||
|
|
|
@ -73,10 +73,10 @@ typedef uint32_t uip_stats_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
||||||
* RTIMER_CLOCK_LT to override this
|
* RTIMER_CLOCK_DIFF to override this
|
||||||
*/
|
*/
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -60,7 +60,7 @@ typedef uint16_t uip_stats_t;
|
||||||
typedef uint32_t clock_time_t;
|
typedef uint32_t clock_time_t;
|
||||||
|
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a,b) ((int32_t)((a)-(b)))
|
||||||
|
|
||||||
#define RF_CHANNEL 13
|
#define RF_CHANNEL 13
|
||||||
|
|
||||||
|
|
|
@ -325,10 +325,10 @@ typedef uint32_t uip_stats_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
||||||
* RTIMER_CLOCK_LT to override this
|
* RTIMER_CLOCK_DIFF to override this
|
||||||
*/
|
*/
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* board.h assumes that basic configuration is done */
|
/* board.h assumes that basic configuration is done */
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
#define CLOCK_CONF_SECOND 128
|
#define CLOCK_CONF_SECOND 128
|
||||||
/* One tick: 62.5 ms */
|
/* One tick: 62.5 ms */
|
||||||
|
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((signed short)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((signed short)((a) - (b)))
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
typedef unsigned long clock_time_t;
|
typedef unsigned long clock_time_t;
|
||||||
typedef unsigned long long rtimer_clock_t;
|
typedef unsigned long long rtimer_clock_t;
|
||||||
|
|
|
@ -71,10 +71,10 @@ typedef uint32_t uip_stats_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
* rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
|
||||||
* RTIMER_CLOCK_LT to override this
|
* RTIMER_CLOCK_DIFF to override this
|
||||||
*/
|
*/
|
||||||
typedef uint32_t rtimer_clock_t;
|
typedef uint32_t rtimer_clock_t;
|
||||||
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
|
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue