Skip to content

Commit

Permalink
Merge branch 'master' of github.com:adafruit/SPI-Flash-Library
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Mar 27, 2018
2 parents 38be2a6 + f59f39a commit 6945985
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 28 deletions.
19 changes: 13 additions & 6 deletions examples/fatfs_circuitpython/fatfs_circuitpython.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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!");
Expand All @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions examples/fatfs_datalogging/fatfs_datalogging.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions examples/fatfs_format/fatfs_format.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 15 additions & 7 deletions examples/fatfs_full_usage/fatfs_full_usage.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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!");
Expand Down Expand Up @@ -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!");

Expand Down Expand Up @@ -220,7 +228,7 @@ void setup() {
while(1);
}
Serial.println("Test directory was deleted!");

Serial.println("Finished!");
}

Expand Down
21 changes: 14 additions & 7 deletions examples/fatfs_print_file/fatfs_print_file.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand All @@ -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);
Expand All @@ -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!");
Expand All @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions examples/flash_erase/flash_erase.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6945985

Please sign in to comment.