summaryrefslogtreecommitdiff
path: root/software/first/setup_gpio.S
blob: 39003b46666164ff8fc2c4a2cd35f3120bdda726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
.section .text
.align 2
.global setup_GPIO
.include "memory_map.inc"
.include "gpio.inc"

setup_GPIO:
	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 
	li t1, GPIO_RGB_PINS       # get RGB offsets
	sw t1, GPIO_OUTPUT_EN(t0)  # enable output on the RGB pins
	sw t1, GPIO_OUTPUT_XOR(t0) # set the RGB pins to active high
	sw x0, GPIO_OUTPUT_VAL(t0) # set all pins to 0

  lw ra, 12(sp)   # load return address
  addi sp, sp, 16 # deallocate stack frame
	ret