interrupt_sam_nvic.h
Go to the documentation of this file.
1 
33 /*
34  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
35  */
36 
37 #ifndef UTILS_INTERRUPT_INTERRUPT_H
38 #define UTILS_INTERRUPT_INTERRUPT_H
39 
40 #include <compiler.h>
41 #include <parts.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
77 # define ISR(func) \
78  void func (void)
79 
89 # define irq_initialize_vectors() \
90  do { \
91  } while(0)
92 
110 # define irq_register_handler(int_num, int_prio) \
111  NVIC_ClearPendingIRQ( (IRQn_Type)int_num); \
112  NVIC_SetPriority( (IRQn_Type)int_num, int_prio); \
113  NVIC_EnableIRQ( (IRQn_Type)int_num); \
114 
115 
116 
117 # define cpu_irq_enable() \
118  do { \
119  g_interrupt_enabled = true; \
120  __DMB(); \
121  __enable_irq(); \
122  } while (0)
123 # define cpu_irq_disable() \
124  do { \
125  __disable_irq(); \
126  __DMB(); \
127  g_interrupt_enabled = false; \
128  } while (0)
129 
130 typedef uint32_t irqflags_t;
131 
132 #if !defined(__DOXYGEN__)
133 extern volatile bool g_interrupt_enabled;
134 #endif
135 
136 #define cpu_irq_is_enabled() (__get_PRIMASK() == 0)
137 
138 static volatile uint32_t cpu_irq_critical_section_counter;
139 static volatile bool cpu_irq_prev_interrupt_state;
140 
141 static inline irqflags_t cpu_irq_save(void)
142 {
143  volatile irqflags_t flags = cpu_irq_is_enabled();
144  cpu_irq_disable();
145  return flags;
146 }
147 
148 static inline bool cpu_irq_is_enabled_flags(irqflags_t flags)
149 {
150  return (flags);
151 }
152 
153 static inline void cpu_irq_restore(irqflags_t flags)
154 {
155  if (cpu_irq_is_enabled_flags(flags))
156  cpu_irq_enable();
157 }
158 
159 void cpu_irq_enter_critical(void);
160 void cpu_irq_leave_critical(void);
161 
167 #define Enable_global_interrupt() cpu_irq_enable()
168 #define Disable_global_interrupt() cpu_irq_disable()
169 #define Is_global_interrupt_enabled() cpu_irq_is_enabled()
170 
172 
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* UTILS_INTERRUPT_INTERRUPT_H */
#define cpu_irq_disable()
Disable interrupts globally.
static volatile uint32_t cpu_irq_critical_section_counter
#define cpu_irq_is_enabled()
Check if interrupts are globally enabled.
static irqflags_t cpu_irq_save(void)
Get and clear the global interrupt flags.
volatile bool g_interrupt_enabled
static void cpu_irq_restore(irqflags_t flags)
Restore global interrupt flags.
Commonly used includes, types and macros.
Atmel part identification macros.
void cpu_irq_leave_critical(void)
static bool cpu_irq_is_enabled_flags(irqflags_t flags)
Check if interrupts are globally enabled in supplied flags.
static volatile bool cpu_irq_prev_interrupt_state
void cpu_irq_enter_critical(void)
uint32_t irqflags_t
Type used for holding state of interrupt flag.
#define cpu_irq_enable()
Enable interrupts globally.


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57