2016-07-25 09:04:22 +02:00
|
|
|
#include <internals/timer.h>
|
2016-07-06 11:28:51 +02:00
|
|
|
#include <timer.h>
|
|
|
|
|
2016-07-14 21:10:51 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-07-06 11:28:51 +02:00
|
|
|
struct Timer timers[3] = { { NULL, 0 }, { NULL, 0 }, { NULL, 0 } };
|
|
|
|
|
|
|
|
/*
|
|
|
|
timer_interrupt()
|
|
|
|
Handles the interrupt for the given timer.
|
|
|
|
*/
|
|
|
|
void timer_interrupt(int timer)
|
|
|
|
{
|
2016-08-02 07:51:44 +02:00
|
|
|
volatile struct mod_tmu *tmu;
|
2016-07-06 11:28:51 +02:00
|
|
|
timer_get(timer, &tmu, NULL);
|
|
|
|
|
2016-08-02 07:51:44 +02:00
|
|
|
tmu->TCR.UNF = 0;
|
2016-07-06 11:28:51 +02:00
|
|
|
if(timers[timer].callback) timers[timer].callback();
|
|
|
|
|
|
|
|
// Reducing the number of repetitions left, if not infinite.
|
|
|
|
if(!timers[timer].repeats) return;
|
|
|
|
if(timers[timer].repeats == 1) timer_stop(timer);
|
|
|
|
else timers[timer].repeats--;
|
|
|
|
}
|