Go Down

Topic: Ethernet Shield (Read 3180 times) previous topic - next topic

megabit

Ethernet shield examples won't currently compile:

C:\arduino-1.6.5\libraries\Ethernet\src\Ethernet.cpp: In member function 'int EthernetClass::begin(uint8_t*)':
C:\arduino-1.6.5\libraries\Ethernet\src\Ethernet.cpp:19:45: error: no matching function for call to 'SPIClass::beginTransaction(int, SPISettings)'
   SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
                                             ^
C:\arduino-1.6.5\libraries\Ethernet\src\Ethernet.cpp:19:45: note: candidate is:
In file included from C:\arduino-1.6.5\libraries\Ethernet\src\utility/w5100.h:13:0,
                 from C:\arduino-1.6.5\libraries\Ethernet\src\Ethernet.cpp:1:
C:\Users\\AppData\Roaming\Arduino15\packages\arduino\hardware\samd\1.6.0\libraries\SPI/SPI.h:101:8: note: void SPIClass::beginTransaction(SPISettings)
   void beginTransaction(SPISettings settings);
        ^
C:\Users\\AppData\Roaming\Arduino15\packages\arduino\hardware\samd\1.6.0\libraries\SPI/SPI.h:101:8: note:   candidate expects 1 argument, 2 provided

(snipped)

Anything obvious before I go digging?

Thanks!

Denbo

Ok first let me explain that there different versions of the SPIClass library.  There is one for AVR chips (Uno, Mega, etc),  one for SAM chips (Due) and one for SAMD chips (Zero).

This seems to be a problem with the extended SPI functionality of the SAM chip (Due) not being implemented in the SPI library for the SAMD chip (Zero) but the w5100.h library believes it should be.  

You probably already know this but the compiler error pertaining to the two arguments being passed to 'SPIClass::beginTransaction(int, SPISettings)' appears because of the following line of code in <utility\w5100.h> (included by Ethernet.cpp)

Code: [Select]
#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


When you set the board to a non AVR board (ie Due or Zero),  the ARDUINO_ARCH_AVR is not defined so the second definition of SPI_ETHERNET_SETTINGS is used.  Thus the call to SPI.beginTransaction(SPI_ETHERNET_SETTINGS) in Ethernet.cpp will be passed two arguments instead of the documented single argument and look like the following:

SPI.beginTransaction(10,SPISettings(4000000, MSBFIRST, SPI_MODE0));

Now that's fine for the Due because the SPIClass class implementation for SAM chips has two implementations for beginTransmission. They are:

Code: [Select]
void beginTransaction(SPISettings settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); }
void beginTransaction(uint8_t pin, SPISettings settings);

 Where the pin argument is the CS pin(10) (see http://www.arduino.cc/en/Reference/DueExtendedSPI for more info on the CS pin and the Due's extended SPI capability).

The problem you are experiencing is there is also a SAMD (the Zero's chip) implementation for SPI library but looking at its code it does NOT have the the extended beginTransaction method with the CS_PIN argument.  

I am not sure the exact way forward for a temp fix for this.  It might be possible to just copy the SAM version of SPI.h over to the SAMD version.   That will make it compile but um... I don't know if it will actually work. 

It is certainly a bug and should be reported.

megabit

Thanks - that was helpful. I'm not sure how to best approach this. I would rather work towards a permanent fix.

Issue logged here: https://github.com/arduino/ArduinoCore-samd/issues/9

cmaglie

Hi @megabit

I've pushed the needed updates to the Ethernet library:

https://github.com/arduino-libraries/Ethernet

if you can give it a try it would be wonderful, otherwise I'll made it available anyway via library-manager updates within the next 24h.
C.

megabit

This is compiling and working now - thanks for your help!

jmppmj

Is it currently possible to use Wifi.h with the Arduino Zero? If so what must we do differently with the Zero than with other Arduino boards?

a_guadalupi

#6
Jul 10, 2015, 11:57 am Last Edit: Jul 10, 2015, 12:29 pm by a_guadalupi
Is it currently possible to use Wifi.h with the Arduino Zero? If so what must we do differently with the Zero than with other Arduino boards?
Hi! We found an error in the WiFi.h and compatibility with the zero. We pushed it on git so you will find it in the next build!

https://github.com/arduino/ArduinoCore-samd/issues/18

Go Up