This is an example program for the PololuLedStrip library. It generates a simple moving gradient pattern.
Dependencies: PololuLedStrip mbed LedStripGradient
Dependents: LedStripGradient led_phare_crf
For more information, see the PololuLedStrip library.
Revision 6:59f1db26a9ff, committed 2013-02-26
- Comitter:
- DavidEGrayson
- Date:
- Tue Feb 26 02:50:13 2013 +0000
- Parent:
- 5:8b685ba2f16b
- Child:
- 7:242f14ed9055
- Commit message:
- making 24 pulses with assembly
Changed in this revision
led_strip.s | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/led_strip.s Tue Feb 26 02:25:19 2013 +0000 +++ b/led_strip.s Tue Feb 26 02:50:13 2013 +0000 @@ -1,23 +1,213 @@ AREA asm_func, CODE, READONLY - EXPORT led_strip_write_color + EXPORT led_strip_write_color led_strip_write_color - push {R9,R10} -; LDR R9, =0x2009C020 ; 0x2009C020 = GPIO port 1 base address -; MOV.W R10, #0x040000 ; 0x040000 = 1<<18 all "0"s with a "1" in bit 18 -; CMP R3, #0 ; value == 0 ? -; ITE EQ - STR R3, [R1,#0] ; set - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - STR R3, [R2,#0] ; clear - pop {R9,R10} - BX LR + push {r12, r7} + + 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. + + 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 + + it cc + 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 + + it cs + strcs 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 + + 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. + +led_strip_asm_end + pop {r12, r7} + bx lr + END \ No newline at end of file
--- a/main.cpp Tue Feb 26 02:25:19 2013 +0000 +++ b/main.cpp Tue Feb 26 02:50:13 2013 +0000 @@ -110,11 +110,8 @@ gpio_init(&gpio, p8, PIN_OUTPUT); while(1) { - myled2 = 1; + myled2 = !myled2.read(); led_strip_write_color(colors, gpio.reg_set, gpio.reg_clr, gpio.mask); wait(0.2); - led_strip_write_color(colors, gpio.reg_set, gpio.reg_clr, gpio.mask); - myled2 = 0; - wait(1); } }