15 lines
315 B
C++
15 lines
315 B
C++
#include "timer_usec.h"
|
|
|
|
Timer_usec::Timer_usec() = default;
|
|
|
|
void Timer_usec::init(uint16_t period_us) { // for custom duty cycle duration in ms in part 1
|
|
TCCR1A = 0;
|
|
TCCR1B = 0;
|
|
TCNT1 = 0;
|
|
|
|
OCR1A = period_us * 2 - 1;
|
|
TCCR1B |= (1<<WGM12);
|
|
TIMSK1 |= (1<<OCIE1A);
|
|
TCCR1B |= (1<<CS11);
|
|
}
|