summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interrupt.h32
1 files changed, 22 insertions, 10 deletions
diff --git a/interrupt.h b/interrupt.h
index cfc187d..9468a46 100644
--- a/interrupt.h
+++ b/interrupt.h
@@ -1,16 +1,21 @@
#ifndef INTERRUPT_H
#define INTERRUPT_H
+#include "stm32.h"
+
namespace Interrupt {
- enum Interrupt {
- NMI,
- HardFault,
- MemManage,
- BusFault,
- UsageFault,
- SVCall,
- PendSV,
- SysTick,
+ enum Exception {
+ NMI = 2,
+ HardFault = 3,
+ MemManage = 4,
+ BusFault = 5,
+ UsageFault = 6,
+ SVCall = 11,
+ PendSV = 14,
+ SysTick = 15
+ };
+
+ enum IRQ {
WWDG,
PVD,
TAMPER,
@@ -72,9 +77,16 @@ namespace Interrupt {
DMA2_Channel3,
DMA2_Channel4_5
};
+
+ inline void enable(IRQ n) {
+ NVIC.ISER[n >> 5] = 1 << (n & 0x1f);
+ }
};
-template<Interrupt::Interrupt>
+template<Interrupt::Exception>
+void interrupt();
+
+template<Interrupt::IRQ>
void interrupt();
#endif