File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,22 @@ bool core_util_are_interrupts_enabled(void)
37
37
#endif
38
38
}
39
39
40
+ bool core_util_is_isr_active (void )
41
+ {
42
+ #if defined(__CORTEX_A9 )
43
+ switch (__get_CPSR () & 0x1FU ) {
44
+ case MODE_USR :
45
+ case MODE_SYS :
46
+ return false;
47
+ case MODE_SVC :
48
+ default :
49
+ return true;
50
+ }
51
+ #else
52
+ return (__get_IPSR () != 0U );
53
+ #endif
54
+ }
55
+
40
56
MBED_WEAK void core_util_critical_section_enter (void )
41
57
{
42
58
bool interrupts_disabled = !core_util_are_interrupts_enabled ();
Original file line number Diff line number Diff line change @@ -41,6 +41,17 @@ extern "C" {
41
41
*/
42
42
bool core_util_are_interrupts_enabled (void );
43
43
44
+ /** Determine if this code is executing from an interrupt
45
+ *
46
+ * This function can be called to determine if the code is running on interrupt context.
47
+ * @note
48
+ * NOTE:
49
+ * This function works for both cortex-A and cortex-M, although the underlyng implementation
50
+ * differs.
51
+ * @return true if in an isr, false otherwise
52
+ */
53
+ bool core_util_is_isr_active (void );
54
+
44
55
/** Mark the start of a critical section
45
56
*
46
57
* This function should be called to mark the start of a critical section of code.
You can’t perform that action at this time.
0 commit comments