- added non freertos version as option for esp32 users

develop
midilab 5 days ago
parent c336bdd7c3
commit 4203dbb613
  1. 2
      library.json
  2. 2
      library.properties
  3. 9
      src/platforms/avr.h
  4. 32
      src/platforms/esp32-nofrertos.h
  5. 6
      src/platforms/esp32.h
  6. 6
      src/uClock.cpp
  7. 2
      src/uClock.h

@ -1,6 +1,6 @@
{
"name": "uClock",
"version": "2.2.0",
"version": "2.2.1",
"description": "A Library to implement BPM clock tick calls using hardware interruption. Supported and tested on AVR boards(ATmega168/328, ATmega16u4/32u4 and ATmega2560) and ARM boards(Teensy, STM32XX, ESP32, Raspberry Pico, Seedstudio XIAO M0 and RP2040)",
"keywords": "bpm, clock, timing, tick, music, generator",
"repository":

@ -1,5 +1,5 @@
name=uClock
version=2.2.0
version=2.2.1
author=Romulo Silva <contact@midilab.co>
maintainer=Romulo Silva <contact@midilab.co>
sentence=BPM clock generator for Arduino platform.

@ -6,6 +6,15 @@
// TODO: we should do this using macro guards for avrs different clocks freqeuncy setup at compile time
#define AVR_CLOCK_FREQ 16000000
// forward declaration of uClockHandler
void uClockHandler();
// AVR ISR Entrypoint
ISR(TIMER1_COMPA_vect)
{
uClockHandler();
}
void initTimer(uint32_t init_clock)
{
ATOMIC(

@ -0,0 +1,32 @@
#include <Arduino.h>
#define TIMER_ID 0
hw_timer_t * _uclockTimer = NULL;
portMUX_TYPE _uclockTimerMux = portMUX_INITIALIZER_UNLOCKED;
#define ATOMIC(X) portENTER_CRITICAL_ISR(&_uclockTimerMux); X; portEXIT_CRITICAL_ISR(&_uclockTimerMux);
// forward declaration of uClockHandler
void uClockHandler();
// ISR handler
void ARDUINO_ISR_ATTR handlerISR(void)
{
uClockHandler();
}
void initTimer(uint32_t init_clock)
{
_uclockTimer = timerBegin(init_clock);
// attach to generic uclock ISR
timerAttachInterrupt(_uclockTimer, &handlerISR);
// init clock tick time
timerAlarm(_uclockTimer, init_clock, true, 0);
}
void setTimer(uint32_t us_interval)
{
timerAlarmWrite(_uclockTimer, us_interval, true);
}

@ -3,11 +3,7 @@
#include <freertos/semphr.h>
// esp32-specific timer
#define TIMER_ID 0
hw_timer_t * _uclockTimer = NULL;
// mutex control for ISR
//portMUX_TYPE _uclockTimerMux = portMUX_INITIALIZER_UNLOCKED;
//#define ATOMIC(X) portENTER_CRITICAL_ISR(&_uclockTimerMux); X; portEXIT_CRITICAL_ISR(&_uclockTimerMux);
// FreeRTOS main clock task size in bytes
#define CLOCK_STACK_SIZE 5*1024 // adjust for your needs, a sequencer with heavy serial handling should be large in size
@ -47,7 +43,7 @@ void initTimer(uint32_t init_clock)
// create the clockTask
xTaskCreate(clockTask, "clockTask", CLOCK_STACK_SIZE, NULL, 1, &taskHandle);
_uclockTimer = timerBegin(1000000);
_uclockTimer = timerBegin(init_clock);
// attach to generic uclock ISR
timerAttachInterrupt(_uclockTimer, &handlerISR);

@ -2,7 +2,7 @@
* @file uClock.cpp
* Project BPM clock generator for Arduino
* @brief A Library to implement BPM clock tick calls using hardware interruption. Supported and tested on AVR boards(ATmega168/328, ATmega16u4/32u4 and ATmega2560) and ARM boards(RPI2040, Teensy, Seedstudio XIAO M0 and ESP32)
* @version 2.2.0
* @version 2.2.1
* @author Romulo Silva
* @date 10/06/2017
* @license MIT - (c) 2024 - Romulo Silva - contact@midilab.co
@ -532,11 +532,7 @@ volatile uint32_t _millis = 0;
//
// TIMER HANDLER
//
#if defined(ARDUINO_ARCH_AVR)
ISR(TIMER1_COMPA_vect)
#else
void uClockHandler()
#endif
{
// global timer counter
_millis = millis();

@ -2,7 +2,7 @@
* @file uClock.h
* Project BPM clock generator for Arduino
* @brief A Library to implement BPM clock tick calls using hardware interruption. Supported and tested on AVR boards(ATmega168/328, ATmega16u4/32u4 and ATmega2560) and ARM boards(RPI2040, Teensy, Seedstudio XIAO M0 and ESP32)
* @version 2.2.0
* @version 2.2.1
* @author Romulo Silva
* @date 10/06/2017
* @license MIT - (c) 2024 - Romulo Silva - contact@midilab.co

Loading…
Cancel
Save