arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
259 stars 264 forks source link

W5100Class::softReset() failes always when PoE module equipped. #209

Open 7n2jju opened 1 year ago

7n2jju commented 1 year ago

Hardware

Problem

Chip type detection such as W5100Class::isW5100() W5100Class::isW5500() and so on fails except in case of power on reset of W5500, due to W5100Class::softReset() returns 0. softReset() will succeed always when PoE receiver module is not equipped.

Solution

Increase wait count to 200 ms in W5100Class::softReset(), such as:

uint8_t W5100Class::softReset(void)
{
    uint16_t count=0;

    //Serial.println("WIZnet soft reset");
    // write to reset bit
    writeMR(0x80);
    // then wait for soft reset to complete
    do {
        uint8_t mr = readMR();
        //Serial.print("mr=");
        //Serial.println(mr, HEX);
        if (mr == 0) return 1;
        delay(1);
    } while (++count < 200);
    return 0;
}

I'm not sure it's really OK to 200.