Skip to content

[Timer] Add getHandle function #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cores/arduino/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cores/arduino/HardwareTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down