mirror of https://github.com/midilab/uClock
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
500 B
27 lines
500 B
2 years ago
|
#include <Arduino.h>
|
||
|
|
||
|
// 24 bits timer
|
||
|
#include <TimerTCC0.h>
|
||
|
// uses TimerTcc0
|
||
|
// 16 bits timer
|
||
|
//#include <TimerTC3.h>
|
||
|
// uses TimerTc3
|
||
|
#define ATOMIC(X) noInterrupts(); X; interrupts();
|
||
|
|
||
|
IntervalTimer _uclockTimer;
|
||
|
|
||
|
// forward declaration of ISR
|
||
|
void uclockISR();
|
||
|
|
||
|
void initTimer(uint32_t init_clock)
|
||
|
{
|
||
|
TimerTcc0.initialize(init_clock);
|
||
|
|
||
|
// attach to generic uclock ISR
|
||
|
TimerTcc0.attachInterrupt(uclockISR);
|
||
|
}
|
||
|
|
||
|
void setTimer(uint32_t us_interval)
|
||
|
{
|
||
|
TimerTcc0.setPeriod(us_interval);
|
||
|
}
|