This library lets you control the addressable RGB LED strips from Pololu Robotics. Forked to add selectable colour order (Support RGB or GRB Leds)
Fork of PololuLedStrip by
led_strip_write_color.s@8:1578776ceac5, 2013-03-01 (annotated)
- Committer:
- DavidEGrayson
- Date:
- Fri Mar 01 02:05:21 2013 +0000
- Revision:
- 8:1578776ceac5
- Parent:
- 7:9a088f042ee0
- Child:
- 9:6ffb85d69eaf
Changed the registers so that the push and pop commands can work on the Cortex M0 (LPC 11U24). There are still more things to fix though.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DavidEGrayson | 0:06475317f283 | 1 | AREA asm_func, CODE, READONLY |
DavidEGrayson | 0:06475317f283 | 2 | EXPORT led_strip_write_color |
DavidEGrayson | 6:9d0530b7dae2 | 3 | IMPORT led_strip_write_delays |
DavidEGrayson | 0:06475317f283 | 4 | |
DavidEGrayson | 7:9a088f042ee0 | 5 | MACRO |
DavidEGrayson | 7:9a088f042ee0 | 6 | delay $id |
DavidEGrayson | 7:9a088f042ee0 | 7 | ldr r5, =led_strip_write_delays |
DavidEGrayson | 7:9a088f042ee0 | 8 | ldrb r5, [r5, $id] |
DavidEGrayson | 7:9a088f042ee0 | 9 | lsl r5, r5, #1 |
DavidEGrayson | 7:9a088f042ee0 | 10 | ldr r4, =delay_region_end |
DavidEGrayson | 7:9a088f042ee0 | 11 | sub r4, r4, r5 |
DavidEGrayson | 7:9a088f042ee0 | 12 | blx r4 |
DavidEGrayson | 7:9a088f042ee0 | 13 | MEND |
DavidEGrayson | 7:9a088f042ee0 | 14 | |
DavidEGrayson | 0:06475317f283 | 15 | led_strip_write_color |
DavidEGrayson | 5:690fdfb595de | 16 | ; Register usage: |
DavidEGrayson | 5:690fdfb595de | 17 | ; These are the first 4 arguments to the method: |
DavidEGrayson | 5:690fdfb595de | 18 | ; R0: pointer to the color to send |
DavidEGrayson | 5:690fdfb595de | 19 | ; R1: pointer to the register for setting the pin |
DavidEGrayson | 5:690fdfb595de | 20 | ; R2: pointer to the register for clearing the pin |
DavidEGrayson | 5:690fdfb595de | 21 | ; R3: pin mask |
DavidEGrayson | 5:690fdfb595de | 22 | ; Additionally, we use these registers: |
DavidEGrayson | 5:690fdfb595de | 23 | ; R4: temporary register |
DavidEGrayson | 6:9d0530b7dae2 | 24 | ; R5: temporary register |
DavidEGrayson | 8:1578776ceac5 | 25 | ; R6: shift register that holds the 24-bit color |
DavidEGrayson | 5:690fdfb595de | 26 | ; R7: the number of bits we still need to send |
DavidEGrayson | 5:690fdfb595de | 27 | ; R13: Link Register, holds return addresses. |
DavidEGrayson | 7:9a088f042ee0 | 28 | |
DavidEGrayson | 8:1578776ceac5 | 29 | push {r4, r5, r6, r7, lr} ; Push those registers so we can restore them later. |
DavidEGrayson | 5:690fdfb595de | 30 | |
DavidEGrayson | 8:1578776ceac5 | 31 | ldr r6, [r0] ; Read the color. Now we have: xxBbGgRr |
DavidEGrayson | 8:1578776ceac5 | 32 | rbit r6, r6 ; Reverse the order of the bits: rRgGbBxx |
DavidEGrayson | 8:1578776ceac5 | 33 | rev r6, r6 ; Reverse the order of the bytes: xxbBgGrR |
DavidEGrayson | 0:06475317f283 | 34 | mov r7, #24 ; Initialize the loop counter register. |
DavidEGrayson | 0:06475317f283 | 35 | |
DavidEGrayson | 0:06475317f283 | 36 | send_led_strip_bit |
DavidEGrayson | 0:06475317f283 | 37 | str r3, [r1] ; Drive the line high. |
DavidEGrayson | 8:1578776ceac5 | 38 | rrxs r6, r6 ; Rotate right through carry. |
DavidEGrayson | 0:06475317f283 | 39 | |
DavidEGrayson | 7:9a088f042ee0 | 40 | delay #0 |
DavidEGrayson | 0:06475317f283 | 41 | |
DavidEGrayson | 7:9a088f042ee0 | 42 | it cc ; If the bit to send it 0... |
DavidEGrayson | 7:9a088f042ee0 | 43 | strcc r3, [r2] ; Drive the line low. |
DavidEGrayson | 0:06475317f283 | 44 | |
DavidEGrayson | 7:9a088f042ee0 | 45 | delay #1 |
DavidEGrayson | 0:06475317f283 | 46 | |
DavidEGrayson | 7:9a088f042ee0 | 47 | it cs ; If the bit to send is 1... |
DavidEGrayson | 7:9a088f042ee0 | 48 | strcs r3, [r2] ; Drive the line low. |
DavidEGrayson | 0:06475317f283 | 49 | |
DavidEGrayson | 7:9a088f042ee0 | 50 | delay #2 |
DavidEGrayson | 4:d3b60bd43811 | 51 | |
DavidEGrayson | 6:9d0530b7dae2 | 52 | subs r7, r7, #1 ; Decrement the loop counter. |
DavidEGrayson | 5:690fdfb595de | 53 | bne send_led_strip_bit ; Send another bit if we have not reached zero. |
DavidEGrayson | 4:d3b60bd43811 | 54 | |
DavidEGrayson | 4:d3b60bd43811 | 55 | led_strip_asm_end |
DavidEGrayson | 8:1578776ceac5 | 56 | pop {r4, r5, r6, r7, lr} |
DavidEGrayson | 4:d3b60bd43811 | 57 | bx lr |
DavidEGrayson | 4:d3b60bd43811 | 58 | |
DavidEGrayson | 4:d3b60bd43811 | 59 | |
DavidEGrayson | 4:d3b60bd43811 | 60 | delay_region |
DavidEGrayson | 5:690fdfb595de | 61 | ; The following is 128 nops. |
DavidEGrayson | 0:06475317f283 | 62 | nop |
DavidEGrayson | 0:06475317f283 | 63 | nop |
DavidEGrayson | 0:06475317f283 | 64 | nop |
DavidEGrayson | 0:06475317f283 | 65 | nop |
DavidEGrayson | 0:06475317f283 | 66 | nop |
DavidEGrayson | 0:06475317f283 | 67 | nop |
DavidEGrayson | 0:06475317f283 | 68 | nop |
DavidEGrayson | 0:06475317f283 | 69 | nop |
DavidEGrayson | 0:06475317f283 | 70 | nop |
DavidEGrayson | 0:06475317f283 | 71 | nop |
DavidEGrayson | 0:06475317f283 | 72 | nop |
DavidEGrayson | 0:06475317f283 | 73 | nop |
DavidEGrayson | 0:06475317f283 | 74 | nop |
DavidEGrayson | 4:d3b60bd43811 | 75 | nop |
DavidEGrayson | 4:d3b60bd43811 | 76 | nop |
DavidEGrayson | 4:d3b60bd43811 | 77 | nop |
DavidEGrayson | 4:d3b60bd43811 | 78 | |
DavidEGrayson | 0:06475317f283 | 79 | nop |
DavidEGrayson | 0:06475317f283 | 80 | nop |
DavidEGrayson | 0:06475317f283 | 81 | nop |
DavidEGrayson | 0:06475317f283 | 82 | nop |
DavidEGrayson | 0:06475317f283 | 83 | nop |
DavidEGrayson | 0:06475317f283 | 84 | nop |
DavidEGrayson | 0:06475317f283 | 85 | nop |
DavidEGrayson | 0:06475317f283 | 86 | nop |
DavidEGrayson | 0:06475317f283 | 87 | nop |
DavidEGrayson | 0:06475317f283 | 88 | nop |
DavidEGrayson | 0:06475317f283 | 89 | nop |
DavidEGrayson | 0:06475317f283 | 90 | nop |
DavidEGrayson | 0:06475317f283 | 91 | nop |
DavidEGrayson | 0:06475317f283 | 92 | nop |
DavidEGrayson | 0:06475317f283 | 93 | nop |
DavidEGrayson | 0:06475317f283 | 94 | nop |
DavidEGrayson | 4:d3b60bd43811 | 95 | |
DavidEGrayson | 0:06475317f283 | 96 | nop |
DavidEGrayson | 0:06475317f283 | 97 | nop |
DavidEGrayson | 0:06475317f283 | 98 | nop |
DavidEGrayson | 0:06475317f283 | 99 | nop |
DavidEGrayson | 4:d3b60bd43811 | 100 | nop |
DavidEGrayson | 4:d3b60bd43811 | 101 | nop |
DavidEGrayson | 0:06475317f283 | 102 | nop |
DavidEGrayson | 0:06475317f283 | 103 | nop |
DavidEGrayson | 0:06475317f283 | 104 | nop |
DavidEGrayson | 0:06475317f283 | 105 | nop |
DavidEGrayson | 0:06475317f283 | 106 | nop |
DavidEGrayson | 0:06475317f283 | 107 | nop |
DavidEGrayson | 0:06475317f283 | 108 | nop |
DavidEGrayson | 0:06475317f283 | 109 | nop |
DavidEGrayson | 0:06475317f283 | 110 | nop |
DavidEGrayson | 0:06475317f283 | 111 | nop |
DavidEGrayson | 0:06475317f283 | 112 | |
DavidEGrayson | 0:06475317f283 | 113 | nop |
DavidEGrayson | 0:06475317f283 | 114 | nop |
DavidEGrayson | 0:06475317f283 | 115 | nop |
DavidEGrayson | 0:06475317f283 | 116 | nop |
DavidEGrayson | 0:06475317f283 | 117 | nop |
DavidEGrayson | 0:06475317f283 | 118 | nop |
DavidEGrayson | 0:06475317f283 | 119 | nop |
DavidEGrayson | 0:06475317f283 | 120 | nop |
DavidEGrayson | 0:06475317f283 | 121 | nop |
DavidEGrayson | 0:06475317f283 | 122 | nop |
DavidEGrayson | 4:d3b60bd43811 | 123 | nop |
DavidEGrayson | 4:d3b60bd43811 | 124 | nop |
DavidEGrayson | 4:d3b60bd43811 | 125 | nop |
DavidEGrayson | 4:d3b60bd43811 | 126 | nop |
DavidEGrayson | 4:d3b60bd43811 | 127 | nop |
DavidEGrayson | 4:d3b60bd43811 | 128 | nop |
DavidEGrayson | 0:06475317f283 | 129 | |
DavidEGrayson | 0:06475317f283 | 130 | nop |
DavidEGrayson | 0:06475317f283 | 131 | nop |
DavidEGrayson | 0:06475317f283 | 132 | nop |
DavidEGrayson | 0:06475317f283 | 133 | nop |
DavidEGrayson | 0:06475317f283 | 134 | nop |
DavidEGrayson | 0:06475317f283 | 135 | nop |
DavidEGrayson | 0:06475317f283 | 136 | nop |
DavidEGrayson | 0:06475317f283 | 137 | nop |
DavidEGrayson | 0:06475317f283 | 138 | nop |
DavidEGrayson | 0:06475317f283 | 139 | nop |
DavidEGrayson | 4:d3b60bd43811 | 140 | nop |
DavidEGrayson | 4:d3b60bd43811 | 141 | nop |
DavidEGrayson | 4:d3b60bd43811 | 142 | nop |
DavidEGrayson | 4:d3b60bd43811 | 143 | nop |
DavidEGrayson | 4:d3b60bd43811 | 144 | nop |
DavidEGrayson | 4:d3b60bd43811 | 145 | nop |
DavidEGrayson | 0:06475317f283 | 146 | |
DavidEGrayson | 0:06475317f283 | 147 | nop |
DavidEGrayson | 0:06475317f283 | 148 | nop |
DavidEGrayson | 0:06475317f283 | 149 | nop |
DavidEGrayson | 0:06475317f283 | 150 | nop |
DavidEGrayson | 0:06475317f283 | 151 | nop |
DavidEGrayson | 0:06475317f283 | 152 | nop |
DavidEGrayson | 0:06475317f283 | 153 | nop |
DavidEGrayson | 0:06475317f283 | 154 | nop |
DavidEGrayson | 0:06475317f283 | 155 | nop |
DavidEGrayson | 0:06475317f283 | 156 | nop |
DavidEGrayson | 0:06475317f283 | 157 | nop |
DavidEGrayson | 0:06475317f283 | 158 | nop |
DavidEGrayson | 0:06475317f283 | 159 | nop |
DavidEGrayson | 0:06475317f283 | 160 | nop |
DavidEGrayson | 0:06475317f283 | 161 | nop |
DavidEGrayson | 0:06475317f283 | 162 | nop |
DavidEGrayson | 0:06475317f283 | 163 | |
DavidEGrayson | 0:06475317f283 | 164 | nop |
DavidEGrayson | 0:06475317f283 | 165 | nop |
DavidEGrayson | 0:06475317f283 | 166 | nop |
DavidEGrayson | 0:06475317f283 | 167 | nop |
DavidEGrayson | 0:06475317f283 | 168 | nop |
DavidEGrayson | 0:06475317f283 | 169 | nop |
DavidEGrayson | 0:06475317f283 | 170 | nop |
DavidEGrayson | 0:06475317f283 | 171 | nop |
DavidEGrayson | 0:06475317f283 | 172 | nop |
DavidEGrayson | 0:06475317f283 | 173 | nop |
DavidEGrayson | 4:d3b60bd43811 | 174 | nop |
DavidEGrayson | 4:d3b60bd43811 | 175 | nop |
DavidEGrayson | 4:d3b60bd43811 | 176 | nop |
DavidEGrayson | 4:d3b60bd43811 | 177 | nop |
DavidEGrayson | 4:d3b60bd43811 | 178 | nop |
DavidEGrayson | 4:d3b60bd43811 | 179 | nop |
DavidEGrayson | 4:d3b60bd43811 | 180 | |
DavidEGrayson | 0:06475317f283 | 181 | nop |
DavidEGrayson | 0:06475317f283 | 182 | nop |
DavidEGrayson | 0:06475317f283 | 183 | nop |
DavidEGrayson | 0:06475317f283 | 184 | nop |
DavidEGrayson | 0:06475317f283 | 185 | nop |
DavidEGrayson | 0:06475317f283 | 186 | nop |
DavidEGrayson | 4:d3b60bd43811 | 187 | nop |
DavidEGrayson | 4:d3b60bd43811 | 188 | nop |
DavidEGrayson | 4:d3b60bd43811 | 189 | nop |
DavidEGrayson | 4:d3b60bd43811 | 190 | nop |
DavidEGrayson | 4:d3b60bd43811 | 191 | nop |
DavidEGrayson | 4:d3b60bd43811 | 192 | nop |
DavidEGrayson | 4:d3b60bd43811 | 193 | nop |
DavidEGrayson | 4:d3b60bd43811 | 194 | nop |
DavidEGrayson | 4:d3b60bd43811 | 195 | nop |
DavidEGrayson | 4:d3b60bd43811 | 196 | nop |
DavidEGrayson | 5:690fdfb595de | 197 | delay_region_end |
DavidEGrayson | 4:d3b60bd43811 | 198 | bx lr ; return |
DavidEGrayson | 0:06475317f283 | 199 | |
DavidEGrayson | 0:06475317f283 | 200 | END |