Skip to content

Commit 341c29a

Browse files
authored
Merge pull request #138 from Marzogh/stable
v3.2.1 ready to be rolled out!
2 parents f828076 + 5f3f669 commit 341c29a

12 files changed

Lines changed: 539 additions & 174 deletions

File tree

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
![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)
1+
![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)
2+
![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)
3+
![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)
24
###### ---------------------------- **DO NOT DELETE OR EDIT** anything above this line ----------------------------
35
###### ---------------------------- **DO NOT DELETE OR EDIT** anything above this line ----------------------------
46

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ SPIFlash flash(33);
9797

9898
<sub>* Optional</sub>
9999

100+
##### Note on SFDP discovery
101+
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'.
102+
100103
##### Notes on Address overflow and Error checking
101104
- 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.)
102105
- 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)```.

examples/FlashDiagnostics/Diagnostics_functions.ino

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void printTab(uint8_t _times) {
2929
}
3030

3131
void printTime(uint32_t _wTime, uint32_t _rTime) {
32-
printTab(2);
32+
printTab(2);
3333
if (_rTime != 0) {
3434
printTimer(_wTime);
3535
printTab(3);
@@ -118,7 +118,7 @@ bool getID() {
118118
Serial.print("Max Pages: ");
119119
Serial.println(flash.getMaxPage());
120120
printUniqueID();
121-
121+
122122
}
123123
return true;
124124
}
@@ -150,7 +150,7 @@ void byteTest() {
150150
pass(FALSE);
151151
}
152152
printTime(wTime, rTime);
153-
153+
154154
}
155155

156156
void charTest() {
@@ -179,7 +179,7 @@ void charTest() {
179179
pass(FALSE);
180180
}
181181
printTime(wTime, rTime);
182-
182+
183183
}
184184

185185
void wordTest() {
@@ -208,7 +208,7 @@ void wordTest() {
208208
pass(FALSE);
209209
}
210210
printTime(wTime, rTime);
211-
211+
212212
}
213213

214214
void shortTest() {
@@ -237,7 +237,7 @@ void shortTest() {
237237
pass(FALSE);
238238
}
239239
printTime(wTime, rTime);
240-
240+
241241
}
242242

243243
void uLongTest() {
@@ -266,7 +266,7 @@ void uLongTest() {
266266
pass(FALSE);
267267
}
268268
printTime(wTime, rTime);
269-
269+
270270
}
271271

272272
void longTest() {
@@ -295,7 +295,7 @@ void longTest() {
295295
pass(FALSE);
296296
}
297297
printTime(wTime, rTime);
298-
298+
299299
}
300300

301301
void floatTest() {
@@ -324,7 +324,7 @@ void floatTest() {
324324
pass(FALSE);
325325
}
326326
printTime(wTime, rTime);
327-
327+
328328
}
329329

330330
void stringTest() {
@@ -353,7 +353,7 @@ void stringTest() {
353353
pass(FALSE);
354354
}
355355
printTime(wTime, rTime);
356-
356+
357357
}
358358

359359
void structTest() {
@@ -402,7 +402,7 @@ void structTest() {
402402
pass(FALSE);
403403
}
404404
printTime(wTime, rTime);
405-
405+
406406
}
407407

408408
void arrayTest() {
@@ -430,11 +430,13 @@ void arrayTest() {
430430
for (uint16_t i = 0; i < 256; i++) {
431431
if (_data[i] != i) {
432432
pass(FALSE);
433+
Serial.print(i);
434+
Serial.print(", ");
433435
}
434436
}
435437
pass(TRUE);
436438
printTime(wTime, rTime);
437-
439+
438440
}
439441

440442
void powerDownTest() {
@@ -452,7 +454,7 @@ void powerDownTest() {
452454
printTab(2);
453455
Serial.print("Not all chips support power down. Check your datasheet.");
454456
}
455-
457+
456458
}
457459

458460
void powerUpTest() {
@@ -468,7 +470,7 @@ void powerUpTest() {
468470
else {
469471
pass(FALSE);
470472
}
471-
473+
472474
}
473475

474476
void eraseSectorTest() {
@@ -485,7 +487,7 @@ void eraseSectorTest() {
485487
else {
486488
pass(FALSE);
487489
}
488-
490+
489491
}
490492

491493
void eraseSectionTest() {
@@ -502,7 +504,7 @@ void eraseSectionTest() {
502504
else {
503505
pass(FALSE);
504506
}
505-
507+
506508
}
507509

508510
void eraseBlock32KTest() {
@@ -519,7 +521,7 @@ void eraseBlock32KTest() {
519521
else {
520522
pass(FALSE);
521523
}
522-
524+
523525
}
524526

525527
void eraseBlock64KTest() {
@@ -536,7 +538,7 @@ void eraseBlock64KTest() {
536538
else {
537539
pass(FALSE);
538540
}
539-
541+
540542
}
541543

542544
void eraseChipTest() {
@@ -552,6 +554,6 @@ void eraseChipTest() {
552554
else {
553555
pass(FALSE);
554556
}
555-
557+
556558
}
557559

examples/TestFlash/TestFlash.ino

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,37 @@ String inputString, outputString;
8787

8888
#if defined (SIMBLEE)
8989
#define BAUD_RATE 250000
90+
#define RANDPIN 1
9091
#else
9192
#define BAUD_RATE 115200
93+
#if defined(ARCH_STM32)
94+
#define RANDPIN PA0
95+
#else
96+
#define RANDPIN A0
97+
#endif
9298
#endif
9399

94-
SPIFlash flash(11);
100+
SPIFlash flash;
95101
//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
96102

97103
void setup() {
104+
98105
Serial.begin(BAUD_RATE);
99-
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__) || defined(ARCH_STM32)
100-
while (!Serial) ; // Wait for Serial monitor to open
101-
#endif
106+
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__) || defined(ARCH_STM32) || defined(NRF5)
107+
while (!Serial) ; // Wait for Serial monitor to open
108+
#endif
102109
delay(50); //Time to terminal get connected
103-
Serial.print(F("Initialising Flash memory"));
104-
for (int i = 0; i < 10; ++i)
110+
Serial.print(F("Initialising"));
111+
for (uint8_t i = 0; i < 10; ++i)
105112
{
106113
Serial.print(F("."));
107114
}
108115
Serial.println();
109-
#if defined (CHIPSIZE)
110-
flash.begin(CHIPSIZE); //use flash.begin(CHIPSIZE) if using non-Winbond flash (Refer to '#define CHIPSIZE' above)
111-
#else
116+
randomSeed(analogRead(RANDPIN));
112117
flash.begin();
113-
#endif
118+
//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
119+
//flash.begin(MB(1));
120+
114121
Serial.println();
115122
Serial.println();
116123
commandList();
@@ -503,7 +510,7 @@ void printPage(uint32_t _address, uint8_t outputType) {
503510
Serial.begin(115200);
504511

505512
char buffer[24];
506-
sprintf(buffer, "Reading address (%04x)", _address);
513+
sprintf(buffer, "Reading address 0x(%04x)", _address);
507514
Serial.println(buffer);
508515

509516
uint8_t data_buffer[SPI_PAGESIZE];

extras/Changes.log

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
22
// SPIMemory Library //
33
// Changes log //
4+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
5+
// Version 3.2.1 //
6+
// Author: Prajwal Bhattaram //
7+
// 13.04.2018 //
8+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
9+
10+
Bugs squashed
11+
--> 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'.
12+
13+
--> 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.
14+
15+
Enhancements
16+
--> The way the basic functions execute has been modified to keep the function runtime the same (or improved) while reducing their memory footprint.
17+
18+
Test sketch - FlashDiagnostics.ino from v3.2.0 with #RUNDIAGNOSTIC commented out
19+
Test platform - Arduino Pro Mini 8MHz 3.3V
20+
Library version: v3.1.0 Compiled code size - 17652 bytes (SFDP discovery not supported)
21+
Library version: v3.2.0 Compiled code size - 20104 bytes (SFDP discovery supported & on by default) (13.9% larger than v3.1.0)
22+
Library version: v3.2.1 Compiled code size - 15316 bytes (SFDP discovery turned off) (13.75% smaller than v3.1.0)
23+
Library version: v3.2.1 Compiled code size - 17854 bytes (SFDP discovery turned on) (1.1% larger than v3.1.0)
24+
425
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
526
// Version 3.2.0 //
627
// Author: Prajwal Bhattaram //

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=SPIMemory
2-
version=3.2.0
2+
version=3.2.1
33
author=Prajwal Bhattaram
44
maintainer=Prajwal Bhattaram <marzogh@icloud.com>
55
sentence=SPI Memory library for Arduino. (Formerly SPIFlash)
6-
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.
6+
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 )
77
category=Data Storage
88
url=https://github.com/Marzogh/SPIMemory
99
architectures=avr,sam,samd,esp8266,esp32,Simblee,stm32

0 commit comments

Comments
 (0)