FromISR functions outside of the ISR context
I’m looking for clarification whether it is safe to call “FromISR” functions from outside an ISR. Below is the broader context of what I’m trying to do that is leading to this question.
I’m writing a software module which uses time from a RTC. My module has a task which consumes commands from a queue (very similar to the software timers in FreeRTOS). One of the functions in my API is called to indicate an RTC alarm went off, and loads a command into the queue. I want to abstract my module to work with several RTCs. If it is an internal RTC, this alarm function will likely be called from an ISR context and I would use the “FromISR” functions. However, if I’m using an external RTC, the interrupt source may have to be read over I2C or another slow bus before I can categorize it as the alarm going off – something I do not want to do in the ISR context. If my code still calls the “FromISR” functions in this case can that corrupt the kernel? I could #define my way through this, but I’d prefer to limit the amount of configuration users need to put in to use this code.
Thanks for your help!
FromISR functions outside of the ISR context
I’m looking for clarification whether it is safe to call “FromISR” functions from outside an ISR.Yes….and no, depending on the port you are using. You need to be careful with critical sections. If the port you are using supports interrupt nesting then you are probably ok, otherwise you will have to implement the portSETINTERRUPTMASKFROMISR() and portCLEARINTERRUPTMASKFROMISR() macros in such a way that they can be used from both an interrupt and a task.
FromISR functions outside of the ISR context
Hi, thanks for the reply.
After thinking about it some more, I think I’ll mirror the FreeRTOS API and have normal and “FromISR” versions of the function and leave it up to the user to call the appropriate one.
Thanks for the help!