mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-03 22:06:22 +00:00
Stack-friendly cc243x clock ISR enabled by default
This new approach (CLOCK_CONF_ACCURATE=0) was not as inaccurate as originally thought. In fact, it has pretty much the same accuracy as the old, stack-hungry version. * Renamed the define from CLOCK_CONF_ACCURATE (1: old) to CLOCK_CONF_STACK_FRIENDLY (1: new) to stop implying that one is more accurate than the other. * Using CLOCK_CONF_STACK_FRIENDLY by default.
This commit is contained in:
parent
924fe934c1
commit
ce17fa131c
@ -47,15 +47,12 @@
|
|||||||
|
|
||||||
/* Used in sleep timer interrupt for calculating the next interrupt time */
|
/* Used in sleep timer interrupt for calculating the next interrupt time */
|
||||||
static unsigned long timer_value;
|
static unsigned long timer_value;
|
||||||
/*starts calculating the ticks right after reset*/
|
#if CLOCK_CONF_STACK_FRIENDLY
|
||||||
#if CLOCK_CONF_ACCURATE
|
|
||||||
static volatile __data clock_time_t count = 0;
|
|
||||||
#else
|
|
||||||
volatile __data clock_time_t count = 0;
|
|
||||||
/* accurate clock is stack hungry */
|
|
||||||
volatile __bit sleep_flag;
|
volatile __bit sleep_flag;
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
/*calculates seconds*/
|
|
||||||
|
static volatile __data clock_time_t count = 0; /* Uptime in ticks */
|
||||||
static volatile __data clock_time_t seconds = 0; /* Uptime in secs */
|
static volatile __data clock_time_t seconds = 0; /* Uptime in secs */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
@ -152,13 +149,13 @@ clock_ISR(void) __interrupt(ST_VECTOR)
|
|||||||
++seconds;
|
++seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CLOCK_CONF_ACCURATE
|
#if CLOCK_CONF_STACK_FRIENDLY
|
||||||
|
sleep_flag = 1;
|
||||||
|
#else
|
||||||
if(etimer_pending()
|
if(etimer_pending()
|
||||||
&& (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
|
&& (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
|
||||||
etimer_request_poll();
|
etimer_request_poll();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
sleep_flag = 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IRCON_STIF = 0;
|
IRCON_STIF = 0;
|
||||||
|
@ -10,10 +10,12 @@
|
|||||||
#include "project-conf.h"
|
#include "project-conf.h"
|
||||||
#endif /* PROJECT_CONF_H */
|
#endif /* PROJECT_CONF_H */
|
||||||
|
|
||||||
/* The clock ISR is stack-hungry and may cause crashes.
|
/*
|
||||||
* Define this as 0 if you are suffering from frequent stack overflows */
|
* Define this as 1 to poll the etimer process from within main instead of from
|
||||||
#ifndef CLOCK_CONF_ACCURATE
|
* the clock ISR. This reduces the ISR's stack usage and may prevent crashes.
|
||||||
#define CLOCK_CONF_ACCURATE 1
|
*/
|
||||||
|
#ifndef CLOCK_CONF_STACK_FRIENDLY
|
||||||
|
#define CLOCK_CONF_STACK_FRIENDLY 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Memory filesystem RAM size. */
|
/* Memory filesystem RAM size. */
|
||||||
|
@ -54,10 +54,7 @@ static __data int len;
|
|||||||
#define PUTCHAR(...) do {} while(0)
|
#define PUTCHAR(...) do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CLOCK_CONF_STACK_FRIENDLY
|
||||||
#if !CLOCK_CONF_ACCURATE
|
|
||||||
extern volatile __data clock_time_t count;
|
|
||||||
/* accurate clock is stack hungry */
|
|
||||||
extern volatile __bit sleep_flag;
|
extern volatile __bit sleep_flag;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -294,11 +291,10 @@ main(void)
|
|||||||
/* Reset watchdog and handle polls and events */
|
/* Reset watchdog and handle polls and events */
|
||||||
watchdog_periodic();
|
watchdog_periodic();
|
||||||
|
|
||||||
/**/
|
#if CLOCK_CONF_STACK_FRIENDLY
|
||||||
#if !CLOCK_CONF_ACCURATE
|
|
||||||
if(sleep_flag) {
|
if(sleep_flag) {
|
||||||
if(etimer_pending() &&
|
if(etimer_pending() &&
|
||||||
(etimer_next_expiration_time() - count - 1) > MAX_TICKS) { /*core/sys/etimer.c*/
|
(etimer_next_expiration_time() - clock_time() - 1) > MAX_TICKS) {
|
||||||
etimer_request_poll();
|
etimer_request_poll();
|
||||||
}
|
}
|
||||||
sleep_flag = 0;
|
sleep_flag = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user