1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 23:41:18 +01:00

Merge pull request #14302 from fjmolinas/pr_sam0_rtt_opt

cpu/sam0_common/rt%: use READREQUEST when accessing CLOCK/COUNT regs
This commit is contained in:
Francisco 2020-06-24 08:42:03 +02:00 committed by GitHub
commit 48bdd7018a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -52,6 +52,14 @@ static void _wait_syncbusy(void)
#endif
}
static void _rtt_read_req(void)
{
#ifdef RTC_READREQ_RREQ
RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ;
_wait_syncbusy();
#endif
}
static inline void _rtc_set_enabled(bool on)
{
#ifdef REG_RTC_MODE2_CTRLA
@ -145,6 +153,7 @@ int rtc_get_time(struct tm *time)
RTC_MODE2_CLOCK_Type clock;
/* Read register in one time */
_rtt_read_req();
clock.reg = RTC->MODE2.CLOCK.reg;
time->tm_year = clock.bit.YEAR + reference_year;

View File

@ -61,6 +61,14 @@ static void _wait_syncbusy(void)
#endif
}
static void _rtt_read_req(void)
{
#ifdef RTC_READREQ_RREQ
RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ;
_wait_syncbusy();
#endif
}
static inline void _rtt_reset(void)
{
#ifdef RTC_MODE0_CTRL_SWRST
@ -150,6 +158,7 @@ void rtt_clear_overflow_cb(void)
uint32_t rtt_get_counter(void)
{
_wait_syncbusy();
_rtt_read_req();
return RTC->MODE0.COUNT.reg;
}