Beispiel #1
0
int __hw_clock_source_init(uint32_t start_t)
{
	/*
	 * 1. Use ITIM16-1 as internal time reading
	 * 2. Use ITIM16-2 for event handling
	 */

	/* Enable clock for ITIM peripheral */
	clock_enable_peripheral(CGC_OFFSET_TIMER, CGC_TIMER_MASK,
			CGC_MODE_RUN | CGC_MODE_SLEEP);

	/* init tick & event timer first */
	init_hw_timer(ITIM32,  ITIM_SOURCE_CLOCK_APB2);
	init_hw_timer(ITIM_EVENT_NO, ITIM_SOURCE_CLOCK_32K);

	/* Set initial prescaler */
	update_prescaler();

	/*
	 * Override the count with the start value now that counting has
	 * started.
	 */
	hw_clock_source_set_preload(start_t, 1);

	/* Enable interrupt of ITIM */
	task_enable_irq(NPCX_IRQ_ITIM32);

	return NPCX_IRQ_ITIM32;
}
Beispiel #2
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;
}