aboutsummaryrefslogtreecommitdiff
path: root/blink.s
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2023-12-24 23:03:47 -0600
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2023-12-24 23:03:47 -0600
commitad75550260068087c4351a6a197e10c02fe3b399 (patch)
treeb9d6504843caa03b7aa0e0823672104ec57bfd79 /blink.s
parent8c8569bf9575a4f1077a1b8a61f47d5b4ff55727 (diff)
Add blinkN subroutine
Diffstat (limited to 'blink.s')
-rw-r--r--blink.s44
1 files changed, 34 insertions, 10 deletions
diff --git a/blink.s b/blink.s
index 3bda498..62b6654 100644
--- a/blink.s
+++ b/blink.s
@@ -12,10 +12,10 @@
.equ ATOMIC_CLEAR, 0x3000
-.type blink, %function
-.global blink
+.type setup_led, %function
+.global setup_led
-blink:
+setup_led:
ldr r1, =GPIO25_CTRL
movs r0, 5 // SIO function = 5
str r0, [r1, 0]
@@ -23,10 +23,34 @@ blink:
movs r0, 1
lsls r0, r0, 25 // GPIO 25 (LED) output enable
str r0, [r1, GPIO_OE_SET_OFST]
-toggle_one_second:
- str r0, [r1, GPIO_OUT_XOR_OFST] // toggle GPIO 25 output level
- ldr r2, =0x1fca055 // 33.3 * 10^6 (one-third of a second at 100MHz)
-1: // 3 clock cycle loop
- subs r2, r2, 1 // 1 clock cycle
- bne 1b // 2 clock cycles when taken
- b toggle_one_second
+ bx lr
+
+.type blink, %function
+.global blink
+
+blink:
+ movs r0, 1
+ lsls r0, 25
+1:
+ str r0, [r1, GPIO_OUT_XOR_OFST]
+ bl delay_1s
+ b 1b
+
+.type blinkN, %function
+.global blinkN
+
+blinkN:
+ push {lr}
+ movs r2, 1
+ lsls r2, 25
+ tst r0, r0
+ beq done
+on_then_off:
+ str r2, [r1, GPIO_OUT_XOR_OFST]
+ bl delay_1s
+ str r2, [r1, GPIO_OUT_XOR_OFST]
+ bl delay_1s
+ subs r0, r0, 1
+ bne on_then_off
+done:
+ pop {pc}