school project using led strip
Fork of PololuLedStrip by
Revision 4:d3b60bd43811, committed 2013-02-28
- Comitter:
- DavidEGrayson
- Date:
- Thu Feb 28 00:42:44 2013 +0000
- Parent:
- 3:809dae64a994
- Child:
- 5:690fdfb595de
- Commit message:
- Proof of the concept that we can achieve variable delays by jumping into a particular portion of a large subroutine with noops.
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 Wed Feb 27 02:45:31 2013 +0000 +++ b/PololuLedStrip.cpp Thu Feb 28 00:42:44 2013 +0000 @@ -2,6 +2,9 @@ bool PololuLedStrip::interruptFriendly = false; +// TODO: read clock frequency from SystemCoreClock and use that to make this work on different boards. +// calculate the three delays needed and pass them to the assembly. The assembly can implement them with computed jumps. + PololuLedStrip::PololuLedStrip(PinName pinName) { gpio_init(&gpio, pinName, PIN_OUTPUT);
--- a/led_strip_write_color.s Wed Feb 27 02:45:31 2013 +0000 +++ b/led_strip_write_color.s Thu Feb 28 00:42:44 2013 +0000 @@ -2,7 +2,7 @@ EXPORT led_strip_write_color led_strip_write_color - push {r12, r7} + push {r4, r12, r7} ldr r12, [r0] ; Read the next color. rbit r12, r12 ; Reverse the order of the bits. @@ -156,9 +156,21 @@ it cs ; If the bit to send is 1... strcs r3, [r2] ; Drive the line low. - nop - nop - nop + ldr r4, =delay_region + add r4, r4, 34*2 + 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. + +led_strip_asm_end + pop {r4, r12, r7} + bx lr + + +delay_region + ; The following is 128 no-ops nop nop nop @@ -166,18 +178,16 @@ nop nop nop - - nop - nop - nop - nop nop nop nop nop nop nop - + nop + nop + nop + nop nop nop @@ -188,18 +198,19 @@ nop nop nop - nop nop nop nop nop nop + nop nop nop nop - + nop + nop nop nop nop @@ -221,6 +232,12 @@ nop nop nop + nop + nop + nop + nop + nop + nop nop nop @@ -232,6 +249,12 @@ nop nop nop + nop + nop + nop + nop + nop + nop nop nop @@ -243,17 +266,12 @@ nop nop nop - nop nop nop nop nop nop - nop - nop - nop - nop nop nop @@ -265,21 +283,29 @@ 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 + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + bx lr ; return END \ No newline at end of file