Lines Matching full:top
175 static uint32_t ticks_add(uint32_t val1, uint32_t val2, uint32_t top) in ticks_add() argument
179 if (likely(IS_BIT_MASK(top))) { in ticks_add()
180 return (val1 + val2) & top; in ticks_add()
183 to_top = top - val1; in ticks_add()
188 static uint32_t ticks_sub(uint32_t val, uint32_t old, uint32_t top) in ticks_sub() argument
190 if (likely(IS_BIT_MASK(top))) { in ticks_sub()
191 return (val - old) & top; in ticks_sub()
194 /* if top is not 2^n-1 */ in ticks_sub()
195 return (val >= old) ? (val - old) : val + top + 1 - old; in ticks_sub()
216 uint32_t top = counter_gd32_timer_get_top_value(dev); in set_cc() local
234 max_rel_val = top - data->guard_period; in set_cc()
246 irq_on_late = val < (top / 2); in set_cc()
248 max_rel_val = irq_on_late ? top / 2 : top; in set_cc()
249 val = ticks_add(now, val, top); in set_cc()
257 diff = ticks_sub(val - 1, get_counter(dev), top); in set_cc()
389 __ASSERT(cb != NULL, "top event enabled - expecting callback"); in top_irq_handle()