1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sam0/rtc_rtt: optimize pm_unblock/pm_block ping-pong during set alarm

This commit is contained in:
Juergen Fitschen 2022-11-16 11:34:07 +01:00
parent e59446eaf8
commit 9c6f07f80a

View File

@ -588,10 +588,22 @@ int rtc_get_time(struct tm *time)
return 0;
}
static void _rtc_clear_alarm(void)
{
/* disable alarm interrupt */
RTC->MODE2.INTENCLR.reg = RTC_MODE2_INTENCLR_ALARM0;
}
void rtc_clear_alarm(void)
{
_rtc_clear_alarm();
_pm_unblock(&_pm_alarm);
}
int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg)
{
/* prevent old alarm from ringing */
rtc_clear_alarm();
_rtc_clear_alarm();
/* normalize input */
rtc_tm_normalize(time);
@ -650,14 +662,6 @@ int rtc_set_time(struct tm *time)
return 0;
}
void rtc_clear_alarm(void)
{
/* disable alarm interrupt */
RTC->MODE2.INTENCLR.reg = RTC_MODE2_INTENCLR_ALARM0;
_pm_unblock(&_pm_alarm);
}
void rtc_poweron(void)
{
_poweron();
@ -713,10 +717,22 @@ uint32_t rtt_get_alarm(void)
return RTC->MODE0.COMP[0].reg;
}
static void _rtt_clear_alarm(void)
{
/* disable compare interrupt */
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
}
void rtt_clear_alarm(void)
{
_rtt_clear_alarm();
_pm_unblock(&_pm_alarm);
}
void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
{
/* disable interrupt to avoid race */
rtt_clear_alarm();
_rtt_clear_alarm();
/* setup callback */
alarm_cb.cb = cb;
@ -736,14 +752,6 @@ void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
}
}
void rtt_clear_alarm(void)
{
/* disable compare interrupt */
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
_pm_unblock(&_pm_alarm);
}
void rtt_poweron(void)
{
_poweron();