newlib/time: fix compilation error when only RTC is used as clock source

Fixes https://github.com/espressif/esp-idf/issues/1245
This commit is contained in:
Ivan Grokhotkov
2017-12-08 16:06:11 +08:00
parent f4554c81fc
commit 50b710d267

View 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 // when RTC is used to persist time, two RTC_STORE registers are used to store boot time
#elif defined(WITH_FRC1) #elif defined(WITH_FRC1)
static uint64_t s_boot_time; static uint64_t s_boot_time;
#endif #endif // WITH_RTC
#if defined(WITH_RTC) || defined(WITH_FRC1) #if defined(WITH_RTC) || defined(WITH_FRC1)
static _lock_t s_boot_time_lock; static _lock_t s_boot_time_lock;
#endif #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; uint64_t s_microseconds_offset;
#endif #endif
@@ -171,10 +173,14 @@ static uint64_t get_time_since_boot()
{ {
uint64_t microseconds = 0; uint64_t microseconds = 0;
#ifdef WITH_FRC1 #ifdef WITH_FRC1
#ifdef WITH_RTC
microseconds = s_microseconds_offset + esp_timer_get_time(); microseconds = s_microseconds_offset + esp_timer_get_time();
#else
microseconds = esp_timer_get_time();
#endif // WITH_RTC
#elif defined(WITH_RTC) #elif defined(WITH_RTC)
microseconds = get_rtc_time_us(); microseconds = get_rtc_time_us();
#endif #endif // WITH_FRC1
return microseconds; return microseconds;
} }
#endif // defined( WITH_FRC1 ) || defined( WITH_RTC ) #endif // defined( WITH_FRC1 ) || defined( WITH_RTC )