organizing namespace to avoid uctrl clashes

pull/7/head
midilab 4 years ago
parent 8f40365a13
commit 6ff4120cc4
  1. 21
      src/uClock.cpp
  2. 4
      src/uClock.h

@ -28,27 +28,24 @@
*/
#include "uClock.h"
#define ATOMIC(X) noInterrupts(); X; interrupts();
//
// Timer setup for work clock
//
#if defined(TEENSYDUINO) && !defined(__AVR_ATmega32U4__)
IntervalTimer _teensyTimer;
void teensyInterrupt();
void workClock()
IntervalTimer _uclockTimer;
void uclockISR();
void uclockInitTimer()
{
_teensyTimer.begin(teensyInterrupt, 16);
_uclockTimer.begin(uclockISR, 16);
// 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).
_teensyTimer.priority(0);
_uclockTimer.priority(0);
}
#else
void workClock()
void uclockInitTimer()
{
ATOMIC(
// Timer1
@ -126,8 +123,8 @@ uClockClass::uClockClass()
void uClockClass::init()
{
// init work clock timer interrupt in Hz
workClock();
// init work clock timer interrupt at 16 microseconds
uclockInitTimer();
}
void uClockClass::start()
@ -433,7 +430,7 @@ volatile uint32_t _timer = 0;
// Clocked at: 62.5kHz/16usec
//
#if defined(TEENSYDUINO) && !defined(__AVR_ATmega32U4__)
void teensyInterrupt()
void uclockISR()
#else
ISR(TIMER1_COMPA_vect)
//ISR(TIMER2_COMPA_vect)

@ -33,6 +33,8 @@
#include <Arduino.h>
#include <inttypes.h>
namespace umodular { namespace clock {
#define PHASE_FACTOR 16
#define EXT_INTERVAL_BUFFER_SIZE 24
@ -44,7 +46,7 @@
#define MIN_BPM 1
#define MAX_BPM 300
namespace umodular { namespace clock {
#define ATOMIC(X) noInterrupts(); X; interrupts();
class uClockClass {

Loading…
Cancel
Save