From 65301f315b1f3bfd8bca7b441368359bca31ad40 Mon Sep 17 00:00:00 2001 From: AranaCorp <113541627+AranaCorp@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:16:38 +0200 Subject: [PATCH 1/5] Update Sd2Card.h #define USE_SPI_LIB //moved line 56 defined when SOFTWARE_SPI not defined --- src/utility/Sd2Card.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utility/Sd2Card.h b/src/utility/Sd2Card.h index 5d91ebf..b38a1d8 100644 --- a/src/utility/Sd2Card.h +++ b/src/utility/Sd2Card.h @@ -35,7 +35,7 @@ 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. */ -#define USE_SPI_LIB +//#define USE_SPI_LIB //moved line 56 /** Define MEGA_SOFT_SPI non-zero to use software SPI on Mega Arduinos. Pins used are SS 10, MOSI 11, MISO 12, and SCK 13. @@ -53,6 +53,7 @@ uint8_t const SPI_QUARTER_SPEED = 2; // SPI pin definitions // #ifndef SOFTWARE_SPI + #define USE_SPI_LIB // hardware pin defs // include pins_arduino.h or variant.h depending on architecture, via Arduino.h From 6c434627d1cac400b9aff74016981ec5467e63fb Mon Sep 17 00:00:00 2001 From: AranaCorp <113541627+AranaCorp@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:23:34 +0200 Subject: [PATCH 2/5] Update Sd2Card.cpp lin20: #define USE_SPI_LIB //moved line 25 --- src/utility/Sd2Card.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utility/Sd2Card.cpp b/src/utility/Sd2Card.cpp index 7cfbe73..a8e8a66 100644 --- a/src/utility/Sd2Card.cpp +++ b/src/utility/Sd2Card.cpp @@ -17,11 +17,12 @@ along with the Arduino Sd2Card Library. If not, see . */ -#define USE_SPI_LIB +//#define USE_SPI_LIB //moved line 25 #include #include "Sd2Card.h" //------------------------------------------------------------------------------ #ifndef SOFTWARE_SPI +#define USE_SPI_LIB #ifdef USE_SPI_LIB #ifndef SDCARD_SPI From 8ab666ba588df993c05e91ccc361f0f3d6dc62e8 Mon Sep 17 00:00:00 2001 From: AranaCorp <113541627+AranaCorp@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:30:31 +0200 Subject: [PATCH 3/5] Update SD.cpp line 357, remove card.setSpiClock(clock) in function SDClass::begin(uint32_t clock, uint8_t csPin) when SOFTWARE_SPI is defined --- src/SD.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/SD.cpp b/src/SD.cpp index e97256c..f7214e7 100644 --- a/src/SD.cpp +++ b/src/SD.cpp @@ -354,7 +354,7 @@ namespace SDLib { volume.init(card) && root.openRoot(volume); } - +#ifndef SOFTWARE_SPI //Added compiler directive so that MEGA works with this code bool SDClass::begin(uint32_t clock, uint8_t csPin) { if (root.isOpen()) { root.close(); @@ -365,7 +365,19 @@ namespace SDLib { volume.init(card) && root.openRoot(volume); } +#else + bool SDClass::begin(uint32_t clock, uint8_t csPin) { + if (root.isOpen()) { + root.close(); + } + return card.init(SPI_HALF_SPEED, csPin) && + card.setSpiClock(clock) && + volume.init(card) && + root.openRoot(volume); + } +#endif  //SOFTWARE_SPI + //call this when a card is removed. It will allow you to insert and initialise a new card. void SDClass::end() { root.close(); From f62cef3171f89792c8b2e0b0690414285c05af0b Mon Sep 17 00:00:00 2001 From: AranaCorp <113541627+AranaCorp@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:32:20 +0200 Subject: [PATCH 4/5] Update README.adoc --- README.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.adoc b/README.adoc index ab370cb..075b004 100644 --- a/README.adoc +++ b/README.adoc @@ -11,3 +11,6 @@ The SD library allows for reading from and writing to SD cards. For more information about this library please visit us at http://www.arduino.cc/en/Reference/{repository-name} + +Added patch to adapt library for TFT shield on Arduino Mega +https://www.aranacorp.com/fr/utilisation-du-module-sd-du-shield-tft-avec-arduino-mega/ From b84ead4c035ed439e56356dbdbad9681044e94ab Mon Sep 17 00:00:00 2001 From: AranaCorp <113541627+AranaCorp@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:32:55 +0200 Subject: [PATCH 5/5] Update README.adoc --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 075b004..4297d72 100644 --- a/README.adoc +++ b/README.adoc @@ -12,5 +12,5 @@ The SD library allows for reading from and writing to SD cards. For more information about this library please visit us at http://www.arduino.cc/en/Reference/{repository-name} -Added patch to adapt library for TFT shield on Arduino Mega +Added patch to adapt library for TFT shield on Arduino Mega. Description of the changes at https://www.aranacorp.com/fr/utilisation-du-module-sd-du-shield-tft-avec-arduino-mega/