4 #include "AudioTools/CoreAudio/AudioTimer/AudioTimerBase.h"
7 typedef void (*repeating_timer_callback_t)(
void* obj);
8 class TimerAlarmRepeatingDriverAVR;
9 static TimerAlarmRepeatingDriverAVR* timerAlarmRepeatingRef =
nullptr;
26 bool begin(repeating_timer_callback_t callback_f, uint32_t time,
28 callback = callback_f;
45 setupTimer(1000000 / time);
59 static void tickerCallback() {
60 if (timerAlarmRepeatingRef !=
nullptr &&
61 timerAlarmRepeatingRef->callback !=
nullptr)
62 timerAlarmRepeatingRef->callback(timerAlarmRepeatingRef);
66 repeating_timer_callback_t callback =
nullptr;
68 void setupTimer(uint64_t sample_rate) {
72 uint32_t steps = F_CPU / 8 / sample_rate;
74 LOGE(
"requested sample rate not supported: %d - we use %d", sample_rate,
78 LOGD(
"compare match register set to %d", steps);
86 TCCR1B |= (1 << WGM12);
88 TCCR1B |= (1 << CS11);
89 TIMSK1 |= (1 << OCIE1A);
TimeUnit
Time Units.
Definition: AudioTypes.h:45