aversive_10-03-12/modules/hardware/timer/timer_definitions.h File Reference

#include <aversive/parts.h>

Go to the source code of this file.

Defines

#define DEFINE_TIMER_START_STOP(x)
#define DEFINE_TIMER_GET_SET(x)
#define DEFINE_OV_INTR(x)
#define DEFINE_OC_INTR(x)
#define DEFINE_REGISTER_OV_INTR(x)
#define DEFINE_REGISTER_OC_INTR_AT_TICS(x)
#define DEFINE_REGISTER_OC_INTR_IN_US(x, y)
#define DEFINE_DYNAMIC_PRESCALER_FUNCS(x)
#define DEFINE_STATIC_PRESCALER_FUNCS(x)
#define DEFINE_TIMER_US_CONVERSIONS(x)


Define Documentation

#define DEFINE_DYNAMIC_PRESCALER_FUNCS (  ) 

Value:

\
int16_t timer##x##_div_to_reg(uint16_t div)                         \
{                                                                   \
        return __timer##x##_div_to_reg(div);                        \
}                                                                   \
                                                                    \
int16_t timer##x##_reg_to_div(uint8_t reg)                          \
{                                                                   \
        return __timer##x##_reg_to_div(reg);                        \
}                                                                   \
                                                                    \
uint16_t timer##x##_get_prescaler_div(void)                         \
{                                                                   \
        return __timer##x##_reg_to_div(CS##x##0_REG >> CS##x##0);   \
}                                                                   \
                                                                    \
void timer##x##_set_prescaler_div(uint16_t div)                     \
{                                                                   \
        CS##x##0_REG = __timer##x##_div_to_reg(div) << CS##x##0 ;   \
}

Definition at line 141 of file timer_definitions.h.

#define DEFINE_OC_INTR (  ) 

Value:

SIGNAL(x)                                               \
{                                                       \
        if(timer_OC_callback_table[x##_NUM])            \
                timer_OC_callback_table[x##_NUM]();     \
}

Definition at line 67 of file timer_definitions.h.

#define DEFINE_OV_INTR (  ) 

Value:

SIGNAL(x)                                               \
{                                                       \
        if(timer_OV_callback_table[x##_NUM])            \
                timer_OV_callback_table[x##_NUM]();     \
}

Definition at line 59 of file timer_definitions.h.

#define DEFINE_REGISTER_OC_INTR_AT_TICS (  ) 

Value:

\
void timer##x##_register_OC_intr_at_tics(void (*func)(void), uint16_t t)        \
{                                                                               \
        uint8_t flags;                                                          \
                                                                                \
        IRQ_LOCK(flags);                                                        \
        timer_OC_callback_table[SIG_OUTPUT_COMPARE##x##_NUM] = func;            \
        if (func) {                                                             \
                OCIE##x##_REG |= (1<<OCIE##x);                                  \
                OCR##x = t;                                                     \
        }                                                                       \
        else {                                                                  \
                OCIE##x##_REG &= (uint8_t)(~(1<<OCIE##x));                      \
        }                                                                       \
        IRQ_UNLOCK(flags);                                                      \
}

Definition at line 93 of file timer_definitions.h.

#define DEFINE_REGISTER_OC_INTR_IN_US ( x,
 ) 

Value:

\
int8_t timer##y##_register_OC_intr_in_us(void (*func)(void), uint16_t t)        \
{                                                                               \
        uint8_t flags;                                                          \
        float tics;                                                             \
                                                                                \
        IRQ_LOCK(flags);                                                        \
        if (! func) {                                                           \
                timer_OC_callback_table[SIG_OUTPUT_COMPARE##y##_NUM] = func;    \
                OCIE##y##_REG &= (uint8_t)(~(1<<OCIE##y));                      \
                IRQ_UNLOCK(flags);                                              \
                return 0;                                                       \
        }                                                                       \
                                                                                \
        tics = timer##x##_us_to_tics(t);                                        \
        if ( tics > 0xFFFF ) {  /* XXX use MAX_TIMER */                         \
                IRQ_UNLOCK(flags);                                              \
                return -1;                                                      \
        }                                                                       \
                                                                                \
        OCR##y = TCNT##x + tics;                                                \
        timer_OC_callback_table[SIG_OUTPUT_COMPARE##y##_NUM] = func;            \
        OCIE##y##_REG |= (1<<OCIE##y);                                          \
        IRQ_UNLOCK(flags);                                                      \
        return 0;                                                               \
}

Definition at line 112 of file timer_definitions.h.

#define DEFINE_REGISTER_OV_INTR (  ) 

Value:

\
void timer##x##_register_OV_intr(void (*func)(void))                \
{                                                                   \
        uint8_t flags;                                              \
                                                                    \
        IRQ_LOCK(flags);                                            \
        timer_OV_callback_table[SIG_OVERFLOW##x##_NUM] = func;      \
        if (func) {                                                 \
                TOIE##x##_REG |= (1<<TOIE##x);                      \
        }                                                           \
        else {                                                      \
                TOIE##x##_REG &= (uint8_t)(~(1<<TOIE##x));          \
        }                                                           \
        IRQ_UNLOCK(flags);                                          \
}

Definition at line 75 of file timer_definitions.h.

#define DEFINE_STATIC_PRESCALER_FUNCS (  ) 

Value:

\
int16_t timer##x##_div_to_reg(uint16_t div)                         \
{                                                                   \
        return __timer##x##_div_to_reg(TIMER##x##_PRESCALER_DIV);   \
}                                                                   \
                                                                    \
uint16_t timer##x##_get_prescaler_div(void)                         \
{                                                                   \
        return TIMER##x##_PRESCALER_DIV;                            \
}

Definition at line 164 of file timer_definitions.h.

#define DEFINE_TIMER_GET_SET (  ) 

Value:

\
uint16_t timer##x##_get(void)                                                            \
{                                                                                        \
        return TCNT##x ;                                                                 \
}                                                                                        \
                                                                                         \
void timer##x##_set(uint16_t t)                                                          \
{                                                                                        \
        TCNT##x = t;                                                                     \
}

Definition at line 46 of file timer_definitions.h.

#define DEFINE_TIMER_START_STOP (  ) 

Value:

\                                                                        \
void timer##x##_start(void)                                                              \
{                                                                                        \
        TCNT##x = 0;                                                                     \
        CS##x##0_REG = __timer##x##_div_to_reg(TIMER##x##_PRESCALER_DIV) << CS##x##0 ;   \
}                                                                                        \
                                                                                         \                                                                       \
void timer##x##_stop(void)                                                               \
{                                                                                        \
        CS##x##0_REG = 0;                                                                \
        TCNT##x = 0;                                                                     \
}

Definition at line 28 of file timer_definitions.h.

#define DEFINE_TIMER_US_CONVERSIONS (  ) 

Value:

\
static inline float timer##x##_us_to_tics(float us)                      \
{                                                                        \
        return ((float)CONFIG_QUARTZ /                                   \
                ((float)MHz * timer##x##_get_prescaler_div()) ) * us;    \
}                                                                        \
                                                                         \
static inline float timer##x##_tics_to_us(float t)                       \
{                                                                        \
        return t / ((float)CONFIG_QUARTZ /                               \
                ((float)MHz * timer##x##_get_prescaler_div()) );         \
}

Definition at line 176 of file timer_definitions.h.


Generated on Fri Mar 12 06:32:07 2010 for AVR by  doxygen 1.5.6