diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-10-30 19:31:21 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-10-30 19:31:21 +0000 |
commit | c145bd903fe61e5593c164bd14782a71fc65e632 (patch) | |
tree | 24aa361be1fbc3111900b9f339f78f7786d2e5f3 | |
parent | b665c20b66e3aff4dc953186df25d0b741634f56 (diff) | |
download | ChibiOS-c145bd903fe61e5593c164bd14782a71fc65e632.tar.gz ChibiOS-c145bd903fe61e5593c164bd14782a71fc65e632.tar.bz2 ChibiOS-c145bd903fe61e5593c164bd14782a71fc65e632.zip |
RTC. Implemented function rtcConvertDateTimeToFAT()
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7436 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/include/rtc.h | 2 | ||||
-rw-r--r-- | os/hal/src/rtc.c | 20 |
2 files changed, 18 insertions, 4 deletions
diff --git a/os/hal/include/rtc.h b/os/hal/include/rtc.h index 91a3d71e5..8e94bc08f 100644 --- a/os/hal/include/rtc.h +++ b/os/hal/include/rtc.h @@ -124,7 +124,7 @@ extern "C" { #if RTC_SUPPORTS_CALLBACKS
void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
#endif
- uint32_t rtcConvertDateTimeToFAT(RTCDateTime *timespec);
+ uint32_t rtcConvertDateTimeToFAT(const RTCDateTime *timespec);
#ifdef __cplusplus
}
#endif
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 */
|