@@ -63,25 +63,17 @@ static void armv7m_timer_insert(void *context, uint32_t data)
6363 {
6464 if (remaining < element -> remaining )
6565 {
66+ element -> remaining -= remaining ;
6667 break ;
6768 }
6869
6970 remaining -= element -> remaining ;
7071 element = element -> next ;
7172 }
7273
73- if (element != (armv7m_timer_t * )& armv7m_timer_control )
74- {
75- timer -> previous = element -> previous ;
76- timer -> next = element ;
77-
78- }
79- else
80- {
81- timer -> previous = element ;
82- timer -> next = element -> next ;
83- }
84-
74+ timer -> previous = element -> previous ;
75+ timer -> next = element ;
76+
8577 timer -> previous -> next = timer ;
8678 timer -> next -> previous = timer ;
8779
@@ -177,25 +169,28 @@ static void armv7m_timer_callback(void *context, uint32_t data)
177169 {
178170 timer = armv7m_timer_control .next ;
179171
180- while (timer != (armv7m_timer_t * )& armv7m_timer_control )
172+ if (timer != (armv7m_timer_t * )& armv7m_timer_control )
181173 {
182174 timer -> remaining -- ;
183175
184- if (timer -> remaining != 0 )
185- {
186- break ;
187- }
188-
189- callback = timer -> callback ;
190-
191- armv7m_timer_remove (timer , 0 );
192-
193- if ((uint32_t )callback & 1 )
176+ while (timer != (armv7m_timer_t * )& armv7m_timer_control )
194177 {
195- (* callback )(timer );
178+ if (timer -> remaining )
179+ {
180+ break ;
181+ }
182+
183+ callback = timer -> callback ;
184+
185+ armv7m_timer_remove (timer , 0 );
186+
187+ if ((uint32_t )callback & 1 )
188+ {
189+ (* callback )(timer );
190+ }
191+
192+ timer = armv7m_timer_control .next ;
196193 }
197-
198- timer = armv7m_timer_control .next ;
199194 }
200195
201196 armv7m_timer_control .millis ++ ;
0 commit comments