32#define CURRENT_CLASS ATmega4809
34#define HAS_FLASH_READ 1
35#define HAS_HARDWARE_PWM 1
37#define HAS_INPUT_CAPTURE 0
39#define STRCPY_PF_CAST(x) (x)
50#define TIMER_INTR_NAME TCB0_INT_vect
53 TCB0.INTFLAGS = TCB_CAPT_bm;
59 TCB0.CTRLB |= TCB_CCMPEN_bm;
63 TCB0.CTRLB &= ~(TCB_CCMPEN_bm);
67 TCB0.INTCTRL = TCB_CAPT_bm;
71 TCB0.INTCTRL &= ~TCB_CAPT_bm;
75 const uint8_t pwmval = F_CPU / 2U / frequency;
76 TCB0.CTRLB = TCB_CNTMODE_PWM8_gc;
78 TCB0.CCMPH = pwmval * dutyCycle / 100UL;
79 TCB0.CTRLA = TCB_CLKSEL_CLKDIV2_gc | TCB_ENABLE_bm;
83 TCB0.CTRLB = TCB_CNTMODE_INT_gc;
85 TCB0.INTCTRL = TCB_CAPT_bm;
86 TCB0.CTRLA = TCB_CLKSEL_CLKDIV1_gc | TCB_ENABLE_bm;
92#elif defined(IR_USE_TIMER2)
95#error IR_USE_TIMER2 for this architecture is not yet implemented, sorry.
99#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.
virtual void timerReset()
TODO.