31#ifndef LIBOPENCM3_CORTEX_H
32#define LIBOPENCM3_CORTEX_H
46 __asm__
volatile (
"CPSIE I\n");
56 __asm__
volatile (
"CPSID I\n");
66 __asm__
volatile (
"CPSIE F\n");
76 __asm__
volatile (
"CPSID F\n");
86__attribute__((always_inline))
89 register uint32_t result;
90 __asm__
volatile (
"MRS %0, PRIMASK" :
"=r" (result));
94#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
102__attribute__((always_inline))
103static inline bool cm_is_masked_faults(
void)
105 register uint32_t result;
106 __asm__
volatile (
"MRS %0, FAULTMASK" :
"=r" (result));
121__attribute__((always_inline))
124 register uint32_t old;
125 __asm__ __volatile__(
"MRS %0, PRIMASK" :
"=r" (old));
126 __asm__ __volatile__(
"" : : :
"memory");
127 __asm__ __volatile__(
"MSR PRIMASK, %0" : :
"r" (mask));
131#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
142__attribute__((always_inline))
143static inline uint32_t cm_mask_faults(uint32_t mask)
145 register uint32_t old;
146 __asm__ __volatile__ (
"MRS %0, FAULTMASK" :
"=r" (old));
147 __asm__ __volatile__ (
"" : : :
"memory");
148 __asm__ __volatile__ (
"MSR FAULTMASK, %0" : :
"r" (mask));
164#if !defined(__DOXYGEN__)
171#define __CM_SAVER(state) \
173 __save __attribute__((__cleanup__(__cm_atomic_set))) = \
174 __cm_atomic_set(&__val)
221#if defined(__DOXYGEN__)
222#define CM_ATOMIC_BLOCK()
224#define CM_ATOMIC_BLOCK() \
225 for (uint32_t __CM_SAVER(true), __my = true; __my; __my = false)
275#if defined(__DOXYGEN__)
276#define CM_ATOMIC_CONTEXT()
278#define CM_ATOMIC_CONTEXT() uint32_t __CM_SAVER(true)
static uint32_t __cm_atomic_set(uint32_t *val)
static void cm_enable_interrupts(void)
Cortex M Enable interrupts.
static void cm_disable_faults(void)
Cortex M Disable faults.
static void cm_enable_faults(void)
Cortex M Enable faults.
static void cm_disable_interrupts(void)
Cortex M Disable interrupts.
static bool cm_is_masked_interrupts(void)
Cortex M Check if interrupts are masked.
static uint32_t cm_mask_interrupts(uint32_t mask)
Cortex M Mask interrupts.