File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -251,9 +251,14 @@ void LowPowerTickerWrapper::_schedule_match(timestamp_t current)
251
251
if (!_set_interrupt_allowed) {
252
252
253
253
// Can't use _intf->set_interrupt so use microsecond Timeout instead
254
- uint32_t ticks = cycles_until_match < _min_count_until_match ? cycles_until_match : _min_count_until_match;
255
- _timeout.attach_us (mbed::callback (this , &LowPowerTickerWrapper::_timeout_handler), _lp_ticks_to_us (ticks));
256
- _pending_timeout = true ;
254
+
255
+ // Speed optimization - if a timer has already been scheduled
256
+ // then don't schedule it again.
257
+ if (!_pending_timeout) {
258
+ uint32_t ticks = cycles_until_match < _min_count_until_match ? cycles_until_match : _min_count_until_match;
259
+ _timeout.attach_us (mbed::callback (this , &LowPowerTickerWrapper::_timeout_handler), _lp_ticks_to_us (ticks));
260
+ _pending_timeout = true ;
261
+ }
257
262
return ;
258
263
}
259
264
You can’t perform that action at this time.
0 commit comments