forked from gillespie/raspi_asm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathled.S
116 lines (97 loc) · 1.57 KB
/
led.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <[email protected]> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return - Thomas Gillespie
* ----------------------------------------------------------------------------
*/
.include "macros.inc"
/*
Initialises the led - sets gpio pin 16 to output
void led_init();
*/
FUNC led_init
push {lr}
/* Set pin 16 to output */
ldr r0, =16
ldr r1, =1
bl gpio_set_mode
pop {lr}
bx lr
/*
Switches on the OK LED
void led_on();
*/
FUNC led_on
push {lr}
/* Call gpio_clear(16) */
ldr r0, =16
bl gpio_clear
pop {lr}
bx lr
/*
Switches off the OK LED
void led_off();
*/
FUNC led_off
push {lr}
/* Call gpio_set(16) */
ldr r0, =16
bl gpio_set
pop {lr}
bx lr
FUNC led_flash
push {lr}
bl led_on
bl wait
bl led_off
bl wait
pop {lr}
bx lr
/*
'prints' r0 by flashing the led
void led_print(uint32_t value);
*/
FUNC led_print
push {lr}
ldr r1, =0xF
ldr r3, =28
0:
push {r0-r3}
bl led_on
bl wait
bl wait
bl wait
bl wait
bl wait
bl wait
bl wait
bl led_off
bl wait
bl wait
bl wait
bl wait
pop {r0-r3}
and r2, r1, r0, lsr r3
cmp r2, #0
beq 2f
1:
push {r0-r3}
bl led_flash
pop {r0-r3}
subs r2, #1
bne 1b
2:
push {r0-r3}
bl wait
bl wait
bl wait
bl wait
bl wait
bl wait
pop {r0-r3}
subs r3, #4
bge 0b
pop {lr}
bx lr