@@ -48,7 +48,8 @@ static volatile int8_t currentServoIndex[_Nbr_16timers];
4848extern " C" {
4949#endif
5050
51- inline void Servo_Handler (timer16_Sequence_t timer, NRF_TIMER_Type *nrfTimer, uint32_t ccReg)
51+ static __inline__ void Servo_Handler (timer16_Sequence_t timer, NRF_TIMER_Type *nrfTimer, uint32_t ccReg) __attribute__((always_inline));
52+ static __inline__ void Servo_Handler (timer16_Sequence_t timer, NRF_TIMER_Type *nrfTimer, uint32_t ccReg)
5253{
5354 // Clear the interrupt event flag
5455 nrfTimer->EVENTS_COMPARE [ccReg] = 0 ;
@@ -125,10 +126,10 @@ static void _initISR(NRF_TIMER_Type *nrfTimer, uint32_t ccReg, IRQn_Type timerIR
125126 __disable_irq ();
126127 nrfTimer->TASKS_STOP = 1 ;
127128
128- nrfTimer->MODE = TIMER_MODE_MODE_Timer;
129- nrfTimer->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
130- nrfTimer->PRESCALER = ( TMR_FREQ_REG_PRESCALER << TIMER_PRESCALER_PRESCALER_Pos) ;
131- nrfTimer->SHORTS = 0 ; // No CC event and CLEAR task shortcuts
129+ nrfTimer->MODE = TIMER_MODE_MODE_Timer << TIMER_MODE_MODE_Pos ;
130+ nrfTimer->BITMODE = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos ;
131+ nrfTimer->PRESCALER = TMR_FREQ_REG_PRESCALER << TIMER_PRESCALER_PRESCALER_Pos;
132+ nrfTimer->SHORTS = TIMER_SHORTS_DISABLE_ALL;
132133 nrfTimer->TASKS_CLEAR = 1 ; // Clear task
133134 nrfTimer->EVENTS_COMPARE [ccReg] = 0 ; // Clear interrupt event flag
134135 nrfTimer->CC [ccReg] = (uint32_t )usToTicks (REFRESH_INTERVAL);
@@ -142,6 +143,7 @@ static void _initISR(NRF_TIMER_Type *nrfTimer, uint32_t ccReg, IRQn_Type timerIR
142143 } else if (ccReg == TMR_CC_REG3) {
143144 nrfTimer->INTENSET = (TIMER_INTENSET_COMPARE3_Set << TIMER_INTENSET_COMPARE3_Pos);
144145 }
146+ NVIC_ClearPendingIRQ (timerIRQn);
145147 NVIC_SetPriority (timerIRQn, TMR_PRIORITY);
146148 NVIC_EnableIRQ (timerIRQn);
147149
0 commit comments