Skip to content

Commit

Permalink
keeping track of dstflag in RTC
Browse files Browse the repository at this point in the history
  • Loading branch information
xaelsouth committed Oct 10, 2024
1 parent d6c50fd commit cf967ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions os/hal/ports/SILABS/LLD/EFR32FG23/BURTCv1/hal_rtc_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ __STATIC_INLINE int _rtc_lld_wday(int year, int month, int day) {
return wday;
}

__STATIC_INLINE void _rtc_lld_to_timespec(uint32_t tv_sec, uint32_t tv_msec, RTCDateTime* timespec) {
__STATIC_INLINE void _rtc_lld_to_timespec(uint32_t tv_sec, uint32_t tv_msec, RTCDateTime* timespec, uint32_t dstflag) {

int year = RTC_BASE_YEAR;
int day = tv_sec / 86400;
Expand Down Expand Up @@ -164,7 +164,7 @@ __STATIC_INLINE void _rtc_lld_to_timespec(uint32_t tv_sec, uint32_t tv_msec, RTC
}

timespec->millisecond = tv_sec * 1000U + tv_msec;
timespec->dstflag = 0;
timespec->dstflag = dstflag;
timespec->year = year - RTC_BASE_YEAR;
timespec->month = month;
timespec->day = day + 1 /* 0 .. 30 -> 1 .. 31 */;
Expand Down Expand Up @@ -240,6 +240,7 @@ void rtc_lld_init(void) {
RTCD1.ovf_counter = buramAllocateAtI(&BURAMD1, 0, 4);
RTCD1.tv_sec = buramAllocateAtI(&BURAMD1, 4, 4);
RTCD1.tv_msec = buramAllocateAtI(&BURAMD1, 8, 4);
RTCD1.dstflag = buramAllocateAtI(&BURAMD1, 12, 4);
#endif

/* Enable clock. */
Expand Down Expand Up @@ -277,6 +278,7 @@ void rtc_lld_init(void) {
*(RTCD1.ovf_counter) = 0U;
*(RTCD1.tv_sec) = 0U;
*(RTCD1.tv_msec) = 0U;
*(RTCD1.dstflag) = 0U;
#endif

/* Clear interrupt flags. */
Expand Down Expand Up @@ -354,6 +356,7 @@ void rtc_lld_set_time(RTCDriver* rtcp, const RTCDateTime* timespec) {
*(rtcp->ovf_counter) = 0U;
*(rtcp->tv_sec) = tv_sec;
*(rtcp->tv_msec) = tv_msec;
*(rtcp->dstflag) = timespec->dstflag;

while ((BURTC->SYNCBUSY & _BURTC_SYNCBUSY_MASK) != 0U);

Expand All @@ -378,7 +381,7 @@ void rtc_lld_get_time(RTCDriver* rtcp, RTCDateTime* timespec) {

syssts_t sts;
uint32_t cnt;
uint32_t ovf_counter, tv_sec, tv_msec;
uint32_t ovf_counter, tv_sec, tv_msec, dstflag;

/* Entering a reentrant critical zone.*/
sts = osalSysGetStatusAndLockX();
Expand All @@ -387,6 +390,7 @@ void rtc_lld_get_time(RTCDriver* rtcp, RTCDateTime* timespec) {
ovf_counter = *(rtcp->ovf_counter);
tv_sec = *(rtcp->tv_sec);
tv_msec = *(rtcp->tv_msec);
dstflag = *(rtcp->dstflag);

/* Read counter. */
cnt = BURTC->CNT;
Expand All @@ -403,7 +407,7 @@ void rtc_lld_get_time(RTCDriver* rtcp, RTCDateTime* timespec) {
tv_sec += tv_msec / 1000U;
tv_msec = tv_msec % 1000U;

_rtc_lld_to_timespec(tv_sec, tv_msec, timespec);
_rtc_lld_to_timespec(tv_sec, tv_msec, timespec, dstflag);
}

#if (RTC_ALARMS > 0) || defined(__DOXYGEN__)
Expand Down
1 change: 1 addition & 0 deletions os/hal/ports/SILABS/LLD/EFR32FG23/BURTCv1/hal_rtc_lld.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ typedef struct {
volatile uint32_t *ovf_counter; /**< BURTC overflow counter. */ \
volatile uint32_t *tv_sec; /**< Seconds since RTC_BASE_YEAR.. */ \
volatile uint32_t *tv_msec; /**< .. and additional milliseconds. */ \
volatile uint32_t *dstflag; /**< Keep DST flag. */ \
rtccb_t callback /**< Callback function. */

/*===========================================================================*/
Expand Down

0 comments on commit cf967ef

Please sign in to comment.