diff options
Diffstat (limited to 'software')
-rw-r--r-- | software/first/set_LED.S | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/software/first/set_LED.S b/software/first/set_LED.S deleted file mode 100644 index 0785d43..0000000 --- a/software/first/set_LED.S +++ /dev/null @@ -1,46 +0,0 @@ -.section .text -.align 2 -.global set_LED -.include "memory_map.inc" -.include "gpio.inc" - -.equ NOERROR, 0x0 -.equ ERROR, 0x1 -.equ LEDON, 0x1 - -# a0 contains LED to set, desired LED state in a1 -# a0 is also the return value... - -set_LED: - addi sp, sp, -16 # Allocate stack frame - sw ra, 12(sp) # save return address to the stack - - li t0, GPIO_CTRL_ADDR # load base GPIO address - lw t1, GPIO_OUTPUT_VAL(t0) # load state - - beqz a1, ledOff # branch if == 0 - li t2, LEDON # load up on val into t2 - - beq a1, t2, ledOn # branch if on requested - li a0, ERROR # bad status request, return error - j exit - - -ledOn: - or t1, t1, a0 # only change the value of the requested LED (xor in the video) - sw t1, GPIO_OUTPUT_VAL(t0) # write new LED values to the right address - li a0, NOERROR # success - j exit - - -ledOff: - xor a0, a0, 0xffffffff # invert bits so off bits are off - and t1, t1, a0 # turn of LEDs - sw t1, GPIO_OUTPUT_VAL(t0) # write new LED values to the right address - li a0, NOERROR # success - - -exit: - lw ra, 12(sp) # load return address - addi sp, sp, 16 # deallocate stack frame - ret |