-
Notifications
You must be signed in to change notification settings - Fork 0
/
NVIC_program.c
94 lines (85 loc) · 1.97 KB
/
NVIC_program.c
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "Macros.h"
#include "STD_TYPES.h"
#include "NVIC_interface.h"
#include "TM4C123.h" // Device header
void NVIC_vidSetInterrupt(u8 u8InterruptID)
{
if (u8InterruptID < 32)
{
NVIC->ISER[0] |= (1<<u8InterruptID);
}
else if ((u8InterruptID >= 32) & (u8InterruptID < 63))
{
NVIC->ISER[1] |= (1<<(u8InterruptID-32));
}
else if ((u8InterruptID >= 64) & (u8InterruptID < 97))
{
NVIC->ISER[2] |= (1<<(u8InterruptID-64));
}
}
void NVIC_vidClearInterrupt(u8 u8InterruptID)
{
if (u8InterruptID < 32)
{
NVIC->ICER[0] |= (1<<u8InterruptID);
}
else if ((u8InterruptID >= 32) & (u8InterruptID < 63))
{
NVIC->ICER[1] |= (1<<(u8InterruptID-32));
}
else if ((u8InterruptID >= 64) & (u8InterruptID < 97))
{
NVIC->ICER[2] |= (1<<(u8InterruptID-64));
}
}
void NVIC_vidSetPending(u8 u8InterruptID)
{
if (u8InterruptID < 32)
{
NVIC->ISPR[0] |= (1<<u8InterruptID);
}
else if ((u8InterruptID >= 32) & (u8InterruptID < 63))
{
NVIC->ISPR[1] |= (1<<(u8InterruptID-32));
}
else if ((u8InterruptID >= 64) & (u8InterruptID < 97))
{
NVIC->ISPR[2] |= (1<<(u8InterruptID-64));
}
}
void NVIC_vidClearPending(u8 u8InterruptID)
{
if (u8InterruptID < 32)
{
NVIC->ICPR[0] |= (1<<u8InterruptID);
}
else if ((u8InterruptID >= 32) & (u8InterruptID < 63))
{
NVIC->ICPR[1] |= (1<<(u8InterruptID-32));
}
else if ((u8InterruptID >= 64) & (u8InterruptID < 97))
{
NVIC->ICPR[2] |= (1<<(u8InterruptID-64));
}
}
u8 NVIC_u8GetPending(u8 u8InterruptID)
{
u8 u8PendingResult = 0;
if (u8InterruptID < 32)
{
u8PendingResult = GET_BIT(NVIC->ISPR[0],u8InterruptID);
}
else if ((u8InterruptID >= 32) & (u8InterruptID < 63))
{
u8PendingResult = GET_BIT(NVIC->ISPR[1],(u8InterruptID-32));
}
else if ((u8InterruptID >= 64) & (u8InterruptID < 97))
{
u8PendingResult = GET_BIT(NVIC->ISPR[1],(u8InterruptID-64));
}
return u8PendingResult;
}
void NVIC_vidSetPriority(u8 u8InterruptID, u8 u8InterruptPriority)
{
NVIC->IP[u8InterruptID] = (u8InterruptPriority<<5);
}