diff --git a/src/xtimer.rs b/src/xtimer.rs index 8cf2467..b2c5aec 100644 --- a/src/xtimer.rs +++ b/src/xtimer.rs @@ -104,10 +104,22 @@ impl XTimer { self.get_tick_count = Some(get_tick_count); self.cache_timer_num = cache_timer_num; self.free_timer_num = 0; - self.mut_traverse_timer_list( - &mut |timer_list: &mut TimerListListHeadRp| { - *timer_list = crate::ListHead::::new_head(); - }); + self.work_list = crate::ListHead::::new_head(); + for i in 0..TVR_SIZE-1 { + self.tv1.push(crate::ListHead::::new_head()); + } + for i in 0..TVN_SIZE-1 { + self.tv2.push(crate::ListHead::::new_head()); + } + for i in 0..TVN_SIZE-1 { + self.tv3.push(crate::ListHead::::new_head()); + } + for i in 0..TVN_SIZE-1 { + self.tv4.push(crate::ListHead::::new_head()); + } + for i in 0..TVN_SIZE-1 { + self.tv5.push(crate::ListHead::::new_head()); + } match &self.get_tick_count { Some(v) => { self.timer_tick = (*v)(); @@ -140,20 +152,6 @@ impl XTimer { for_each_cb(&self.tv5); } - fn mut_traverse_timer_list(&mut self, cb: &mut dyn FnMut (&mut TimerListListHeadRp)) { - (*cb)(&mut self.work_list); - let mut for_each_cb = |tv: &mut [TimerListListHeadRp]| { - for i in 0..tv.len() { - (*cb)(&mut tv[i]); - } - }; - for_each_cb(&mut self.tv1); - for_each_cb(&mut self.tv2); - for_each_cb(&mut self.tv3); - for_each_cb(&mut self.tv4); - for_each_cb(&mut self.tv5); - } - pub fn uninit(&mut self) { self.clear(); }