From 9c3bf3eca4219f3b0778369bd9a73867f5f6d7a4 Mon Sep 17 00:00:00 2001 From: AreaScout Date: Sat, 23 Dec 2017 14:16:08 +0000 Subject: [PATCH 1/2] Fix: Somehow Software SPI mode for Mega Arduinos was broken --- src/SD.cpp | 2 ++ src/utility/Sd2Card.cpp | 1 - src/utility/Sd2Card.h | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SD.cpp b/src/SD.cpp index fbadb62..63e9f05 100644 --- a/src/SD.cpp +++ b/src/SD.cpp @@ -353,7 +353,9 @@ boolean SDClass::begin(uint32_t clock, uint8_t csPin) { if(root.isOpen()) root.close(); return card.init(SPI_HALF_SPEED, csPin) && +#ifdef USE_SPI_LIB card.setSpiClock(clock) && +#endif volume.init(card) && root.openRoot(volume); } diff --git a/src/utility/Sd2Card.cpp b/src/utility/Sd2Card.cpp index 406f838..26cb15a 100644 --- a/src/utility/Sd2Card.cpp +++ b/src/utility/Sd2Card.cpp @@ -17,7 +17,6 @@ * along with the Arduino Sd2Card Library. If not, see * . */ -#define USE_SPI_LIB #include #include "Sd2Card.h" //------------------------------------------------------------------------------ diff --git a/src/utility/Sd2Card.h b/src/utility/Sd2Card.h index 9c3faff..c3e1c12 100644 --- a/src/utility/Sd2Card.h +++ b/src/utility/Sd2Card.h @@ -45,6 +45,11 @@ uint8_t const SPI_QUARTER_SPEED = 2; * but many SD cards will fail with GPS Shield V1.0. */ #define MEGA_SOFT_SPI 0 + +#if MEGA_SOFT_SPI +#undef USE_SPI_LIB +#endif + //------------------------------------------------------------------------------ #if MEGA_SOFT_SPI && (defined(__AVR_ATmega1280__)||defined(__AVR_ATmega2560__)) #define SOFTWARE_SPI From aff1607e26ca4e2db71933404a19835ca350f70f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Jan 2018 09:33:53 +0100 Subject: [PATCH 2/2] Add: move to device specific define --- src/utility/Sd2Card.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utility/Sd2Card.h b/src/utility/Sd2Card.h index c3e1c12..e005c5d 100644 --- a/src/utility/Sd2Card.h +++ b/src/utility/Sd2Card.h @@ -45,14 +45,10 @@ uint8_t const SPI_QUARTER_SPEED = 2; * but many SD cards will fail with GPS Shield V1.0. */ #define MEGA_SOFT_SPI 0 - -#if MEGA_SOFT_SPI -#undef USE_SPI_LIB -#endif - //------------------------------------------------------------------------------ #if MEGA_SOFT_SPI && (defined(__AVR_ATmega1280__)||defined(__AVR_ATmega2560__)) #define SOFTWARE_SPI +#undef USE_SPI_LIB #endif // MEGA_SOFT_SPI //------------------------------------------------------------------------------ // SPI pin definitions