1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00

ztimer/periph_rtt: add start() and stop() ops

This commit is contained in:
Juergen Fitschen 2022-02-04 18:04:36 +01:00 committed by Jue
parent d22e078118
commit a1ee7a5e05
2 changed files with 32 additions and 0 deletions

View File

@ -243,6 +243,13 @@ config MODULE_ZTIMER_ONDEMAND_TIMER
Turn off the underlying Timer peripheral if related ztimer clocks
have no users.
config MODULE_ZTIMER_ONDEMAND_RTT
bool "Run RTT only on demand"
depends on MODULE_ZTIMER_PERIPH_RTT
help
Turn off the underlying RTT peripheral if related ztimer clocks
have no users.
config MODULE_ZTIMER_ONDEMAND_RTC
bool "Run RTC only on demand"
depends on MODULE_ZTIMER_PERIPH_RTC

View File

@ -74,10 +74,28 @@ static void _ztimer_periph_rtt_cancel(ztimer_clock_t *clock)
rtt_clear_alarm();
}
#if MODULE_ZTIMER_ONDEMAND_RTT
static void _ztimer_periph_rtt_start(ztimer_clock_t *clock)
{
(void)clock;
rtt_poweron();
}
static void _ztimer_periph_rtt_stop(ztimer_clock_t *clock)
{
(void)clock;
rtt_poweroff();
}
#endif /* MODULE_ZTIMER_ONDEMAND_RTT */
static const ztimer_ops_t _ztimer_periph_rtt_ops = {
.set = _ztimer_periph_rtt_set,
.now = _ztimer_periph_rtt_now,
.cancel = _ztimer_periph_rtt_cancel,
#if MODULE_ZTIMER_ONDEMAND_RTT
.start = _ztimer_periph_rtt_start,
.stop = _ztimer_periph_rtt_stop,
#endif
};
void ztimer_periph_rtt_init(ztimer_periph_rtt_t *clock)
@ -85,6 +103,13 @@ void ztimer_periph_rtt_init(ztimer_periph_rtt_t *clock)
clock->ops = &_ztimer_periph_rtt_ops;
clock->max_value = RTT_MAX_VALUE;
rtt_init();
#if MODULE_ZTIMER_ONDEMAND_RTT
rtt_poweroff();
#else
rtt_poweron();
#endif
#if !MODULE_ZTIMER_ONDEMAND
ztimer_init_extend(clock);
#endif
}