forked from urjaman/fernly
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmt6261-test.S
85 lines (74 loc) · 1.83 KB
/
mt6261-test.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
.text
.global _start
_start:
disable_interrupts:
mrs r0, cpsr
mov r1, #0xc0
orr r0, r0, r1
msr cpsr_cxsf, r0
relocate_stack:
ldr r0, =0x70009ffc // stack_start
mov sp, r0
demo:
mov r0, #0x08
bl delay
bl leds
bl delay
// bl .
// bl motor_pulse
bl reboot
error: // if we didn't reboot, leave motor on
bl motor_on
b error
.equ GPIO_CTRL_ADDR, 0xa0020000
.equ GPIO_CTRL_MODE2, GPIO_CTRL_ADDR + 0x0c20
.equ GPIO_CTRL_MODE2_IO16_GPIO16, (0 << 0)
.equ GPIO_CTRL_MODE2_IO16_MASK, (0x7 << 4)
.equ GPIO_CTRL_MODE2_IO18_GPIO18, (0 << 8)
.equ GPIO_CTRL_MODE2_IO18_MASK, (0x7 << 8)
leds:
ldr r0, =GPIO_CTRL_MODE2
// ldr r1, =(GPIO_CTRL_MODE2_IO16_GPIO16 | GPIO_CTRL_MODE2_IO16_MASK | GPIO_CTRL_MODE2_IO18_GPIO18 | GPIO_CTRL_MODE2_IO18_MASK)
ldr r1, =(GPIO_CTRL_MODE2_IO16_GPIO16 | GPIO_CTRL_MODE2_IO16_MASK)
str r1, [r0]
bx lr
.equ MOTOR_CTRL, 0xa07001b0
.equ MOTOR_CTRL_OFF, 0x0422
.equ MOTOR_CTRL_LOW, 0x8000
.equ MOTOR_CTRL_MED, 0x8010
.equ MOTOR_CTRL_HIGH, 0x8020
motor_on:
ldr r0, =MOTOR_CTRL
ldr r1, =MOTOR_CTRL_HIGH
str r1, [r0]
bx lr
motor_off:
ldr r0, =MOTOR_CTRL
ldr r1, =MOTOR_CTRL_OFF
str r1, [r0]
bx lr
// pulse motor r0 times
motor_pulse:
push {lr}
mov r4, r0
1:
bl motor_on
bl delay
bl motor_off
bl delay
subs r4, r4, #1
bne 1b
pop {lr}
bx lr
// trigger WDT reboot
reboot:
ldr r0, =0xa003001c
ldr r1, =0x1209
str r1, [r0]
bx lr // shouldn't get here
delay:
mov r0, #0x400000
1:
subs r0, r0, #1
bne 1b
bx lr