-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Milestone
Description
Ethernet example sketches compile but do not work on a Due. This appears to originate in the SPI library begin function in libraries/SPI/arch/sam/SPI.cpp when it is called with an argument
The begin function works properly when called with no argument as in libraries/SD/src/utility/Sd2Card.cpp but this code from libraries/Ethernet/arch/sam/utility/w5100.cpp never returns from writeMR.
SPI.begin(SPI_CS);
// Set clock to 4Mhz (W5100 should support up to about 14Mhz)
SPI.setClockDivider(SPI_CS, 21);
SPI.setDataMode(SPI_CS, SPI_MODE0);
writeMR(1<<RST);
Adding three lines to the begin function in libraries/SPI/arch/sam/SPI.cpp corrects this behaviour
void SPIClass::begin(uint8_t _pin) {
uint32_t spiPin = BOARD_PIN_TO_SPI_PIN(_pin);
initCb();//1
SPI_Configure(spi, id, SPI_MR_MSTR | SPI_MR_PS | SPI_MR_MODFDIS);//2
SPI_Enable(spi);//3
PIO_Configure(
g_APinDescription[spiPin].pPort,
g_APinDescription[spiPin].ulPinType,
g_APinDescription[spiPin].ulPin,
g_APinDescription[spiPin].ulPinConfiguration);
// Default speed set to 4Mhz
setClockDivider(_pin, 21);
setDataMode(_pin, SPI_MODE0);
setBitOrder(_pin, MSBFIRST);
}
This still exists in the nightly build as of 9/1/2013.