29#define CURRENT_CLASS ATmega328P
38 TCCR1A |= _BV(COM1A1);
42 TCCR1A &= ~(_BV(COM1A1));
53#define TIMER_INTR_NAME TIMER1_COMPA_vect
56 const uint16_t pwmval = F_CPU / 2U / val;
58 TCCR1B = _BV(WGM13) | _BV(CS10);
60 OCR1A = pwmval * dutyCycle / 100U;
65 TCCR1B = _BV(WGM12) | _BV(CS10);
72#elif defined(IR_USE_TIMER2) || defined(DOXYGEN)
75 TCCR2A |= _BV(COM2B1);
79 TCCR2A &= ~(_BV(COM2B1));
90#define TIMER_INTR_NAME TIMER2_COMPA_vect
93 const uint8_t pwmval = F_CPU / 2U / val;
95 TCCR2B = _BV(WGM22) | _BV(CS20);
97 OCR2B = pwmval * dutyCycle / 100U;
112#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.
void timerConfigHz(frequency_t val, dutycycle_t dutyCycle)
Configure hardware PWM, but do not enable it.
void timerDisablePwm()
Turn off PWM output.
void timerEnableIntr()
Start periodic sampling routine.
void timerConfigNormal()
Disables the PWM configuration.
void timerDisableIntr()
Turn off periodic interrupts.
void timerEnablePwm()
Start PWM output.
This class serves as an HAL (Hardware Abstraction Layer).
static const unsigned long microsPerTick