[riot-devel] Blinking LEDs with xtimer

malo malo at 25cmsquare.io
Tue Feb 23 21:10:39 CET 2016


Hello riots,

just joined the list, have been playing with riot for few days already.
at first - all the admiration for the hard and good work!

while playing with msp430 and blinking LED threads have noticed two
"glitches" in xtimer_core.

If somebody more familiar with code could have look at it, since maybe Im
missing something...

here is the proposed change
@@ -217,8 +217,9 @@ static void _add_timer_to_list(xtimer_t **list_head,
xtimer_t *timer)
 static void _add_timer_to_long_list(xtimer_t **list_head, xtimer_t *timer)
 {
     while (*list_head
-            && (*list_head)->long_target <= timer->long_target
-            && (*list_head)->target <= timer->target) {
+            && (((*list_head)->long_target < timer->long_target)
+            || ((*list_head)->long_target == timer->long_target
+            && (*list_head)->target <= timer->target))) {
         list_head = &((*list_head)->next);
     }

example: there is already long list head -> long target  = 1 and target = 5
while adding new timer with long target = 0 and target  = 6

one more improvement would be
@@ -179,7 +179,7 @@ int _xtimer_set_absolute(xtimer_t *timer, uint32_t
target)
         timer->long_target++;
     }

-    if ( !_this_high_period(target) ) {
+    if ( timer->long_target > _long_cnt || !_this_high_period(target) ) {
         DEBUG("xtimer_set_absolute(): the timer doesn't fit into the
low-level timer's mask.\n");
         _add_timer_to_long_list(&long_list_head, timer);
     }

since xtimer_set_wakeup - xtimer_set  can be called with 0xFFFFFFFF offset.

wbr
malo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20160223/cb5e5010/attachment.html>


More information about the devel mailing list