; EP7311 System registers
constant SYSCON1	8000.0100
constant SYSCON2	8000.1100
constant SYSCON3	8000.2200
constant SYNCIO		8000.0500
constant MEMCFG1	8000.0180
constant MEMCFG2	8000.01C0
constant SDCONF		8000.2300
constant SDRFPR		8000.2340
constant UBRLCR1	8000.04C0

; Hardware addresses
constant FLASH		7000.0000
constant SDRAM		C000.0000
constant LATCH		4002.0000

; Global variables
variable LVALUE		%1111,1111,0000,0000,0000,1100,1111,0000


;			 3322 2222 2222 1111 1111 1100 0000 0000
;			 1098 7654 3210 9876 5432 1098 7654 3210
w32	SYSCON1	%0000,0000,0000,0011,0000,0001,0000,0010
w32	SYSCON2	%0000,0000,0000,0000,0000,0000,0000,0000
w32	SYSCON3	%0000,0000,0000,0000,0000,0000,0000,0111
w32	SDCONF	%0000,0000,0000,0000,0000,0111,0010,0010
w32	LATCH	LVALUE
print "System registers configured."

; Setup function keys
key .10	EXIT	EXIT;

;
; The test system has a 32 bit hardware output latch at address "LATCH"
; for controlling misc. functions.
; These functions allow us to easily set (LS) or clear (LC) individual
; latch bits.
;

; Set a bit on the latch
function LS
	LVALUE	= LVALUE | (1<<#1)
	w32		LATCH LVALUE
	print	"LS" {D}#1 {W}LVALUE
end

; Clear a bit on the latch
function LC
	LVALUE	= LVALUE & ~(1<<#1)
	w32		LATCH LVALUE
	print	"LC" {D}#1 {W}LVALUE
end

