This library lets you control the addressable RGB LED strips from Pololu Robotics. Forked to add selectable colour order (Support RGB or GRB Leds)
Fork of PololuLedStrip by
Diff: led_strip_write_color.s
- Revision:
- 5:690fdfb595de
- Parent:
- 4:d3b60bd43811
- Child:
- 6:9d0530b7dae2
--- a/led_strip_write_color.s Thu Feb 28 00:42:44 2013 +0000 +++ b/led_strip_write_color.s Fri Mar 01 00:05:26 2013 +0000 @@ -2,7 +2,20 @@ EXPORT led_strip_write_color led_strip_write_color - push {r4, r12, r7} + ; Register usage: + ; These are the first 4 arguments to the method: + ; R0: pointer to the color to send + ; R1: pointer to the register for setting the pin + ; R2: pointer to the register for clearing the pin + ; R3: pin mask + ; Additionally, we use these registers: + ; R4: temporary register + ; R7: the number of bits we still need to send + ; R12: shift register that holds the 24-bit color + ; R13: Link Register, holds return addresses. + + + push {r4, r12, r7, lr} ldr r12, [r0] ; Read the next color. rbit r12, r12 ; Reverse the order of the bits. @@ -13,164 +26,34 @@ str r3, [r1] ; Drive the line high. rrxs r12, r12 ; Rotate right through carry. - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop + ldr r4, =delay_region_end + sub r4, r4, #59*2 + blx r4 it cc ; If the bit to send it 0... strcc r3, [r2] ; Drive the line low. - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - - nop - nop - nop - nop - nop - nop - nop - nop - nop - + ldr r4, =delay_region_end + sub r4, r4, #59*2 + blx r4 it cs ; If the bit to send is 1... strcs r3, [r2] ; Drive the line low. ldr r4, =delay_region - add r4, r4, 34*2 + add r4, r4, #68 blx r4 - sub r7, r7, #1 ; Decrement the loop counter. - cbz r7, led_strip_asm_end ; If we have sent 24 bits, go to the end. - b send_led_strip_bit ; Otherwise, go back and send another bit. + subs r7, r7, #1 ; Decrement the loop counter. + bne send_led_strip_bit ; Send another bit if we have not reached zero. led_strip_asm_end - pop {r4, r12, r7} + pop {r4, r12, r7, lr} bx lr delay_region - ; The following is 128 no-ops + ; The following is 128 nops. nop nop nop @@ -306,6 +189,7 @@ nop nop nop +delay_region_end bx lr ; return END \ No newline at end of file