mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

targets/hal/TARGET_Atmel/common/utils/interrupt/interrupt_sam_nvic.c

Committer:
mbed_official
Date:
2015-07-17
Revision:
592:a274ee790e56
Parent:
579:53297373a894

File content as of revision 592:a274ee790e56:

#include "interrupt_sam_nvic.h"

#if !defined(__DOXYGEN__)
/* Deprecated - global flag to determine the global interrupt state. Required by
 * QTouch library, however new applications should use cpu_irq_is_enabled()
 * which probes the true global interrupt state from the CPU special registers.
 */
volatile bool g_interrupt_enabled = true;
#endif

void cpu_irq_enter_critical(void)
{
    if (cpu_irq_critical_section_counter == 0) {
        if (cpu_irq_is_enabled()) {
            cpu_irq_disable();
            cpu_irq_prev_interrupt_state = true;
        } else {
            /* Make sure the to save the prev state as false */
            cpu_irq_prev_interrupt_state = false;
        }

    }

    cpu_irq_critical_section_counter++;
}

void cpu_irq_leave_critical(void)
{
    /* Check if the user is trying to leave a critical section when not in a critical section */
    Assert(cpu_irq_critical_section_counter > 0);

    cpu_irq_critical_section_counter--;

    /* Only enable global interrupts when the counter reaches 0 and the state of the global interrupt flag
       was enabled when entering critical state */
    if ((cpu_irq_critical_section_counter == 0) && (cpu_irq_prev_interrupt_state)) {
        cpu_irq_enable();
    }
}