Example #1
0
/*
 * Enable the hw timer, setting its tick period, and setup its interrupt
 */
int z_clock_driver_init(struct device *device)
{
	ARG_UNUSED(device);

	tick_period = 1000000ul / CONFIG_SYS_CLOCK_TICKS_PER_SEC;

	hwtimer_enable(tick_period);

	IRQ_CONNECT(TIMER_TICK_IRQ, 1, sp_timer_isr, 0, 0);
	irq_enable(TIMER_TICK_IRQ);

	return 0;
}
Example #2
0
void up_timerinit(void)
{
  up_disable_irq(IRQ_SYSTIMER);

  /* The timer runs at 13MHz / 32, i.e. 406.25kHz */
  /* 4062 ticks until expiry yields 100Hz interrupt */
  hwtimer_load(2, 4062);
  hwtimer_config(2, 0, 1);
  hwtimer_enable(2, 1);

  /* Attach and enable the timer interrupt */
  irq_attach(IRQ_SYSTIMER, (xcpt_t)up_timerisr);
  up_enable_irq(IRQ_SYSTIMER);
}