1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
.text
.global ASM_ISR
/* R0 = iCount addr, R1=Strip4_mask_pntr addr, R2 = Strip4_pntr addr, R3 = Strip4_base_pntr addr, Stack = Strip4_Num_LED addr, CC addr */
ASM_ISR:
cpsid i @ disable all interrupts
ldr r4, [r0, #0] @ get iCounter
cmp r4,#0 @ is iCount = 0 ?
beq ext @ exit routine if so
pop {r4} @ CC Addr
pop {r5} @ Num LEDs Addr
push {r0} @ Free r0 | iCount Addr on stack
ldr r7, = 0x38 @ value for 1 CC PWM LED
lsl r7, r7, #6 @ Position for CC reg
ldr r0, [r1, #0] @ get mask
ldr r6, [r2, #0] @ get array element
and r6, r6, r0 @ test bit
beq jmp1 @ if it's 1 jmp
lsr r7, r7, #1 @ value for 0 CC PWM LED
jmp1: str r7, [r4, #0] @ set new CC val | open regs r4, r6
lsr r0, r0, #1 @ shift mask bit
cmp r0, #0 @ Did we empty mask reg
bne ext @ if not we're done
ldr r4, = 0x80 @ reinitialize mask | open regs r6
lsl r4, r4, #16 @ 0x00800000
mov r6, r2 @ get array pointer address
add r6, #4 @ increment array pntr address
lsl r5, r5, #2 @ multi num leds x4 for address calculation
add r5, r5, r3 @ point to end of array
cmp r6, r5 @ are we at the last array element
bne jmp2 @ if not jmp
ldr r6, [r3, #0] @ array pointer back to top of array
jmp2: str r4, [r1, #0] @ mask reg to memory
str r6, [r2, #0] @ array pointer to memory
pop {r0} @ get iCount address
ldr r4, [r0, #0] @ get iCount
sub r4, #1 @ Decrement iCount
str r4, [r0, #0] @ iCount to memory
ext: cpsie i @ Enable interrupts
bx lr @ Exit
.end
|