avr-libc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-commit] [2356] Change set_system_time(struct tm *) to set_syst


From: Mike Rice
Subject: [avr-libc-commit] [2356] Change set_system_time(struct tm *) to set_system_time(time_t)
Date: Sun, 21 Apr 2013 16:20:04 +0000

Revision: 2356
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2356
Author:   swfltek
Date:     2013-04-21 16:20:01 +0000 (Sun, 21 Apr 2013)
Log Message:
-----------
Change set_system_time(struct tm *) to set_system_time(time_t)

Modified Paths:
--------------
    trunk/avr-libc/include/time.h
    trunk/avr-libc/libc/time/set_system_time.c
    trunk/avr-libc/tests/simulate/time/tick.c

Modified: trunk/avr-libc/include/time.h
===================================================================
--- trunk/avr-libc/include/time.h       2013-04-20 11:32:50 UTC (rev 2355)
+++ trunk/avr-libc/include/time.h       2013-04-21 16:20:01 UTC (rev 2356)
@@ -196,7 +196,7 @@
     This implementation handles all conversions specified by the standard, 
with the exception of g, G, V, and Z.
     Conversions not implemented are replaced in the output text with the 
character '?'
 
-    All conversions are made in the 'C Locale', ignoring the E or O modifiers.
+    All conversions are made using the 'C Locale', ignoring the E or O 
modifiers.
     */
     size_t          strftime(char *s, size_t maxsize, const char *format, 
const struct tm * timeptr);
 
@@ -227,9 +227,29 @@
     void            set_zone(int32_t);
 
     /**
-        Set the system time. The values of tmptr are interpreted as Local 
Standard Time.
+        Initialize the system time. Examples are...
+
+        From a Clock / Calendar type RTC:
+        \code
+        struct tm rtc_time;
+
+        read_rtc(&rtc_time);
+        rtc_time.tm_isdst = 0;
+        set_system_time( mktime(&rtc_time) );
+        \endcode
+
+        From a Network Time Protocol time stamp:
+        \code
+        set_system_time(ntp_timestamp - NTP_OFFSET);
+        \endcode
+
+        From a UNIX time stamp:
+         \code
+        set_system_time(ntp_timestamp - UNIX_OFFSET);
+        \endcode
+
     */
-    void            set_system_time(struct tm * tmptr);
+    void            set_system_time(time_t timestamp);
 
     /**
         Maintain the system time by calling this function at a rate of 1 Hertz.

Modified: trunk/avr-libc/libc/time/set_system_time.c
===================================================================
--- trunk/avr-libc/libc/time/set_system_time.c  2013-04-20 11:32:50 UTC (rev 
2355)
+++ trunk/avr-libc/libc/time/set_system_time.c  2013-04-21 16:20:01 UTC (rev 
2356)
@@ -39,17 +39,15 @@
 extern volatile time_t __system_time;
 
 void
-set_system_time(struct tm * tmptr)
+set_system_time(time_t timestamp)
 {
-       time_t          t;
 
-       t = mktime(tmptr);
        asm             volatile(
                                           "in __tmp_reg__, __SREG__" "\n\t"
                                                 "cli" "\n\t"
                                 ::
        );
-       __system_time = t;
+       __system_time = timestamp;
        asm             volatile(
                                          "out __SREG__, __tmp_reg__" "\n\t"
                                 ::

Modified: trunk/avr-libc/tests/simulate/time/tick.c
===================================================================
--- trunk/avr-libc/tests/simulate/time/tick.c   2013-04-20 11:32:50 UTC (rev 
2355)
+++ trunk/avr-libc/tests/simulate/time/tick.c   2013-04-21 16:20:01 UTC (rev 
2356)
@@ -47,8 +47,7 @@
     if(t != tt ) return (__LINE__);
 
     t = 0xffffffff;
-    gmtime_r(&t, &calendar);
-    set_system_time(&calendar);
+    set_system_time(t);
 
     t++;
     system_tick();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]