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:
Simon Duquennoy 2016-04-23 00:19:21 +02:00 committed by Simon Duquennoy
parent 5b5f07ba52
commit bb5e5d5c6b
14 changed files with 24 additions and 22 deletions

View File

@ -737,7 +737,7 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t))
if(linkaddr_cmp(&destination_address, &linkaddr_node_addr)
|| linkaddr_cmp(&destination_address, &linkaddr_null)) {
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
/* remove jitter due to measurement errors */

View File

@ -55,10 +55,12 @@
#include "contiki-conf.h"
#ifndef RTIMER_CLOCK_LT
#ifndef RTIMER_CLOCK_DIFF
typedef unsigned short rtimer_clock_t;
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#endif /* RTIMER_CLOCK_LT */
#define RTIMER_CLOCK_DIFF(a,b) ((signed short)((a)-(b)))
#endif /* RTIMER_CLOCK_DIFF */
#define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0)
#include "rtimer-arch.h"

View File

@ -46,7 +46,7 @@ typedef uint32_t clock_time_t;
typedef uint16_t uip_stats_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);
#endif

View File

@ -55,8 +55,8 @@ typedef unsigned short uip_stats_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;
#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define RTIMER_CLOCK_DIFF(a,b) ((signed long)((a)-(b)))
#endif

View File

@ -34,10 +34,10 @@ typedef uint32_t uip_stats_t;
/*
* 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;
#define RTIMER_CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0)
#define RTIMER_CLOCK_DIFF(a,b) ((int32_t)((a)-(b)))
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -201,7 +201,7 @@ typedef unsigned short uip_stats_t;
#define CLOCK_CONF_SECOND 1000L
typedef unsigned long clock_time_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_NUM_RT_ENTRIES 32

View File

@ -46,7 +46,7 @@ typedef unsigned long clock_time_t;
typedef uint64_t rtimer_clock_t;
#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
* compile.

View File

@ -80,9 +80,9 @@
#define JN516X_EXTERNAL_CRYSTAL_OSCILLATOR (RTIMER_USE_32KHZ || JN516X_SLEEP_ENABLED)
#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;
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
/* 8ms timer tick */
#define CLOCK_CONF_SECOND 125

View File

@ -87,7 +87,7 @@ typedef unsigned long clock_time_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_GREEN_PIN boardDescription->io->leds[0].gpioPin

View File

@ -73,10 +73,10 @@ typedef uint32_t uip_stats_t;
/*
* 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;
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
/** @} */
/*---------------------------------------------------------------------------*/
/**

View File

@ -60,7 +60,7 @@ typedef uint16_t uip_stats_t;
typedef uint32_t clock_time_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

View File

@ -325,10 +325,10 @@ typedef uint32_t uip_stats_t;
/*
* 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;
#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 */

View File

@ -78,7 +78,7 @@
#define CLOCK_CONF_SECOND 128
/* 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 long rtimer_clock_t;

View File

@ -71,10 +71,10 @@ typedef uint32_t uip_stats_t;
/*
* 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;
#define RTIMER_CLOCK_LT(a, b) ((int32_t)((a) - (b)) < 0)
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
/** @} */
/*---------------------------------------------------------------------------*/
/**