You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uClock/src/platforms/stm32.h

33 lines
845 B

#include <Arduino.h>
#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/install stm32duino core."
#endif
#if defined(TIM1)
TIM_TypeDef * TimerInstance = TIM1;
#else
TIM_TypeDef * TimerInstance = TIM2;
#endif
// instantiate HardwareTimer object
HardwareTimer * _uclockTimer = new HardwareTimer(TimerInstance);
#define ATOMIC(X) noInterrupts(); X; interrupts();
// forward declaration of ISR
void uclockISR();
void initTimer(uint32_t us_interval)
{
_uclockTimer->setOverflow(us_interval, MICROSEC_FORMAT);
_uclockTimer->attachInterrupt(uclockISR);
_uclockTimer->resume();
}
void setTimer(uint32_t us_interval)
{
_uclockTimer->setOverflow(us_interval, MICROSEC_FORMAT);
_uclockTimer->refresh();
}