Reverse the logic to get_interrupts_disabled() to are_interrupts_enabled()

and update the using functions accordingly.

Usage:
bool interrupts_enabled = are_interrupts_enabled()

Remove superfluos shift in are_interrupts_enabled().
pull/1883/head
Anna Bridge 2016-06-09 16:41:58 +01:00
parent 9f052bc500
commit 2292794385
2 changed files with 9 additions and 10 deletions

View File

@ -25,16 +25,16 @@ extern "C" {
#endif #endif
/** Determine the current interrupts disabled state /** Determine the current interrupts enabled state
* *
* This function can be called to determine whether or not interrupts are currently disabled. * This function can be called to determine whether or not interrupts are currently enabled.
* \note * \note
* NOTE: * NOTE:
* This function works for both cortex-A and cortex-M, although the underlyng implementation * This function works for both cortex-A and cortex-M, although the underlyng implementation
* differs. * differs.
* @return true if interrupts are disabled, false otherwise * @return true if interrupts are enabled, false otherwise
*/ */
bool get_interrupts_disabled(void); bool are_interrupts_enabled(void);
/** Mark the start of a critical section /** Mark the start of a critical section
* *

View File

@ -29,19 +29,18 @@
static volatile uint32_t interrupt_enable_counter = 0; static volatile uint32_t interrupt_enable_counter = 0;
static volatile bool critical_interrupts_disabled = false; static volatile bool critical_interrupts_disabled = false;
bool get_interrupts_disabled(void) bool are_interrupts_enabled(void)
{ {
#if defined(__CORTEX_A9) #if defined(__CORTEX_A9)
bool interrupts_disabled = (bool)(((__get_CPSR() & 0x80) >> 7) & 0x1); return ((__get_CPSR() & 0x80) == 0);
#else #else
bool interrupts_disabled = (bool)(__get_PRIMASK() & 0x1); return ((__get_PRIMASK() & 0x1) == 0);
#endif #endif
return interrupts_disabled;
} }
void core_util_critical_section_enter() void core_util_critical_section_enter()
{ {
bool interrupts_disabled = get_interrupts_disabled(); bool interrupts_disabled = !are_interrupts_enabled();
__disable_irq(); __disable_irq();
/* Save the interrupt disabled state as it was prior to any nested critical section lock use */ /* Save the interrupt disabled state as it was prior to any nested critical section lock use */
@ -71,7 +70,7 @@ void core_util_critical_section_exit()
// FIXME // FIXME
#ifndef FEATURE_UVISOR #ifndef FEATURE_UVISOR
bool interrupts_disabled = get_interrupts_disabled(); /* get the current interrupt disabled state */ bool interrupts_disabled = !are_interrupts_enabled(); /* get the current interrupt disabled state */
MBED_ASSERT(interrupts_disabled); /* Interrupts must be disabled on invoking an exit from a critical section */ MBED_ASSERT(interrupts_disabled); /* Interrupts must be disabled on invoking an exit from a critical section */
#else #else