@@ -142,7 +142,6 @@ static void alarm_pool_irq_handler(void) {
142
142
uint timer_num = ta_timer_num (timer );
143
143
alarm_pool_t * pool = pools [timer_num ][timer_alarm_num ];
144
144
assert (pool -> timer_alarm_num == timer_alarm_num );
145
- int64_t now = (int64_t ) ta_time_us_64 (timer );
146
145
int64_t earliest_target ;
147
146
// 1. clear force bits if we were forced (do this outside the loop, as forcing is hopefully rare)
148
147
ta_clear_force_irq (timer , timer_alarm_num );
@@ -159,7 +158,7 @@ static void alarm_pool_irq_handler(void) {
159
158
if (earliest_index >= 0 ) {
160
159
alarm_pool_entry_t * earliest_entry = & pool -> entries [earliest_index ];
161
160
earliest_target = earliest_entry -> target ;
162
- if ((now - earliest_target ) >= 0 ) {
161
+ if ((( int64_t ) ta_time_us_64 ( timer ) - earliest_target ) >= 0 ) {
163
162
// time to call the callback now (or in the past)
164
163
// note that an entry->target of < 0 means the entry has been canceled (not this is set
165
164
// by this function, in response to the entry having been queued by the cancel_alarm API
@@ -259,15 +258,14 @@ static void alarm_pool_irq_handler(void) {
259
258
index = next ;
260
259
}
261
260
}
262
- now = (int64_t ) ta_time_us_64 (timer );
263
261
earliest_index = pool -> ordered_head ;
264
262
if (earliest_index < 0 ) break ;
265
263
// need to wait
266
264
alarm_pool_entry_t * earliest_entry = & pool -> entries [earliest_index ];
267
265
earliest_target = earliest_entry -> target ;
268
266
ta_set_timeout (timer , timer_alarm_num , earliest_target );
269
267
// check we haven't now past the target time; if not we don't want to loop again
270
- } while ((earliest_target - now ) <= 0 );
268
+ } while ((earliest_target - ( int64_t ) ta_time_us_64 ( timer ) ) <= 0 );
271
269
}
272
270
273
271
void alarm_pool_post_alloc_init (alarm_pool_t * pool , alarm_pool_timer_t * timer , uint hardware_alarm_num , uint max_timers ) {
0 commit comments