comment notes updates

pull/24/head
midilab 2 years ago
parent 9b7abae36b
commit 69b9467cc1
  1. 4
      src/platforms/stm32.h
  2. 15
      src/uClock.cpp

@ -1,7 +1,7 @@
#include <Arduino.h> #include <Arduino.h>
#if !defined(STM32_CORE_VERSION) || (STM32_CORE_VERSION < 0x01090000) #if !defined(STM32_CORE_VERSION) || (STM32_CORE_VERSION < 0x01090000)
#error "Due to API change, this library is compatible with STM32_CORE_VERSION >= 0x01090000. Please update your stm32duino core." #error "Due to API change, this library is compatible with STM32_CORE_VERSION >= 0x01090000. Please update/install stm32duino core."
#endif #endif
#if defined(TIM1) #if defined(TIM1)
@ -10,7 +10,7 @@
TIM_TypeDef * TimerInstance = TIM2; TIM_TypeDef * TimerInstance = TIM2;
#endif #endif
// Instantiate HardwareTimer object. Thanks to 'new' instanciation, HardwareTimer is not destructed when setup() function is finished. // instantiate HardwareTimer object
HardwareTimer * _uclockTimer = new HardwareTimer(TimerInstance); HardwareTimer * _uclockTimer = new HardwareTimer(TimerInstance);
#define ATOMIC(X) noInterrupts(); X; interrupts(); #define ATOMIC(X) noInterrupts(); X; interrupts();

@ -58,20 +58,23 @@
#include "platforms/stm32.h" #include "platforms/stm32.h"
#endif #endif
//
// Platform specific timer setup/control
//
// initTimer(uint32_t us_interval) and setTimer(uint32_t us_interval)
// are called from architecture specific module included at the
// header of this file
void uclockInitTimer() void uclockInitTimer()
{ {
// begin at 120bpm (20833us) // begin at 120bpm (20833us)
const uint32_t init_clock = 20833; initTimer(20833);
// called from architecture specific module
initTimer(init_clock);
} }
void setTimerTempo(float bpm) void setTimerTempo(float bpm)
{ {
// convert bpm float into 96 ppqn resolution microseconds interval // convert bpm float into 96 ppqn resolution microseconds interval
uint32_t tick_us_interval = (60000000 / 24 / bpm); uint32_t us_interval = (60000000 / 24 / bpm);
// called from architecture specific module setTimer(us_interval);
setTimer(tick_us_interval);
} }
namespace umodular { namespace clock { namespace umodular { namespace clock {

Loading…
Cancel
Save