48 lines
676 B
ArmAsm
48 lines
676 B
ArmAsm
|
.global sk6812_send_led
|
||
|
|
||
|
.equ BSRR_REGISTER, 0x48000018
|
||
|
.equ PINNUM, 3
|
||
|
.syntax unified
|
||
|
|
||
|
sk6812_send_led:
|
||
|
push {lr}
|
||
|
push {r4, r5, r6}
|
||
|
ldr r1, =BSRR_REGISTER
|
||
|
ldr r2, =(1<<PINNUM)
|
||
|
ldr r3, =(1<<(PINNUM+16))
|
||
|
ldr r4, =32
|
||
|
ldr r5, =0x80000000
|
||
|
_bitloop:
|
||
|
tst r0, r5
|
||
|
beq sk6812_send_zero
|
||
|
bne sk6812_send_one
|
||
|
_bitloop_ret:
|
||
|
lsls r0, r0, #1
|
||
|
subs r4, r4, #1
|
||
|
bne _bitloop
|
||
|
pop {r4, r5, r6}
|
||
|
pop {pc}
|
||
|
|
||
|
sk6812_send_one:
|
||
|
str r2, [r1]
|
||
|
ldr r6, =0x5
|
||
|
bl wait_r6
|
||
|
str r3, [r1]
|
||
|
ldr r6, =0x2
|
||
|
bl wait_r6
|
||
|
b _bitloop_ret
|
||
|
|
||
|
sk6812_send_zero:
|
||
|
str r2, [r1]
|
||
|
ldr r6, =0x1
|
||
|
bl wait_r6
|
||
|
str r3, [r1]
|
||
|
ldr r6, =0x5
|
||
|
bl wait_r6
|
||
|
b _bitloop_ret
|
||
|
|
||
|
wait_r6:
|
||
|
subs r6, r6, #1
|
||
|
bne wait_r6
|
||
|
bx lr
|