4 * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
10 * \author Francesco Sacchi <batt@develer.com>
12 * \brief Low-level timer module for Atmel AT91 (inplementation).
15 #include <drv/timer_at91.h>
16 #include <cfg/macros.h> // BV()
21 /** HW dependent timer initialization */
22 #if (CONFIG_TIMER == TIMER_ON_PIT)
23 #warning Very untested!
24 INLINE static void timer_hw_irq(void)
26 /* Reset counters, this is needed to start timer and interrupt flags */
27 volatile uint32_t dummy = PIT_PIVR;
31 static void timer_hw_init(void)
34 IRQ_SAVE_DISABLE(flags);
36 PIT_MR = CLOCK_FREQ / (16 * TIMER_TICKS_PER_SEC) - 1;
37 /* Register system interrupt handler. */
38 sysirq_setHandler(SYSIRQ_PIT, timer_handler);
40 /* Enable interval timer and interval timer interrupts */
41 PIT_MR |= BV(PIT_PITEN);
42 sysirq_setEnable(SYSIRQ_PIT, true);
44 /* Reset counters, this is needed to start timer and interrupt flags */
45 volatile uint32_t dummy = PIT_PIVR;
50 INLINE hptime_t timer_hw_hpread(void)
52 /* In the upper part of PIT_PIIR there is unused data */
53 return PIT_PIIR & 0xfffff;
57 #error Unimplemented value for CONFIG_TIMER
58 #endif /* CONFIG_TIMER */