Beispiel #1
0
static void
bridge_set_poll_ticks(int poll_ticks)
{
	if (bridge_data_timer != NULL)
		timer_stop(bridge_data_timer);

	bridge_poll_ticks = poll_ticks;
	bridge_data_timer = timer_start_repeat(bridge_poll_ticks,
	    bridge_poll_ticks, bridge_update_all, NULL, bridge_module);
}
Beispiel #2
0
// Stop the oneway application
void oneway_stop () {
    if (_config.my_role == TAG) {
        if (_config.update_mode == ONEWAY_UPDATE_MODE_PERIODIC) {
            timer_stop(_app_timer);
        }
        oneway_tag_stop();
    } else if (_config.my_role == ANCHOR) {
        oneway_anchor_stop();
    }
}
Beispiel #3
0
/*
 * Untimeout the timers for the thread termination.
 */
void
timer_cancel(thread_t t)
{

	if (t->periodic != NULL) {
		timer_stop(t->periodic);
		kmem_free(t->periodic);
		t->periodic = NULL;
	}
}
Beispiel #4
0
void timer_delete(uint8_t timerId) {
	if (timers[timerId].handlerArg != NULL) {
		free(timers[timerId].handlerArg);
	}

	timer_stop(timerId);
	timers[timerId].taken = false;
	timers[timerId].handler = NULL;
	timers[timerId].handlerArg = NULL;
}
Beispiel #5
0
/*
 * Timer clock event
 */
static inline void timer_event_resume(struct timer_info *info)
{
	int ch = info->channel;
	if (info->in_tclk) {
		clk_set_rate(info->clk, info->rate);
		clk_enable(info->clk);
	}
	timer_stop(ch, 1);
	timer_clock(ch, info->tmmux, info->prescale);
}
Beispiel #6
0
/* ----------------------------------------------------------------------------*/
static void prvSetupTimerInterrupt(void)
{
	unsigned int cyc = configCPU_CLOCK_HZ / configTICK_RATE_HZ;

	int_disable(BOARD_OS_TIMER_INTNO); /* disable os timer interrupt */
	timer_stop(BOARD_OS_TIMER_ID);
	timer_start(BOARD_OS_TIMER_ID, TIMER_CTRL_IE | TIMER_CTRL_NH, cyc);

	int_handler_install(BOARD_OS_TIMER_INTNO, (INT_HANDLER)vKernelTick);
	int_enable(BOARD_OS_TIMER_INTNO);
}
Beispiel #7
0
void NewPing::timer_setup() {
#if defined (__AVR_ATmega32U4__) // Use Timer4 for ATmega32U4 (Teensy/Leonardo).
	timer_stop(); // Disable Timer4 interrupt.
	TCCR4A = TCCR4C = TCCR4D = TCCR4E = 0;
	TCCR4B = (1<<CS42) | (1<<CS41) | (1<<CS40) | (1<<PSR4); // Set Timer4 prescaler to 64 (4uS/count, 4uS-1020uS range).
	TIFR4 = (1<<TOV4);
	TCNT4 = 0;    // Reset Timer4 counter.
#else
	timer_stop();           // Disable Timer2 interrupt.
	
	TCCR4A &= ~(1<<WGM41|1<<WGM40);    // Set Timer4 to CTC mode.
	TCCR4B &= ~(1<<WGM43);
	TCCR4B |= (1<<WGM42);
	
	TCCR4B &= ~(1<<CS42);     // Set Timer4 prescaler to 64 (4uS/count, 4uS-1020uS range).
	TCCR4B |= (1<<CS41|1<<CS40);
	
	TCNT4 = 0;              // Reset Timer4 counter.
#endif
}
Beispiel #8
0
Datei: input.c Projekt: erikg/vp
	/*
	 * instead of actually exiting, we just fake the escape key 
	 */
