4.5 __disable_irq intrinsic

This intrinsic disables IRQ interrupts.

To use this intrinsic, your source file must contain #include <arm_compat.h>. This is only available for targets in AArch32 state.

Note:

Typically, this intrinsic disables IRQ interrupts by setting the I-bit in the CPSR. However, for M-profile it sets the exception mask register (PRIMASK).

Syntax

int __disable_irq(void)

Usage

int __disable_irq(void); disables interrupts and returns the value the IRQ interrupt mask has in the PSR before disabling interrupts.

Return value

int __disable_irq(void); returns the value the IRQ interrupt mask has in the PSR before disabling IRQ interrupts.

Example

void foo(void)
{
    int was_masked = __disable_irq();
    /* ... */
    if (!was_masked)
        __enable_irq();
}

Restrictions

The __disable_irq intrinsic can only be executed in privileged modes, that is, in non-user modes. In User mode this intrinsic does not change the interrupt flags in the CPSR.

Non-ConfidentialPDF file icon PDF version100067_0609_00_en
Copyright © 2014–2017 Arm Limited (or its affiliates). All rights reserved.