experimental support for esp32

pull/22/head
midilab 2 years ago
parent a4dc3fbbda
commit 08e62bd0be
  1. 24
      src/uClock.cpp
  2. 2
      src/uClock.h

@ -50,9 +50,22 @@
// //
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32) #if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
hw_timer_t * _uclockTimer = NULL; hw_timer_t * _uclockTimer = NULL;
portMUX_TYPE _uclockTimerMux = portMUX_INITIALIZER_UNLOCKED;
#define TIMER_ID 0 #define TIMER_ID 0
#endif #endif
//
// multicore archs
//
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
#define ATOMIC(X) portENTER_CRITICAL_ISR(&_uclockTimerMux); X; portEXIT_CRITICAL_ISR(&_uclockTimerMux);
//
// singlecore archs
//
#else
#define ATOMIC(X) noInterrupts(); X; interrupts();
#endif
#if defined(ARDUINO_ARCH_AVR) #if defined(ARDUINO_ARCH_AVR)
void uclockInitTimer() void uclockInitTimer()
{ {
@ -73,7 +86,14 @@ void uclockInitTimer()
) )
} }
#else #else
void uclockISR();
// forward declaration of ISR
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
void ARDUINO_ISR_ATTR uclockISR();
#else
void uclockISR();
#endif
void uclockInitTimer() void uclockInitTimer()
{ {
// begin at 120bpm (20833us) // begin at 120bpm (20833us)
@ -501,6 +521,8 @@ volatile uint32_t _timer = 0;
// //
#if defined(ARDUINO_ARCH_AVR) #if defined(ARDUINO_ARCH_AVR)
ISR(TIMER1_COMPA_vect) ISR(TIMER1_COMPA_vect)
#elif defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
void ARDUINO_ISR_ATTR uclockISR()
#else #else
void uclockISR() void uclockISR()
#endif #endif

@ -54,8 +54,6 @@ namespace umodular { namespace clock {
#define SECS_PER_HOUR (3600UL) #define SECS_PER_HOUR (3600UL)
#define SECS_PER_DAY (SECS_PER_HOUR * 24L) #define SECS_PER_DAY (SECS_PER_HOUR * 24L)
#define ATOMIC(X) noInterrupts(); X; interrupts();
class uClockClass { class uClockClass {
private: private:

Loading…
Cancel
Save