Merge pull request #444 from simonduq/contrib/rtimer-config

rtimer clock size: more consistent config
This commit is contained in:
Simon Duquennoy 2018-05-12 09:59:38 +02:00 committed by GitHub
commit f93c334ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 25 deletions

View File

@ -57,8 +57,6 @@
typedef uint32_t clock_time_t;
typedef uint32_t uip_stats_t;
typedef uint32_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
/** @} */
/*

View File

@ -79,6 +79,9 @@ typedef long off_t;
/* Our clock resolution, this is the same as Unix HZ. */
#define CLOCK_CONF_SECOND 128UL
/* Use 16-bit rtimer (default in Contiki-NG is 32) */
#define RTIMER_CONF_CLOCK_SIZE 2
typedef int spl_t;
spl_t splhigh_(void);

View File

@ -42,11 +42,7 @@
#include "sys/rtimer.h"
#ifdef RTIMER_CONF_SECOND
#define RTIMER_ARCH_SECOND RTIMER_CONF_SECOND
#else
#define RTIMER_ARCH_SECOND (4096U*8)
#endif
/* Do the math in 32bits to save precision.
* Round to nearest integer rather than truncate. */

View File

@ -113,8 +113,9 @@ typedef unsigned short uip_stats_t;
#define CLOCK_CONF_SECOND 1000L
typedef unsigned long clock_time_t;
typedef uint64_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a,b) ((int64_t)((a)-(b)))
/* Use 64-bit rtimer (default in Contiki-NG is 32) */
#define RTIMER_CONF_CLOCK_SIZE 8
#define RADIO_DELAY_BEFORE_TX 0
#define RADIO_DELAY_BEFORE_RX 0

View File

@ -43,9 +43,6 @@
#include "sys/rtimer.h"
#ifdef RTIMER_CONF_SECOND
# define RTIMER_ARCH_SECOND RTIMER_CONF_SECOND
#else
#if RTIMER_USE_32KHZ
#if JN516X_EXTERNAL_CRYSTAL_OSCILLATOR
#define RTIMER_ARCH_SECOND 32768
@ -56,7 +53,6 @@
/* 32MHz CPU clock => 16MHz timer */
#define RTIMER_ARCH_SECOND (F_CPU / 2)
#endif
#endif
#if RTIMER_USE_32KHZ
#define US_TO_RTIMERTICKS(US) ((US) >= 0 ? \

View File

@ -79,10 +79,6 @@
#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_DIFF is defined */
typedef uint32_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
/* 8ms timer tick */
#define CLOCK_CONF_SECOND 125

View File

@ -55,11 +55,34 @@
#include "contiki.h"
#ifndef RTIMER_CLOCK_DIFF
typedef unsigned short rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a,b) ((signed short)((a)-(b)))
#endif /* RTIMER_CLOCK_DIFF */
/** \brief The rtimer size (in bytes) */
#ifdef RTIMER_CONF_CLOCK_SIZE
#define RTIMER_CLOCK_SIZE RTIMER_CONF_CLOCK_SIZE
#else /* RTIMER_CONF_CLOCK_SIZE */
/* Default: 32bit rtimer*/
#define RTIMER_CLOCK_SIZE 4
#endif /* RTIMER_CONF_CLOCK_SIZE */
#if RTIMER_CLOCK_SIZE == 2
/* 16-bit rtimer */
typedef uint16_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a,b) ((int16_t)((a)-(b)))
#elif RTIMER_CLOCK_SIZE == 4
/* 32-bit rtimer */
typedef uint32_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
#elif RTIMER_CLOCK_SIZE == 8
/* 64-bit rtimer */
typedef uint64_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a,b) ((int64_t)((a)-(b)))
#else
#error Unsupported rtimer size (check RTIMER_CLOCK_SIZE)
#endif
#define RTIMER_CLOCK_MAX ((rtimer_clock_t)-1)
#define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0)
#include "rtimer-arch.h"