xTimerIsTimerActive from an ISR

Could xTimerIsTimerActive be used from an ISR? what is the solution to make use of this functions from an ISR?

No, it cannot be called from an ISR. You can likely add a FromISR version of this function -

    BaseType_t xTimerIsTimerActiveFromISR( TimerHandle_t xTimer )
        BaseType_t xReturn;
        Timer_t * pxTimer = xTimer;
        UBaseType_t uxSavedInterruptStatus;

        traceENTER_xTimerIsTimerActiveFromISR( xTimer );

        configASSERT( xTimer );

        /* Is the timer in the list of active timers? */
        uxSavedInterruptStatus = ( UBaseType_t ) taskENTER_CRITICAL_FROM_ISR();
            if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0U )
                xReturn = pdFALSE;
                xReturn = pdTRUE;
        taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );

        traceRETURN_xTimerIsTimerActiveFromISR( xReturn );

        return xReturn;

Why do you need this though? What problem are you trying to solve?


Thank you for the answer. I need it for some buttons situation. I have the buttons on ISRs and I also need to measure long/short press. And because of the noise the ISR can get trigger also when unwanted moments, and thats why i need to check the active state of the timer in the ISR.

Any other idea for this?

How about recording the time (which can be FreerTOS tick count or a hardware timer) at the ISR entry and then compare it to the last recorded time to filter out unwanted ISRs? Would something like that work for you?

Thank you! I think it can work. Thanks for the idea!