Skip to content

Commit

Permalink
Merge pull request #54 from Marzogh/v2.6.0-w.i.p
Browse files Browse the repository at this point in the history
v2.6.0 w.i.p is ready to go.
  • Loading branch information
Marzogh authored Apr 16, 2017
2 parents 3a7a8f5 + d178dad commit 2d10db9
Show file tree
Hide file tree
Showing 19 changed files with 2,777 additions and 2,452 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ script:
#- build_platform zero
- build_platform esp8266
- build_platform leonardo
- build_platform rtl8195a
- build_platform simblee
- build_platform mega
- build_platform fio
- build_platform micro
Expand Down
118 changes: 77 additions & 41 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Diagnostic_functions.ino |
| FlashDiagnostic_functions.ino |
| SPIFlash library |
| v 2.5.0 |
| v 2.6.0 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Marzogh |
| 13.11.2016 |
Expand Down Expand Up @@ -42,82 +42,12 @@ void getID() {
uint16_t b3;
uint32_t JEDEC = flash.getJEDECID();
uint32_t maxPage = flash.getMaxPage();
uint16_t _name = flash.getChipName();
uint32_t capacity = flash.getCapacity();
b1 = (JEDEC >> 16);
b2 = (JEDEC >> 8);
b3 = (JEDEC >> 0);

#define WINBOND 0xEF
#define MICROCHIP 0xBF

if (b1 == WINBOND) {
//---------------------------------------------------------------------------------------------//
//--------------------------Prints the name of the Flash chip in use---------------------------//
//---------------------------------------------------------------------------------------------//
for (uint8_t i = 0; i < 76; i++) {
Serial.print(F(" "));
}
Serial.print(F("Winbond "));
if (_name < 80) {
if (_name == 05) {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25X%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
else if (_name % 10 == 0) {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25X%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
else {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25Q%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
}
else {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25Q%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
}
else if (b1 == MICROCHIP) {
for (uint8_t i = 0; i < 72; i++) {
Serial.print(F(" "));
}
Serial.print(F("Microchip "));
if (_name < 80) {
if (_name == 05) {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25X%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
else if (_name % 10 == 0) {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25X%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
else {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25Q%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
}
else {
clearprintBuffer(&printBuffer[1]);
sprintf(printBuffer, "W25Q%02d**", _name);
Serial.println(printBuffer);
clearprintBuffer(&printBuffer[1]);
}
}
printLine();
//---------------------------------------------------------------------------------------------//

Expand Down Expand Up @@ -832,16 +762,17 @@ void powerFuncDiag(void) {
printTab(5, 0);
Serial.print(F("powerDown"));
printTab(2, 2);
if (flash.writeStr(stringAddress1, _string)) {
//if (flash.writeStr(stringAddress1, _string)) {
wTime = micros();
if (flash.powerDown()) {
wTime = micros() - wTime;
if (!flash.writeStr(stringAddress2, _string))
printPass();
else
printFail();
printPass();
}
}
else {
wTime = micros() - wTime;
printFail();
}
//}
printTab(3, 2);
printTimer(wTime);
Serial.println();
Expand All @@ -852,13 +783,13 @@ void powerFuncDiag(void) {
wTime = micros();
if (flash.powerUp()) {
wTime = micros() - wTime;
if (flash.writeStr(stringAddress3, _string)) {
//if (flash.writeStr(stringAddress3, _string)) {
printPass();
}
else {
printFail();
}
}
//}
printTab(3, 2);
printTimer(wTime);
Serial.println();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Diagnostics.ino |
| FlashDiagnostics.ino |
| SPIFlash library |
| v 2.5.0 |
| v 2.6.0 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Marzogh |
| 30.09.2016 |
| 16.04.2017 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| |
| For a full diagnostics rundown - with error codes and details of the errors |
Expand All @@ -17,21 +17,48 @@

#include<SPIFlash.h>

//Define a flash memory size (if using non-Winbond memory) according to the list in defines.h
//#define CHIPSIZE MB64

#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
#endif

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

SPIFlash flash;

void setup() {
Serial.begin(115200);
Serial.begin(BAUD_RATE);
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__)
while (!Serial) ; // Wait for Serial monitor to open
#endif
Serial.print(F("Initialising Flash memory"));
for (int 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
flash.begin();
#endif
Serial.println();
Serial.println();

randomSeed(analogRead(A0));
#if defined (ARDUINO_ARCH_ESP32)
randomSeed(65535537);
#else
randomSeed(analogRead(RANDPIN));
#endif
getID();
diagnose();
}
Expand Down
84 changes: 52 additions & 32 deletions examples/Struct_writer/Struct_writer.ino
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
/*
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Struct_writer.ino |
| SPIFlash library |
| v 2.5.0 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Marzogh |
| 30.09.2016 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| |
| This program writes a struct to a random location on your flash memory chip and reads it back. |
| Uncomment #define SENSOR below to get real world readings. Real world readings require a Light dependant resistor hooked up to A0. |
| For information on how to hook up an LDR to an Arduino, please refer to Adafruit's excellent tutorial at |
| https://learn.adafruit.com/photocells/using-a-photocell |
| |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Struct_writer.ino |
| SPIFlash library |
| v 2.6.0 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Marzogh |
| 16.04.2017 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| |
| This program writes a struct to a random location on your flash memory chip and reads it back. |
| Uncomment #define SENSOR below to get real world readings. Real world readings require a Light dependant resistor hooked up to A0. |
| For information on how to hook up an LDR to an Arduino, please refer to Adafruit's excellent tutorial at |
| https://learn.adafruit.com/photocells/using-a-photocell |
| |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
*/

#include<SPIFlash.h>

#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
#endif

#if defined (SIMBLEE)
#define BAUD_RATE 250000
#else
#define BAUD_RATE 115200
#endif

/*
* Uncomment the #define below if you would like real world readings.
* For real world readings, hook up a light dependant resistor to A0.
*
*/
//#define SENSOR
Uncomment the #define below if you would like real world readings.
For real world readings, hook up a light dependant resistor to A1.
#ifdef SENSOR
const int LDR = A0;
*/
//#define SENSOR
#if defined (SIMBLEE)
#define BAUD_RATE 250000
#define LDR 1
#else
#define BAUD_RATE 115200
#define LDR A0
#endif


Expand All @@ -36,28 +50,34 @@ SPIFlash flash;

struct Configuration {
float lux;
float vOut; // Voltage ouput from potential divider to Anolg input
float vOut; // Voltage ouput from potential divider to Analog input
float RLDR; // Resistance calculation of potential divider with LDR
bool light;
uint8_t adc;
};
Configuration configuration;

void setup() {
Serial.begin(115200);
flash.begin();
randomSeed(analogRead(A0));
Serial.begin(BAUD_RATE);
#if defined (ARDUINO_SAMD_ZERO) || (__AVR_ATmega32U4__)
while (!Serial) ; // Wait for Serial monitor to open
#endif
#if defined (ARDUINO_ARCH_ESP32)
randomSeed(65535537);
#else
randomSeed(analogRead(LDR));
#endif
Serial.print(F("Initialising Flash memory"));
for (int i = 0; i < 10; ++i)
{
Serial.print(F("."));
}
Serial.println();
Serial.println();
flash.begin();


uint16_t pageNo = random(0, 4095);
uint8_t offset = random(0, 255);
uint32_t _addr = random(0, 1677215);

#ifndef SENSOR
configuration.lux = 98.43;
Expand All @@ -71,7 +91,7 @@ void setup() {
readLDR();
#endif

if (flash.writeAnything(pageNo, offset, configuration))
if (flash.writeAnything(_addr, configuration))
Serial.println ("Data write successful");
else
Serial.println ("Data write failed");
Expand All @@ -96,8 +116,8 @@ void setup() {
Serial.println(configuration.light);
Serial.println(configuration.adc);
Serial.println();
flash.readAnything(pageNo, offset, configuration);
flash.eraseSector(pageNo, 0);
flash.readAnything(_addr, configuration);
flash.eraseSector(_addr, 0);

Serial.println("After reading");
Serial.println(configuration.lux);
Expand All @@ -109,7 +129,7 @@ void setup() {
}

void loop() {
delay(1000);
delay(1000);
}

#ifdef SENSOR
Expand Down
10 changes: 8 additions & 2 deletions examples/TestFlash/TestFlash.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| SPIFlash library test v2.4.0 |
|----------------------------------------------------------------------------------------------------------------------------------|
| Marzogh |
| 11.09.2016 |
| 16.11.2016 |
|----------------------------------------------------------------------------------------------------------------------------------|
| (Please make sure your Serial monitor is set to 'No Line Ending') |
| ***************************************************************** |
Expand Down Expand Up @@ -80,11 +80,17 @@ String inputString, outputString;
#define Serial SERIAL_PORT_USBVIRTUAL
#endif

#if defined (SIMBLEE)
#define BAUD_RATE 250000
#else
#define BAUD_RATE 115200
#endif

SPIFlash flash;

void setup() {
delay(10);
Serial.begin(115200);
Serial.begin(BAUD_RATE);
Serial.print(F("Initialising Flash memory"));
for (int i = 0; i < 10; ++i)
{
Expand Down
Loading

0 comments on commit 2d10db9

Please sign in to comment.