diff --git a/cores/arduino/HardwareTimer.cpp b/cores/arduino/HardwareTimer.cpp index 081ad5dae4..8eeec08cfd 100644 --- a/cores/arduino/HardwareTimer.cpp +++ b/cores/arduino/HardwareTimer.cpp @@ -712,6 +712,18 @@ void HardwareTimer::refresh() HAL_TIM_GenerateEvent(&(_timerObj.handle), TIM_EVENTSOURCE_UPDATE); } +/** + * @brief Return the timer object handle object for more advanced setup + * @note Using this function and editing the Timer handle is at own risk! No support will + * be provided whatsoever if the HardwareTimer does not work as expected when editing + * the handle using the HAL functionality or other custom coding. + * @retval TIM_HandleTypeDef address + */ +TIM_HandleTypeDef *HardwareTimer::getHandle() +{ + return &_timerObj.handle; +} + /** * @brief Generic Update (rollover) callback which will call user callback * @param htim: HAL timer handle diff --git a/cores/arduino/HardwareTimer.h b/cores/arduino/HardwareTimer.h index ce3e0cc1ac..a687af36ee 100644 --- a/cores/arduino/HardwareTimer.h +++ b/cores/arduino/HardwareTimer.h @@ -126,6 +126,8 @@ class HardwareTimer { static void captureCompareCallback(TIM_HandleTypeDef *htim); // Generic Caputre and Compare callback which will call user callback static void updateCallback(TIM_HandleTypeDef *htim); // Generic Update (rollover) callback which will call user callback + // The following function(s) are available for more advanced timer options + TIM_HandleTypeDef *getHandle(); // return the handle address for HAL related configuration private: TIM_OC_InitTypeDef _channelOC[TIMER_CHANNELS]; TIM_IC_InitTypeDef _channelIC[TIMER_CHANNELS];