mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ztimer/periph_rtc: add start() and stop() ops
This commit is contained in:
parent
5818e5e452
commit
d22e078118
@ -243,6 +243,13 @@ config MODULE_ZTIMER_ONDEMAND_TIMER
|
|||||||
Turn off the underlying Timer peripheral if related ztimer clocks
|
Turn off the underlying Timer peripheral if related ztimer clocks
|
||||||
have no users.
|
have no users.
|
||||||
|
|
||||||
|
config MODULE_ZTIMER_ONDEMAND_RTC
|
||||||
|
bool "Run RTC only on demand"
|
||||||
|
depends on MODULE_ZTIMER_PERIPH_RTC
|
||||||
|
help
|
||||||
|
Turn off the underlying RTC peripheral if related ztimer clocks
|
||||||
|
have no users.
|
||||||
|
|
||||||
endif # MODULE_ZTIMER_ONDEMAND
|
endif # MODULE_ZTIMER_ONDEMAND
|
||||||
|
|
||||||
config MODULE_ZTIMER_INIT
|
config MODULE_ZTIMER_INIT
|
||||||
|
@ -138,10 +138,28 @@ static void _ztimer_periph_rtc_cancel(ztimer_clock_t *clock)
|
|||||||
rtc_clear_alarm();
|
rtc_clear_alarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MODULE_ZTIMER_ONDEMAND_RTC
|
||||||
|
static void _ztimer_periph_rtc_start(ztimer_clock_t *clock)
|
||||||
|
{
|
||||||
|
(void)clock;
|
||||||
|
rtc_poweron();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _ztimer_periph_rtc_stop(ztimer_clock_t *clock)
|
||||||
|
{
|
||||||
|
(void)clock;
|
||||||
|
rtc_poweroff();
|
||||||
|
}
|
||||||
|
#endif /* MODULE_ZTIMER_ONDEMAND_RTC */
|
||||||
|
|
||||||
static const ztimer_ops_t _ztimer_periph_rtc_ops = {
|
static const ztimer_ops_t _ztimer_periph_rtc_ops = {
|
||||||
.set = _ztimer_periph_rtc_set,
|
.set = _ztimer_periph_rtc_set,
|
||||||
.now = _ztimer_periph_rtc_now,
|
.now = _ztimer_periph_rtc_now,
|
||||||
.cancel = _ztimer_periph_rtc_cancel,
|
.cancel = _ztimer_periph_rtc_cancel,
|
||||||
|
#if MODULE_ZTIMER_ONDEMAND_RTC
|
||||||
|
.start = _ztimer_periph_rtc_start,
|
||||||
|
.stop = _ztimer_periph_rtc_stop,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void ztimer_periph_rtc_init(ztimer_periph_rtc_t *clock)
|
void ztimer_periph_rtc_init(ztimer_periph_rtc_t *clock)
|
||||||
@ -149,5 +167,10 @@ void ztimer_periph_rtc_init(ztimer_periph_rtc_t *clock)
|
|||||||
clock->ops = &_ztimer_periph_rtc_ops;
|
clock->ops = &_ztimer_periph_rtc_ops;
|
||||||
clock->max_value = UINT32_MAX;
|
clock->max_value = UINT32_MAX;
|
||||||
rtc_init();
|
rtc_init();
|
||||||
|
|
||||||
|
#if MODULE_ZTIMER_ONDEMAND_RTC
|
||||||
|
rtc_poweroff();
|
||||||
|
#else
|
||||||
rtc_poweron();
|
rtc_poweron();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user