Example #1
0
int __hw_clock_source_init(uint32_t start_t)
{
	/* Set the reload and current value. */
	GR_TIMEHS_BGLOAD(0, 1) = 0xffffffff;
	GR_TIMEHS_LOAD(0, 1) = 0xffffffff;

	/* HW Timer enabled, periodic, interrupt enabled, 32-bit, wrapping */
	GR_TIMEHS_CONTROL(0, 1) = 0xe2;
	/* Event timer disabled */
	__hw_clock_event_clear();

	/* Account for the clock speed. */
	update_prescaler();

	/* Clear any pending interrupts */
	GR_TIMEHS_INTCLR(0, 1) = 0x1;

	/* Force the time to whatever we're told it is */
	__hw_clock_source_set(start_t);

	/* Here we go... */
	task_enable_irq(GC_IRQNUM_TIMEHS0_TIMINT1);
	task_enable_irq(GC_IRQNUM_TIMEHS0_TIMINT2);

	/* Return the Event timer IRQ number (NOT the HW timer IRQ) */
	return GC_IRQNUM_TIMEHS0_TIMINT2;
}
Example #2
0
/* Triggered when Timer 1 reaches 0. */
void __hw_clock_event_irq(void)
{
	/*
	 * Clear the event which disables the timer and clears the pending
	 * interrupt.
	 */
	__hw_clock_event_clear();

	/* Process timers now. */
	process_timers(0);
}
Example #3
0
void __hw_clock_event_set(uint32_t deadline)
{
	uint32_t time_now_in_ticks;

	__hw_clock_event_clear();

	/* How long from the current time to the deadline? */
	time_now_in_ticks = (0xffffffff - GR_TIMEHS_VALUE(0, 1));
	GR_TIMEHS_LOAD(0, 2) = (deadline - time_now_in_ticks / clock_mul_factor)
				* clock_mul_factor;

	/* timer & interrupts enabled */
	GR_TIMEHS_CONTROL(0, 2) = 0xa3;
}
Example #4
0
void __hw_clock_event_set(uint32_t deadline)
{
	uint32_t ticks;
	uint32_t delta;

	__hw_clock_event_clear();

	delta = deadline - __hw_clock_source_read();

	/* Convert the delta to ticks. */
	ticks = delta * (clock_get_freq() / SECOND);

	/* Set the timer load count to the deadline. */
	ROTOR_MCU_TMR_TNLC(1) = ticks;

	/* Enable the timer. */
	ROTOR_MCU_TMR_TNCR(1) |= (1 << 0);
}
Example #5
0
/*
 * Handle event matches. It's lower priority than the HW rollover irq, so it
 * will always be either before or after a rollover exception.
 */
void __hw_clock_event_irq(void)
{
	__hw_clock_event_clear();
	process_timers(0);
}