-
Notifications
You must be signed in to change notification settings - Fork 0
/
critical.gcc.s
52 lines (46 loc) · 1.33 KB
/
critical.gcc.s
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
@******************************************************************************
@
@ Useful functions.
@
@******************************************************************************
.global DisableInterrupts
.global EnableInterrupts
.global StartCritical
.global EndCritical
.global WaitForInterrupt
@*********** DisableInterrupts ***************
@ disable interrupts
@ inputs: none
@ outputs: none
DisableInterrupts:
CPSID I
BX LR
@*********** EnableInterrupts ***************
@ disable interrupts
@ inputs: none
@ outputs: none
EnableInterrupts:
CPSIE I
BX LR
@*********** StartCritical ************************
@ make a copy of previous I bit, disable interrupts
@ inputs: none
@ outputs: previous I bit
StartCritical:
MRS R0, PRIMASK @ save old status
CPSID I @ mask all (except faults)
BX LR
@*********** EndCritical ************************
@ using the copy of previous I bit, restore I bit to previous value
@ inputs: previous I bit
@ outputs: none
EndCritical:
MSR PRIMASK, R0
BX LR
@*********** WaitForInterrupt ************************
@ go to low power mode while waiting for the next interrupt
@ inputs: none
@ outputs: none
WaitForInterrupt:
WFI
BX LR