Update Sd2Card.h to use pins_arduino.h definitions

Update Sd2Card.h to use pins_arduino.h or variant.h definitions, depending on architecture, when Hardware SPI is in use.
The definitions for Software SPI pins (for ATmega1280 and ATmega2560 etc) remain unchanged as defined in Sd2PinMap.h.
This commit is contained in:
Phillip Stevens 2016-02-15 21:24:24 +11:00
parent cd9a6ec63c
commit dde6f09e14
1 changed files with 13 additions and 6 deletions

View File

@ -33,7 +33,7 @@ uint8_t const SPI_HALF_SPEED = 1;
uint8_t const SPI_QUARTER_SPEED = 2;
/**
* USE_SPI_LIB: if set, use the SPI library bundled with Arduino IDE, otherwise
* run with a standalone driver for AVR.
* run with a standalone driver for AVR.
*/
#define USE_SPI_LIB
/**
@ -54,6 +54,10 @@ uint8_t const SPI_QUARTER_SPEED = 2;
//
#ifndef SOFTWARE_SPI
// hardware pin defs
// include pins_arduino.h or variant.h depending on architecture, via Arduino.h
#include <Arduino.h>
/**
* SD Chip Select pin
*
@ -62,14 +66,17 @@ uint8_t const SPI_QUARTER_SPEED = 2;
* master unless SS is set to output mode.
*/
/** The default chip select pin for the SD card is SS. */
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
// The following three pins must not be redefined for hardware SPI.
uint8_t const SD_CHIP_SELECT_PIN = SS;
// The following three pins must not be redefined for hardware SPI,
// so ensure that they are taken from pins_arduino.h or variant.h, depending on architecture.
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
uint8_t const SPI_MOSI_PIN = MOSI;
/** SPI Master In Slave Out pin */
uint8_t const SPI_MISO_PIN = MISO_PIN;
uint8_t const SPI_MISO_PIN = MISO;
/** SPI Clock pin */
uint8_t const SPI_SCK_PIN = SCK_PIN;
uint8_t const SPI_SCK_PIN = SCK;
/** optimize loops for hardware SPI */
#ifndef USE_SPI_LIB
#define OPTIMIZE_HARDWARE_SPI