Robobo
interrupt_sam_nvic.h
1 /* ----------------------------------------------------------------------------
2  * SAM Software Package License
3  * ----------------------------------------------------------------------------
4  * Copyright (c) 2011-2012, Atmel Corporation
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following condition is met:
10  *
11  * - Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the disclaimer below.
13  *
14  * Atmel's name may not be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * ----------------------------------------------------------------------------
28  */
29 
30 #ifndef UTILS_INTERRUPT_INTERRUPT_H
31 #define UTILS_INTERRUPT_INTERRUPT_H
32 
33 #include "../chip.h"
34 
65 # define ISR(func) \
66  void func (void)
67 
77 # define irq_initialize_vectors() \
78  do { \
79  } while(0)
80 
98 # define irq_register_handler(...) \
99  do { \
100  } while(0)
101 
103 
104 # define cpu_irq_enable() \
105  do { \
106  g_interrupt_enabled = 1; \
107  __DMB(); \
108  __enable_irq(); \
109  } while (0)
110 # define cpu_irq_disable() \
111  do { \
112  __disable_irq(); \
113  __DMB(); \
114  g_interrupt_enabled = 0; \
115  } while (0)
116 
117 typedef uint32_t irqflags_t;
118 extern int g_interrupt_enabled;
119 
120 static inline irqflags_t cpu_irq_save(void)
121 {
122  irqflags_t flags = g_interrupt_enabled;
123  cpu_irq_disable();
124  return flags;
125 }
126 
127 static inline int cpu_irq_is_enabled_flags(irqflags_t flags)
128 {
129  return (flags);
130 }
131 
132 static inline void cpu_irq_restore(irqflags_t flags)
133 {
134  if (cpu_irq_is_enabled_flags(flags))
135  cpu_irq_enable();
136 }
137 
138 #define cpu_irq_is_enabled() g_interrupt_enabled
139 
145 #define Enable_global_interrupt() cpu_irq_enable()
146 #define Disable_global_interrupt() cpu_irq_disable()
147 #define Is_global_interrupt_enabled() cpu_irq_is_enabled()
148 
150 
152 
153 #endif /* UTILS_INTERRUPT_INTERRUPT_H */
int g_interrupt_enabled
Global NVIC interrupt enable status (by default it's enabled)
Definition: interrupt_sam_nvic.c:33