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.
25 lines
719 B
25 lines
719 B
#include <Arduino.h>
|
|
|
|
#define ATOMIC(X) noInterrupts(); X; interrupts();
|
|
|
|
IntervalTimer _uclockTimer;
|
|
|
|
// forward declaration of ISR
|
|
void uclockISR();
|
|
|
|
void initTimer(uint32_t init_clock)
|
|
{
|
|
_uclockTimer.begin(uclockISR, init_clock);
|
|
|
|
// Set the interrupt priority level, controlling which other interrupts
|
|
// this timer is allowed to interrupt. Lower numbers are higher priority,
|
|
// with 0 the highest and 255 the lowest. Most other interrupts default to 128.
|
|
// As a general guideline, interrupt routines that run longer should be given
|
|
// lower priority (higher numerical values).
|
|
_uclockTimer.priority(80);
|
|
}
|
|
|
|
void setTimer(uint32_t us_interval)
|
|
{
|
|
_uclockTimer.update(us_interval);
|
|
} |