File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -676,23 +676,29 @@ bool jshSleep(JsSysTime timeUntilWake) {
676
676
return true;
677
677
}
678
678
679
+ bool utilTimerActive = false;
680
+
679
681
/// Reschedule the timer (it should already be running) to interrupt after 'period'
680
682
void jshUtilTimerReschedule (JsSysTime period ) {
681
683
period = period * 1000000 / SYSCLK_FREQ ;
682
- if (period < 5 ) period = 5 ;
684
+ if (period < 1 ) period = 1 ;
683
685
if (period > 0xFFFFFFFF ) period = 0xFFFFFFFF ;
686
+ if (utilTimerActive ) nrf_timer_task_trigger (NRF_TIMER1 , NRF_TIMER_TASK_STOP );
684
687
nrf_timer_task_trigger (NRF_TIMER1 , NRF_TIMER_TASK_CLEAR );
685
688
nrf_timer_cc_write (NRF_TIMER1 , NRF_TIMER_CC_CHANNEL0 , (uint32_t )period );
689
+ if (utilTimerActive ) nrf_timer_task_trigger (NRF_TIMER1 , NRF_TIMER_TASK_START );
686
690
}
687
691
688
692
/// Start the timer and get it to interrupt after 'period'
689
693
void jshUtilTimerStart (JsSysTime period ) {
690
694
jshUtilTimerReschedule (period );
695
+ utilTimerActive = true;
691
696
nrf_timer_task_trigger (NRF_TIMER1 , NRF_TIMER_TASK_START );
692
697
}
693
698
694
699
/// Stop the timer
695
700
void jshUtilTimerDisable () {
701
+ utilTimerActive = false;
696
702
nrf_timer_task_trigger (NRF_TIMER1 , NRF_TIMER_TASK_STOP );
697
703
}
698
704
You can’t perform that action at this time.
0 commit comments