aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2015-07-13 20:07:35 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2015-07-13 20:07:35 +0000
commit9c863974f824ef9c0e534740ebb8f8a8bdb359cd (patch)
tree0e3840f07b5265c8f5719f73d6624574b091feb4 /os/hal/src
parent97321699e996e4e7c439a216b7c5f760a51858c4 (diff)
downloadChibiOS-9c863974f824ef9c0e534740ebb8f8a8bdb359cd.tar.gz
ChibiOS-9c863974f824ef9c0e534740ebb8f8a8bdb359cd.tar.bz2
ChibiOS-9c863974f824ef9c0e534740ebb8f8a8bdb359cd.zip
RTC. Fixed rtcConvertDateTimeToFAT() function (bug #615).
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8091 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r--os/hal/src/rtc.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c
index 41015ad8b..785b07721 100644
--- a/os/hal/src/rtc.c
+++ b/os/hal/src/rtc.c
@@ -220,19 +220,18 @@ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) {
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
struct tm *timp,
uint32_t *tv_msec) {
- int tmp;
+ int sec;
timp->tm_year = (int)timespec->year + (1980 - 1900);
timp->tm_mon = (int)timespec->month - 1;
timp->tm_mday = (int)timespec->day;
timp->tm_isdst = (int)timespec->dstflag;
- tmp = (int)timespec->millisecond / 1000;
- timp->tm_sec = tmp % 60;
- tmp -= timp->tm_sec;
- timp->tm_min = (tmp % 3600) / 60;
- tmp -= timp->tm_min * 60;
- timp->tm_hour = tmp / 3600;
+ sec = (int)timespec->millisecond / 1000;
+ timp->tm_hour = sec / 3600;
+ sec %= 3600;
+ timp->tm_min = sec / 60;
+ timp->tm_sec = sec % 60;
if (NULL != tv_msec) {
*tv_msec = (uint32_t)timespec->millisecond % 1000U;
@@ -283,13 +282,14 @@ void rtcConvertStructTmToDateTime(const struct tm *timp,
*/
uint32_t rtcConvertDateTimeToFAT(const RTCDateTime *timespec) {
uint32_t fattime;
- uint32_t sec, min, hour, day, month, tmp;
-
- tmp = timespec->millisecond / 1000U;
- sec = tmp % 60U;
- min = (tmp - sec) % 3600U;
- hour = ((tmp - sec) - (min * 60U)) / 3600U;
- day = timespec->day;
+ uint32_t sec, min, hour, day, month;
+
+ sec = timespec->millisecond / 1000U;
+ hour = sec / 3600U;
+ sec %= 3600U;
+ min = sec / 60U;
+ sec %= 60U;
+ day = timespec->day;
month = timespec->month;
/* handle DST flag */