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

Fork of PololuLedStrip by David Grayson

led_strip_write_color.s

Committer:
DavidEGrayson
Date:
2013-03-01
Revision:
5:690fdfb595de
Parent:
4:d3b60bd43811
Child:
6:9d0530b7dae2

File content as of revision 5:690fdfb595de:

    AREA asm_func, CODE, READONLY
    EXPORT led_strip_write_color

led_strip_write_color
    ; 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.
    rev r12, r12       ; Reverse the order of the bytes.
    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 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.

    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, #68
    blx r4
    
    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, lr}
    bx lr
    

delay_region
    ; The following is 128 nops.
    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

    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
delay_region_end
    bx lr    ; return
    
    END