Ported the stack-friendly clock ISR code over from cc243x to cc253x
This commit is contained in:
parent
11a7f644ac
commit
b3de052e01
3 changed files with 31 additions and 0 deletions
|
@ -47,6 +47,11 @@
|
||||||
/* One clock tick is 7.8 ms */
|
/* One clock tick is 7.8 ms */
|
||||||
#define TICK_VAL (32768/128) /* 256 */
|
#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 */
|
/* Do NOT remove the absolute address and do NOT remove the initialiser here */
|
||||||
__xdata __at(0x0000) static unsigned long timer_value = 0;
|
__xdata __at(0x0000) static unsigned long timer_value = 0;
|
||||||
|
|
||||||
|
@ -158,10 +163,14 @@ clock_isr(void) __interrupt(ST_VECTOR)
|
||||||
++seconds;
|
++seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
STIF = 0; /* IRCON.STIF */
|
STIF = 0; /* IRCON.STIF */
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||||
|
|
|
@ -10,6 +10,14 @@
|
||||||
#include "project-conf.h"
|
#include "project-conf.h"
|
||||||
#endif /* 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 */
|
/* Energest Module */
|
||||||
#ifndef ENERGEST_CONF_ON
|
#ifndef ENERGEST_CONF_ON
|
||||||
#define ENERGEST_CONF_ON 0
|
#define ENERGEST_CONF_ON 0
|
||||||
|
|
|
@ -45,6 +45,10 @@ PROCESS_NAME(viztool_process);
|
||||||
#define PUTCHAR(...) do {} while(0)
|
#define PUTCHAR(...) do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#if CLOCK_CONF_STACK_FRIENDLY
|
||||||
|
extern volatile __bit sleep_flag;
|
||||||
|
#endif
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
extern rimeaddr_t rimeaddr_node_addr;
|
extern rimeaddr_t rimeaddr_node_addr;
|
||||||
static __data int r;
|
static __data int r;
|
||||||
static __data int len;
|
static __data int len;
|
||||||
|
@ -252,6 +256,16 @@ main(void)
|
||||||
do {
|
do {
|
||||||
/* Reset watchdog and handle polls and events */
|
/* Reset watchdog and handle polls and events */
|
||||||
watchdog_periodic();
|
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();
|
r = process_run();
|
||||||
} while(r > 0);
|
} while(r > 0);
|
||||||
len = NETSTACK_RADIO.pending_packet();
|
len = NETSTACK_RADIO.pending_packet();
|
||||||
|
|
Loading…
Reference in a new issue