/** HW dependent timer initialization */
#if (CONFIG_TIMER == TIMER_ON_PIT)
- INLINE void timer_hw_irq(void)
- {
- /* Reset counters, this is needed to reset timer and interrupt flags */
- uint32_t dummy = PIVR;
- (void) dummy;
- }
-
- INLINE bool timer_hw_triggered(void)
- {
- return PIT_SR & BV(PITS);
- }
- INLINE void timer_hw_init(void)
+ void timer_hw_init(void)
{
sysirq_init();
IRQ_RESTORE(flags);
}
- INLINE hptime_t timer_hw_hpread(void)
- {
- /* In the upper part of PIT_PIIR there is unused data */
- return PIIR & CPIV_MASK;
- }
-
#else
#error Unimplemented value for CONFIG_TIMER
#endif /* CONFIG_TIMER */
#ifndef DRV_AT91_TIMER_H
#define DRV_AT91_TIMER_H
-#include <hw/hw_cpufreq.h> /* CPU_FREQ */
+#include <hw/hw_cpufreq.h> /* CPU_FREQ */
#include "cfg/cfg_timer.h" /* CONFIG_TIMER */
#include <cfg/compiler.h> /* uint8_t */
+#include <cfg/macros.h> /* BV */
+
+#include <io/arm.h>
/**
* \name Values for CONFIG_TIMER.
/** Frequency of the hardware high-precision timer. */
#define TIMER_HW_HPTICKS_PER_SEC (CPU_FREQ / 16)
- /// Type of time expressed in ticks of the hardware high-precision timer
+ /** Type of time expressed in ticks of the hardware high-precision timer */
typedef uint32_t hptime_t;
+
+ INLINE void timer_hw_irq(void)
+ {
+ /* Reset counters, this is needed to reset timer and interrupt flags */
+ uint32_t dummy = PIVR;
+ (void) dummy;
+ }
+
+ INLINE bool timer_hw_triggered(void)
+ {
+ return PIT_SR & BV(PITS);
+ }
+
+ INLINE hptime_t timer_hw_hpread(void)
+ {
+ /* In the upper part of PIT_PIIR there is unused data */
+ return PIIR & CPIV_MASK;
+ }
+
#else
#error Unimplemented value for CONFIG_TIMER
#endif /* CONFIG_TIMER */
+void timer_hw_init(void);
+
#endif /* DRV_TIMER_AT91_H */
#include <cpu/types.h>
#include <cpu/irq.h>
-#include <avr/interrupt.h>
#include <avr/io.h>
#if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168
/** HW dependent timer initialization */
#if (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE0)
- static void timer_hw_init(void)
+ void timer_hw_init(void)
{
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
IRQ_RESTORE(flags);
}
- INLINE hptime_t timer_hw_hpread(void)
- {
- return TCNT0;
- }
-
#elif (CONFIG_TIMER == TIMER_ON_OVERFLOW1)
- static void timer_hw_init(void)
+ void timer_hw_init(void)
{
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
IRQ_RESTORE(flags);
}
- INLINE hptime_t timer_hw_hpread(void)
- {
- return TCNT1;
- }
-
#elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2)
- static void timer_hw_init(void)
+ void timer_hw_init(void)
{
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
IRQ_RESTORE(flags);
}
- INLINE hptime_t timer_hw_hpread(void)
- {
- return TCNT2;
- }
#elif (CONFIG_TIMER == TIMER_ON_OVERFLOW3)
- static void timer_hw_init(void)
+ void timer_hw_init(void)
{
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
IRQ_RESTORE(flags);
}
- INLINE hptime_t timer_hw_hpread(void)
- {
- return TCNT3;
- }
-
#else
#error Unimplemented value for CONFIG_TIMER
#endif /* CONFIG_TIMER */
#ifndef DRV_TIMER_AVR_H
#define DRV_TIMER_AVR_H
-#include <hw/hw_cpufreq.h> /* CPU_FREQ */
+#include <hw/hw_cpufreq.h> /* CPU_FREQ */
-#include "cfg/cfg_timer.h" /* CONFIG_TIMER */
-#include <cfg/compiler.h> /* uint8_t */
-#include <cfg/macros.h> /* DIV_ROUND */
+#include "cfg/cfg_timer.h" /* CONFIG_TIMER */
+#include <cfg/compiler.h> /* uint8_t */
+#include <cfg/macros.h> /* DIV_ROUND */
+#include <avr/io.h>
+#include <avr/interrupt.h>
/**
* \name Values for CONFIG_TIMER.
/// Type of time expressed in ticks of the hardware high-precision timer
typedef uint8_t hptime_t;
+ INLINE hptime_t timer_hw_hpread(void)
+ {
+ return TCNT0;
+ }
+
#elif (CONFIG_TIMER == TIMER_ON_OVERFLOW1)
#define TIMER_PRESCALER 1
/// Type of time expressed in ticks of the hardware high precision timer
typedef uint16_t hptime_t;
+ INLINE hptime_t timer_hw_hpread(void)
+ {
+ return TCNT1;
+ }
+
#elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2)
#define TIMER_PRESCALER 64
/** Value for OCR register in output-compare based timers. */
#define TIMER_HW_CNT OCR_DIVISOR
-
/// Type of time expressed in ticks of the hardware high precision timer
typedef uint8_t hptime_t;
+ INLINE hptime_t timer_hw_hpread(void)
+ {
+ return TCNT2;
+ }
+
#elif (CONFIG_TIMER == TIMER_ON_OVERFLOW3)
#define TIMER_PRESCALER 1
/// Type of time expressed in ticks of the hardware high precision timer
typedef uint16_t hptime_t;
+
+ INLINE hptime_t timer_hw_hpread(void)
+ {
+ return TCNT3;
+ }
+
#else
#error Unimplemented value for CONFIG_TIMER
/** Not needed, timer IRQ handler called only for timer source */
#define timer_hw_triggered() (true)
+void timer_hw_init(void);
#endif /* DRV_TIMER_AVR_H */
#if OS_HOSTED
//#include OS_CSOURCE(timer)
#include <emul/timer_posix.c>
-#else
- #include CPU_CSOURCE(timer)
#endif
/*