Ejemplo n.º 1
0
/**
 * Initialize the on-chip timer controller. We snag TMU channel 2 in its
 * highest resolution mode, and start it counting down from max_int. 
 */
void timer_init() {
    unsigned int val = byte_read(TSTR);
    byte_write( TSTR, val & (~(1<<TMU_CHANNEL)) ); /* Stop counter */
    long_write( TCOR(TMU_CHANNEL), 0xFFFFFFFF );
    long_write( TCNT(TMU_CHANNEL), 0xFFFFFFFF );
    word_write( TCR(TMU_CHANNEL), 0x00000000 );
}
Ejemplo n.º 2
0
/**
     Initialize the MAC timer.  Called at powerup, or when you
   want to clear all timers.  Sets the timeout for each tick of the
   system clock.
 */
void timerInit(void)
{
    TIMER_INIT();

    // Init the PRNG
    if (NODE_TYPE == ROUTER || NODE_TYPE == COORD)
        srand(TCNT(TICKTIMER));

	TIMER_CLEAR();

    // Enable timer output compare interrupt.  -- Timer starts to interrupt as soon as Global interrup is enabled
    TIMER_ENABLE();
}
Ejemplo n.º 3
0
/**
 * Stop TMU2 and report the current value.
 */
unsigned int timer_stop() {
    long_write( TSTR, long_read(TSTR) & (~(1<<TMU_CHANNEL)) );
    return long_read( TCNT(TMU_CHANNEL) );
}
Ejemplo n.º 4
0
/**
 * Report the current value of TMU2.
 */
unsigned int timer_gettime() {
    return long_read(TCNT(TMU_CHANNEL));
}