/** * \file timer_hw.h * * \brief Microcontroller specific code for timer functions. * * Target platform: ATmega128A using Atmel AVRGCC8 * * Created: 25-04-2013 18:46:38 * Author: pf */ #ifndef TIMER_HW_H_ #define TIMER_HW_H_ #define XTAL_FREQ 16000000 ///< Oscillator crystal frequency /** * \fn set_timer(uint32_t frequency) * * \brief Program TIMER0 register to generate end-of-count * events at a defined frequency. * * \arg \c frequency Frequency of end-of-count events * * \retval 0 if OK * \retval -1 if error: could not find a proper value for programming the registers * * TIMER0 is initialized in CTC mode, to allow resetting the * counter value when reaching end-of-count. The oscillator frequency is * defined by XTAL_FREQ * * If frequency is 0, TIMER0 is halted. * * \c set_timer does not program interruptions. * * \sa XTAL_FREQ */ int8_t set_timer(uint32_t frequency); #endif /* TIMER_HW_H_ */