diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-03-08 19:52:44 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-03-08 19:52:44 +0000 |
commit | 2b35b5a2a5a9484332edebaca861a87910cf6715 (patch) | |
tree | 1216ba8ac63cec6ae618f52e061bf776dc726ea3 /os/hal/platforms/STM32/RTCv1/rtc_lld.c | |
parent | 41895e5c3682637c17e42f3d78c195266721e6dd (diff) | |
download | ChibiOS-2b35b5a2a5a9484332edebaca861a87910cf6715.tar.gz ChibiOS-2b35b5a2a5a9484332edebaca861a87910cf6715.tar.bz2 ChibiOS-2b35b5a2a5a9484332edebaca861a87910cf6715.zip |
SDC. Added RTC support. Improved testhal.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/sdc_dev2@4031 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/STM32/RTCv1/rtc_lld.c')
-rw-r--r-- | os/hal/platforms/STM32/RTCv1/rtc_lld.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/os/hal/platforms/STM32/RTCv1/rtc_lld.c b/os/hal/platforms/STM32/RTCv1/rtc_lld.c index 066e0f659..6496cfae9 100644 --- a/os/hal/platforms/STM32/RTCv1/rtc_lld.c +++ b/os/hal/platforms/STM32/RTCv1/rtc_lld.c @@ -30,6 +30,8 @@ * @{
*/
+#include <time.h>
+
#include "ch.h"
#include "hal.h"
@@ -290,6 +292,28 @@ void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback) { }
}
+/**
+ * @brief Get current time in format suitable for usage in FatFS.
+ *
+ * @param[in] timespec pointer to RTCTime structure
+ * @return FAT time value.
+ *
+ * @api
+ */
+uint32_t rtc_lld_calc_fat_time(RTCTime *timespec){
+ uint32_t fattime = 0;
+ struct tm *timp;
+
+ timp = localtime((time_t *)(timespec->tv_sec));
+
+ fattime |= (timp->tm_sec / 2);
+ 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 */
/** @} */
|