sstaub / Ethernet3

Ethernet library for Arduino and Ethernetshield2 / WIZ550io / WIZ850io / USR-ES1 with Wiznet W5500 chip
Other
76 stars 34 forks source link

Ability to call softreset() prior to begin() #15

Closed jjhuff closed 6 years ago

jjhuff commented 6 years ago

In few cases I've needed to call softreset() upon startup. Right now, I have to do something like:

  Ethernet.begin(mac, IPAddress(0, 0, 0, 0)); // HACK: set a static IP first, so we can do softreset
  Ethernet.softreset();
  Ethernet.begin(mac); // Then DHCP

Not sure what the best solution is here. Maybe have softreset call w5500.init()?

sstaub commented 6 years ago

Hmmm, may there is a missing destructor for for Ethernet class. Softreset set all registers back to the default values of the chip, so it makes only sense if you have done a configuration initialized with the .begin function. Is Hardreset a solution?

jjhuff commented 6 years ago

The case I run into:

  1. It's all running fine, responding to ping and UDP.
  2. I load new firmware via JTAG/SWD. This causes a CPU reset.
  3. Responds to ping, but not UDP.

So, the w5500 is configured, but the CPU isn't aware.

Yes, hardreset will be an option once we have our final hardware. The softreset is a fairly minor issue -- and I'm more or less ok with my hack.

sstaub commented 6 years ago

On Arduino, I think the cpu reset causes also an hardware reset on the ethernetshield.

jjhuff commented 6 years ago

I'm currently using the Adafruit Feather boards. However, my custom board will have hardware reset. Is calling w5500.init() safe after begin? If not, maybe softreset can check if init has been called and call it?

sstaub commented 6 years ago

begin calls w5500.int(), generally after a soft reset (have a look to the manual if it also for hardreset) you must call the begin() function to give the registers all the necessray infos. I have tested the procedure extensively but I can't find the code example. The function calls the MR register of the chip.