Make rtimer 32-bit by default

This commit is contained in:
Simon Duquennoy 2018-04-20 02:44:58 -07:00
parent cb120e328b
commit ff7c3ee042
6 changed files with 35 additions and 44 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

@ -1,30 +1,30 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef MSP430_DEF_H_
@ -79,6 +79,10 @@ 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) */
typedef unsigned short rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a,b) ((signed short)((a)-(b)))
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

@ -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

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

@ -56,8 +56,9 @@
#include "contiki.h"
#ifndef RTIMER_CLOCK_DIFF
typedef unsigned short rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a,b) ((signed short)((a)-(b)))
/* By default: 32-bit rtimer. Set RTIMER_CLOCK_DIFF for custom rtimer width */
typedef uint32_t rtimer_clock_t;
#define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b)))
#endif /* RTIMER_CLOCK_DIFF */
#define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0)