Skip to content

Conversation

@dac1e
Copy link

@dac1e dac1e commented Jan 7, 2025

There is an essential problem without these 2 new functions:

  • Determining time and date by subsequent calls of RTC_GetTime() and
    RTC_GetDate() will retrieve a wrong result, when there happens a day
    transition between the 2 calls.

  • Setting time and date by subsequent calls of RTC_SetTime() and
    RTC_SetDate() will result in a wrong setting, when there happens a day
    transition between the 2 calls.
    Since time synchronization happens today over networks it isn't totally
    unlikely that time will be set to 23:59:59.
    Reason2:
    2 Subsequent calls will result in a 2 times wait for the RTC_SR_ACKUPD
    flag of RTC_SR. A single wait consumes processor time by polling in a
    loop for 1 second (as per microcontroller data sheet section 14.5.5).

This PR has also a bugfix and removed unnecessary data from rtc.h. Refer to comments of the commits.

dac1e added 8 commits January 6, 2025 11:20
second to new internal function dwTime2time().
consistent read of time and date.
Reason:
Determining time and date by subsequent calls of RTC_GetTime() and
RTC_GetDate() will retrieve a wrong result, when there happens a day
transition between the 2 calls.

Introduced API function RTC_SetTimeAndDate() that provides an atomic
consistent write of time and date.
Reason1:
Setting time and date by subsequent calls of RTC_SetTime() and
RTC_SetDate() will result in a wrong setting, when there happens a day
transition between the 2 calls.
Since time synchronization happens today over networks it isn't totally
unlikely that time will be set to 23:59:59.
Reason2:
2 Subsequent calls will result in a 2 times wait for the RTC_SR_ACKUPD
flag of RTC_SR. A single wait consumes processor time by polling in a
loop for 1 second (as per microcontroller data sheet section 14.5.5).
.h to .c file in order to fulfill the 'information hiding' principle.
They are not required to call the API functions.
@dac1e dac1e closed this Jan 24, 2025
@dac1e
Copy link
Author

dac1e commented Jan 24, 2025

I found more bugs. I will create a new pull request that fixes those bugs and will have commits with the enhancements on top of the commits for the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant