Skip to content

Commit b592804

Browse files
author
Don Dominic
committed
feat: add ISR context check API
Signed-off-by: Don Dominic <[email protected]>
1 parent 0f1313a commit b592804

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Source/os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,7 @@ void OSInit (OS_ERR *p_err);
18971897

18981898
void OSIntEnter (void);
18991899
void OSIntExit (void);
1900+
CPU_BOOLEAN OSIntIsInIsr (void);
19001901

19011902
#if (OS_CFG_SCHED_ROUND_ROBIN_EN > 0u)
19021903
void OSSchedRoundRobinCfg (CPU_BOOLEAN en,

Source/os_core.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,35 @@ void OSIntExit (void)
403403
}
404404

405405

406+
/*
407+
************************************************************************************************************************
408+
* ISR CHECK
409+
*
410+
* Description: This function is called to check if the current context is in an ISR or not.
411+
*
412+
* Arguments : none
413+
*
414+
* Returns : If current context is in iSR (OS_TRUE) or not (OS_FALSE).
415+
*
416+
* Note(s) : none
417+
************************************************************************************************************************
418+
*/
419+
420+
CPU_BOOLEAN OSIntIsInIsr (void)
421+
{
422+
CPU_BOOLEAN in_isr;
423+
424+
if (OSIntNestingCtr > 0u) {
425+
in_isr = OS_TRUE;
426+
}
427+
else {
428+
in_isr = OS_FALSE;
429+
}
430+
431+
return (in_isr);
432+
}
433+
434+
406435
/*
407436
************************************************************************************************************************
408437
* INDICATE THAT IT'S NO LONGER SAFE TO CREATE OBJECTS

0 commit comments

Comments
 (0)