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).
16 #include "at91sam7s.h"
19 #include <cfg/macros.h> // BV()
20 #include <cfg/module.h>
24 /** HW dependent timer initialization */
25 #if (CONFIG_TIMER == TIMER_ON_PIT)
26 INLINE void timer_hw_irq(void)
28 /* Reset counters, this is needed to reset timer and interrupt flags */
29 uint32_t dummy = PIVR;
33 INLINE bool timer_hw_triggered(void)
35 return PIT_SR & BV(PITS);
38 INLINE void timer_hw_init(void)
44 IRQ_SAVE_DISABLE(flags);
46 PIT_MR = TIMER_HW_CNT;
47 /* Register system interrupt handler. */
48 sysirq_setHandler(SYSIRQ_PIT, timer_handler);
50 /* Enable interval timer and interval timer interrupts */
52 sysirq_setEnable(SYSIRQ_PIT, true);
54 /* Reset counters, this is needed to start timer and interrupt flags */
55 uint32_t dummy = PIVR;
61 INLINE hptime_t timer_hw_hpread(void)
63 /* In the upper part of PIT_PIIR there is unused data */
64 return PIIR & CPIV_MASK;
68 #error Unimplemented value for CONFIG_TIMER
69 #endif /* CONFIG_TIMER */