void
throw_exit ()
{
    SDL_Event thrower;

    printf ("Throwing ext\n");
    thrower.type = SDL_KEYDOWN;
    thrower.key.keysym.sym = 27;
    timer_stop ();
    SDL_PushEvent (&thrower);
}
Beispiel #9
0
// Tell the anchor to stop ranging with TAGs.
// This cancels whatever the anchor was doing.
void oneway_anchor_stop () {
	// Put the anchor in SLEEP state. This is useful in case we need to
	// re-init some stuff after the anchor comes back alive.
	_state = ASTATE_IDLE;

	// Stop the timer in case it was in use
	timer_stop(_anchor_timer);

	// Put the DW1000 in SLEEP mode.
	dw1000_sleep();
}
Beispiel #10
0
int main (void)
{
  timer_info_t *timer_info = NULL;
  int status;

  status = timer_start (1000, 0, 1, callback, &timer_info);
  while (timer_expiry_count < 10)
  {
  }
  status = timer_stop (timer_info);

  status = timer_start (3000, 0, 0, callback, &timer_info);
  sleep (5);

  status = timer_start (3000, 0, 0, callback, &timer_info);
  sleep (2);
  status = timer_stop (timer_info);

  return 0;
}
Beispiel #11
0
void flash_light(TimerInstance* instance)
{
  // ISR callback
  GPIOG->ODR ^= 1 << pin;

  // Test that it stops
  if (count++ > 1000000)
  {
    timer_stop(instance);
    count = 0;
  }
}
Beispiel #12
0
JEMALLOC_INLINE_C void
time_func(timedelta_t *timer, uint64_t nwarmup, uint64_t niter, void (*func)(void))
{
	uint64_t i;

	for (i = 0; i < nwarmup; i++)
		func();
	timer_start(timer);
	for (i = 0; i < niter; i++)
		func();
	timer_stop(timer);
}
Beispiel #13
0
int16_t ll_advertise_stop()
{
	int16_t err_code;

	if (current_state != LL_STATE_ADVERTISING)
		return -ENOREADY;

	timer_stop(t_ll_ifs);

	err_code = timer_stop(t_ll_interval);
	if (err_code < 0)
		return err_code;

	err_code = timer_stop(t_ll_single_shot);
	if (err_code < 0)
		return err_code;

	current_state = LL_STATE_STANDBY;

	return 0;
}
Beispiel #14
0
static void managed_comparator_callback(void *priv_data)
{
	struct managed_comparator_info *priv =
		(struct managed_comparator_info *)priv_data;

	if (priv->pin_deb_counter > 0)
		timer_stop(priv->pin_debounce_timer);

	priv->pin_status = !priv->pin_status;
	comp_configure(priv->evt_dev, priv->source_pin,
		       priv->pin_status ? 1 : 0, 1, managed_comparator_callback,
		       priv_data);
	timer_start(priv->pin_debounce_timer, priv->debounce_delay, NULL);

	priv->pin_deb_counter = priv->pin_deb_counter + 1;
	if (priv->pin_deb_counter == 10) {
		timer_stop(priv->pin_debounce_timer);
		pr_error(LOG_MODULE_DRV, "pin %d unexpected toggling",
			 priv->source_pin);
	}
}
Beispiel #15
0
/* 
	Clear the input window. Reset cursor to start position. 
	Stop char_tmr.
*/
void
win_cursor_clr(){
	if (NULL == pcursor_win) 
		return; 
	pcursor_win->txt[0] = '\0';
	pcursor_win->text_len = 0;
	cursor_pos = 0;
	key_cnt = -1;
	last_key = -1;
	timer_stop(&char_tmr);
	win_draw_text(pcursor_win);	
}
Beispiel #16
0
/* Accurate usec delay for JEDEC */
static void jedec_delay(int usec) {

    timer_prime(TMU1, 1000000, 0);
    timer_clear(TMU1);
    timer_start(TMU1);

    while(usec--) {
    	while(!timer_clear(TMU1)) ;
    }

    timer_stop(TMU1);
}
Beispiel #17
0
void test_divide(int depth)
{
  int i,move_count;
  move_t ms[MOVE_STACK];
  uint64 nodes;
  uint64 total_nodes;
  int legal_moves;
  #ifdef EVASIONS
  char strbuff[256];
  move_t ms_test[MOVE_STACK];
  #endif
  
  if(!depth) return;
  nodes = 0;
  total_nodes = 0;
  legal_moves = 0;
  
  pht_init();
  depth -= 1;
  timer_start();
    
  #ifdef EVASIONS
  if(is_in_check(board->side))
  { move_count = move_gen_evasions(&ms[0]);
    if(move_count != move_gen_legal(&ms_test[0]))
    { board_to_fen(&strbuff[0]);
      printf("error: \n %s \n",strbuff);
    }
  }
  else
  { move_count = move_gen(&ms[0]);
  }
  #else
  move_count = move_gen(&ms[0]);
  #endif
    
  for(i = 0; i < move_count; i++)
  { if(!move_make(ms[i])) continue;
    nodes = perft(depth);
    print_move(ms[i].p);
    legal_moves++;
    printf("%I64u",nodes);
    printf("\n");
    move_undo();
    total_nodes += nodes;
  }
  printf("\nNodes: %I64u",total_nodes);
  printf("\nMoves: %d",legal_moves);
  printf("\n\n");
  timer_stop();
  pht_free();
}
Beispiel #18
0
void adi(int local_grid_points[3])
{
  if (timeron) timer_start(t_rhs);
  compute_rhs();
  if (timeron) timer_stop(t_rhs);

  if (timeron) timer_start(t_xsolve);
  x_solve();
  if (timeron) timer_stop(t_xsolve);

  if (timeron) timer_start(t_ysolve);
  y_solve();
  if (timeron) timer_stop(t_ysolve);

  if (timeron) timer_start(t_zsolve);
  z_solve();
  if (timeron) timer_stop(t_zsolve);

  if (timeron) timer_start(t_add);
  add(local_grid_points);
  if (timeron) timer_stop(t_add);
}
Beispiel #19
0
void key_timer_tick(void) {
  if (timer_running)
  {
    timer++;
  }

  if (last_state == KEY_DOWN &&
      timer >= KEY_CLICK_TIME_TICKS)
  {
    event = LONG_PRESS;
    timer_stop();
  }
}
Beispiel #20
0
	void NewPing::timer_setup() {
	#if defined (__AVR_ATmega32U4__) // Use Timer4 for ATmega32U4 (Teensy/Leonardo).
		timer_stop(); // Disable Timer4 interrupt.
		TCCR4A = TCCR4C = TCCR4D = TCCR4E = 0;
		TCCR4B = (1<<CS42) | (1<<CS41) | (1<<CS40) | (1<<PSR4); // Set Timer4 prescaler to 64 (4uS/count, 4uS-1020uS range).
		TIFR4 = (1<<TOV4);
		TCNT4 = 0;    // Reset Timer4 counter.
	#elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega8535__) // Alternate timer commands for certain microcontrollers.
		timer_stop();                 // Disable Timer2 interrupt.
		ASSR &= ~(1<<AS2);            // Set clock, not pin.
		TCCR2 = (1<<WGM21 | 1<<CS22); // Set Timer2 to CTC mode, prescaler to 64 (4uS/count, 4uS-1020uS range).
		TCNT2 = 0;                    // Reset Timer2 counter.
	#elif defined (__arm__) && (defined (TEENSYDUINO) || defined (PARTICLE))
		timer_stop(); // Stop the timer.
	#else
		timer_stop();        // Disable Timer2 interrupt.
		ASSR &= ~(1<<AS2);   // Set clock, not pin.
		TCCR2A = (1<<WGM21); // Set Timer2 to CTC mode.
		TCCR2B = (1<<CS22);  // Set Timer2 prescaler to 64 (4uS/count, 4uS-1020uS range).
		TCNT2 = 0;           // Reset Timer2 counter.
	#endif
	}
