irq_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
22 #ifndef IRQ_ARCH_H
23 #define IRQ_ARCH_H
24 
25 #include <stdint.h>
26 #include "cpu_conf.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 static inline __attribute__((always_inline)) unsigned int irq_disable(void)
36 {
37  uint32_t mask = __get_PRIMASK();
38 
39  __disable_irq();
40  return mask;
41 }
42 
46 static inline __attribute__((always_inline)) __attribute__((used)) unsigned int
48 {
49  unsigned result = __get_PRIMASK();
50 
51  __enable_irq();
52  return result;
53 }
54 
58 static inline __attribute__((always_inline)) void irq_restore(
59  unsigned int state)
60 {
61  __set_PRIMASK(state);
62 }
63 
67 static inline __attribute__((always_inline)) int irq_is_in(void)
68 {
69  return (__get_IPSR() & 0xFF);
70 }
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* IRQ_ARCH_H */
77 
irq_enable
static unsigned int irq_enable(void)
Enable all maskable interrupts.
Definition: irq_arch.h:47
irq_disable
static unsigned int irq_disable(void)
Disable all maskable interrupts.
Definition: irq_arch.h:35
irq_restore
static void irq_restore(unsigned int state)
Restore the state of the IRQ flags.
Definition: irq_arch.h:58
irq_is_in
static int irq_is_in(void)
See if the current context is inside an ISR.
Definition: irq_arch.h:67