Merge pull request #444 from simonduq/contrib/rtimer-config
rtimer clock size: more consistent config
This commit is contained in:
commit
f93c334ef1
@ -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)))
|
||||
/** @} */
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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. */
|
||||
|
@ -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
|
||||
|
@ -43,19 +43,15 @@
|
||||
|
||||
#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
|
||||
# else
|
||||
# define RTIMER_ARCH_SECOND 32000
|
||||
#if JN516X_EXTERNAL_CRYSTAL_OSCILLATOR
|
||||
#define RTIMER_ARCH_SECOND 32768
|
||||
#else
|
||||
#define RTIMER_ARCH_SECOND 32000
|
||||
#endif
|
||||
#else
|
||||
/* 32MHz CPU clock => 16MHz timer */
|
||||
# define RTIMER_ARCH_SECOND (F_CPU / 2)
|
||||
#endif
|
||||
#define RTIMER_ARCH_SECOND (F_CPU / 2)
|
||||
#endif
|
||||
|
||||
#if RTIMER_USE_32KHZ
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user