Beispiel #21
0
/**********************************************************************
  Read value from timer.  If the timer is not stopped, this stops the
  timer, reads it (and accumulates), and then restarts it.
  Returns 0.0 for unused timers.
***********************************************************************/
double timer_read_seconds(struct timer *t)
{
    fc_assert_ret_val(NULL != t, -1.0);

    if (t->use == TIMER_IGNORE) {
        return 0.0;
    }
    if (t->state == TIMER_STARTED) {
        timer_stop(t);
        t->state = TIMER_STARTED;
    }
    return t->sec + t->usec / (double)N_USEC_PER_SEC;
}
Beispiel #22
0
void double_array_copy(unsigned int n, volatile double *src, double *dst)
{
    unsigned int i;
    
    timer_start(TIMER_ARRAY_COPY);
    
    for(i=0; i<n; i++)
    {
        *(dst + i) = *(src + i);
    }
    
    timer_stop(TIMER_ARRAY_COPY);
}
Beispiel #23
0
void double_array_init(unsigned int n, volatile double *array, double val)
{
    unsigned int i;
    
    timer_start(TIMER_ARRAY_INIT);
    
    for(i=0; i<n; i++)
    {
        *(array + i) = val;
    }
    
    timer_stop(TIMER_ARRAY_INIT);
}
Beispiel #24
0
/**
 * Fills an array with a value.
 * @param n     Length of the array
 * @param array Array to initialize
 * @param val   Value to initialize with
 */
void array_init(fixedgrid_t* G, unsigned int n, real_t *array, real_t val)
{
    int i;

    timer_start(&G->metrics.array_init);

    for(i=0; i<n; i++)
    {
        array[i] = val;
    }

    timer_stop(&G->metrics.array_init);
}
Beispiel #25
0
/**
 * Safety procedure: if something goes wrong, for example an opto is triggered during normal movement,
 * we shut down the entire machine.
 * @param msg The reason why the machine did an emergency stop
 */
