We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I'm running RL-RTX and I have a function that can be called either from a task, from an ISR or from main (at startup).
Is there is way to identify the calling routine so I can make the proper function call. In my particular case, I want to write something like the example below:
myFunction( ) {
execute some code here;
if calling function is a task
os_dly_wait( ); //put the task to sleep
else
SysCtlDelay( ); //wait using CPU cycles
}
thanks. Khaled.
Just give it a parameter:
myFunction( bool calling_function_is_a_task ) { execute some code here; if( calling_function_is_a_task ) os_dly_wait( ); //put the task to sleep else SysCtlDelay( ); //wait using CPU cycles }
Note how to properly post source code: www.danlhenry.com/.../keil_code.png
I didn't want to use a flag since this function is at the lowest level and I didn't want to change my code. Khaled.
myFunction( bool calling_function_is_a_task ) {
if( calling_function_is_a_task )
} if you want to more knowledge please contact me at www.janbaskdigitaldesign.com/
Assuming you work with an ARM target, you can do this:
static BOOL IsIRQ() { BOOL is_irq = FALSE ; if (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) is_irq = TRUE ; return is_irq ; }
Note that once the kernel is started, no function can be called from main - so the code above covers all your needs.
Thank Michael This is what I have looking for ;-)
But still this lower function that is giving me all of those issues, IS called from main and its causing a hard fault.
Is there a similar instruction to know if it's running from main or from a task? Thanks Khaled
That's up to you!
BOOL isKernelStarted() { return (flagSetToTrueJustBeforeKernelIsStarted) ; }
Thanks :-) Khaled.