Skip to content

Commit

Permalink
Merge pull request #138 from Marzogh/stable
Browse files Browse the repository at this point in the history
v3.2.1 ready to be rolled out!
  • Loading branch information
Marzogh authored May 21, 2018
2 parents f828076 + 5f3f669 commit 341c29a
Show file tree
Hide file tree
Showing 12 changed files with 539 additions and 174 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
![GitHub issue state](https://img.shields.io/github/issues/detail/s/Marzogh/SPIFlash/14.svg) ![GitHub issue title](https://img.shields.io/github/issues/detail/title/Marzogh/SPIFlash/14.svg) ![GitHub issue author](https://img.shields.io/github/issues/detail/u/Marzogh/SPIFlash/14.svg) ![GitHub issue label](https://img.shields.io/github/issues/detail/label/Marzogh/SPIFlash/14.svg) ![GitHub issue comments](https://img.shields.io/github/issues/detail/comments/Marzogh/SPIFlash/14.svg) ![GitHub issue age](https://img.shields.io/github/issues/detail/age/Marzogh/SPIFlash/14.svg) ![GitHub issue last update](https://img.shields.io/github/issues/detail/last-update/Marzogh/SPIFlash/14.svg)
![GitHub issue state](https://img.shields.io/github/issues/detail/s/Marzogh/SPIFlash/14.svg) ![GitHub issue title](https://img.shields.io/github/issues/detail/title/Marzogh/SPIFlash/14.svg)
![GitHub issue author](https://img.shields.io/github/issues/detail/u/Marzogh/SPIFlash/14.svg) ![GitHub issue label](https://img.shields.io/github/issues/detail/label/Marzogh/SPIFlash/14.svg) ![GitHub issue comments](https://img.shields.io/github/issues/detail/comments/Marzogh/SPIFlash/14.svg)
![GitHub issue age](https://img.shields.io/github/issues/detail/age/Marzogh/SPIFlash/14.svg) ![GitHub issue last update](https://img.shields.io/github/issues/detail/last-update/Marzogh/SPIFlash/14.svg)
###### ---------------------------- **DO NOT DELETE OR EDIT** anything above this line ----------------------------
###### ---------------------------- **DO NOT DELETE OR EDIT** anything above this line ----------------------------

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ SPIFlash flash(33);

<sub>* Optional</sub>

##### Note on SFDP discovery
As of v3.2.1, SFDP parameter discovery is an user controlled option. To get the library to work with SFDP compatible flash memory chips that are not officially supported by the library, the user must uncomment '//#define USES_SFDP' in 'SPIMemory.h'.

##### Notes on Address overflow and Error checking
- The library has Address overflow enabled by default - i.e. if the last address read/written from/to, in any function, is 0xFFFFF then, the next address read/written from/to is 0x00000. This can be disabled by uncommenting ```#define DISABLEOVERFLOW``` in SPIMemory.h. (Address overflow only works for Read / Write functions. Erase functions erase only a set number of blocks/sectors irrespective of overflow.)
- All write functions have Error checking turned on by default - i.e. every byte written to the flash memory will be checked against the data stored on the Arduino. Users who require greater write speeds can disable this function by setting an optional last 'errorCheck' argument in any write function to NOERRCHK - For eg. call the function ```writeByte(address, *data_buffer, NOERRCHK)``` instead of ```writeByte(address, *data_buffer)```.
Expand Down
40 changes: 21 additions & 19 deletions examples/FlashDiagnostics/Diagnostics_functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void printTab(uint8_t _times) {
}

void printTime(uint32_t _wTime, uint32_t _rTime) {
printTab(2);
printTab(2);
if (_rTime != 0) {
printTimer(_wTime);
printTab(3);
Expand Down Expand Up @@ -118,7 +118,7 @@ bool getID() {
Serial.print("Max Pages: ");
Serial.println(flash.getMaxPage());
printUniqueID();

}
return true;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ void byteTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void charTest() {
Expand Down Expand Up @@ -179,7 +179,7 @@ void charTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void wordTest() {
Expand Down Expand Up @@ -208,7 +208,7 @@ void wordTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void shortTest() {
Expand Down Expand Up @@ -237,7 +237,7 @@ void shortTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void uLongTest() {
Expand Down Expand Up @@ -266,7 +266,7 @@ void uLongTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void longTest() {
Expand Down Expand Up @@ -295,7 +295,7 @@ void longTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void floatTest() {
Expand Down Expand Up @@ -324,7 +324,7 @@ void floatTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void stringTest() {
Expand Down Expand Up @@ -353,7 +353,7 @@ void stringTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void structTest() {
Expand Down Expand Up @@ -402,7 +402,7 @@ void structTest() {
pass(FALSE);
}
printTime(wTime, rTime);

}

void arrayTest() {
Expand Down Expand Up @@ -430,11 +430,13 @@ void arrayTest() {
for (uint16_t i = 0; i < 256; i++) {
if (_data[i] != i) {
pass(FALSE);
Serial.print(i);
Serial.print(", ");
}
}
pass(TRUE);
printTime(wTime, rTime);

}

void powerDownTest() {
Expand All @@ -452,7 +454,7 @@ void powerDownTest() {
printTab(2);
Serial.print("Not all chips support power down. Check your datasheet.");
}

}

void powerUpTest() {
Expand All @@ -468,7 +470,7 @@ void powerUpTest() {
else {
pass(FALSE);
}

}

void eraseSectorTest() {
Expand All @@ -485,7 +487,7 @@ void eraseSectorTest() {
else {
pass(FALSE);
}

}

void eraseSectionTest() {
Expand All @@ -502,7 +504,7 @@ void eraseSectionTest() {
else {
pass(FALSE);
}

}

void eraseBlock32KTest() {
Expand All @@ -519,7 +521,7 @@ void eraseBlock32KTest() {
else {
pass(FALSE);
}

}

void eraseBlock64KTest() {
Expand All @@ -536,7 +538,7 @@ void eraseBlock64KTest() {
else {
pass(FALSE);
}

}

void eraseChipTest() {
Expand All @@ -552,6 +554,6 @@ void eraseChipTest() {
else {
pass(FALSE);
}

}

29 changes: 18 additions & 11 deletions examples/TestFlash/TestFlash.ino
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,37 @@ String inputString, outputString;

#if defined (SIMBLEE)
#define BAUD_RATE 250000
#define RANDPIN 1
#else
#define BAUD_RATE 115200
#if defined(ARCH_STM32)
#define RANDPIN PA0
#else
#define RANDPIN A0
#endif
#endif

SPIFlash flash(11);
SPIFlash flash;
//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)
while (!Serial) ; // Wait for Serial monitor to open
#endif
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__) || defined(ARCH_STM32) || defined(NRF5)
while (!Serial) ; // Wait for Serial monitor to open
#endif
delay(50); //Time to terminal get connected
Serial.print(F("Initialising Flash memory"));
for (int i = 0; i < 10; ++i)
Serial.print(F("Initialising"));
for (uint8_t i = 0; i < 10; ++i)
{
Serial.print(F("."));
}
Serial.println();
#if defined (CHIPSIZE)
flash.begin(CHIPSIZE); //use flash.begin(CHIPSIZE) if using non-Winbond flash (Refer to '#define CHIPSIZE' above)
#else
randomSeed(analogRead(RANDPIN));
flash.begin();
#endif
//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));

Serial.println();
Serial.println();
commandList();
Expand Down Expand Up @@ -503,7 +510,7 @@ void printPage(uint32_t _address, uint8_t outputType) {
Serial.begin(115200);

char buffer[24];
sprintf(buffer, "Reading address (%04x)", _address);
sprintf(buffer, "Reading address 0x(%04x)", _address);
Serial.println(buffer);

uint8_t data_buffer[SPI_PAGESIZE];
Expand Down
21 changes: 21 additions & 0 deletions extras/Changes.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// SPIMemory Library //
// Changes log //
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Version 3.2.1 //
// Author: Prajwal Bhattaram //
// 13.04.2018 //
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

Bugs squashed
--> Fixes issue #135 : The addition of the SFDP checking to _chipID resulted in a sudden (very large) increase in compiled code size. As of the current version (v3.2.1), SFDP checking is an user controlled option. To get the library to work with SFDP compatible flash memory that is not officially supported, the user must uncomment '//#define USES_SFDP' in 'SPIMemory.h'.

--> Moved `bool _loopedOver` from being a local variable in `getAddress()` to a global one. Now it actually does what it was meant to do - i.e. prevent looping over data a second time.

Enhancements
--> The way the basic functions execute has been modified to keep the function runtime the same (or improved) while reducing their memory footprint.

Test sketch - FlashDiagnostics.ino from v3.2.0 with #RUNDIAGNOSTIC commented out
Test platform - Arduino Pro Mini 8MHz 3.3V
Library version: v3.1.0 Compiled code size - 17652 bytes (SFDP discovery not supported)
Library version: v3.2.0 Compiled code size - 20104 bytes (SFDP discovery supported & on by default) (13.9% larger than v3.1.0)
Library version: v3.2.1 Compiled code size - 15316 bytes (SFDP discovery turned off) (13.75% smaller than v3.1.0)
Library version: v3.2.1 Compiled code size - 17854 bytes (SFDP discovery turned on) (1.1% larger than v3.1.0)

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Version 3.2.0 //
// Author: Prajwal Bhattaram //
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=SPIMemory
version=3.2.0
version=3.2.1
author=Prajwal Bhattaram
maintainer=Prajwal Bhattaram <[email protected]>
sentence=SPI Memory library for Arduino. (Formerly SPIFlash)
paragraph=Starting v3.2.0, this library enables read, write, erase and power functions on all SFDP compatible Flash chips. Older versions are only compatible with specific chips as listed here - < v2.6.0 is compatible with W25X05**, W25X10**, W25X20**, W25X40**, W25Q80**, W25Q16**, W25Q32** & W25Q64**. All other Winbond flash chips can also be used with this library from v2.6.0 onwards. A number of Microchip, Cypress & Spansion chips - W25Q128**, W25Q256**, SST25VF064C, SST26VF064B & S25FL116K - can be used with with the library from v3.0.0 onwards. Refer to change log for further information about this release.
paragraph=This library enables read, write, erase and power functions on number of compatible flash memory chips. Refer to change log for further information about this release. To download any version of this library pre v3.2.0 (pre name-change from SPIFlash please visit https://github.com/Marzogh/SPIMemory/releases?after=v3.2.0 )
category=Data Storage
url=https://github.com/Marzogh/SPIMemory
architectures=avr,sam,samd,esp8266,esp32,Simblee,stm32
Expand Down
Loading

0 comments on commit 341c29a

Please sign in to comment.