mirror of https://github.com/ARMmbed/mbed-os.git
Add function to check for ISR context
Add the function core_util_in_isr() so code can determine if it is running in the context of an ISR.pull/4389/head
parent
5f138810a9
commit
5ab3de0bfa
|
|
@ -37,6 +37,22 @@ bool core_util_are_interrupts_enabled(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool core_util_is_isr_active(void)
|
||||
{
|
||||
#if defined(__CORTEX_A9)
|
||||
switch(__get_CPSR() & 0x1FU) {
|
||||
case MODE_USR:
|
||||
case MODE_SYS:
|
||||
return false;
|
||||
case MODE_SVC:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return (__get_IPSR() != 0U);
|
||||
#endif
|
||||
}
|
||||
|
||||
MBED_WEAK void core_util_critical_section_enter(void)
|
||||
{
|
||||
bool interrupts_disabled = !core_util_are_interrupts_enabled();
|
||||
|
|
|
|||
|
|
@ -41,6 +41,17 @@ extern "C" {
|
|||
*/
|
||||
bool core_util_are_interrupts_enabled(void);
|
||||
|
||||
/** Determine if this code is executing from an interrupt
|
||||
*
|
||||
* This function can be called to determine if the code is running on interrupt context.
|
||||
* @note
|
||||
* NOTE:
|
||||
* This function works for both cortex-A and cortex-M, although the underlyng implementation
|
||||
* differs.
|
||||
* @return true if in an isr, false otherwise
|
||||
*/
|
||||
bool core_util_is_isr_active(void);
|
||||
|
||||
/** Mark the start of a critical section
|
||||
*
|
||||
* This function should be called to mark the start of a critical section of code.
|
||||
|
|
|
|||
Loading…
Reference in New Issue