school project using led strip
Fork of PololuLedStrip by
Revision 10:f1bb84b97788, committed 2013-03-01
- Comitter:
- DavidEGrayson
- Date:
- Fri Mar 01 04:15:35 2013 +0000
- Parent:
- 9:6ffb85d69eaf
- Child:
- 11:e00ba70ac54c
- Commit message:
- Saved one cycle per bit by shifting the delays to the left in C.
Changed in this revision
PololuLedStrip.cpp | Show annotated file Show diff for this revision Revisions of this file |
led_strip_write_color.s | Show annotated file Show diff for this revision Revisions of this file |
--- a/PololuLedStrip.cpp Fri Mar 01 03:57:49 2013 +0000 +++ b/PololuLedStrip.cpp Fri Mar 01 04:15:35 2013 +0000 @@ -10,7 +10,7 @@ int f_mhz = SystemCoreClock / 1000000; // Arrange for a 700 nanosecond delay between the rise time and the fall time for a 0 bit. - led_strip_write_delays[0] = 700*f_mhz/1000 - 25 - 5; + led_strip_write_delays[0] = 700*f_mhz/1000 - 32; // Arrange for a 600 nanosecond delay between the fall time for a 0 bit and the fall time for a 1 bit. // This means the pulses representing a 1 will be 700+600 = 1300 nanoseconds. @@ -19,6 +19,10 @@ // Arrange for a 1200 nanosecond delay between the fall time for a 1 bit and rise time of the next bit. // This means the period of the signal will be 2500 nanoseconds. led_strip_write_delays[2] = 1200*f_mhz/1000 - 24; + + led_strip_write_delays[0] <<= 1; + led_strip_write_delays[1] <<= 1; + led_strip_write_delays[2] <<= 1; } PololuLedStrip::PololuLedStrip(PinName pinName)
--- a/led_strip_write_color.s Fri Mar 01 03:57:49 2013 +0000 +++ b/led_strip_write_color.s Fri Mar 01 04:15:35 2013 +0000 @@ -6,7 +6,6 @@ delay $id ldr r5, =led_strip_write_delays ldrb r5, [r5, $id] - lsls r5, r5, #1 ldr r4, =delay_region_end subs r4, r4, r5 blx r4 @@ -30,16 +29,16 @@ push {r4, r5, r6, r7} mov r4, lr push {r4} - + ldrb r4, [r0, #0] ; Load red. lsls r4, r4, #24 mov r6, r4 ; Put red in MSB of r6. ldrb r4, [r0, #1] ; Load green. lsls r4, r4, #16 - orrs r6, r6, r4 ; Put green in r6. + orrs r6, r6, r4 ; Put green in r6. ldrb r4, [r0, #2] ; Load blue. lsls r4, r4, #8 - orrs r6, r6, r4 ; Put blue in MSB of r6. + orrs r6, r6, r4 ; Put blue in MSB of r6. ; On the Cortex M0 we simply did: ; ldr r6, [r0] ; Read the color. Now we have: xxBbGgRr @@ -70,7 +69,7 @@ delay #2 - lsls r6, r6, #1 ; Shift color bits. + lsls r6, r6, #1 ; Shift color bits. subs r7, r7, #1 ; Decrement the loop counter. bne send_led_strip_bit ; Send another bit if we have not reached zero.