OMG, if only I could link all the times I have seen this.
Background: I am working on a project that, to work optimally, requires 2 micros (micro-controllers: a Due and an ESP8266 to be precise) to have access, ONE AT A TIME [shouty, but happy man], to the same SD card.
I incorrectly thought it [the init access issues I was having] was due to the 8266 (I read something, somewhere): From step 2 (see THIS, HERE, HELLO, OVER HERE, [waving hand]), I discovered that the Due was at fault; Even though step 2 was testing for MISO tri-state behaviour, the Due was holding MOSI high and SCK low! WHAT?
I tried setting (Arduino digital) pins 10 to 13 to inputs, but obviously that won't work, because the Due SPI is not mapped (duplicated) to these pins! (To maximise GPIOs, I guess).
In the end what worked for me was,
// pinMode(12, INPUT); // MISO OK
pinMode(SS, INPUT); // CS
pinMode(MOSI, INPUT); // Due leaves HIGH (MOSI)
pinMode(SCK, INPUT); // Due leaves LOW
.
I don't think you need to set CS as an i/p, but it cannot hurt, unless you want it to do something else between SPI access.
Strange that the test for MISO tristate revealed one of the bus pins that actually worked properly! A great reference for any SPI, and perhaps other, interfaces!
It was due to the Due