Skip to content

Commit

Permalink
Increase delays for reliable ECCx08 operations
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Jan 27, 2021
1 parent 3e7590d commit cd843d8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arduino/libraries/ArduinoECCX08/src/ECCX08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ int ECCX08Class::read(int zone, int address, byte buffer[], int length)
return 0;
}

delay(5);
delay(15);

if (!receiveResponse(buffer, length)) {
return 0;
Expand Down Expand Up @@ -717,11 +717,13 @@ int ECCX08Class::sendCommand(uint8_t opcode, uint8_t param1, uint16_t param2, co

int ECCX08Class::receiveResponse(void* response, size_t length)
{
int retries = 20;
int retries = 40;
size_t responseSize = length + 3; // 1 for length header, 2 for CRC
byte responseBuffer[responseSize];

while (_wire->requestFrom((uint8_t)_address, (size_t)responseSize, (bool)true) != responseSize && retries--);
while (_wire->requestFrom((uint8_t)_address, (size_t)responseSize, (bool)true) != responseSize && retries--) {
delay(1);
}

responseBuffer[0] = _wire->read();

Expand Down

0 comments on commit cd843d8

Please sign in to comment.