diff options
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/include/rtc.h | 3 | ||||
-rw-r--r-- | os/hal/src/rtc.c | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/os/hal/include/rtc.h b/os/hal/include/rtc.h index 97ff07b49..d282c2adf 100644 --- a/os/hal/include/rtc.h +++ b/os/hal/include/rtc.h @@ -128,7 +128,8 @@ extern "C" { void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
#endif
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
- struct tm *timp);
+ struct tm *timp,
+ uint32_t *tv_msec);
void rtcConvertStructTmToDateTime(const struct tm *timp,
uint32_t tv_msec,
RTCDateTime *timespec);
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c index a60ddd6a0..5459b3b85 100644 --- a/os/hal/src/rtc.c +++ b/os/hal/src/rtc.c @@ -213,11 +213,13 @@ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) { *
* @param[in] timespec pointer to a @p RTCDateTime structure
* @param[out] timp pointer to a broken-down time structure
+ * @param[out] tv_msec pointer to milliseconds value or @p NULL
*
* @api
*/
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
- struct tm *timp) {
+ struct tm *timp,
+ uint32_t *tv_msec) {
int tmp;
timp->tm_year = (int)timespec->year + (1980 - 1900);
@@ -231,6 +233,10 @@ void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec, timp->tm_min = (tmp % 3600) / 60;
tmp -= timp->tm_min * 60;
timp->tm_hour = tmp / 3600;
+
+ if (NULL != tv_msec) {
+ *tv_msec = (uint32_t)timespec->millisecond % 1000;
+ }
}
/**
|