Page 1 of 1

Is gettimeofday() safe from an ISR perspective?

Posted: Mon Jan 16, 2017 5:02 am
by kolban
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?

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

Posted: Mon Jan 16, 2017 7:17 am
by WiFive
Probably better to use xthal_get_ccount like

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