May I use the FromISRs?

Hi In a few M3 and M4 projects I have had a need for a function that tells me one thing about the calling context. Firstly I simply check if the MCU is running an interrupt or if it not. If it is running an interrupt I want to be able to detect if that interrupt is allowed to use the FromISR functions. I have basically done this: ` // See the vPortValidateInterruptPriority function in port.c boolean bMayCallRTOSISR(void) { /* Constants required to check the validity of an interrupt priority. */ // These two defines are copied from port.c from FreeRTOS. // If you are porting this code, ensure that the defines below are correct for your processor! const uint32_t portFIRST_USER_INTERRUPT_NUMBER_UTIL = 16u const uint32_t portNVIC_IP_REGISTERS_OFFSET_16_UTIL = 0xE000E3F0u;
uint32_t ulCurrentInterrupt;
uint8_t ucCurrentPriority;
boolean may_call_ISR = TRUE;
static const volatile uint8_t * const pcInterruptPriorityRegisters_UTIL = ( const volatile uint8_t * const ) portNVIC_IP_REGISTERS_OFFSET_16_UTIL;

ulCurrentInterrupt  = uCurrentInterruptPrio();

if ( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER_UTIL ) {
    ucCurrentPriority   = pcInterruptPriorityRegisters_UTIL[ ulCurrentInterrupt ];
    may_call_ISR        = ucCurrentPriority >= 80 ;
}
return may_call_ISR;
} ` In a separate sourcefile. Now this does not feel very elegant as it copies from port.c and in the end I don’t even calculate the compare value but rather looked it up for my system. Is this not feateure that could make it into the kernel utilitis if it were to be cleaned up Regards Martin

May I use the FromISRs?

There is already xPortIsInsideInterrupt(), maybe that could be extended.

May I use the FromISRs?

🙂 By googeling I just realized that I actually asked the same question here a year ago. Sorry for the spamming. https://www.freertos.org/FreeRTOSSupportForumArchive/March2017/freertosDetectingthecurrentexecutingcontextb46f20a4j.html // Martin