Forked PololuLedStrip and modified it to work with the KL25Z. Renamed it to Adafruit_NeoPixel.

Dependents:   idd_hw3 idd_fa15_hw3_lauren_bill_tomas idd_fa15_hw3_lauren_bill_tomas Raiden ... more

Fork of PololuLedStrip by David Grayson

Revision:
7:9a088f042ee0
Parent:
6:9d0530b7dae2
Child:
8:1578776ceac5
--- a/led_strip_write_color.s	Fri Mar 01 00:31:24 2013 +0000
+++ b/led_strip_write_color.s	Fri Mar 01 01:16:48 2013 +0000
@@ -2,6 +2,16 @@
     EXPORT led_strip_write_color
     IMPORT led_strip_write_delays
 
+    MACRO
+    delay $id
+    ldr r5, =led_strip_write_delays
+    ldrb r5, [r5, $id]
+    lsl r5, r5, #1
+    ldr r4, =delay_region_end
+    sub r4, r4, r5
+    blx r4
+    MEND
+
 led_strip_write_color
     ; Register usage:
     ; These are the first 4 arguments to the method:
@@ -15,39 +25,29 @@
     ;   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, r5, r12, r7, lr}  ; Push those registers so we can restore them later.
     
-    push {r4, r5, r12, r7, lr}
-   
-    ldr r12, [r0]      ; Read the next color.
-    rbit r12, r12      ; Reverse the order of the bits.
-    rev r12, r12       ; Reverse the order of the bytes.
+    ldr r12, [r0]      ; Read the color.  Now we have:     xxBbGgRr
+    rbit r12, r12      ; Reverse the order of the bits:    rRgGbBxx
+    rev r12, r12       ; Reverse the order of the bytes:   xxbBgGrR
     mov r7, #24        ; Initialize the loop counter register.
     
 send_led_strip_bit
     str r3, [r1]       ; Drive the line high.
     rrxs r12, r12      ; Rotate right through carry.
     
-    ldr r5, =led_strip_write_delays
-    ldrb r5, [r5, #0]
-    lsl r5, r5, #1
-    ldr r4, =delay_region_end
-    sub r4, r4, r5
-    blx r4
+    delay #0
     
-    it cc                ; If the bit to send it 0...
-    strcc r3, [r2]       ; Drive the line low.
+    it cc              ; If the bit to send it 0...
+    strcc r3, [r2]     ; Drive the line low.
 
-    ldr r4, =delay_region_end
-    sub r4, r4, #59*2
-    blx r4
+    delay #1
 
-    it cs                ; If the bit to send is 1...
-    strcs r3, [r2]       ; Drive the line low.
+    it cs              ; If the bit to send is 1...
+    strcs r3, [r2]     ; Drive the line low.
     
-    ldr r4, =delay_region
-    add r4, r4, #68
-    blx r4
+    delay #2
     
     subs r7, r7, #1           ; Decrement the loop counter.
     bne send_led_strip_bit    ; Send another bit if we have not reached zero.