LED screen driver build for hackspace.

Dependencies:   mbed

Committer:
madcowswe
Date:
Wed Feb 29 17:09:46 2012 +0000
Revision:
1:1af5060b2a34
Parent:
0:f16a1d69a386

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 0:f16a1d69a386 1 AREA framefunc, CODE, READONLY
madcowswe 0:f16a1d69a386 2 ; Export my_asm function location so that C compiler can find it and link
madcowswe 0:f16a1d69a386 3 EXPORT frameout
madcowswe 0:f16a1d69a386 4 frameout
madcowswe 0:f16a1d69a386 5
madcowswe 0:f16a1d69a386 6 ; r0 - dsVal array base address
madcowswe 0:f16a1d69a386 7 ; r1 - data array base address
madcowswe 0:f16a1d69a386 8 ; r2 - base address for port 0
madcowswe 0:f16a1d69a386 9 ; r3 - loop counter
madcowswe 0:f16a1d69a386 10 ; r4 - sclk bitmask
madcowswe 0:f16a1d69a386 11 ; r5 - RGB channels bitmask
madcowswe 0:f16a1d69a386 12 ; r6 - data reg 1
madcowswe 0:f16a1d69a386 13 ; r7 - data reg 2
madcowswe 0:f16a1d69a386 14 ; r8 - temporary value holding intensity info (used as an offset into dsVal array)
madcowswe 0:f16a1d69a386 15
madcowswe 0:f16a1d69a386 16
madcowswe 0:f16a1d69a386 17 ; Save state
madcowswe 0:f16a1d69a386 18 PUSH {R4, R5, R6, R7, R8}
madcowswe 0:f16a1d69a386 19
madcowswe 0:f16a1d69a386 20 ; Load GPIO Port 0 base address in register R6
madcowswe 0:f16a1d69a386 21 LDR R2, =0x2009C000 ; GPIO port 0 base address
madcowswe 0:f16a1d69a386 22
madcowswe 0:f16a1d69a386 23 ; R3 - loop counter
madcowswe 0:f16a1d69a386 24 MOV R3, #256
madcowswe 0:f16a1d69a386 25
madcowswe 0:f16a1d69a386 26 ; sclk mask
madcowswe 0:f16a1d69a386 27 MOV R4, #0x00010000 ; sclk bitmask
madcowswe 0:f16a1d69a386 28
madcowswe 0:f16a1d69a386 29 ; RGB channels mask
madcowswe 0:f16a1d69a386 30 MOV R5, #0x03800000 ; bitmask for RGB bits
madcowswe 0:f16a1d69a386 31
madcowswe 0:f16a1d69a386 32 LOOP
madcowswe 0:f16a1d69a386 33
madcowswe 0:f16a1d69a386 34 ;NOTE clocking swapped due to inverter used for logic levels|
madcowswe 0:f16a1d69a386 35 ;STR R4, [R2, #0x18] ; setting clock high
madcowswe 0:f16a1d69a386 36 STR R4, [R2, #0x1C] ; cleark clk to clock in data (negative edge)
madcowswe 0:f16a1d69a386 37
madcowswe 0:f16a1d69a386 38
madcowswe 0:f16a1d69a386 39 STR R5, [R2, #0x1C] ; clear RGB via FIOCLEAR
madcowswe 0:f16a1d69a386 40
madcowswe 0:f16a1d69a386 41 ; R channel
madcowswe 0:f16a1d69a386 42 LDRB R8, [R1], #1 ; read data word (0-255 intensity) and post-increment array pointer to point to next word in data
madcowswe 0:f16a1d69a386 43 LDRB R6, [R0, R8] ; loading on/off state from dsVal, pointed to by offset equal to intensity of data
madcowswe 0:f16a1d69a386 44
madcowswe 0:f16a1d69a386 45
madcowswe 0:f16a1d69a386 46 ; G channel
madcowswe 0:f16a1d69a386 47 LDRB R8, [R1], #1 ; read data word (0-255 intensity) into R8 and post-increment to point to next word in data
madcowswe 0:f16a1d69a386 48 LDRB R7, [R0, R8] ; loading on/off state from dsVal, pointed to by offset equal to intensity of data
madcowswe 0:f16a1d69a386 49
madcowswe 0:f16a1d69a386 50 AND R7, R7, #0x2 ; pick blue channel bit
madcowswe 0:f16a1d69a386 51
madcowswe 0:f16a1d69a386 52 ORR R6, R7, R6, lsr #7 ; store RG bits in R6 with clever stuff in R chan
madcowswe 0:f16a1d69a386 53
madcowswe 0:f16a1d69a386 54 ; B channel
madcowswe 0:f16a1d69a386 55 LDRB R8, [R1], #1 ; read data word (0-255 intensity) into R8 and post-increment to point to next word in data
madcowswe 0:f16a1d69a386 56 LDRB R7, [R0, R8] ; loading on/off state from dsVal, pointed to by offset equal to intensity of data
madcowswe 0:f16a1d69a386 57
madcowswe 0:f16a1d69a386 58 AND R7, R7, #0x4 ; pick green channel bit
madcowswe 0:f16a1d69a386 59
madcowswe 0:f16a1d69a386 60 ; writing to output
madcowswe 0:f16a1d69a386 61 ORR R6, R6, R7 ; RGB bits in R6
madcowswe 0:f16a1d69a386 62
madcowswe 0:f16a1d69a386 63 MOV R6, R6, lsl #23
madcowswe 0:f16a1d69a386 64
madcowswe 0:f16a1d69a386 65 STR R6, [R2,#0x18] ; FIOSET on/off for LED
madcowswe 0:f16a1d69a386 66
madcowswe 0:f16a1d69a386 67 SUBS R3, R3, #0x1 ; decrement loop counter
madcowswe 0:f16a1d69a386 68
madcowswe 0:f16a1d69a386 69 STR R4, [R2, #0x18] ; setting clock high
madcowswe 0:f16a1d69a386 70
madcowswe 0:f16a1d69a386 71
madcowswe 0:f16a1d69a386 72 BNE LOOP
madcowswe 0:f16a1d69a386 73
madcowswe 0:f16a1d69a386 74 POP {R4, R5, R6, R7, R8}
madcowswe 0:f16a1d69a386 75
madcowswe 0:f16a1d69a386 76 BX LR
madcowswe 0:f16a1d69a386 77 END