Is gettimeofday() safe from an ISR perspective?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Is gettimeofday() safe from an ISR perspective?

Postby kolban » Mon Jan 16, 2017 5:02 am

A specific question and then a general one.

I have an ISR that is triggered from a GPIO interrupt when a button is pressed. My plan is to check for button debounce by discarding interrupts that happen too close together. So for example, a button pressed interrupt will not cause action if it occurs less than 100 msecs since the last button pressed. The question I am considering in my design then seems to ask "Can I determine the current time stamp within an ISR?" and that leads me to "gettimeofday()" ... is that a "safe" call to use in an ISR?

Following on from this question then leads me to the next semi obvious question ... which ESP-IDF supplied functions are or are not safe to be invoked from within an ISR? Do we have a table or mapping of which ones can and can't be used?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Is gettimeofday() safe from an ISR perspective?

Postby WiFive » Mon Jan 16, 2017 7:17 am

Probably better to use xthal_get_ccount like

https://github.com/espressif/esp-idf/bl ... _ops.c#L42

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 207 guests