5555FAIL = "FAIL"
5656NA = "N/A"
5757
58+
5859# Open comms to I2C EEPROM by trying a write to memory address
5960def _eeprom_i2c_wait (
6061 i2c : busio .I2C , i2c_addr : int , mem_addr : int , timeout : float = 1.0
6162) -> bool :
62-
6363 # Try to access the I2C EEPROM (it becomes unresonsive during a write)
6464 timestamp = time .monotonic ()
6565 while time .monotonic () < timestamp + timeout :
@@ -76,7 +76,6 @@ def _eeprom_i2c_wait(
7676def _eeprom_i2c_write_byte (
7777 i2c : busio .I2C , i2c_addr : int , mem_addr : int , mem_data : int
7878) -> bool :
79-
8079 # Make sure address is only one byte:
8180 if mem_addr > 255 :
8281 return False
@@ -98,7 +97,6 @@ def _eeprom_i2c_write_byte(
9897def _eeprom_i2c_read_byte (
9998 i2c : busio .I2C , i2c_addr : int , mem_addr : int , timeout : float = 1.0
10099) -> Tuple [bool , bytearray ]:
101-
102100 # Make sure address is only one byte:
103101 if mem_addr > 255 :
104102 return False , bytearray ()
@@ -117,7 +115,6 @@ def _eeprom_i2c_read_byte(
117115def run_test (
118116 pins : Sequence [str ], sda_pin : str = SDA_PIN_NAME , scl_pin : str = SCL_PIN_NAME
119117) -> Tuple [str , List [str ]]:
120-
121118 """
122119 Performs random writes and reads to I2C EEPROM.
123120
@@ -129,7 +126,6 @@ def run_test(
129126
130127 # Write values to I2C EEPROM and verify the values match
131128 if list (set (pins ).intersection (set ([sda_pin , scl_pin ]))):
132-
133129 # Tell user to connect EEPROM chip
134130 print (
135131 "Connect a Microchip AT24HC04B EEPROM I2C chip. "
@@ -147,7 +143,6 @@ def run_test(
147143 # Pick a random address, write to it, read from it, and see if they match
148144 pass_test = True
149145 for _ in range (NUM_I2C_TESTS ):
150-
151146 # Randomly pick an address and a data value (one byte)
152147 mem_addr = random .randint (0 , EEPROM_I2C_MAX_ADDR )
153148 mem_data = random .randint (0 , 255 )
0 commit comments