diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-09-21 09:26:41 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-09-21 09:26:41 +0000 |
commit | 7a68e17dd09c3c148ba9d50a5728491988940d69 (patch) | |
tree | c5d616388d1ebe71cf3e4393ec7425c41474c2a4 /os/hal/platforms/STM32/RTCv1 | |
parent | bf0682028d8b9588b696019f9f54c6f295ab8aef (diff) | |
download | ChibiOS-7a68e17dd09c3c148ba9d50a5728491988940d69.tar.gz ChibiOS-7a68e17dd09c3c148ba9d50a5728491988940d69.tar.bz2 ChibiOS-7a68e17dd09c3c148ba9d50a5728491988940d69.zip |
RTCv1. Added FAT timestamp support in driver using chrtclib for deviced without hardware calendar.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4706 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/STM32/RTCv1')
-rw-r--r-- | os/hal/platforms/STM32/RTCv1/rtc_lld.c | 27 | ||||
-rw-r--r-- | os/hal/platforms/STM32/RTCv1/rtc_lld.h | 1 |
2 files changed, 26 insertions, 2 deletions
diff --git a/os/hal/platforms/STM32/RTCv1/rtc_lld.c b/os/hal/platforms/STM32/RTCv1/rtc_lld.c index 1b0fd433c..bc083ffbd 100644 --- a/os/hal/platforms/STM32/RTCv1/rtc_lld.c +++ b/os/hal/platforms/STM32/RTCv1/rtc_lld.c @@ -30,10 +30,9 @@ * @{
*/
-#include <time.h>
-
#include "ch.h"
#include "hal.h"
+#include "chrtclib.h"
#if HAL_USE_RTC || defined(__DOXYGEN__)
@@ -300,6 +299,30 @@ void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback) { rtcp->callback = NULL;
}
}
+
+/**
+ * @brief Get current time in format suitable for usage in FatFS.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @return FAT time value.
+ *
+ * @api
+ */
+uint32_t rtc_lld_get_time_fat(RTCDriver *rtcp) {
+ uint32_t fattime;
+ struct tm timp;
+
+ rtcGetTimeTm(rtcp, &timp);
+
+ fattime = (timp.tm_sec) >> 1;
+ fattime |= (timp.tm_min) << 5;
+ fattime |= (timp.tm_hour) << 11;
+ fattime |= (timp.tm_mday) << 16;
+ fattime |= (timp.tm_mon + 1) << 21;
+ fattime |= (timp.tm_year - 80) << 25;
+
+ return fattime;
+}
#endif /* HAL_USE_RTC */
/** @} */
diff --git a/os/hal/platforms/STM32/RTCv1/rtc_lld.h b/os/hal/platforms/STM32/RTCv1/rtc_lld.h index 4944ff735..c0ad92525 100644 --- a/os/hal/platforms/STM32/RTCv1/rtc_lld.h +++ b/os/hal/platforms/STM32/RTCv1/rtc_lld.h @@ -178,6 +178,7 @@ extern "C" { rtcalarm_t alarm,
RTCAlarm *alarmspec);
void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback);
+ uint32_t rtc_lld_get_time_fat(RTCDriver *rtcp);
#ifdef __cplusplus
}
#endif
|