-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.h
42 lines (32 loc) · 912 Bytes
/
System.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef __SYSTEM_H__
#define __SYSTEM_H__
#include <stdbool.h>
#include "stm32f4xx.h"
typedef void InterruptHandler();
void InitializeSystem();
void InstallInterruptHandler(IRQn_Type interrupt,InterruptHandler handler);
void RemoveInterruptHandler(IRQn_Type interrupt,InterruptHandler handler);
static inline void EnableInterrupt(IRQn_Type interrupt)
{
int regindex=interrupt>>5;
int shift=interrupt&0x1f;
NVIC->ISER[regindex]|=1<<shift;
}
static inline void DisableInterrupt(IRQn_Type interrupt)
{
int regindex=interrupt>>5;
int shift=interrupt&0x1f;
NVIC->ISER[regindex]&=~(1<<shift);
}
static inline bool IsInterruptEnabled(IRQn_Type interrupt)
{
int regindex=interrupt>>5;
int shift=interrupt&0x1f;
if(NVIC->ISER[regindex]&(1<<shift)) return true;
else return false;
}
static inline void SetInterruptPriority(IRQn_Type interrupt,int priority)
{
NVIC->IP[interrupt]=priority<<4;
}
#endif