Putting overflow code inside an atomic block, and style improvement (using predefined constant instead of raw number)
This commit is contained in:
parent
e9aaff808e
commit
8a9e51c779
|
@ -806,10 +806,12 @@ void timerStart(void)
|
|||
**/
|
||||
void timerForceOverflow(volatile TIM_TypeDef *tim)
|
||||
{
|
||||
// Save the current count so that PPM reading will work on the same timer that was forced to overflow
|
||||
uint8_t timerIndex = lookupTimerIndex((const TIM_TypeDef *)tim);
|
||||
timerConfig[timerIndex].forcedOverflowTimerValue = tim->CNT + 1;
|
||||
ATOMIC_BLOCK(NVIC_PRIO_TIMER) {
|
||||
// Save the current count so that PPM reading will work on the same timer that was forced to overflow
|
||||
uint8_t timerIndex = lookupTimerIndex((const TIM_TypeDef *)tim);
|
||||
timerConfig[timerIndex].forcedOverflowTimerValue = tim->CNT + 1;
|
||||
|
||||
// Force an overflow by setting the UG bit
|
||||
tim->EGR |= 0x0001;
|
||||
// Force an overflow by setting the UG bit
|
||||
tim->EGR |= TIM_EGR_UG;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue