diff options
Diffstat (limited to 'os/hal/src')
| -rw-r--r-- | os/hal/src/rtc.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c index d3799a011..4b57614a1 100644 --- a/os/hal/src/rtc.c +++ b/os/hal/src/rtc.c @@ -193,12 +193,26 @@ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) { *
* @api
*/
-uint32_t rtcConvertDateTimeToFAT(RTCDateTime *timespec) {
+uint32_t rtcConvertDateTimeToFAT(const RTCDateTime *timespec) {
+
+ uint32_t fattime;
+ uint32_t sec, min, hour, tmp;
osalDbgCheck(timespec != NULL);
- /* TODO: Implement.*/
- return 0;
+ tmp = timespec->millisecond / 1000;
+ sec = tmp % 60;
+ min = (tmp - sec) % 3600;
+ hour = (tmp - sec - min * 60) / 3600;
+
+ fattime = sec >> 1;
+ fattime |= min << 5;
+ fattime |= hour << 11;
+ fattime |= timespec->day << 16;
+ fattime |= timespec->month << 21;
+ fattime |= timespec->year << 25;
+
+ return fattime;
}
#endif /* HAL_USE_RTC */
|
