29#if !defined(ARDUINO_AVR_LEONARDO) && !defined(ARDUINO_AVR_MICRO)
30#error Board not supported
33#define CURRENT_CLASS ATmega32U4
42#if defined(IR_USE_TIMER1)
44#define TIMER_INTR_NAME TIMER1_COMPA_vect
47 TCCR1A |= _BV(COM1A1);
51 TCCR1A &= ~(_BV(COM1A1));
63 const uint16_t pwmval = F_CPU / 2UL / frequency;
65 TCCR1B = _BV(WGM13) | _BV(CS10);
67 OCR1A = pwmval * dutyCycle / 100UL;
72 TCCR1B = _BV(WGM12) | _BV(CS10);
80#elif defined(IR_USE_TIMER2)
81#define TIMER_INTR_NAME TIMER2_COMPA_vect
83#error IR_USE_TIMER2 in Leonardo currently broken.
91 const uint8_t pwmval = F_CPU / 2U / frequency;
93 TCCR2B = _BV(WGM22) | _BV(CS20);
95 OCR2B = pwmval * dutyCycle / 100UL; \
103 OCR2A = TIMER_COUNT_TOP / 8U;
111#error Config error, either IR_USE_TIMER1 or IR_USE_TIMER2 must be defined.
int8_t dutycycle_t
Type for duty cycle in percent.
uint32_t frequency_t
Type for modulation frequency in Hz.
This class serves as an HAL (Hardware Abstraction Layer).
virtual void timerEnableIntr()=0
Start periodic sampling routine.
virtual void timerDisablePwm()=0
Turn off PWM output.
virtual void timerConfigHz(frequency_t hz, dutycycle_t dutyCycle=defaultDutyCycle)=0
Configure hardware PWM, but do not enable it.
static const unsigned long microsPerTick
virtual void timerDisableIntr()=0
Turn off periodic interrupts.
virtual void timerEnablePwm()=0
Start PWM output.
virtual void timerConfigNormal()=0
Disables the PWM configuration.