mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-22 09:06:27 +00:00
esp_timer: do init check in timer implementation
This commit is contained in:

committed by
KonstantinKondrashov

parent
0fa3ff8bf0
commit
e70f240e12
@@ -103,7 +103,7 @@ static intr_handle_t s_timer_interrupt_handle;
|
||||
|
||||
// Function from the upper layer to be called when the interrupt happens.
|
||||
// Registered in esp_timer_impl_init.
|
||||
static intr_handler_t s_alarm_handler;
|
||||
static intr_handler_t s_alarm_handler = NULL;
|
||||
|
||||
// Time in microseconds from startup to the moment
|
||||
// when timer counter was last equal to 0. This variable is updated each time
|
||||
@@ -178,6 +178,9 @@ void esp_timer_impl_unlock(void)
|
||||
|
||||
int64_t IRAM_ATTR esp_timer_impl_get_time(void)
|
||||
{
|
||||
if (s_alarm_handler == NULL) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t timer_val;
|
||||
uint64_t time_base;
|
||||
uint32_t ticks_per_us;
|
||||
@@ -209,6 +212,8 @@ int64_t IRAM_ATTR esp_timer_impl_get_time(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t esp_timer_get_time(void) __attribute__((alias("esp_timer_impl_get_time")));
|
||||
|
||||
void IRAM_ATTR esp_timer_impl_set_alarm(uint64_t timestamp)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&s_time_update_lock);
|
||||
|
Reference in New Issue
Block a user