]> granicus.if.org Git - esp-idf/commitdiff
newlib/time: fix compilation error when only RTC is used as clock source
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 8 Dec 2017 08:06:11 +0000 (16:06 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Wed, 27 Dec 2017 08:54:19 +0000 (16:54 +0800)
Fixes https://github.com/espressif/esp-idf/issues/1245

components/newlib/time.c

index edb9a59fe0e0f4664b27560ecb054695e0348325..8aeb5b37efe6519c084b10ed005861ae56a60642 100644 (file)
@@ -74,13 +74,15 @@ static uint64_t get_rtc_time_us()
 // when RTC is used to persist time, two RTC_STORE registers are used to store boot time
 #elif defined(WITH_FRC1)
 static uint64_t s_boot_time;
-#endif
+#endif // WITH_RTC
 
 #if defined(WITH_RTC) || defined(WITH_FRC1)
 static _lock_t s_boot_time_lock;
 #endif
 
-#ifdef WITH_RTC
+// Offset between FRC timer and the RTC.
+// Initialized after reset or light sleep.
+#if defined(WITH_RTC) && defined(WITH_FRC1)
 uint64_t s_microseconds_offset;
 #endif
 
@@ -171,10 +173,14 @@ static uint64_t get_time_since_boot()
 {
     uint64_t microseconds = 0;
 #ifdef WITH_FRC1
+#ifdef WITH_RTC
     microseconds = s_microseconds_offset + esp_timer_get_time();
+#else
+    microseconds = esp_timer_get_time();
+#endif // WITH_RTC
 #elif defined(WITH_RTC)
     microseconds = get_rtc_time_us();
-#endif
+#endif // WITH_FRC1
     return microseconds;
 }
 #endif // defined( WITH_FRC1 ) || defined( WITH_RTC )