Skip to content
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

Fixed setting HardwareTimer interrupt priority #1062

Merged
merged 2 commits into from
May 13, 2020
Merged
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: 9 additions & 3 deletions cores/arduino/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
/* Private Variables */
timerObj_t *HardwareTimer_Handle[TIMER_NUM] = {NULL};

IRQn_Type getTimerUpIrq(TIM_TypeDef *tim);
IRQn_Type getTimerCCIrq(TIM_TypeDef *tim);

/**
* @brief HardwareTimer constructor: set default configuration values
* @param Timer instance ex: TIM1, ...
Expand Down Expand Up @@ -913,6 +910,15 @@ void HardwareTimer::setPWM(uint32_t channel, PinName pin, uint32_t frequency, ui
*/
void HardwareTimer::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriority)
{
// Set Update interrupt priority for immediate use
HAL_NVIC_SetPriority(getTimerUpIrq(_timerObj.handle.Instance), preemptPriority, subPriority);

// Set Capture/Compare interrupt priority if timer provides a unique IRQ
if (getTimerCCIrq(_timerObj.handle.Instance) != getTimerUpIrq(_timerObj.handle.Instance)) {
HAL_NVIC_SetPriority(getTimerCCIrq(_timerObj.handle.Instance), preemptPriority, subPriority);
}

sjasonsmith marked this conversation as resolved.
Show resolved Hide resolved
// Store priority for use if timer is re-initialized
_timerObj.preemptPriority = preemptPriority;
_timerObj.subPriority = subPriority;
}
Expand Down