Skip to content

Commit 7e2f4f6

Browse files
Hendry Kaakfpistm
Hendry Kaak
authored andcommitted
[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 149b648 commit 7e2f4f6

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
@@ -734,6 +734,18 @@ void HardwareTimer::refresh()
734734
HAL_TIM_GenerateEvent(&(_timerObj.handle), TIM_EVENTSOURCE_UPDATE);
735735
}
736736

737+
/**
738+
* @brief Return the timer object handle object for more advanced setup
739+
* @note Using this function and editing the Timer handle is at own risk! No support will
740+
* be provided whatsoever if the HardwareTimer does not work as expected when editing
741+
* the handle using the HAL functionality or other custom coding.
742+
* @retval TIM_HandleTypeDef address
743+
*/
744+
TIM_HandleTypeDef *HardwareTimer::getHandle()
745+
{
746+
return &_timerObj.handle;
747+
}
748+
737749
/**
738750
* @brief Generic Update (rollover) callback which will call user callback
739751
* @param htim: HAL timer handle

Diff for: cores/arduino/HardwareTimer.h

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

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

0 commit comments

Comments
 (0)