# Initialize timer
la a0,timerchannel
la a1,timerinit1
li a7,129 # Send digilines message
ecall
la a1,timerinit2
ecall

loop:

# Check if the timer has ticked
li a7,133 # Get digilines buffer level
ecall
beqz a0,sleep # Sleep if it hasn't
li a7,134 # Clear digilines receive buffer
ecall

# Do the actual flashing
li a7,129 # Send digilines message
la a0,lightchannel1
la a1,lightonmsg
ecall # Light 1 on
pause
la a1,lightoffmsg
ecall # Light 1 off
pause
la a1,lightonmsg
ecall # Light 1 on
pause
la a1,lightoffmsg
ecall # Light 1 off
pause
la a1,lightonmsg
ecall # Light 1 on
pause
la a1,lightoffmsg
ecall # Light 1 off
pause
la a1,lightonmsg
ecall # Light 1 on
pause
la a1,lightoffmsg
ecall # Light 1 off
pause
la a0,lightchannel2
la a1,lightonmsg
ecall # Light 2 on
pause
la a1,lightoffmsg
ecall # Light 2 off
pause
la a1,lightonmsg
ecall # Light 2 on
pause
la a1,lightoffmsg
ecall # Light 2 off
pause
la a1,lightonmsg
ecall # Light 2 on
pause
la a1,lightoffmsg
ecall # Light 2 off
pause
la a1,lightonmsg
ecall # Light 2 on
pause
la a1,lightoffmsg
ecall # Light 2 off
pause
j loop

sleep:
csrw 0x800,1 # Lightweight on
pause
csrw 0x800,0 # Lightweight off
j loop


timerchannel: .asciz "timer"
timerinit1: .asciz "loop_on"
timerinit2: .asciz "1"
lightchannel1: .asciz "light1"
lightchannel2: .asciz "light2"
lightonmsg: .asciz "14"
lightoffmsg: .asciz "0"
