-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stm32-multi: rtc: add functionality for subseconds #302
base: master
Are you sure you want to change the base?
Conversation
multi/stm32l4-multi/rtc.c
Outdated
const unsigned int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
|
||
timestamp->usecs = ((uint64_t) (rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
const unsigned int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | |
timestamp->usecs = ((uint64_t) (rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); | |
const unsigned int month_days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | |
timestamp->usecs = ((uint64_t)(rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); |
multi/stm32l4-multi/rtc.c
Outdated
timestamp->usecs = ((uint64_t) (rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); | ||
|
||
if (ssec > rtc_common.prediv_s) { | ||
timestamp->usecs = ((uint64_t) (2 * rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
timestamp->usecs = ((uint64_t) (2 * rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); | |
timestamp->usecs = ((uint64_t)(2 * rtc_common.prediv_s - (ssec & 0xffff)) * 1000 * 1000) / (rtc_common.prediv_s + 1); |
multi/stm32l4-multi/rtc.c
Outdated
else { | ||
timestamp->hours = (24 + timestamp->hours - carry) % 24; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
multi/stm32l4-multi/rtc.c
Outdated
prev_month = (11 + timestamp->month) % 12; | ||
prev_month_days = month_days[prev_month]; | ||
if (prev_month == 2 && ((timestamp->year % 4 == 0 && timestamp->year % 100 != 0) || timestamp->year % 400 == 0)) { | ||
prev_month_days ++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
prev_month_days ++; | |
prev_month_days++; |
multi/stm32l4-multi/rtc.c
Outdated
} | ||
else { | ||
timestamp->month = (12 + timestamp->month - carry) % 12; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
} | |
} |
multi/stm32l4-multi/rtc.c
Outdated
ssec = *(rtc_common.base + ssr) & 0xffff; | ||
ssec = ((uint64_t) (rtc_common.prediv_s - ssec) * 1000 * 1000) / (rtc_common.prediv_s + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
ssec = *(rtc_common.base + ssr) & 0xffff; | |
ssec = ((uint64_t) (rtc_common.prediv_s - ssec) * 1000 * 1000) / (rtc_common.prediv_s + 1); | |
ssec = *(rtc_common.base + ssr) & 0xffff; | |
ssec = ((uint64_t)(rtc_common.prediv_s - ssec) * 1000 * 1000) / (rtc_common.prediv_s + 1); |
multi/stm32l4-multi/rtc.c
Outdated
ssec = *(rtc_common.base + ssr) & 0xffff; | ||
ssec = ((uint64_t) (rtc_common.prediv_s - ssec) * 1000 * 1000) / (rtc_common.prediv_s + 1); | ||
/*Setting TR has a side effect of changing SSR value to prediv_s*/ | ||
*(rtc_common.base + tr) = time; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
*(rtc_common.base + tr) = time; | |
*(rtc_common.base + tr) = time; |
multi/stm32l4-multi/rtc.c
Outdated
*(rtc_common.base + isr) &= ~(1 << 7); | ||
while ((*(rtc_common.base + isr) & (1 << 3))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
while ((*(rtc_common.base + isr) & (1 << 3))); | |
while ((*(rtc_common.base + isr) & (1 << 3))) | |
; |
multi/stm32l4-multi/rtc.c
Outdated
*(rtc_common.base + isr) &= ~(1 << 7); | ||
while ((*(rtc_common.base + isr) & (1 << 3))); | ||
*(rtc_common.base + shiftr) = ((1000 * 1000 - timestamp->usecs) * (rtc_common.prediv_s + 1) / (1000 * 1000)) | (1 << 31); | ||
while ((*(rtc_common.base + isr) & (1 << 3))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[clang-format-pr] reported by reviewdog 🐶
suggested fix
while ((*(rtc_common.base + isr) & (1 << 3))); | |
while ((*(rtc_common.base + isr) & (1 << 3))) | |
; |
1b08ad4
to
4bd887a
Compare
Adds functionality for rtc for subseconds
Description
Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment