fix #293 #324 #347, hang of PCD_Init() on ESP8266 boards (#354)

On the Wemos D1 mini ESP8266 board the RST pin was LOW all the time and the MFRC522::PCD_Init() didn't reset the MFRC522 because of a non working digitalWrite, resulting in a endless loop.
This commit is contained in:
heziegl
2018-01-14 13:04:01 +01:00
committed by Rotzbua
parent 5b77ff7c6a
commit ff4f51f38b

View File

@@ -198,11 +198,12 @@ void MFRC522::PCD_Init() {
digitalWrite(_chipSelectPin, HIGH); digitalWrite(_chipSelectPin, HIGH);
// If a valid pin number has been set, pull device out of power down / reset state. // If a valid pin number has been set, pull device out of power down / reset state.
if (_resetPowerDownPin != UINT8_MAX) { if (_resetPowerDownPin != UNUSED_PIN) {
// Set the resetPowerDownPin as digital output, do not reset or power down. // First set the resetPowerDownPin as digital input, to check the MFRC522 power down mode.
pinMode(_resetPowerDownPin, OUTPUT); pinMode(_resetPowerDownPin, INPUT);
if (digitalRead(_resetPowerDownPin) == LOW) { // The MFRC522 chip is in power down mode. if (digitalRead(_resetPowerDownPin) == LOW) { // The MFRC522 chip is in power down mode.
pinMode(_resetPowerDownPin, OUTPUT); // Now set the resetPowerDownPin as digital output.
digitalWrite(_resetPowerDownPin, HIGH); // Exit power down mode. This triggers a hard reset. digitalWrite(_resetPowerDownPin, HIGH); // Exit power down mode. This triggers a hard reset.
// 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. // 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); delay(50);