Skip to content

Commit

Permalink
Merge pull request #178 from Marzogh/development
Browse files Browse the repository at this point in the history
Latest stable changes from development - Custom SPI pins and multiple SPI support for ESP32
  • Loading branch information
Marzogh committed Jun 1, 2019
2 parents dae23b2 + de3c71f commit 2711ccc
Show file tree
Hide file tree
Showing 10 changed files with 564 additions and 400 deletions.
475 changes: 475 additions & 0 deletions Change log.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![GitHub issues](https://img.shields.io/github/issues/Marzogh/SPIMemory.svg)](https://github.com/Marzogh/SPIMemory/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/Marzogh/SPIMemory.svg)](https://github.com/Marzogh/SPIMemory/pulls)
[![license](https://img.shields.io/github/license/Marzogh/SPIMemory.svg)](https://github.com/Marzogh/SPIMemory/blob/master/LICENSE)
[![Join the chat at https://gitter.im/SPIMemory/community](https://badges.gitter.im/SPIMemory/community.svg)](https://gitter.im/SPIMemory/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Arduino library for Flash & FRAM Memory Chips (SPI based only)
<sup> Download the latest stable release from [here](https://github.com/Marzogh/SPIMemory/releases/latest). Please report any bugs in [issues](https://github.com/Marzogh/SPIMemory/issues/new).</sup>
Expand Down Expand Up @@ -88,6 +89,7 @@ This Arduino library is for use with flash and FRAM memory chips that communicat
- Every version of the library >= v3.0.0 supports the ability to use any of multiple SPI interfaces (if your micro-controller supports them). Switching to use another SPI interface is done by calling ```SPIFlash flash(csPin, &SPI1);``` (or &SPI2 and so on), instead of ```SPIFlash flash(csPin)```.

<sub>* NOTE: This is currently only supported on the SAMD and STM32 architectures.</sub>
- An alternate version ```SPIFlash flash (SPIPinsArray)``` of the constructor can be used (only with ESP32 board as of now) to enable the use of custom SPI pins. ```SPIPinsArray``` has to be a 4 element array containing the custom SPI pin numbers (as signed integers - int8_t) in the following order - sck, miso, mosi, ss.
- Also make sure to include ```flash.begin(CHIPSIZE*)``` in ```void setup()```. This enables the library to detect the type of flash chip installed and load the right parameters.

<sub>* Optional</sub>
Expand Down Expand Up @@ -279,6 +281,7 @@ Note: If you are unable to fix the error/s, please raise an issue [here](http://
| **0x11** | Unable to read Erase Parameters from chip. <br> Reverting to library defaults. |
| **0x12** | Unable to read erase times from flash memory. <br> Reverting to library defaults. |
| **0x13** | Unable to read program times from flash memory. <br> Reverting to library defaults. |
| **0x14** | No Chip Select pin defined in the custom SPI Array. <br> Refer to section about Constructor for information on how to use custom SPI pins. |
| **0xFE** | Unknown error. <br> Please raise an issue. |

<hr>
14 changes: 10 additions & 4 deletions examples/FlashDiagnostics/FlashDiagnostics.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| FlashDiagnostics.ino |
| SPIMemory library |
| v 3.2.0 |
| v 3.4.0 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Marzogh |
| 02.05.2018 |
| 01.06.2019 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| |
| For a full diagnostics rundown - with error codes and details of the errors |
Expand Down Expand Up @@ -37,15 +37,20 @@
#define TRUE 1
#define FALSE 0

int8_t SPIPins[4] = {-1, -1, -1, 33};

SPIFlash flash;
//SPIFlash flash(11);
//SPIFlash flash(SPIPins);
//SPIFlash flash(33);
//SPIFlash flash(SS1, &SPI1); //Use this constructor if using an SPI bus other than the default SPI. Only works with chips with more than one hardware SPI bus

void setup() {

Serial.begin(BAUD_RATE);
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__) || defined(ARCH_STM32) || defined(NRF5)
#if defined (ARDUINO_ARCH_SAMD) || defined (__AVR_ATmega32U4__) || defined (ARCH_STM32) || defined (NRF5) || defined (ARDUINO_ARCH_ESP32)
while (!Serial) ; // Wait for Serial monitor to open
#endif

delay(50); //Time to terminal get connected
Serial.print(F("Initialising"));
for (uint8_t i = 0; i < 10; ++i)
Expand All @@ -54,6 +59,7 @@ void setup() {
}
Serial.println();
randomSeed(analogRead(RANDPIN));
Serial.println(flash.error(VERBOSE));
flash.begin();
//To use a custom flash memory size (if using memory from manufacturers not officially supported by the library) - declare a size variable according to the list in defines.h
//flash.begin(MB(1));
Expand Down
Loading

0 comments on commit 2711ccc

Please sign in to comment.