Ejemplo n.º 1
0
Archivo: clock.c Proyecto: semigold/582
/*---------------------------------------------------------------------------*/
ISR(TIMER1_A1, timera1)
{
  ENERGEST_ON(ENERGEST_TYPE_IRQ);

  watchdog_start();
  if(TA1IV == 2) {

    /* HW timer bug fix: Interrupt handler called before TR==CCR.
     * Occurs when timer state is toggled between STOP and CONT. */
    while(TA1CTL & MC__CONTINUOUS && TA1CCR1 - TA1R == 1);

    last_tar = read_tar();
    /* Make sure interrupt time is future */
    while(!CLOCK_LT(last_tar, TA1CCR1)) {
      TA1CCR1 += INTERVAL;
      ++count;

      /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure
         that the modulo operation below becomes a logical and and not
         an expensive divide. Algorithm from Wikipedia:
         http://en.wikipedia.org/wiki/Power_of_two */
#if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
#error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
#error Change CLOCK_CONF_SECOND in contiki-conf.h.
#endif
      if(count % CLOCK_CONF_SECOND == 0) {
        ++seconds;
        energest_flush();
      }
      last_tar = read_tar();
    }

    if(etimer_pending() &&
       (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
      etimer_request_poll();
      LPM4_EXIT;
    }

  }
  /*  if(process_nevents() >= 0) {
    LPM4_EXIT;
    }*/

  watchdog_stop();

  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
Ejemplo n.º 2
0
int main(int argc, const char* argv[])
{
    entry_callbacks_t entry_callbacks = { entry_header_cb, 
                                          entry_data_cb,
                                          entry_end_cb };

    if(argc < 2)
    {
        printf("Please provide the file-path of a TAR file.\n\n");
        return -1;
    }

    if(read_tar(argv[1], &entry_callbacks, NULL) != 0)
    {
        printf("Read failed.\n\n");
        return -2;
    }

    return 0;
}