test_i2c: whitespace cleanups
This commit is contained in:
parent
643f3f9a93
commit
67e6614eb2
|
@ -68,6 +68,7 @@ class _MockTristate:
|
||||||
self.assertEqual((yield dut.scl_t.i), some_value)
|
self.assertEqual((yield dut.scl_t.i), some_value)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lower(t):
|
def lower(t):
|
||||||
return _MockTristateImpl(t)
|
return _MockTristateImpl(t)
|
||||||
|
@ -156,7 +157,7 @@ class TestI2C(unittest.TestCase):
|
||||||
|
|
||||||
def i2c_write(value, ack=True):
|
def i2c_write(value, ack=True):
|
||||||
value = int(value)
|
value = int(value)
|
||||||
test_bin = '{0:08b}'.format(value)
|
test_bin = "{0:08b}".format(value)
|
||||||
# print(f"I2C_WRITE | {hex(value)}:0x{test_bin}")
|
# print(f"I2C_WRITE | {hex(value)}:0x{test_bin}")
|
||||||
yield from dut.bus.write(I2C_XFER_ADDR, I2C_WRITE | value)
|
yield from dut.bus.write(I2C_XFER_ADDR, I2C_WRITE | value)
|
||||||
for i in list(test_bin):
|
for i in list(test_bin):
|
||||||
|
@ -165,20 +166,19 @@ class TestI2C(unittest.TestCase):
|
||||||
|
|
||||||
def i2c_read(value, ack=True):
|
def i2c_read(value, ack=True):
|
||||||
value = int(value)
|
value = int(value)
|
||||||
test_bin = '{0:08b}'.format(value)
|
test_bin = "{0:08b}".format(value)
|
||||||
print(f"I2C_READ | {hex(value)}:0x{test_bin}")
|
print(f"I2C_READ | {hex(value)}:0x{test_bin}")
|
||||||
yield from dut.bus.write(I2C_XFER_ADDR, I2C_READ | (I2C_ACK if ack else 0))
|
yield from dut.bus.write(I2C_XFER_ADDR, I2C_READ | (I2C_ACK if ack else 0))
|
||||||
for i in list(test_bin):
|
for i in list(test_bin):
|
||||||
yield from read_bit(int(i))
|
yield from read_bit(int(i))
|
||||||
yield dut.sda_tristate.i_mock.eq(True)
|
yield dut.sda_tristate.i_mock.eq(True)
|
||||||
data = (yield from dut.bus.read(I2C_XFER_ADDR)) & 0xff
|
data = (yield from dut.bus.read(I2C_XFER_ADDR)) & 0xFF
|
||||||
self.assertEqual(data, value)
|
self.assertEqual(data, value)
|
||||||
yield from write_ack(ack)
|
yield from write_ack(ack)
|
||||||
|
|
||||||
def check():
|
def check():
|
||||||
|
|
||||||
yield from dut.bus.write(I2C_CONFIG_ADDR, 4)
|
yield from dut.bus.write(I2C_CONFIG_ADDR, 4)
|
||||||
data = (yield from dut.bus.read(I2C_CONFIG_ADDR)) & 0xff
|
data = (yield from dut.bus.read(I2C_CONFIG_ADDR)) & 0xFF
|
||||||
self.assertEqual(data, 4)
|
self.assertEqual(data, 4)
|
||||||
|
|
||||||
print("write 1 byte 0x18 to address 0x41")
|
print("write 1 byte 0x18 to address 0x41")
|
||||||
|
|
Loading…
Reference in New Issue