Reincarnate the sensinode/cc2430 port

This commit is contained in:
George Oikonomou 2012-03-05 16:28:06 +00:00
parent c78b5bad5c
commit b7674c3636
114 changed files with 10044 additions and 3068 deletions

View file

@ -46,20 +46,24 @@
#include "sys/clock.h"
#include "sys/etimer.h"
#include "cc2430_sfr.h"
#include "sys/energest.h"
/*Sleep timer runs on the 32k RC osc. */
/* One clock tick is 7.8 ms */
#define TICK_VAL (32768/128)
#define MAX_TICKS (~((clock_time_t)0) / 2)
#define TICK_VAL (32768/128) /* 256 */
/* Used in sleep timer interrupt for calculating the next interrupt time */
static unsigned long timer_value;
/*starts calculating the ticks right after reset*/
static volatile clock_time_t count = 0;
#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;
#endif
/*calculates seconds*/
static volatile clock_time_t seconds = 0;
static volatile __data clock_time_t seconds = 0;
/*---------------------------------------------------------------------------*/
/**
@ -103,7 +107,7 @@ clock_seconds(void)
void
clock_init(void)
{
CLKCON = OSC32K | TICKSPD2|TICKSPD1|TICKSPD0; /*tickspeed 250 kHz*/
CLKCON = OSC32K | TICKSPD2|TICKSPD1; /*tickspeed 500 kHz for timers[1-4]*/
/*Initialize tick value*/
timer_value = ST0; /*sleep timer 0. low bits [7:0]*/
@ -118,9 +122,18 @@ clock_init(void)
}
/*---------------------------------------------------------------------------*/
void
cc2430_clock_ISR( void ) __interrupt (ST_VECTOR)
clock_ISR( void ) __interrupt (ST_VECTOR)
{
IEN0_EA = 0; /*interrupt disable*/
ENERGEST_ON(ENERGEST_TYPE_IRQ);
/*
* If the Sleep timer throws an interrupt while we are powering down to
* PM1, we need to abort the power down. Clear SLEEP.MODE, this will signal
* main() to abort the PM1 transition
*/
SLEEP &= 0xFC;
/* When using the cooperative scheduler the timer 2 ISR is only
required to increment the RTOS tick count. */
@ -148,12 +161,17 @@ cc2430_clock_ISR( void ) __interrupt (ST_VECTOR)
++seconds;
}
#if CLOCK_CONF_ACCURATE
if(etimer_pending() &&
(etimer_next_expiration_time() - count - 1) > MAX_TICKS) { /*core/sys/etimer.c*/
etimer_request_poll();
}
#else
sleep_flag = 1;
#endif
IRCON &= ~STIF; /*IRCON.STIF=Sleep timer interrupt flag. This flag called this interrupt func, now reset it*/
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
IEN0_EA = 1; /*interrupt enable*/
}
/*---------------------------------------------------------------------------*/