void dda_emergency_shutdown(PGM_P msg) {
  // Todo: is it smart to enable all interrupts again? e.g. can we create concurrent executions?
  sei();  // Enable interrupts to print the message
  serial_writestr_P(PSTR("error: emergency stop:"));
  if(msg!=NULL) serial_writestr_P(msg);
  serial_writestr_P(PSTR("\r\n"));
  delay_ms(20);   // Delay so the buffer can be flushed - otherwise the message is never sent
  timer_stop();
  queue_flush();
  power_off();
  cli();
  for (;;) { }
}
Beispiel #26
0
static void loras_timer_poll_timeout(LORA* lora)
{
    int last_error;
#if (LORA_DEBUG)
    uint32_t duration_ms;
    ++lora->polls_cnt;
#endif

    if (lora->status != LORA_STATUS_TRANSFER_IN_PROGRESS)
    {
        loras_fatal(lora);
#if (LORA_DEBUG)
        printf("[loras] [fatal error] unexpected status %d => server closed\n", lora->status);
#endif
        return;
    }

    (lora->tx ? loras_hw_tx_async_wait : loras_hw_rx_async_wait)(lora);

    last_error = get_last_error();

#if (LORA_DEBUG)
    //check for internal unexpected errors (ex. ERROR_INVALID_STATE -- chip is in invalid state)
    if (!(last_error >= ERROR_OK || last_error == ERROR_TIMEOUT))
    {
        loras_fatal(lora);
        printf("[loras] [fatal error] unexpected error %d => server closed\n", last_error);
        return;
    }
#endif

    switch (lora->status)
    {
    case LORA_STATUS_TRANSFER_IN_PROGRESS:
        timer_start_ms(lora->timer_poll_timeout, LORA_POLL_TIMEOUT_MS);
        //note: do not check if last_error == ERROR_OK (should be)
        ipc_post_inline(lora->process, HAL_CMD(HAL_LORA, LORA_TRANSFER_IN_PROGRESS), 0, 0, last_error);
        break;
    case LORA_STATUS_TRANSFER_COMPLETED:
        timer_stop(lora->timer_txrx_timeout, 0, HAL_LORA);
#if (LORA_DEBUG)
        duration_ms = loras_get_uptime_ms() - lora->transfer_in_progress_ms;
        printf("[loras] [info] poll completed duration_ms:%u polls_cnt:%u\n", duration_ms, lora->polls_cnt);
#endif
        ipc_post_inline(lora->process, HAL_CMD(HAL_LORA, LORA_TRANSFER_COMPLETED), 0, 0, last_error);
        break;
    default:
        error(ERROR_NOT_SUPPORTED);
        break;
    }
}
Beispiel #27
0
int main (int argc, char * argv[])
{
  int nthreads;
  int iterations;
  int objSize;
  int repetitions;

  if (argc > 4) {
    nthreads = atoi(argv[1]);
    iterations = atoi(argv[2]);
    objSize = atoi(argv[3]);
    repetitions = atoi(argv[4]);
  } else {
    fprintf (stderr, "Usage: %s nthreads iterations objSize repetitions\n", argv[0]);
    exit(1);
  }

  pthread_t threads[nthreads];
  int numCPU = getNumProcessors();
  pthread_setconcurrency(numCPU);

  int i;

  /* Call allocator-specific initialization function */
  mm_init();

  pthread_attr_t attr;
  initialize_pthread_attr(PTHREAD_CREATE_JOINABLE, SCHED_RR, -10, PTHREAD_EXPLICIT_SCHED, 
			  PTHREAD_SCOPE_SYSTEM, &attr);

  timer_start();

  for (i = 0; i < nthreads; i++) {
    struct workerArg * w = (struct workerArg *)mm_malloc(sizeof(struct workerArg));
    w->_objSize = objSize;
    w->_repetitions = repetitions / nthreads;
    w->_iterations = iterations;
    w->_cpu = (i+1)%numCPU;
    pthread_create(&threads[i], &attr, &worker, (void *)w);
  }

  for (i = 0; i < nthreads; i++) {
    pthread_join(threads[i], NULL);
  }

  double t = timer_stop();

  printf ("Time elapsed = %f seconds\n", t);
  printf ("Memory used = %d bytes\n",mem_usage());
  return 0;
}
Beispiel #28
0
static void ll_key_event(bool push) {
  if (push == true)
  {
    timer_start();
  } else {
    // Release event
    if (timer < KEY_CLICK_TIME_TICKS) {
      timer_stop();
      event = CLICKED;
    } else {
      // already handled by timer tick function.
    }
  }
}
Beispiel #29
0
i32 cc_timer_stop(cc_hndl hndl)
{
        struct sw_timer *swt = (struct sw_timer*) hndl;
        u32 intr_mask;
        i32 rv = -1;

        intr_mask = dsbl_irqc();
        if(swt && has_started(swt)) {
                rv = timer_stop(swt);
        }
        enbl_irqc(intr_mask);

        return rv;
}
bool timer_set(long cycles, bool start)
{
    timer_stop();
    
    if(start && pfn_unregister)
    {
        pfn_unregister();
        pfn_unregister = NULL;
    }

    timer_cycles = cycles;

    return true;
}