Skip to content

Commit cebc5b3

Browse files
author
Hendry Kaak
committed
[Timer] Add getHandle function
This enables users to config timers using the HAL layers for more advanced timer settings when needed. This is especially useful when multiple timer channels require separate configurations under the same timer instance.
1 parent 1e2a598 commit cebc5b3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: cores/arduino/HardwareTimer.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,18 @@ void HardwareTimer::refresh()
712712
HAL_TIM_GenerateEvent(&(_timerObj.handle), TIM_EVENTSOURCE_UPDATE);
713713
}
714714

715+
/**
716+
* @brief Return the timer object handle object for more advanced setup
717+
* @note Using this function and editing the Timer handle is at own risk! No support will
718+
* be provided whatsoever if the HardwareTimer does not work as expected when editing
719+
* the handle using the HAL functionality or other custom coding.
720+
* @retval TIM_HandleTypeDef address
721+
*/
722+
TIM_HandleTypeDef *HardwareTimer::getHandle()
723+
{
724+
return &_timerObj.handle;
725+
}
726+
715727
/**
716728
* @brief Generic Update (rollover) callback which will call user callback
717729
* @param htim: HAL timer handle

Diff for: cores/arduino/HardwareTimer.h

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class HardwareTimer {
126126
static void captureCompareCallback(TIM_HandleTypeDef *htim); // Generic Caputre and Compare callback which will call user callback
127127
static void updateCallback(TIM_HandleTypeDef *htim); // Generic Update (rollover) callback which will call user callback
128128

129+
// The following function(s) are available for more advanced timer options
130+
TIM_HandleTypeDef *getHandle(); // return the handle address for HAL related configuration
129131
private:
130132
TIM_OC_InitTypeDef _channelOC[TIMER_CHANNELS];
131133
TIM_IC_InitTypeDef _channelIC[TIMER_CHANNELS];

0 commit comments

Comments
 (0)