aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/STM32/RTCv2/rtc_lld.c
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-03-08 19:52:44 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-03-08 19:52:44 +0000
commit2b35b5a2a5a9484332edebaca861a87910cf6715 (patch)
tree1216ba8ac63cec6ae618f52e061bf776dc726ea3 /os/hal/platforms/STM32/RTCv2/rtc_lld.c
parent41895e5c3682637c17e42f3d78c195266721e6dd (diff)
downloadChibiOS-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/RTCv2/rtc_lld.c')
-rw-r--r--os/hal/platforms/STM32/RTCv2/rtc_lld.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/os/hal/platforms/STM32/RTCv2/rtc_lld.c b/os/hal/platforms/STM32/RTCv2/rtc_lld.c
index cae3f812b..c2268fd82 100644
--- a/os/hal/platforms/STM32/RTCv2/rtc_lld.c
+++ b/os/hal/platforms/STM32/RTCv2/rtc_lld.c
@@ -265,6 +265,29 @@ void rtcGetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec){
}
/**
+ * @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;
+
+ stm32_rtc_bcd2tm(&timp, timespec);
+
+ 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;
+}
+
+/**
* @brief Converts from STM32 BCD to canonicalized time format.
*
* @param[out] timp pointer to a @p tm structure defined in time.h