litescope/example_designs/test/test_inout.py

38 lines
818 B
Python
Raw Normal View History

2015-09-07 05:49:54 -04:00
import time
from litescope.software.driver.inout import LiteScopeInOutDriver
2015-09-07 05:49:54 -04:00
def led_anim0(inout):
2015-09-07 05:49:54 -04:00
for i in range(10):
inout.write(0xA5)
2015-09-07 05:49:54 -04:00
time.sleep(0.1)
inout.write(0x5A)
2015-09-07 05:49:54 -04:00
time.sleep(0.1)
def led_anim1(inout):
2015-09-07 05:49:54 -04:00
for j in range(4):
# Led <<
led_data = 1
for i in range(8):
inout.write(led_data)
2015-09-07 05:49:54 -04:00
time.sleep(i*i*0.0020)
led_data = (led_data << 1)
# Led >>
ledData = 128
for i in range(8):
inout.write(led_data)
2015-09-07 05:49:54 -04:00
time.sleep(i*i*0.0020)
led_data = (led_data >> 1)
def main(wb):
inout = LiteScopeInOutDriver(wb.regs, "inout")
2015-09-07 05:49:54 -04:00
wb.open()
# # #
led_anim0(inout)
led_anim1(inout)
print("{:02X}".format(inout.read()))
2015-09-07 05:49:54 -04:00
# # #
wb.close()