Skip to content

Commit b955c66

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 b955c66

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: cores/arduino/HardwareTimer.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,14 @@ 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+
* @retval TIM_HandleTypeDef address
718+
*/
719+
TIM_HandleTypeDef * HardwareTimer::getHandle() {
720+
return &_timerObj.handle;
721+
}
722+
715723
/**
716724
* @brief Generic Update (rollover) callback which will call user callback
717725
* @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)