timer: pooling update bit before reading count value

This commit is contained in:
morris 2020-11-11 19:54:04 +08:00
parent f5939c9e68
commit deea402cf4
3 changed files with 3 additions and 0 deletions

View File

@ -103,6 +103,7 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_
FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val)
{
hw->hw_timer[timer_num].update = 1;
while (hw->hw_timer[timer_num].update) {}
*timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high << 32) | (hw->hw_timer[timer_num].cnt_low);
}

View File

@ -99,6 +99,7 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_
FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val)
{
hw->hw_timer[timer_num].update.update = 1;
while (hw->hw_timer[timer_num].update.update) {}
*timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high << 32) | (hw->hw_timer[timer_num].cnt_low);
}

View File

@ -100,6 +100,7 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_
FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val)
{
hw->hw_timer[timer_num].update.update = 1;
while (hw->hw_timer[timer_num].update.update) {}
*timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high.hi << 32) | (hw->hw_timer[timer_num].cnt_low);
}