Skip to content

Commit ff4f51f

Browse files
hezieglRotzbua
authored andcommitted
fix miguelbalboa#293 miguelbalboa#324 miguelbalboa#347, hang of PCD_Init() on ESP8266 boards (miguelbalboa#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.
1 parent 5b77ff7 commit ff4f51f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/MFRC522.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,12 @@ void MFRC522::PCD_Init() {
198198
digitalWrite(_chipSelectPin, HIGH);
199199

200200
// If a valid pin number has been set, pull device out of power down / reset state.
201-
if (_resetPowerDownPin != UINT8_MAX) {
202-
// Set the resetPowerDownPin as digital output, do not reset or power down.
203-
pinMode(_resetPowerDownPin, OUTPUT);
201+
if (_resetPowerDownPin != UNUSED_PIN) {
202+
// First set the resetPowerDownPin as digital input, to check the MFRC522 power down mode.
203+
pinMode(_resetPowerDownPin, INPUT);
204204

205205
if (digitalRead(_resetPowerDownPin) == LOW) { // The MFRC522 chip is in power down mode.
206+
pinMode(_resetPowerDownPin, OUTPUT); // Now set the resetPowerDownPin as digital output.
206207
digitalWrite(_resetPowerDownPin, HIGH); // Exit power down mode. This triggers a hard reset.
207208
// 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.
208209
delay(50);

0 commit comments

Comments
 (0)