forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsleeprestore.s
61 lines (58 loc) · 1.17 KB
/
sleeprestore.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
53
54
55
56
57
58
59
60
61
.syntax unified
.cpu cortex-m4
.thumb
.text
.align 2
@ global variable with the backup registers
.extern vault_arm_registers
@ global function that performs the wake up actions
.extern pyb_sleep_suspend_exit
@ uint sleep_store(void)
.global sleep_store
.thumb
.thumb_func
.type sleep_store, %function
sleep_store:
dsb
isb
push {r0-r12, lr}
ldr r1, =vault_arm_registers
mrs r0, msp
str r0, [r1]
mrs r0, psp
str r0, [r1, #4]
mrs r0, primask
str r0, [r1, #12]
mrs r0, faultmask
str r0, [r1, #16]
mrs r0, basepri
str r0, [r1, #20]
mrs r0, control
str r0, [r1, #24]
dsb
isb
bx lr
@ uint sleep_restore(void)
.global sleep_restore
.thumb
.thumb_func
.type sleep_restore, %function
sleep_restore:
dsb
isb
mrs r0, msp
msr psp, r0
ldr r1, =vault_arm_registers
ldr r0, [r1, #24]
msr control, r0
ldr r0, [r1]
msr msp, r0
ldr r0, [r1, #12]
msr primask, r0
ldr r0, [r1, #16]
msr faultmask, r0
ldr r0, [r1, #20]
msr basepri, r0
dsb
isb
bl pyb_sleep_suspend_exit