Overriding SPI settings for Ethernet2

I have the Ethernet2 library installed via the library manager in IDE 1.6.1.2
I would like to override the SPI setting which can be found in w5500.cpp, but without altering the library if possible.
I can override settings in w5500.h easily by including the .h and specifying 'w5500.' before the item I want to override, for example:

#include <utility/w5500.h>
...stuff and things...
w5500.setRetransmissionCount(1);

but I can't work out if there's a way to override the SPISettings in w5500.cpp (line 25).
Can anyone help?

Which settings do you wish to override?

edit: The only settings you can override is the CS and speed. Both are in w5100.h around line 325.

edit2: My bad. In Ethernet2 library, it is in w5500.cpp, line 25. You must change the settings there. The only setting it appears you can change is the speed, and only reduce it. 8MHz is as fast as most Arduinos support.

The speed in w5500.cpp is actually 0.8MHz

// SPI details
SPISettings wiznet_SPI_settings(800000, MSBFIRST, SPI_MODE0);

I really only want to change the speed on a per project basis, not globally for just my local install. I could attempt to manually edit a local copy of the library but this feels a bit overkill... (i'm not even sure I could manage it, I smell include mess hell).
I want 42MHz for my Due and probably a little less for an Uno.

I was hoping there was a way to do something like

W5500Class::wiznet_SPI_settings(42000000, MSBFIRST, SPI_MODE0);

If you are using any library from Github, I can't verify that. Github is not responding this morning.

edit: You are correct. You must change that value to either 4000000 or 8000000. I filed an issue with the Adafruit Github site.

BTW, the W5500 datasheet shows that THEORETICALLY it can handle clock speeds to 80Mhz, the realistic limit is 33MHz. You might want to try 21MHz on the Due.

You can use a pre-compiler statement to change the settings for each device.

Intereating! Why is the realistic limit 33MHz? The tracks are quite short. 28MHz is an option :slight_smile:

Page 63 here.
http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v106e_141230.pdf

Ta, I missed that :slight_smile:
28MHz should be enough for now, if I need more I'll just have to have a PCB made with the parts closer together :smiley:

SurferTim:
You can use a pre-compiler statement to change the settings for each device.

I missed that bit, I don't think I understand, could you give an example?

Use defines to set the SPI settings. The first here is for the Uno and Mega. The second is for the Due.

#if defined(ARDUINO_ARCH_AVR)
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
#else
#define SPI_ETHERNET_SETTINGS SPI_CS,SPISettings(4000000, MSBFIRST, SPI_MODE0)
#endif

I assume I'd have to modify w5500.cpp to make use of that?

weird_dave:
I assume I'd have to modify w5500.cpp to make use of that?

Yes

Thanks for the input Tim :slight_smile:

FYI: The adafruit library has been updated to the correct speed (8000000).