Skip to content

Commit 2d10db9

Browse files
authored
Merge pull request #54 from Marzogh/v2.6.0-w.i.p
v2.6.0 w.i.p is ready to go.
2 parents 3a7a8f5 + d178dad commit 2d10db9

19 files changed

+2777
-2452
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ script:
99
#- build_platform zero
1010
- build_platform esp8266
1111
- build_platform leonardo
12+
- build_platform rtl8195a
13+
- build_platform simblee
1214
- build_platform mega
1315
- build_platform fio
1416
- build_platform micro

README.md

+77-41
Large diffs are not rendered by default.

examples/Diagnostics/Diagnostic_functions.ino examples/FlashDiagnostics/FlashDiagnostic_functions.ino

+11-80
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
3-
| Diagnostic_functions.ino |
3+
| FlashDiagnostic_functions.ino |
44
| SPIFlash library |
5-
| v 2.5.0 |
5+
| v 2.6.0 |
66
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
77
| Marzogh |
88
| 13.11.2016 |
@@ -42,82 +42,12 @@ void getID() {
4242
uint16_t b3;
4343
uint32_t JEDEC = flash.getJEDECID();
4444
uint32_t maxPage = flash.getMaxPage();
45-
uint16_t _name = flash.getChipName();
4645
uint32_t capacity = flash.getCapacity();
4746
b1 = (JEDEC >> 16);
4847
b2 = (JEDEC >> 8);
4948
b3 = (JEDEC >> 0);
5049

51-
#define WINBOND 0xEF
52-
#define MICROCHIP 0xBF
5350

54-
if (b1 == WINBOND) {
55-
//---------------------------------------------------------------------------------------------//
56-
//--------------------------Prints the name of the Flash chip in use---------------------------//
57-
//---------------------------------------------------------------------------------------------//
58-
for (uint8_t i = 0; i < 76; i++) {
59-
Serial.print(F(" "));
60-
}
61-
Serial.print(F("Winbond "));
62-
if (_name < 80) {
63-
if (_name == 05) {
64-
clearprintBuffer(&printBuffer[1]);
65-
sprintf(printBuffer, "W25X%02d**", _name);
66-
Serial.println(printBuffer);
67-
clearprintBuffer(&printBuffer[1]);
68-
}
69-
else if (_name % 10 == 0) {
70-
clearprintBuffer(&printBuffer[1]);
71-
sprintf(printBuffer, "W25X%02d**", _name);
72-
Serial.println(printBuffer);
73-
clearprintBuffer(&printBuffer[1]);
74-
}
75-
else {
76-
clearprintBuffer(&printBuffer[1]);
77-
sprintf(printBuffer, "W25Q%02d**", _name);
78-
Serial.println(printBuffer);
79-
clearprintBuffer(&printBuffer[1]);
80-
}
81-
}
82-
else {
83-
clearprintBuffer(&printBuffer[1]);
84-
sprintf(printBuffer, "W25Q%02d**", _name);
85-
Serial.println(printBuffer);
86-
clearprintBuffer(&printBuffer[1]);
87-
}
88-
}
89-
else if (b1 == MICROCHIP) {
90-
for (uint8_t i = 0; i < 72; i++) {
91-
Serial.print(F(" "));
92-
}
93-
Serial.print(F("Microchip "));
94-
if (_name < 80) {
95-
if (_name == 05) {
96-
clearprintBuffer(&printBuffer[1]);
97-
sprintf(printBuffer, "W25X%02d**", _name);
98-
Serial.println(printBuffer);
99-
clearprintBuffer(&printBuffer[1]);
100-
}
101-
else if (_name % 10 == 0) {
102-
clearprintBuffer(&printBuffer[1]);
103-
sprintf(printBuffer, "W25X%02d**", _name);
104-
Serial.println(printBuffer);
105-
clearprintBuffer(&printBuffer[1]);
106-
}
107-
else {
108-
clearprintBuffer(&printBuffer[1]);
109-
sprintf(printBuffer, "W25Q%02d**", _name);
110-
Serial.println(printBuffer);
111-
clearprintBuffer(&printBuffer[1]);
112-
}
113-
}
114-
else {
115-
clearprintBuffer(&printBuffer[1]);
116-
sprintf(printBuffer, "W25Q%02d**", _name);
117-
Serial.println(printBuffer);
118-
clearprintBuffer(&printBuffer[1]);
119-
}
120-
}
12151
printLine();
12252
//---------------------------------------------------------------------------------------------//
12353

@@ -832,16 +762,17 @@ void powerFuncDiag(void) {
832762
printTab(5, 0);
833763
Serial.print(F("powerDown"));
834764
printTab(2, 2);
835-
if (flash.writeStr(stringAddress1, _string)) {
765+
//if (flash.writeStr(stringAddress1, _string)) {
836766
wTime = micros();
837767
if (flash.powerDown()) {
838768
wTime = micros() - wTime;
839-
if (!flash.writeStr(stringAddress2, _string))
840-
printPass();
841-
else
842-
printFail();
769+
printPass();
843770
}
844-
}
771+
else {
772+
wTime = micros() - wTime;
773+
printFail();
774+
}
775+
//}
845776
printTab(3, 2);
846777
printTimer(wTime);
847778
Serial.println();
@@ -852,13 +783,13 @@ void powerFuncDiag(void) {
852783
wTime = micros();
853784
if (flash.powerUp()) {
854785
wTime = micros() - wTime;
855-
if (flash.writeStr(stringAddress3, _string)) {
786+
//if (flash.writeStr(stringAddress3, _string)) {
856787
printPass();
857788
}
858789
else {
859790
printFail();
860791
}
861-
}
792+
//}
862793
printTab(3, 2);
863794
printTimer(wTime);
864795
Serial.println();

examples/Diagnostics/Diagnostics.ino examples/FlashDiagnostics/FlashDiagnostics.ino

+32-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
22
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
3-
| Diagnostics.ino |
3+
| FlashDiagnostics.ino |
44
| SPIFlash library |
5-
| v 2.5.0 |
5+
| v 2.6.0 |
66
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
77
| Marzogh |
8-
| 30.09.2016 |
8+
| 16.04.2017 |
99
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1010
| |
1111
| For a full diagnostics rundown - with error codes and details of the errors |
@@ -17,21 +17,48 @@
1717

1818
#include<SPIFlash.h>
1919

20+
//Define a flash memory size (if using non-Winbond memory) according to the list in defines.h
21+
//#define CHIPSIZE MB64
22+
23+
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
24+
// Required for Serial on Zero based boards
25+
#define Serial SERIAL_PORT_USBVIRTUAL
26+
#endif
27+
28+
#if defined (SIMBLEE)
29+
#define BAUD_RATE 250000
30+
#define RANDPIN 1
31+
#else
32+
#define BAUD_RATE 115200
33+
#define RANDPIN A0
34+
#endif
35+
2036
SPIFlash flash;
2137

2238
void setup() {
23-
Serial.begin(115200);
39+
Serial.begin(BAUD_RATE);
40+
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__)
41+
while (!Serial) ; // Wait for Serial monitor to open
42+
#endif
2443
Serial.print(F("Initialising Flash memory"));
2544
for (int i = 0; i < 10; ++i)
2645
{
2746
Serial.print(F("."));
2847
}
2948
Serial.println();
49+
#if defined (CHIPSIZE)
50+
flash.begin(CHIPSIZE); //use flash.begin(CHIPSIZE) if using non-Winbond flash (Refer to '#define CHIPSIZE' above)
51+
#else
3052
flash.begin();
53+
#endif
3154
Serial.println();
3255
Serial.println();
3356

34-
randomSeed(analogRead(A0));
57+
#if defined (ARDUINO_ARCH_ESP32)
58+
randomSeed(65535537);
59+
#else
60+
randomSeed(analogRead(RANDPIN));
61+
#endif
3562
getID();
3663
diagnose();
3764
}

examples/Struct_writer/Struct_writer.ino

+52-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
11
/*
2-
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
3-
| Struct_writer.ino |
4-
| SPIFlash library |
5-
| v 2.5.0 |
6-
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
7-
| Marzogh |
8-
| 30.09.2016 |
9-
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
10-
| |
11-
| This program writes a struct to a random location on your flash memory chip and reads it back. |
12-
| Uncomment #define SENSOR below to get real world readings. Real world readings require a Light dependant resistor hooked up to A0. |
13-
| For information on how to hook up an LDR to an Arduino, please refer to Adafruit's excellent tutorial at |
14-
| https://learn.adafruit.com/photocells/using-a-photocell |
15-
| |
16-
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
2+
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
3+
| Struct_writer.ino |
4+
| SPIFlash library |
5+
| v 2.6.0 |
6+
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
7+
| Marzogh |
8+
| 16.04.2017 |
9+
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
10+
| |
11+
| This program writes a struct to a random location on your flash memory chip and reads it back. |
12+
| Uncomment #define SENSOR below to get real world readings. Real world readings require a Light dependant resistor hooked up to A0. |
13+
| For information on how to hook up an LDR to an Arduino, please refer to Adafruit's excellent tutorial at |
14+
| https://learn.adafruit.com/photocells/using-a-photocell |
15+
| |
16+
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
1717
*/
1818

1919
#include<SPIFlash.h>
2020

21+
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
22+
// Required for Serial on Zero based boards
23+
#define Serial SERIAL_PORT_USBVIRTUAL
24+
#endif
25+
26+
#if defined (SIMBLEE)
27+
#define BAUD_RATE 250000
28+
#else
29+
#define BAUD_RATE 115200
30+
#endif
31+
2132
/*
22-
* Uncomment the #define below if you would like real world readings.
23-
* For real world readings, hook up a light dependant resistor to A0.
24-
*
25-
*/
26-
//#define SENSOR
33+
Uncomment the #define below if you would like real world readings.
34+
For real world readings, hook up a light dependant resistor to A1.
2735
28-
#ifdef SENSOR
29-
const int LDR = A0;
36+
*/
37+
//#define SENSOR
38+
#if defined (SIMBLEE)
39+
#define BAUD_RATE 250000
40+
#define LDR 1
41+
#else
42+
#define BAUD_RATE 115200
43+
#define LDR A0
3044
#endif
3145

3246

@@ -36,28 +50,34 @@ SPIFlash flash;
3650

3751
struct Configuration {
3852
float lux;
39-
float vOut; // Voltage ouput from potential divider to Anolg input
53+
float vOut; // Voltage ouput from potential divider to Analog input
4054
float RLDR; // Resistance calculation of potential divider with LDR
4155
bool light;
4256
uint8_t adc;
4357
};
4458
Configuration configuration;
4559

4660
void setup() {
47-
Serial.begin(115200);
48-
flash.begin();
49-
randomSeed(analogRead(A0));
61+
Serial.begin(BAUD_RATE);
62+
#if defined (ARDUINO_SAMD_ZERO) || (__AVR_ATmega32U4__)
63+
while (!Serial) ; // Wait for Serial monitor to open
64+
#endif
65+
#if defined (ARDUINO_ARCH_ESP32)
66+
randomSeed(65535537);
67+
#else
68+
randomSeed(analogRead(LDR));
69+
#endif
5070
Serial.print(F("Initialising Flash memory"));
5171
for (int i = 0; i < 10; ++i)
5272
{
5373
Serial.print(F("."));
5474
}
5575
Serial.println();
5676
Serial.println();
77+
flash.begin();
5778

5879

59-
uint16_t pageNo = random(0, 4095);
60-
uint8_t offset = random(0, 255);
80+
uint32_t _addr = random(0, 1677215);
6181

6282
#ifndef SENSOR
6383
configuration.lux = 98.43;
@@ -71,7 +91,7 @@ void setup() {
7191
readLDR();
7292
#endif
7393

74-
if (flash.writeAnything(pageNo, offset, configuration))
94+
if (flash.writeAnything(_addr, configuration))
7595
Serial.println ("Data write successful");
7696
else
7797
Serial.println ("Data write failed");
@@ -96,8 +116,8 @@ void setup() {
96116
Serial.println(configuration.light);
97117
Serial.println(configuration.adc);
98118
Serial.println();
99-
flash.readAnything(pageNo, offset, configuration);
100-
flash.eraseSector(pageNo, 0);
119+
flash.readAnything(_addr, configuration);
120+
flash.eraseSector(_addr, 0);
101121

102122
Serial.println("After reading");
103123
Serial.println(configuration.lux);
@@ -109,7 +129,7 @@ void setup() {
109129
}
110130

111131
void loop() {
112-
delay(1000);
132+
delay(1000);
113133
}
114134

115135
#ifdef SENSOR

examples/TestFlash/TestFlash.ino

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| SPIFlash library test v2.4.0 |
55
|----------------------------------------------------------------------------------------------------------------------------------|
66
| Marzogh |
7-
| 11.09.2016 |
7+
| 16.11.2016 |
88
|----------------------------------------------------------------------------------------------------------------------------------|
99
| (Please make sure your Serial monitor is set to 'No Line Ending') |
1010
| ***************************************************************** |
@@ -80,11 +80,17 @@ String inputString, outputString;
8080
#define Serial SERIAL_PORT_USBVIRTUAL
8181
#endif
8282

83+
#if defined (SIMBLEE)
84+
#define BAUD_RATE 250000
85+
#else
86+
#define BAUD_RATE 115200
87+
#endif
88+
8389
SPIFlash flash;
8490

8591
void setup() {
8692
delay(10);
87-
Serial.begin(115200);
93+
Serial.begin(BAUD_RATE);
8894
Serial.print(F("Initialising Flash memory"));
8995
for (int i = 0; i < 10; ++i)
9096
{

0 commit comments

Comments
 (0)