experimental support for esp32

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

@ -50,9 +50,22 @@
//
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
hw_timer_t * _uclockTimer = NULL;
portMUX_TYPE _uclockTimerMux = portMUX_INITIALIZER_UNLOCKED;
#define TIMER_ID 0
#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)
void uclockInitTimer()
{
@ -72,8 +85,15 @@ void uclockInitTimer()
TIMSK1 |= (1 << OCIE1A);
)
}
#else
// forward declaration of ISR
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
void ARDUINO_ISR_ATTR uclockISR();
#else
void uclockISR();
#endif
void uclockInitTimer()
{
// begin at 120bpm (20833us)
@ -501,6 +521,8 @@ volatile uint32_t _timer = 0;
//
#if defined(ARDUINO_ARCH_AVR)
ISR(TIMER1_COMPA_vect)
#elif defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
void ARDUINO_ISR_ATTR uclockISR()
#else
void uclockISR()
#endif

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

Loading…
Cancel
Save