fix #355 possible infinite loop PCD_Reset()

commited by @psgreco
This commit is contained in:
Rotzbua
2018-02-25 02:19:12 +01:00
parent b239257694
commit 5879252f82

View File

@@ -232,11 +232,11 @@ void MFRC522::PCD_Reset() {
// The datasheet does not mention how long the SoftRest command takes to complete.
// But the MFRC522 might have been in soft power-down mode (triggered by bit 4 of CommandReg)
// Section 8.8.2 in the datasheet says the oscillator start-up time is the start up time of the crystal + 37,74μs. Let us be generous: 50ms.
delay(50);
// Wait for the PowerDown bit in CommandReg to be cleared
while (PCD_ReadRegister(CommandReg) & (1<<4)) {
// PCD still restarting - unlikely after waiting 50ms, but better safe than sorry.
}
uint8_t count = 0;
do {
// Wait for the PowerDown bit in CommandReg to be cleared (max 3x50ms)
delay(50);
} while ((PCD_ReadRegister(CommandReg) & (1 << 4)) && (++count) < 3);
} // End PCD_Reset()
/**