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" #include "uClock.h"
#define ATOMIC(X) noInterrupts(); X; interrupts();
// //
// Timer setup for work clock // Timer setup for work clock
// //
#if defined(TEENSYDUINO) && !defined(__AVR_ATmega32U4__) #if defined(TEENSYDUINO) && !defined(__AVR_ATmega32U4__)
IntervalTimer _teensyTimer; IntervalTimer _uclockTimer;
void teensyInterrupt(); void uclockISR();
void workClock() void uclockInitTimer()
{ {
_teensyTimer.begin(teensyInterrupt, 16); _uclockTimer.begin(uclockISR, 16);
// Set the interrupt priority level, controlling which other interrupts // Set the interrupt priority level, controlling which other interrupts
// this timer is allowed to interrupt. Lower numbers are higher priority, // 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. // 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 // As a general guideline, interrupt routines that run longer should be given
// lower priority (higher numerical values). // lower priority (higher numerical values).
_teensyTimer.priority(0); _uclockTimer.priority(0);
} }
#else #else
void workClock() void uclockInitTimer()
{ {
ATOMIC( ATOMIC(
// Timer1 // Timer1
@ -126,8 +123,8 @@ uClockClass::uClockClass()
void uClockClass::init() void uClockClass::init()
{ {
// init work clock timer interrupt in Hz // init work clock timer interrupt at 16 microseconds
workClock(); uclockInitTimer();
} }
void uClockClass::start() void uClockClass::start()
@ -433,7 +430,7 @@ volatile uint32_t _timer = 0;
// Clocked at: 62.5kHz/16usec // Clocked at: 62.5kHz/16usec
// //
#if defined(TEENSYDUINO) && !defined(__AVR_ATmega32U4__) #if defined(TEENSYDUINO) && !defined(__AVR_ATmega32U4__)
void teensyInterrupt() void uclockISR()
#else #else
ISR(TIMER1_COMPA_vect) ISR(TIMER1_COMPA_vect)
//ISR(TIMER2_COMPA_vect) //ISR(TIMER2_COMPA_vect)

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

Loading…
Cancel
Save