Page 1 of 1

Deprecated timer_spinlock_take

Posted: Tue Sep 13, 2022 12:54 pm
by NRollo
After an update to the ESP-IDF framework release (currently on 4.4.1) I get these two build warnings coming from the timer interrupt routine:
timer_spinlock_take' is deprecated
timer_spinlock_give' is deprecated
I am unsure on what to use instead (what is appreciated) - because not using these spinlocks will, sort of, block the timer interrupt.
The ISR, as is, works perfectly - what is the right way to handle timer interrupts according to the "new" ESP-IDF framework?

My timer ISR:

Code: Select all

void IRAM_ATTR timer_group0_isr(void *para)
{
    // Enter critical section
    timer_spinlock_take(TIMER_GROUP_0);

    /* Retrieve the interrupt status */
    uint32_t timer_intr = timer_group_get_intr_status_in_isr(TIMER_GROUP_0);

    /* If Timer 0 interrupt -> stop the timer, clear the interrupt and turn heating off */
    if (timer_intr & TIMER_INTR_T0) {
        timer_pause(TIMER_GROUP_0, TIMER_0);
        timer_group_clr_intr_status_in_isr(TIMER_GROUP_0, TIMER_0);
        // Heating off
        gpio_set_level(HEATING, HEAT_OFF);
    }

    // Re-enable timer interrupt
    timer_group_enable_alarm_in_isr(TIMER_GROUP_0, TIMER_0);

    // Exit critical section
    timer_spinlock_give(TIMER_GROUP_0);
}

Re: Deprecated timer_spinlock_take

Posted: Tue Sep 13, 2022 1:46 pm
by NRollo
Resolved!!

Okay, I found this note in the timer.h header file:
/** @brief Take timer spinlock to enter critical protect
*
* @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/

Code: Select all

esp_err_t timer_spinlock_take(timer_group_t group_num) __attribute__ ((deprecated));