avr-classes
Classes | Public Member Functions | Static Public Member Functions | List of all members
Timer Class Referenceabstract

#include <timer.h>

Inheritance diagram for Timer:
Timer0

Classes

struct  Config
 
class  InterruptHandler
 

Public Member Functions

virtual void configure (const Config &config)=0
 
virtual uint8_t getCounterRegister (void)=0
 
virtual void setCounterRegister (uint8_t value)=0
 
virtual void setOutputCompareValue (uint8_t value)=0
 
virtual void forceOutputCompareMatch (void)=0
 
virtual void setInterruptHandler (InterruptHandler *handler)=0
 
virtual void enableOutputCompareMatchInterrupt (bool state)=0
 
virtual void enableOverflowInterrupt (bool state)=0
 

Static Public Member Functions

template<uint32_t CPUFREQUENCY>
static bool autoFill (Config &config, uint32_t desiredCycleTime, uint32_t *actualCycleTime=nullptr)
 

Detailed Description

Interface for devices that implement an 8 bit timer.

Member Function Documentation

◆ autoFill()

template<uint32_t CPUFREQUENCY>
static bool Timer::autoFill ( Config config,
uint32_t  desiredCycleTime,
uint32_t *  actualCycleTime = nullptr 
)
inlinestatic

Automatically fills a configuration structure for CTC mode.

Parameters
configConfiguration structure to fill.
desiredCycleTimeCycle time in microseconds to achieve.
actualCycleTimeOptional pointer to buffer to receive the cycle time that was actually configured.
Returns
True if configuration structure was filled successfully, false otherwise.
Note
Template parameter CPUFREQUENCY must contain the CPU frequency in Hertz.
Using compile-time constants for cycleTime reduces code size dramatically.

◆ configure()

virtual void Timer::configure ( const Config config)
pure virtual

Configures the timer device.

Parameters
configConfiguration for timer device.

Implemented in Timer0.

◆ enableOutputCompareMatchInterrupt()

virtual void Timer::enableOutputCompareMatchInterrupt ( bool  state)
pure virtual

Enables or disabled the Output Compare Match interrupt.

Parameters
stateTrue to enable interrupt, false to disable.

Implemented in Timer0.

◆ enableOverflowInterrupt()

virtual void Timer::enableOverflowInterrupt ( bool  state)
pure virtual

Enables or disabled the Overflow interrupt.

Parameters
stateTrue to enable interrupt, false to disable.

Implemented in Timer0.

◆ forceOutputCompareMatch()

virtual void Timer::forceOutputCompareMatch ( void  )
pure virtual

Strobes the force output compare match flag.

Implemented in Timer0.

◆ getCounterRegister()

virtual uint8_t Timer::getCounterRegister ( void  )
pure virtual

Gets the current value of the counter register.

Returns
Current value of the counter register.

Implemented in Timer0.

◆ setCounterRegister()

virtual void Timer::setCounterRegister ( uint8_t  value)
pure virtual

Sets the counter register value.

Parameters
valueValue to set.

Implemented in Timer0.

◆ setInterruptHandler()

virtual void Timer::setInterruptHandler ( InterruptHandler handler)
pure virtual

Sets callback for interrupts.

Parameters
handlerPointer to class implementing the interrupt handler interface.

Implemented in Timer0.

◆ setOutputCompareValue()

virtual void Timer::setOutputCompareValue ( uint8_t  value)
pure virtual

Sets the output compare register value.

Parameters
valueValue to set.

Implemented in Timer0.