diff --git a/examples/fatfs_circuitpython/fatfs_circuitpython.ino b/examples/fatfs_circuitpython/fatfs_circuitpython.ino index e77da62..63e3ec3 100644 --- a/examples/fatfs_circuitpython/fatfs_circuitpython.ino +++ b/examples/fatfs_circuitpython/fatfs_circuitpython.ino @@ -6,7 +6,7 @@ // You can create, update, and read files on the CircuitPython // filesystem in an Arduino sketch and then later load CircuitPython // to interact with the same files. This example will print out -// the contents of boot.py and main.py (if found) and add a line +// the contents of boot.py and main.py (if found) and add a line // to a data.txt file on CircuitPython's filesystem. // // Note before you use this sketch you must load CircuitPython @@ -35,10 +35,17 @@ // sure to change the fatfs // object type below to match. -#define FLASH_SS SS1 // Flash chip SS pin. -#define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? +#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define FLASH_SS SS // Flash chip SS pin. + #define FLASH_SPI_PORT SPI // What SPI port is Flash on? + #define NEOPIN 8 +#else + #define FLASH_SS SS1 // Flash chip SS pin. + #define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? + #define NEOPIN 40 +#endif -Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI +Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI // Alternatively you can define and use non-SPI pins! //Adafruit_SPIFlash flash(SCK1, MISO1, MOSI1, FLASH_SS); @@ -56,7 +63,7 @@ void setup() { delay(100); } Serial.println("Adafruit M0 Express CircuitPython Flash Example"); - + // Initialize flash library and check its chip ID. if (!flash.begin(FLASH_TYPE)) { Serial.println("Error, failed to initialize flash chip!"); @@ -72,7 +79,7 @@ void setup() { while(1); } Serial.println("Mounted filesystem!"); - + // Check if a boot.py exists and print it out. if (pythonfs.exists("boot.py")) { File bootPy = pythonfs.open("boot.py", FILE_READ); diff --git a/examples/fatfs_datalogging/fatfs_datalogging.ino b/examples/fatfs_datalogging/fatfs_datalogging.ino index 5e629c4..4cc02fe 100644 --- a/examples/fatfs_datalogging/fatfs_datalogging.ino +++ b/examples/fatfs_datalogging/fatfs_datalogging.ino @@ -27,8 +27,15 @@ // sure to change the fatfs // object type below to match. -#define FLASH_SS SS1 // Flash chip SS pin. -#define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? +#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define FLASH_SS SS // Flash chip SS pin. + #define FLASH_SPI_PORT SPI // What SPI port is Flash on? + #define NEOPIN 8 +#else + #define FLASH_SS SS1 // Flash chip SS pin. + #define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? + #define NEOPIN 40 +#endif Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI diff --git a/examples/fatfs_format/fatfs_format.ino b/examples/fatfs_format/fatfs_format.ino index 128b101..426df3b 100755 --- a/examples/fatfs_format/fatfs_format.ino +++ b/examples/fatfs_format/fatfs_format.ino @@ -44,10 +44,17 @@ // sure to change the fatfs // object type below to match. -#define FLASH_SS SS1 // Flash chip SS pin. -#define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? - -Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI +#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define FLASH_SS SS // Flash chip SS pin. + #define FLASH_SPI_PORT SPI // What SPI port is Flash on? + #define NEOPIN 8 +#else + #define FLASH_SS SS1 // Flash chip SS pin. + #define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? + #define NEOPIN 40 +#endif + +Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI // Alternatively you can define and use non-SPI pins! // Adafruit_SPIFlash flash(FLASH_SCK, FLASH_MISO, FLASH_MOSI, FLASH_SS); diff --git a/examples/fatfs_full_usage/fatfs_full_usage.ino b/examples/fatfs_full_usage/fatfs_full_usage.ino index a5345e1..06d68af 100755 --- a/examples/fatfs_full_usage/fatfs_full_usage.ino +++ b/examples/fatfs_full_usage/fatfs_full_usage.ino @@ -34,10 +34,18 @@ // If you change this be // sure to change the fatfs // object type below to match. -#define FLASH_SS SS1 // Flash chip SS pin. -#define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? -Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI +#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define FLASH_SS SS // Flash chip SS pin. + #define FLASH_SPI_PORT SPI // What SPI port is Flash on? + #define NEOPIN 8 +#else + #define FLASH_SS SS1 // Flash chip SS pin. + #define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? + #define NEOPIN 40 +#endif + +Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI // Alternatively you can define and use non-SPI pins! // Adafruit_SPIFlash flash(FLASH_SCK, FLASH_MISO, FLASH_MOSI, FLASH_SS); @@ -52,7 +60,7 @@ void setup() { delay(100); } Serial.println("Adafruit SPI Flash FatFs Full Usage Example"); - + // Initialize flash library and check its chip ID. if (!flash.begin(FLASH_TYPE)) { Serial.println("Error, failed to initialize flash chip!"); @@ -87,12 +95,12 @@ void setup() { Serial.println("Creating deep folder structure..."); if (!fatfs.mkdir("/test/foo/bar")) { Serial.println("Error, couldn't create deep directory structure!"); - while(1); + while(1); } // This will create the hierarchy /test/foo/baz, even when /test/foo already exists: if (!fatfs.mkdir("/test/foo/baz")) { Serial.println("Error, couldn't create deep directory structure!"); - while(1); + while(1); } Serial.println("Created /test/foo/bar and /test/foo/baz folders!"); @@ -220,7 +228,7 @@ void setup() { while(1); } Serial.println("Test directory was deleted!"); - + Serial.println("Finished!"); } diff --git a/examples/fatfs_print_file/fatfs_print_file.ino b/examples/fatfs_print_file/fatfs_print_file.ino index cd654ee..a12a864 100644 --- a/examples/fatfs_print_file/fatfs_print_file.ino +++ b/examples/fatfs_print_file/fatfs_print_file.ino @@ -3,9 +3,9 @@ // // This is a simple example that opens a file and prints its // entire contents to the serial monitor. Note that -// you MUST have a flash chip that's formatted with a flash +// you MUST have a flash chip that's formatted with a flash // filesystem before running, and there should be some sort -// of text file on it to open and read. See the fatfs_format +// of text file on it to open and read. See the fatfs_format // example to perform this formatting, and the fatfs_datalogging // example to write a simple text file. // @@ -31,10 +31,17 @@ // sure to change the fatfs // object type below to match. -#define FLASH_SS SS1 // Flash chip SS pin. -#define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? +#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define FLASH_SS SS // Flash chip SS pin. + #define FLASH_SPI_PORT SPI // What SPI port is Flash on? + #define NEOPIN 8 +#else + #define FLASH_SS SS1 // Flash chip SS pin. + #define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? + #define NEOPIN 40 +#endif -Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI +Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI // Alternatively you can define and use non-SPI pins! // Adafruit_SPIFlash flash(FLASH_SCK, FLASH_MISO, FLASH_MOSI, FLASH_SS); @@ -52,7 +59,7 @@ void setup() { delay(100); } Serial.println("Adafruit SPI Flash FatFs Simple File Printing Example"); - + // Initialize flash library and check its chip ID. if (!flash.begin(FLASH_TYPE)) { Serial.println("Error, failed to initialize flash chip!"); @@ -68,7 +75,7 @@ void setup() { while(1); } Serial.println("Mounted filesystem!"); - + // Open the file for reading and check that it was successfully opened. // The FILE_READ mode will open the file for reading. File dataFile = fatfs.open(FILE_NAME, FILE_READ); diff --git a/examples/flash_erase/flash_erase.ino b/examples/flash_erase/flash_erase.ino index d75af92..0bc7efa 100644 --- a/examples/flash_erase/flash_erase.ino +++ b/examples/flash_erase/flash_erase.ino @@ -30,8 +30,15 @@ // sure to change the fatfs // object type below to match. -#define FLASH_SS SS1 // Flash chip SS pin. -#define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? +#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) + #define FLASH_SS SS // Flash chip SS pin. + #define FLASH_SPI_PORT SPI // What SPI port is Flash on? + #define NEOPIN 8 +#else + #define FLASH_SS SS1 // Flash chip SS pin. + #define FLASH_SPI_PORT SPI1 // What SPI port is Flash on? + #define NEOPIN 40 +#endif Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT); // Use hardware SPI