test_i2c: fix for missing readback

This commit is contained in:
spaqin 2022-03-01 17:36:03 +08:00 committed by Sébastien Bourdeauducq
parent a85b4d5f5e
commit 17ecd35530
1 changed files with 4 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import os, unittest
from artiq.experiment import *
from artiq.test.hardware_testbench import ExperimentCase
from artiq.coredevice.exceptions import I2CError
from artiq.coredevice.i2c import I2CSwitch
from artiq.coredevice.i2c import I2CSwitch, i2c_read_byte
class I2CSwitchTest(EnvExperiment):
@ -16,7 +16,9 @@ class I2CSwitchTest(EnvExperiment):
passed = True
for i in range(8):
self.i2c_switch.set(i)
if self.i2c_switch.readback() != 1 << i:
# this will work only with pca9548 (like on kc705)
# otherwise we cannot guarantee exact readback values
if i2c_read_byte(self.i2c_switch.busno, self.i2c_switch.address) != 1 << i:
passed = False
self.set_dataset("passed", passed)