Ported the stack-friendly clock ISR code over from cc243x to cc253x

This commit is contained in:
George Oikonomou 2012-04-02 17:05:08 +01:00
parent 11a7f644ac
commit b3de052e01
3 changed files with 31 additions and 0 deletions

View File

@ -47,6 +47,11 @@
/* One clock tick is 7.8 ms */
#define TICK_VAL (32768/128) /* 256 */
/*---------------------------------------------------------------------------*/
#if CLOCK_CONF_STACK_FRIENDLY
volatile __bit sleep_flag;
#else
#endif
/*---------------------------------------------------------------------------*/
/* Do NOT remove the absolute address and do NOT remove the initialiser here */
__xdata __at(0x0000) static unsigned long timer_value = 0;
@ -158,10 +163,14 @@ clock_isr(void) __interrupt(ST_VECTOR)
++seconds;
}
#if CLOCK_CONF_STACK_FRIENDLY
sleep_flag = 1;
#else
if(etimer_pending()
&& (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
etimer_request_poll();
}
#endif
STIF = 0; /* IRCON.STIF */
ENERGEST_OFF(ENERGEST_TYPE_IRQ);

View File

@ -10,6 +10,14 @@
#include "project-conf.h"
#endif /* PROJECT_CONF_H */
/*
* Define this as 1 to poll the etimer process from within main instead of from
* the clock ISR. This reduces the ISR's stack usage and may prevent crashes.
*/
#ifndef CLOCK_CONF_STACK_FRIENDLY
#define CLOCK_CONF_STACK_FRIENDLY 1
#endif
/* Energest Module */
#ifndef ENERGEST_CONF_ON
#define ENERGEST_CONF_ON 0

View File

@ -45,6 +45,10 @@ PROCESS_NAME(viztool_process);
#define PUTCHAR(...) do {} while(0)
#endif
/*---------------------------------------------------------------------------*/
#if CLOCK_CONF_STACK_FRIENDLY
extern volatile __bit sleep_flag;
#endif
/*---------------------------------------------------------------------------*/
extern rimeaddr_t rimeaddr_node_addr;
static __data int r;
static __data int len;
@ -252,6 +256,16 @@ main(void)
do {
/* Reset watchdog and handle polls and events */
watchdog_periodic();
#if CLOCK_CONF_STACK_FRIENDLY
if(sleep_flag) {
if(etimer_pending() &&
(etimer_next_expiration_time() - clock_time() - 1) > MAX_TICKS) {
etimer_request_poll();
}
sleep_flag = 0;
}
#endif
r = process_run();
} while(r > 0);
len = NETSTACK_RADIO.pending_packet();