mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/sam0_common/rt%: issue READREQUEST to access CLOCK/COUNT regs
read-synchronized register will stall immediatly when read, instead issue READREQUEST and wait for sync to be unset.
This commit is contained in:
parent
1992f57765
commit
bdda25c534
@ -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;
|
||||
|
@ -51,6 +51,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
|
||||
@ -136,6 +144,7 @@ void rtt_clear_overflow_cb(void)
|
||||
uint32_t rtt_get_counter(void)
|
||||
{
|
||||
_wait_syncbusy();
|
||||
_rtt_read_req();
|
||||
return RTC->MODE0.COUNT.reg;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user