@@ -372,7 +372,7 @@ uint8_t AS726X::virtualReadRegister(uint8_t virtualAddr)
372372 if (status == 0xFF ) return status;
373373 if ((status & AS72XX_SLAVE_TX_VALID) == 0 ) break ; // If TX bit is clear, it is ok to write
374374 delay (POLLING_DELAY);
375- if (retries++ > retries ) return 0xFF ;
375+ if (retries++ > MAX_RETRIES ) return 0xFF ;
376376 }
377377
378378 // Send the virtual register address (bit 7 should be 0 to indicate we are reading a register).
@@ -387,7 +387,7 @@ uint8_t AS726X::virtualReadRegister(uint8_t virtualAddr)
387387 if (status == 0xFF ) return status;
388388 if ((status & AS72XX_SLAVE_RX_VALID) != 0 ) break ; // Read data is ready.
389389 delay (POLLING_DELAY);
390- if (retries++ > retries ) return 0xFF ;
390+ if (retries++ > MAX_RETRIES ) return 0xFF ;
391391 }
392392
393393 uint8_t incoming = readRegister (AS72XX_SLAVE_READ_REG);
@@ -407,7 +407,7 @@ int AS726X::virtualWriteRegister(uint8_t virtualAddr, uint8_t dataToWrite)
407407 if (status == 0xFF ) return -1 ;
408408 if ((status & AS72XX_SLAVE_TX_VALID) == 0 ) break ; // No inbound TX pending at slave. Okay to write now.
409409 delay (POLLING_DELAY);
410- if (retries++ > retries ) return -1 ;
410+ if (retries++ > MAX_RETRIES ) return -1 ;
411411 }
412412
413413 // Send the virtual register address (setting bit 7 to indicate we are writing to a register).
@@ -422,7 +422,7 @@ int AS726X::virtualWriteRegister(uint8_t virtualAddr, uint8_t dataToWrite)
422422 if (status == 0xFF ) return -1 ;
423423 if ((status & AS72XX_SLAVE_TX_VALID) == 0 ) break ; // No inbound TX pending at slave. Okay to write now.
424424 delay (POLLING_DELAY);
425- if (retries++ > retries ) return -1 ;
425+ if (retries++ > MAX_RETRIES ) return -1 ;
426426 }
427427
428428 // Send the data to complete the operation.
0 commit comments