Skip to content

Commit a57d390

Browse files
committed
SD: remove any reference to pinMode(10, OUTPUT) in the examples
correct SS pin setup is already handled by SPI subsystem. this should prevent future issues like #2868 current implementation assures that: * pin10 is OUTPUT HIGH if SPI.begin() is called and the pin was unconfigured * pin10 state is not modified if pinMode(10, OUTPUT) is called before SPI.begin() * pin10 is INPUT HI-Z if nor pinMode(10, OUTPUT) nor SPI.begin() are called
1 parent ae6a5d8 commit a57d390

File tree

6 files changed

+0
-35
lines changed

6 files changed

+0
-35
lines changed

libraries/SD/examples/CardInfo/CardInfo.ino

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ void setup()
4444

4545

4646
Serial.print("\nInitializing SD card...");
47-
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
48-
// Note that even if it's not used as the CS pin, the hardware SS pin
49-
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
50-
// or the SD library functions will not work.
51-
pinMode(10, OUTPUT); // change this to 53 on a mega
52-
5347

5448
// we'll use the initialization code from the utility libraries
5549
// since we're just testing if the card is working!

libraries/SD/examples/Datalogger/Datalogger.ino

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#include <SPI.h>
2424
#include <SD.h>
2525

26-
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
27-
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
28-
// 53 on the Mega) must be left as an output or the SD library
29-
// functions will not work.
3026
const int chipSelect = 4;
3127

3228
void setup()
@@ -39,9 +35,6 @@ void setup()
3935

4036

4137
Serial.print("Initializing SD card...");
42-
// make sure that the default chip select pin is set to
43-
// output, even if you don't use it:
44-
pinMode(10, OUTPUT);
4538

4639
// see if the card is present and can be initialized:
4740
if (!SD.begin(chipSelect)) {

libraries/SD/examples/DumpFile/DumpFile.ino

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#include <SPI.h>
2424
#include <SD.h>
2525

26-
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
27-
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
28-
// 53 on the Mega) must be left as an output or the SD library
29-
// functions will not work.
3026
const int chipSelect = 4;
3127

3228
void setup()
@@ -39,9 +35,6 @@ void setup()
3935

4036

4137
Serial.print("Initializing SD card...");
42-
// make sure that the default chip select pin is set to
43-
// output, even if you don't use it:
44-
pinMode(10, OUTPUT);
4538

4639
// see if the card is present and can be initialized:
4740
if (!SD.begin(chipSelect)) {

libraries/SD/examples/Files/Files.ino

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ void setup()
3232

3333

3434
Serial.print("Initializing SD card...");
35-
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
36-
// Note that even if it's not used as the CS pin, the hardware SS pin
37-
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
38-
// or the SD library functions will not work.
39-
pinMode(10, OUTPUT);
4035

4136
if (!SD.begin(4)) {
4237
Serial.println("initialization failed!");

libraries/SD/examples/ReadWrite/ReadWrite.ino

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ void setup()
3333

3434

3535
Serial.print("Initializing SD card...");
36-
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
37-
// Note that even if it's not used as the CS pin, the hardware SS pin
38-
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
39-
// or the SD library functions will not work.
40-
pinMode(10, OUTPUT);
4136

4237
if (!SD.begin(4)) {
4338
Serial.println("initialization failed!");

libraries/SD/examples/listfiles/listfiles.ino

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ void setup()
3535
}
3636

3737
Serial.print("Initializing SD card...");
38-
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
39-
// Note that even if it's not used as the CS pin, the hardware SS pin
40-
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
41-
// or the SD library functions will not work.
42-
pinMode(10, OUTPUT);
4338

4439
if (!SD.begin(4)) {
4540
Serial.println("initialization failed!");

0 commit comments

Comments
 (0)