You shouldn't need to refer to the pins at all, excepting the SS pin. I have examples of reading/writing using SPI here. I don't refer to the pins in it. Leave that to the SPI library.
http://www.gammon.com.au/forum/?id=10892You should be able to use the SdFat library to access the card without too many problems.
The SS pin is declared in:
#include "pins_arduino.h"
I agree. Here is a simple test program using the hardware SPI library to test out a new 2 channel 12 bit DAC module I recently obtained. Not the total lack of any pinmode commands and that the SS pin name didn't need to be defined, the library does it all.
// Continous ramping from 0-5vdc analog output on 2 channel DAC module based on MCP4922 13 bit DAC device
// Hardware SPI version
// uses pin 13 (or 52) for SCK, pin 11 (or 51) for MOSI, pin 10 (or 53) for SS
// outputs both channels 0-5vdc in continous loop
// leftyretro 3/31/11
#include <SPI.h>
#include "pins_arduino.h" // defines hardware SPI pins to use
const char channelA = 0; // module has two independent D/A outputs, A & B avalible
const char channelB = 1;
void setup() {
SPI.begin(); // initialize hardware SPI: uses pin 13 (or 52) for SCK and pin 11 (or 51) for MOSI
// pin 10 (or 53) for slave select, SS
}
void loop()
{
for (int i=0; i < 4096; i++) // DAC 12bit count value range is 0-4095
{
dacWrite(channelA, i);
dacWrite(channelB, i);
}
}
//**********************
// MCP4922 Write Data
// *********************
void dacWrite(unsigned char DAC_Channel, unsigned int DAC_Data)
{
switch (DAC_Channel)
{
case 0x00: DAC_Data |= 0x3000; //selects channal A, gain = 1, + 12 bit DAC value
break;
case 0x01: DAC_Data |= 0xB000; //selects channel B, gain = 1, + 12 bit DAC value
break;
}
digitalWrite(SS,LOW); //enable Slave Select SS is pin 10 (or 53)
SPI.transfer(highByte(DAC_Data)); // shift out high 8 bits
SPI.transfer(lowByte(DAC_Data)); // shift out low 8 bits
digitalWrite(SS,HIGH); // disable Slave Select, DAC value is transfered and latched in module
}
Lefty