Skip to content

Commit

Permalink
Merge branch 'stable' of github.com:Marzogh/SPIFlash into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marzogh committed Apr 20, 2019
2 parents 1815dba + 9eba1fa commit d2fe5a3
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 72 deletions.
10 changes: 5 additions & 5 deletions docs/pages/SPIFlash/chipID.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Example code:
flash.begin();
uint16_t manID = flash.getManID(); // Function is used to get the manufacturer ID and store it as
// a 16 bit unsigned integer
Serial.print("Chip Manufacturer ID: 0x");
Serial.print(F("Chip Manufacturer ID: 0x"));
Serial.println(manID, HEX); // The manufacturer ID is printed as a Hexadecimal number
...
}
Expand Down Expand Up @@ -101,7 +101,7 @@ Example code:
flash.begin();
uint32_t JEDEC = flash.getJEDECID(); // Function is used to get the JEDEC ID and store it as
// a 32 bit unsigned integer
Serial.print("JEDEC ID: 0x");
Serial.print(F("JEDEC ID: 0x"));
Serial.println(JEDEC, HEX); // The JEDEC ID is printed as a Hexadecimal number
...
}
Expand Down Expand Up @@ -150,7 +150,7 @@ Example code:
flash.begin();
uint64_t uniqueID = flash.getUniqueID(); // Function is used to get the unique ID and store it as
// a 64 bit unsigned integer
Serial.print("Unique ID: 0x");
Serial.print(F("Unique ID: 0x"));
Serial.println(uniqueID, HEX); // The unique ID is printed as a Hexadecimal number
...
}
Expand Down Expand Up @@ -197,7 +197,7 @@ Example code:
flash.begin();
uint32_t cap = flash.getCapacity(); // Function is used to get the unique ID and store it as
// a 32 bit unsigned integer
Serial.print("Capacity: ");
Serial.print(F("Capacity: "));
Serial.println(cap); // The unique ID is printed as a decimal number - in bytes
...
}
Expand Down Expand Up @@ -253,7 +253,7 @@ Example code:
flash.begin();
uint32_t maxPage = flash.getMaxPage(); // Function is used to get the number of pages and store it as
// a 32 bit unsigned integer
Serial.print("Maximum pages: ");
Serial.print(F("Maximum pages: "));
Serial.println(maxPage); // The number of pages is printed
...
}
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/SPIFlash/readArray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ Example code:
void setup() {
flash.begin();
_address = flash.getAddress(sizeof(dataIn));
Serial.print("Address = ");
Serial.print(F("Address = "));
Serial.println(_address);
dataIn = flash.readByteArray(_address, dataIn, _bufferSize);
// This function should be changed depending on the type of data being read from the flash memory
Serial.print("Data read: ");
Serial.print(F("Data read: "));
for (uint8_t i = 0; i < _bufferSize; i++) {
Serial.print(dataIn[i]);
Serial.print(", ");
Serial.print(F(", "));
}
Serial.println();
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/SPIFlash/readDataIndependent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ Example code:
void setup() {
flash.begin();
_address = flash.getAddress(sizeof(dataIn));
Serial.print("Address = ");
Serial.print(F("Address = "));
Serial.println(_address);
Serial.print("readAnything()");
Serial.print(F("readAnything()"));
if (!flash.readAnything(_address, dataIn)) { // Function is used to get the data from
// address '_address' and save it to the struct 'test'
Serial.println("Failed");
Serial.println(F("Failed"));
}
else {
Serial.println("Passed");
Serial.println(F("Passed"));
}
...
}
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/SPIFlash/readSingleVariable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Example code:
_address = flash.getAddress(sizeof(dataIn));
dataIn = flash.readByte(_address); // This function should be changed depending on the type of data
// being read from the flash memory
Serial.print("Address = ");
Serial.print(F("Address = "));
Serial.println(_address);
Serial.print("Data read : 0x");
Serial.print(F("Data read : 0x"));
Serial.println(dataIn, HEX);
}
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/SPIFlash/writeArray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ Example code:
void setup() {
flash.begin();
_address = flash.getAddress(sizeof(dataIn));
Serial.print("Address = ");
Serial.print(F("Address = "));
Serial.println(_address);
Serial.print("Data write: ");
Serial.print(F("Data write: "));
if (flash.writeByteArray(_address, dataOut, _bufferSize) {
// This function should be changed depending on the type of data being written to the flash memory
Serial.println ("Successful");
Serial.println(F("Successful"));
}
else {
Serial.println("Failed");
Serial.println(F("Failed"));
}
}
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/SPIFlash/writeDataIndependent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ Example code:
void setup() {
flash.begin();
_address = flash.getAddress(sizeof(dataIn));
Serial.print("Address = ");
Serial.print(F("Address = "));
Serial.println(_address);
Serial.print("writeAnything()");
Serial.print(F("writeAnything()"));
if (!flash.writeAnything(_address, dataOut)) { // Function is used to write the data to
// address '_address'
Serial.println("Failed");
Serial.println(F("Failed"));
}
else {
Serial.println("Passed");
Serial.println(F("Passed"));
}
...
}
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/SPIFlash/writeSingleVariable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ Example code:
void setup() {
flash.begin();
_address = flash.getAddress(sizeof(dataIn));
Serial.print("Address = ");
Serial.print(F("Address = "));
Serial.println(_address);
Serial.print("Data write ");
Serial.print(F("Data write "));
// This function should be changed depending on the type of data being written to the flash memory
if (flash.writeStr(_address, dataOut)) {
Serial.println("successful");
Serial.println(F("successful"));
}
else {
Serial.println("failed");
Serial.println(F("failed"));
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/SPIFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ SPIFlash::SPIFlash(uint8_t cs) {
//Identifies chip and establishes parameters
bool SPIFlash::begin(uint32_t flashChipSize) {
#ifdef RUNDIAGNOSTIC
Serial.println("Chip Diagnostics initiated.");
Serial.println(F("Chip Diagnostics initiated."));
Serial.println();
#endif
#ifdef HIGHSPEED
Serial.println("Highspeed mode initiated.");
Serial.println(F("Highspeed mode initiated."));
Serial.println();
#endif
BEGIN_SPI
Expand Down Expand Up @@ -1098,9 +1098,9 @@ bool SPIFlash::eraseSection(uint32_t _addr, uint32_t _sz) {
KB32Blocks = (noOf4KBEraseRuns % 16) / 8;
KB4Blocks = (noOf4KBEraseRuns % 8);
totalBlocks = KB64Blocks + KB32Blocks + KB4Blocks;
//Serial.print("noOf4KBEraseRuns: ");
//Serial.print(F("noOf4KBEraseRuns: "));
//Serial.println(noOf4KBEraseRuns);
//Serial.print("totalBlocks: ");
//Serial.print(F("totalBlocks: "));
//Serial.println(totalBlocks);

uint16_t _eraseFuncOrder[totalBlocks];
Expand All @@ -1126,7 +1126,7 @@ bool SPIFlash::eraseSection(uint32_t _addr, uint32_t _sz) {
noOfEraseRunsB4Boundary = (_sz - _addressOverflow)/16;
noOfEraseRunsB4Boundary += ((_sz - _addressOverflow) % 16) / 8;
noOfEraseRunsB4Boundary += ((_sz - _addressOverflow) % 8);
//Serial.print("noOfEraseRunsB4Boundary: ");
//Serial.print(F("noOfEraseRunsB4Boundary: "));
//Serial.println(noOfEraseRunsB4Boundary);
}
if (!_addressOverflow) {
Expand All @@ -1135,7 +1135,7 @@ bool SPIFlash::eraseSection(uint32_t _addr, uint32_t _sz) {
_endSPI();


//Serial.print("_eraseFuncOrder: 0x");
//Serial.printF("_eraseFuncOrder: 0x"));
//Serial.println(_eraseFuncOrder[j], HEX);

uint16_t _timeFactor = 0;
Expand All @@ -1155,7 +1155,7 @@ bool SPIFlash::eraseSection(uint32_t _addr, uint32_t _sz) {
if (!_prep(ERASEFUNC, (_addr + (_sz - _addressOverflow)), _sz)) {
return false;
}
//Serial.print("Overflow triggered");
//Serial.print(F("Overflow triggered"));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SPIFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ template <class T> bool SPIFlash::_write(uint32_t _addr, const T& value, uint32_
return false;
}
_addrIn = _currentAddress;
//Serial.print("_addrIn: ");
//Serial.print(F("_addrIn: "));
//Serial.println(_addrIn, HEX);
const uint8_t* p = ((const uint8_t*)(const void*)&value);
//Serial.print(F("Address being written to: "));
Expand Down
14 changes: 7 additions & 7 deletions src/SPIFlashIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
return false;
}

//Serial.print("_chip.capacity: ");
//Serial.print(F("_chip.capacity: "));
//Serial.println(_chip.capacity, HEX);

if (_submittedAddress + size >= _chip.capacity) {
//Serial.print("_submittedAddress + size: ");
//Serial.print(F("_submittedAddress + size: "));
//Serial.println(_submittedAddress + size, HEX);
#ifdef DISABLEOVERFLOW
_troubleshoot(OUTOFBOUNDS);
return false; // At end of memory - (!pageOverflow)
#else
_addressOverflow = ((_submittedAddress + size) - _chip.capacity);
_currentAddress = _addr;
//Serial.print("_addressOverflow: ");
//Serial.print(F("_addressOverflow: "));
//Serial.println(_addressOverflow, HEX);
return true; // At end of memory - (pageOverflow)
#endif
Expand All @@ -73,7 +73,7 @@
_currentAddress = _addr;
return true; // Not at end of memory if (address < _chip.capacity)
}
//Serial.print("_currentAddress: ");
//Serial.print(F("_currentAddress: "));
//Serial.println(_currentAddress, HEX);
}

Expand Down Expand Up @@ -559,15 +559,15 @@

if (_chip.supportedMan) {
#ifdef RUNDIAGNOSTIC
Serial.println("No Chip size defined by user. Checking library support.");
Serial.println(F("No Chip size defined by user. Checking library support."));
#endif
//Identify capacity
for (uint8_t j = 0; j < sizeof(_capID); j++) {
if (_chip.capacityID == _capID[j]) {
_chip.capacity = (_memSize[j]);
_chip.supported = true;
#ifdef RUNDIAGNOSTIC
Serial.println("Chip identified. This chip is fully supported by the library.");
Serial.println(F("Chip identified. This chip is fully supported by the library."));
#endif
return true;
}
Expand All @@ -592,7 +592,7 @@
if (flashChipSize) {
// If a custom chip size is defined
#ifdef RUNDIAGNOSTIC
Serial.println("Custom Chipsize defined");
Serial.println(F("Custom Chipsize defined"));
#endif
_chip.capacity = flashChipSize;
_chip.supported = false;
Expand Down
2 changes: 1 addition & 1 deletion src/SPIFlashSFDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool SPIFlash::_checkForSFDP(void) {
if (_getSFDPdword(SFDP_HEADER_ADDR, SFDP_SIGNATURE_DWORD) == SFDPSIGNATURE) {
_chip.sfdpAvailable = true;
#ifdef RUNDIAGNOSTIC
Serial.println("SFDP available");
Serial.println(F("SFDP available"));
#endif
}
else {
Expand Down

0 comments on commit d2fe5a3

Please sign in to comment.