Skip to content

Commit 23a14e8

Browse files
committed
updating example to use sdfat fork
1 parent bd68c1c commit 23a14e8

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

Adafruit_Metro_RP2040/Arduino/Metro_RP2040_SD_Card_Test/.feather_rp2040.test.only

Whitespace-only changes.

Adafruit_Metro_RP2040/Arduino/Metro_RP2040_SD_Card_Test/Metro_RP2040_SD_Card_Test.ino

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,45 @@
44
/*
55
SD card read/write
66
7-
This example shows how to read and write data to and from an SD card file
8-
The circuit:
9-
SD card attached to SPI bus as follows:
10-
** MISO - pin 20
11-
** MOSI - pin 19
12-
** CS - pin 23
13-
** SCK - pin 18
14-
15-
created Nov 2010
16-
by David A. Mellis
17-
modified 9 Apr 2012
18-
by Tom Igoe
19-
20-
This example code is in the public domain.
21-
22-
*/
23-
24-
// SPI0 pins for Metro RP2040
25-
// Pins connected to onboard SD card slot
26-
const int _MISO = 20;
27-
const int _MOSI = 19;
28-
const int _CS = 23;
29-
const int _SCK = 18;
7+
This example shows how to read and write data to and from an SD card file
8+
The circuit:
9+
* SD card attached to SPI0 bus as follows:
10+
** MOSI - pin 19
11+
** MISO - pin 20
12+
** CLK - pin 18
13+
14+
created Nov 2010
15+
by David A. Mellis
16+
modified 9 Apr 2012
17+
by Tom Igoe
18+
modified 14 Feb 2023
19+
by Liz Clark
20+
21+
This example code is in the public domain.
22+
23+
*/
3024

3125
#include <SPI.h>
3226
#include <SD.h>
3327

28+
#define SD_FAT_TYPE 3
29+
30+
// default CS pin is 23 for Metro RP2040
31+
#define SD_CS_PIN 23
32+
3433
File myFile;
3534

3635
void setup() {
3736
// Open serial communications and wait for port to open:
3837
Serial.begin(115200);
38+
while (!Serial) {
39+
; // wait for serial port to connect. Needed for native USB port only
40+
}
3941

40-
Serial.print("Initializing SD card...");
4142

42-
// Ensure the SPI pinout the SD card is connected to is configured properly
43-
SPI.setRX(_MISO);
44-
SPI.setTX(_MOSI);
45-
SPI.setSCK(_SCK);
43+
Serial.print("Initializing SD card...");
4644

47-
if (!SD.begin(_CS)) {
45+
if (!SD.begin(SD_CS_PIN)) {
4846
Serial.println("initialization failed!");
4947
return;
5048
}
@@ -57,6 +55,7 @@ void setup() {
5755
// if the file opened okay, write to it:
5856
if (myFile) {
5957
Serial.print("Writing to test.txt...");
58+
myFile.println("testing 1, 2, 3.");
6059
myFile.println("hello metro rp2040!");
6160
// close the file:
6261
myFile.close();

0 commit comments

Comments
 (0)