Skip to content

Commit f62e103

Browse files
author
Cruz Monrreal
authored
Merge pull request #7600 from c1728p9/remove_unnecissary_low_power_ticker_rescheduling
Remove unnecessary low power ticker rescheduling
2 parents 7927823 + 05d33b0 commit f62e103

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

hal/mbed_ticker_api.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static void initialize(const ticker_data_t *ticker)
6969
ticker->queue->max_delta = max_delta;
7070
ticker->queue->max_delta_us = max_delta_us;
7171
ticker->queue->present_time = 0;
72+
ticker->queue->dispatching = false;
7273
ticker->queue->initialized = true;
7374

7475
update_present_time(ticker);
@@ -229,6 +230,12 @@ int _ticker_match_interval_passed(timestamp_t prev_tick, timestamp_t cur_tick, t
229230
static void schedule_interrupt(const ticker_data_t *const ticker)
230231
{
231232
ticker_event_queue_t *queue = ticker->queue;
233+
if (ticker->queue->dispatching) {
234+
// Don't schedule the next interrupt until dispatching is
235+
// finished. This prevents repeated calls to interface->set_interrupt
236+
return;
237+
}
238+
232239
update_present_time(ticker);
233240

234241
if (ticker->queue->head) {
@@ -280,6 +287,7 @@ void ticker_irq_handler(const ticker_data_t *const ticker)
280287
ticker->interface->clear_interrupt();
281288

282289
/* Go through all the pending TimerEvents */
290+
ticker->queue->dispatching = true;
283291
while (1) {
284292
if (ticker->queue->head == NULL) {
285293
break;
@@ -302,6 +310,7 @@ void ticker_irq_handler(const ticker_data_t *const ticker)
302310
break;
303311
}
304312
}
313+
ticker->queue->dispatching = false;
305314

306315
schedule_interrupt(ticker);
307316

hal/ticker_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ typedef struct {
8181
uint64_t tick_remainder; /**< Ticks that have not been added to base_time */
8282
us_timestamp_t present_time; /**< Store the timestamp used for present time */
8383
bool initialized; /**< Indicate if the instance is initialized */
84+
bool dispatching; /**< The function ticker_irq_handler is dispatching */
8485
uint8_t frequency_shifts; /**< If frequency is a value of 2^n, this is n, otherwise 0 */
8586
} ticker_event_queue_t;
8687

rtos/TARGET_CORTEX/SysTimer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ void SysTimer::handler()
178178
} else {
179179
_set_irq_pending();
180180
_increment_tick();
181+
schedule_tick();
181182
}
182183

183184
core_util_critical_section_exit();

rtos/TARGET_CORTEX/mbed_rtx_idle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void OS_Tick_Disable (void)
6363
/// Acknowledge System Timer IRQ.
6464
void OS_Tick_AcknowledgeIRQ (void)
6565
{
66-
os_timer->schedule_tick();
66+
6767
}
6868

6969
/// Get System Timer count.

0 commit comments

Comments
 (0)