mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/ztimer: properly initialize intermediate extension callback
This commit is contained in:
parent
d03884d7b7
commit
fc68d9c3a3
@ -485,6 +485,23 @@ void ztimer_update_head_offset(ztimer_clock_t *clock);
|
|||||||
*/
|
*/
|
||||||
void ztimer_init(void);
|
void ztimer_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize possible ztimer extension intermediate timer
|
||||||
|
*
|
||||||
|
* This will basically just set a timer to (clock->max_value >> 1), *if*
|
||||||
|
* max_value is not UINT32_MAX.
|
||||||
|
*
|
||||||
|
* This is called automatically by all ztimer backends and extension modules.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
static inline void ztimer_init_extend(ztimer_clock_t *clock)
|
||||||
|
{
|
||||||
|
if (clock->max_value < UINT32_MAX) {
|
||||||
|
clock->ops->set(clock, clock->max_value >> 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* default ztimer virtual devices */
|
/* default ztimer virtual devices */
|
||||||
/**
|
/**
|
||||||
* @brief Default ztimer microsecond clock
|
* @brief Default ztimer microsecond clock
|
||||||
|
@ -91,6 +91,7 @@ void ztimer_convert_frac_init(ztimer_convert_frac_t *self, ztimer_clock_t *lower
|
|||||||
ztimer_convert_frac_compute_scale(self, freq_self, freq_lower);
|
ztimer_convert_frac_compute_scale(self, freq_self, freq_lower);
|
||||||
if (freq_self < freq_lower) {
|
if (freq_self < freq_lower) {
|
||||||
self->super.super.max_value = frac_scale(&self->scale_set, UINT32_MAX);
|
self->super.super.max_value = frac_scale(&self->scale_set, UINT32_MAX);
|
||||||
|
ztimer_init_extend(&self->super.super);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("ztimer_convert_frac_init: rounding up val:%" PRIu32"\n",
|
DEBUG("ztimer_convert_frac_init: rounding up val:%" PRIu32"\n",
|
||||||
|
@ -120,4 +120,5 @@ void ztimer_convert_muldiv64_init(
|
|||||||
ztimer_convert_muldiv64->super.super.ops = &_ztimer_convert_muldiv64_ops;
|
ztimer_convert_muldiv64->super.super.ops = &_ztimer_convert_muldiv64_ops;
|
||||||
ztimer_convert_muldiv64->div = div;
|
ztimer_convert_muldiv64->div = div;
|
||||||
ztimer_convert_muldiv64->mul = mul;
|
ztimer_convert_muldiv64->mul = mul;
|
||||||
|
ztimer_init_extend(&ztimer_convert_muldiv64->super.super);
|
||||||
}
|
}
|
||||||
|
@ -88,4 +88,5 @@ void ztimer_periph_rtt_init(ztimer_periph_rtt_t *clock)
|
|||||||
clock->max_value = RTT_MAX_VALUE;
|
clock->max_value = RTT_MAX_VALUE;
|
||||||
rtt_init();
|
rtt_init();
|
||||||
rtt_poweron();
|
rtt_poweron();
|
||||||
|
ztimer_init_extend(clock);
|
||||||
}
|
}
|
||||||
|
@ -79,4 +79,5 @@ void ztimer_periph_timer_init(ztimer_periph_timer_t *clock, tim_t dev, unsigned
|
|||||||
clock->super.ops = &_ztimer_periph_timer_ops;
|
clock->super.ops = &_ztimer_periph_timer_ops;
|
||||||
clock->super.max_value = max_val;
|
clock->super.max_value = max_val;
|
||||||
timer_init(dev, freq, _ztimer_periph_timer_callback, clock);
|
timer_init(dev, freq, _ztimer_periph_timer_callback, clock);
|
||||||
|
ztimer_init_extend(&clock->super);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user