NeoStrip Code Repository from external source
Fork of NeoStrip by
NeoCore.s@2:0d3d38087543, 2016-04-29 (annotated)
- Committer:
- nbharwani3
- Date:
- Fri Apr 29 11:58:36 2016 +0000
- Revision:
- 2:0d3d38087543
- Parent:
- 0:9f237b11f0a8
None
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aswild | 0:9f237b11f0a8 | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 2 | ; NeoCore.s |
aswild | 0:9f237b11f0a8 | 3 | ; |
aswild | 0:9f237b11f0a8 | 4 | ; Allen Wild |
aswild | 0:9f237b11f0a8 | 5 | ; March 2014 |
aswild | 0:9f237b11f0a8 | 6 | ; |
aswild | 0:9f237b11f0a8 | 7 | ; ARM assembly functions for writing to Adafruit NeoPixels |
aswild | 0:9f237b11f0a8 | 8 | ; with the mbed NXP LPC1768 |
aswild | 0:9f237b11f0a8 | 9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 10 | AREA neo_core, CODE, READONLY |
aswild | 0:9f237b11f0a8 | 11 | |
aswild | 0:9f237b11f0a8 | 12 | IMPORT neo_fio_reg |
aswild | 0:9f237b11f0a8 | 13 | IMPORT neo_bitmask |
aswild | 0:9f237b11f0a8 | 14 | |
aswild | 0:9f237b11f0a8 | 15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 16 | neo_write_pin |
aswild | 0:9f237b11f0a8 | 17 | ; Set the GPIO pin to the value passed in R0 |
aswild | 0:9f237b11f0a8 | 18 | ; Registers and bitmasks are stored in variables set by the C++ library |
aswild | 0:9f237b11f0a8 | 19 | LDR R1, =neo_fio_reg ; load pointers to register values |
aswild | 0:9f237b11f0a8 | 20 | LDR R2, =neo_bitmask |
aswild | 0:9f237b11f0a8 | 21 | LDR R1, [R1] ; load actual values from memory |
aswild | 0:9f237b11f0a8 | 22 | LDR R2, [R2] |
aswild | 0:9f237b11f0a8 | 23 | |
aswild | 0:9f237b11f0a8 | 24 | CMP R0, #0 ; VALUE == 0 ? |
aswild | 0:9f237b11f0a8 | 25 | ITE EQ ; (IF-THEN-ELSE) ON NEXT TWO INSTRUCTIONS USING "EQ" FLAG |
aswild | 0:9f237b11f0a8 | 26 | STREQ R2, [R1,#0x1C] ; if==0, CLEAR BIT |
aswild | 0:9f237b11f0a8 | 27 | STRNE R2, [R1,#0x18] ; if==1, SET BIT |
aswild | 0:9f237b11f0a8 | 28 | BX LR |
aswild | 0:9f237b11f0a8 | 29 | |
aswild | 0:9f237b11f0a8 | 30 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 31 | neo_zero |
aswild | 0:9f237b11f0a8 | 32 | ; Output a NeoPixel zero, composed of a short |
aswild | 0:9f237b11f0a8 | 33 | ; HIGH pulse and a long LOW pulse |
aswild | 0:9f237b11f0a8 | 34 | PUSH {LR} |
aswild | 0:9f237b11f0a8 | 35 | MOV R0, #1 |
aswild | 0:9f237b11f0a8 | 36 | BL neo_write_pin ; set pin high |
aswild | 0:9f237b11f0a8 | 37 | |
aswild | 0:9f237b11f0a8 | 38 | MOV R0, #10 ; delay for long enough |
aswild | 0:9f237b11f0a8 | 39 | BL neo_delay |
aswild | 0:9f237b11f0a8 | 40 | |
aswild | 0:9f237b11f0a8 | 41 | MOV R0, #0 ; set pin low |
aswild | 0:9f237b11f0a8 | 42 | BL neo_write_pin |
aswild | 0:9f237b11f0a8 | 43 | |
aswild | 0:9f237b11f0a8 | 44 | MOV R0, #20 ; delay |
aswild | 0:9f237b11f0a8 | 45 | BL neo_delay |
aswild | 0:9f237b11f0a8 | 46 | |
aswild | 0:9f237b11f0a8 | 47 | POP {LR} |
aswild | 0:9f237b11f0a8 | 48 | BX LR |
aswild | 0:9f237b11f0a8 | 49 | |
aswild | 0:9f237b11f0a8 | 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 51 | neo_one |
aswild | 0:9f237b11f0a8 | 52 | ; Output a NeoPixel one, composed of a long |
aswild | 0:9f237b11f0a8 | 53 | ; HIGH pulse and a short LOW pulse |
aswild | 0:9f237b11f0a8 | 54 | PUSH {LR} |
aswild | 0:9f237b11f0a8 | 55 | MOV R0, #1 |
aswild | 0:9f237b11f0a8 | 56 | BL neo_write_pin |
aswild | 0:9f237b11f0a8 | 57 | |
aswild | 0:9f237b11f0a8 | 58 | MOV R0, #86 |
aswild | 0:9f237b11f0a8 | 59 | BL neo_delay |
aswild | 0:9f237b11f0a8 | 60 | |
aswild | 0:9f237b11f0a8 | 61 | MOV R0, #0 |
aswild | 0:9f237b11f0a8 | 62 | BL neo_write_pin |
aswild | 0:9f237b11f0a8 | 63 | |
aswild | 0:9f237b11f0a8 | 64 | NOP ; really short delay |
aswild | 0:9f237b11f0a8 | 65 | NOP |
aswild | 0:9f237b11f0a8 | 66 | NOP |
aswild | 0:9f237b11f0a8 | 67 | |
aswild | 0:9f237b11f0a8 | 68 | POP {LR} |
aswild | 0:9f237b11f0a8 | 69 | BX LR |
aswild | 0:9f237b11f0a8 | 70 | |
aswild | 0:9f237b11f0a8 | 71 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 72 | EXPORT neo_out ; void neo_out(int *data, int n); |
aswild | 0:9f237b11f0a8 | 73 | ; Main function called from the C++ library |
aswild | 0:9f237b11f0a8 | 74 | ; R0 contains a pointer to the array of color data to send |
aswild | 0:9f237b11f0a8 | 75 | ; R1 contains the number of bytes of data to send |
aswild | 0:9f237b11f0a8 | 76 | neo_out |
aswild | 0:9f237b11f0a8 | 77 | PUSH {LR, R4, R5, R6, R7, R8} |
aswild | 0:9f237b11f0a8 | 78 | MOV R7, R1 ; move length to R7 |
aswild | 0:9f237b11f0a8 | 79 | MOV R6, R0 ; move address to R6 |
aswild | 0:9f237b11f0a8 | 80 | |
aswild | 0:9f237b11f0a8 | 81 | neo_byteloop |
aswild | 0:9f237b11f0a8 | 82 | LDRB R5, [R6] ; load byte to send |
aswild | 0:9f237b11f0a8 | 83 | MOV R4, #0x80 ; load initial bitmask |
aswild | 0:9f237b11f0a8 | 84 | |
aswild | 0:9f237b11f0a8 | 85 | neo_bitloop |
aswild | 0:9f237b11f0a8 | 86 | AND R3, R5, R4 ; mask current byte |
aswild | 0:9f237b11f0a8 | 87 | CMP R3, #0 |
aswild | 0:9f237b11f0a8 | 88 | BLEQ neo_zero ; send current bit |
aswild | 0:9f237b11f0a8 | 89 | BLNE neo_one |
aswild | 0:9f237b11f0a8 | 90 | |
aswild | 0:9f237b11f0a8 | 91 | LSR R4, R4, #1 ; shift bitmask right one |
aswild | 0:9f237b11f0a8 | 92 | CMP R4, #0 ; if still more bits, loop back |
aswild | 0:9f237b11f0a8 | 93 | BNE neo_bitloop |
aswild | 0:9f237b11f0a8 | 94 | |
aswild | 0:9f237b11f0a8 | 95 | ADD R6, R6, #1 ; increment address |
aswild | 0:9f237b11f0a8 | 96 | SUB R7, R7, #1 ; decrement count |
aswild | 0:9f237b11f0a8 | 97 | CMP R7, #0 |
aswild | 0:9f237b11f0a8 | 98 | BNE neo_byteloop ; continue if not done |
aswild | 0:9f237b11f0a8 | 99 | |
aswild | 0:9f237b11f0a8 | 100 | MOV R0, #0 |
aswild | 0:9f237b11f0a8 | 101 | BL neo_write_pin |
aswild | 0:9f237b11f0a8 | 102 | POP {R8, R7, R6, R5, R4, LR} |
aswild | 0:9f237b11f0a8 | 103 | BX LR |
aswild | 0:9f237b11f0a8 | 104 | |
aswild | 0:9f237b11f0a8 | 105 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
aswild | 0:9f237b11f0a8 | 106 | |
aswild | 0:9f237b11f0a8 | 107 | neo_delay |
aswild | 0:9f237b11f0a8 | 108 | ; delay the specified number of cycles in R0 with a bunch of nops |
aswild | 0:9f237b11f0a8 | 109 | LDR R2, =neo_delay_end |
aswild | 0:9f237b11f0a8 | 110 | SUB R2, R2, R0 |
aswild | 0:9f237b11f0a8 | 111 | BX R2 |
aswild | 0:9f237b11f0a8 | 112 | NOP |
aswild | 0:9f237b11f0a8 | 113 | NOP |
aswild | 0:9f237b11f0a8 | 114 | NOP |
aswild | 0:9f237b11f0a8 | 115 | NOP |
aswild | 0:9f237b11f0a8 | 116 | NOP |
aswild | 0:9f237b11f0a8 | 117 | NOP |
aswild | 0:9f237b11f0a8 | 118 | NOP |
aswild | 0:9f237b11f0a8 | 119 | NOP |
aswild | 0:9f237b11f0a8 | 120 | NOP |
aswild | 0:9f237b11f0a8 | 121 | NOP |
aswild | 0:9f237b11f0a8 | 122 | NOP |
aswild | 0:9f237b11f0a8 | 123 | NOP |
aswild | 0:9f237b11f0a8 | 124 | NOP |
aswild | 0:9f237b11f0a8 | 125 | NOP |
aswild | 0:9f237b11f0a8 | 126 | NOP |
aswild | 0:9f237b11f0a8 | 127 | NOP |
aswild | 0:9f237b11f0a8 | 128 | NOP |
aswild | 0:9f237b11f0a8 | 129 | NOP |
aswild | 0:9f237b11f0a8 | 130 | NOP |
aswild | 0:9f237b11f0a8 | 131 | NOP |
aswild | 0:9f237b11f0a8 | 132 | NOP |
aswild | 0:9f237b11f0a8 | 133 | NOP |
aswild | 0:9f237b11f0a8 | 134 | NOP |
aswild | 0:9f237b11f0a8 | 135 | NOP |
aswild | 0:9f237b11f0a8 | 136 | NOP |
aswild | 0:9f237b11f0a8 | 137 | NOP |
aswild | 0:9f237b11f0a8 | 138 | NOP |
aswild | 0:9f237b11f0a8 | 139 | NOP |
aswild | 0:9f237b11f0a8 | 140 | NOP |
aswild | 0:9f237b11f0a8 | 141 | NOP |
aswild | 0:9f237b11f0a8 | 142 | NOP |
aswild | 0:9f237b11f0a8 | 143 | NOP |
aswild | 0:9f237b11f0a8 | 144 | NOP |
aswild | 0:9f237b11f0a8 | 145 | NOP |
aswild | 0:9f237b11f0a8 | 146 | NOP |
aswild | 0:9f237b11f0a8 | 147 | NOP |
aswild | 0:9f237b11f0a8 | 148 | NOP |
aswild | 0:9f237b11f0a8 | 149 | NOP |
aswild | 0:9f237b11f0a8 | 150 | NOP |
aswild | 0:9f237b11f0a8 | 151 | NOP |
aswild | 0:9f237b11f0a8 | 152 | NOP |
aswild | 0:9f237b11f0a8 | 153 | NOP |
aswild | 0:9f237b11f0a8 | 154 | NOP |
aswild | 0:9f237b11f0a8 | 155 | NOP |
aswild | 0:9f237b11f0a8 | 156 | NOP |
aswild | 0:9f237b11f0a8 | 157 | NOP |
aswild | 0:9f237b11f0a8 | 158 | NOP |
aswild | 0:9f237b11f0a8 | 159 | NOP |
aswild | 0:9f237b11f0a8 | 160 | NOP |
aswild | 0:9f237b11f0a8 | 161 | NOP |
aswild | 0:9f237b11f0a8 | 162 | NOP |
aswild | 0:9f237b11f0a8 | 163 | NOP |
aswild | 0:9f237b11f0a8 | 164 | NOP |
aswild | 0:9f237b11f0a8 | 165 | NOP |
aswild | 0:9f237b11f0a8 | 166 | NOP |
aswild | 0:9f237b11f0a8 | 167 | NOP |
aswild | 0:9f237b11f0a8 | 168 | NOP |
aswild | 0:9f237b11f0a8 | 169 | NOP |
aswild | 0:9f237b11f0a8 | 170 | NOP |
aswild | 0:9f237b11f0a8 | 171 | NOP |
aswild | 0:9f237b11f0a8 | 172 | NOP |
aswild | 0:9f237b11f0a8 | 173 | NOP |
aswild | 0:9f237b11f0a8 | 174 | NOP |
aswild | 0:9f237b11f0a8 | 175 | NOP |
aswild | 0:9f237b11f0a8 | 176 | NOP |
aswild | 0:9f237b11f0a8 | 177 | NOP |
aswild | 0:9f237b11f0a8 | 178 | NOP |
aswild | 0:9f237b11f0a8 | 179 | NOP |
aswild | 0:9f237b11f0a8 | 180 | NOP |
aswild | 0:9f237b11f0a8 | 181 | NOP |
aswild | 0:9f237b11f0a8 | 182 | NOP |
aswild | 0:9f237b11f0a8 | 183 | NOP |
aswild | 0:9f237b11f0a8 | 184 | NOP |
aswild | 0:9f237b11f0a8 | 185 | NOP |
aswild | 0:9f237b11f0a8 | 186 | NOP |
aswild | 0:9f237b11f0a8 | 187 | NOP |
aswild | 0:9f237b11f0a8 | 188 | NOP |
aswild | 0:9f237b11f0a8 | 189 | NOP |
aswild | 0:9f237b11f0a8 | 190 | NOP |
aswild | 0:9f237b11f0a8 | 191 | NOP |
aswild | 0:9f237b11f0a8 | 192 | NOP |
aswild | 0:9f237b11f0a8 | 193 | NOP |
aswild | 0:9f237b11f0a8 | 194 | NOP |
aswild | 0:9f237b11f0a8 | 195 | NOP |
aswild | 0:9f237b11f0a8 | 196 | NOP |
aswild | 0:9f237b11f0a8 | 197 | NOP |
aswild | 0:9f237b11f0a8 | 198 | NOP |
aswild | 0:9f237b11f0a8 | 199 | NOP |
aswild | 0:9f237b11f0a8 | 200 | NOP |
aswild | 0:9f237b11f0a8 | 201 | NOP |
aswild | 0:9f237b11f0a8 | 202 | NOP |
aswild | 0:9f237b11f0a8 | 203 | NOP |
aswild | 0:9f237b11f0a8 | 204 | NOP |
aswild | 0:9f237b11f0a8 | 205 | NOP |
aswild | 0:9f237b11f0a8 | 206 | NOP |
aswild | 0:9f237b11f0a8 | 207 | NOP |
aswild | 0:9f237b11f0a8 | 208 | NOP |
aswild | 0:9f237b11f0a8 | 209 | NOP |
aswild | 0:9f237b11f0a8 | 210 | NOP |
aswild | 0:9f237b11f0a8 | 211 | NOP |
aswild | 0:9f237b11f0a8 | 212 | neo_delay_end |
aswild | 0:9f237b11f0a8 | 213 | BX LR |
aswild | 0:9f237b11f0a8 | 214 | |
aswild | 0:9f237b11f0a8 | 215 | END ; end code region |
aswild | 0:9f237b11f0a8 | 216 | |
aswild | 0:9f237b11f0a8 | 217 | |
aswild | 0:9f237b11f0a8 | 218 |