THW-Funk-Audio-Switch/Programm/Audio-Switch/io/Timer.hpp

57 lines
881 B
C++

/*
* Timer.h
*
* Created: 30.10.2020 19:46:04
* Author: netz
*/
#ifndef TIMER_H_
#define TIMER_H_
#include <avr/io.h>
template <int timer_count_till, int timer_prescaler>
class TimerT {
// Methods
private:
protected:
public:
TimerT() {
TCCR1A = 0;
TCCR1B = 0;
TCCR1C = 0;
TCNT1 = 0;
//OCR1AH = (uint8_t)(timer_count_till<<8);
//OCR1AL = (uint8_t)timer_count_till;
//OCR1A = 39062;
OCR1A = timer_count_till;
TIMSK1 = (1<<ICIE1) | (1<<OCIE1A);
}
void Stop() {
TCCR1B = 0;
}
void Start() {
TCCR1B = timer_prescaler;
}
void Reset() {
TCNT1 = 0;
}
// Variables
private:
protected:
public:
};
typedef TimerT<settings_timer_count_till, settings_timer_prescaler> Timer;
#endif /* TIMER_H_ */