sleep: fix deadlock in esp_timer_impl_advance after light sleep

When light sleep is started, the other CPU gets halted using DPORT
stall mechanism. This can happen while it is inside an esp_timer
critical section, which may lead to a deadlock. This change adds
functions to take and release esp_timer lock before entering
DPORT critical section, preventing the deadlock.
This commit is contained in:
Ivan Grokhotkov
2018-05-04 12:50:39 +08:00
parent 296b280801
commit 8c307a5720
4 changed files with 60 additions and 0 deletions

View File

@@ -84,3 +84,18 @@ uint64_t esp_timer_impl_get_time();
* @return minimal period of periodic timer, in microseconds
*/
uint64_t esp_timer_impl_get_min_period_us();
/**
* @brief obtain internal critical section used esp_timer implementation
* This can be used when a sequence of calls to esp_timer has to be made,
* and it is necessary that the state of the timer is consistent between
* the calls. Should be treated in the same way as a spinlock.
* Call esp_timer_impl_unlock to release the lock
*/
void esp_timer_impl_lock();
/**
* @brief counterpart of esp_timer_impl_lock
*/
void esp_timer_impl_unlock();