Skip to content

Arduino Library for Winbond Flash Memory Chips

Compare
Choose a tag to compare
@Marzogh Marzogh released this 13 Nov 15:23
· 378 commits to master since this release

SPIFlash Build Status DOI

GitHub commits
GitHub issues
GitHub pull requests
license

Please report any bugs in issues.

This Arduino library is for use with Winbond serial flash memory chips. In its current form it supports identifying the flash chip and its various features; automatic address allocation and management; reading and writing bytes/chars/ints/longs/floats/Strings from and to various locations; reading and writing pages of bytes; continous reading/writing of data from/to arrays of bytes/chars; sector, block and chip erase; and powering down for low power operation.

  • For details of the Winbond Flash chips compatible with this library please refer to the Excel spreadsheet in the Extras folder.

Compatibility

Arduino IDE versions
  • IDE v1.5.x
  • IDE v1.6.0-v1.6.5
  • IDE v1.6.9-v1.6.11
Boards
  • Arduino Uno
  • Arduino Leonardo
  • Arduino Micro
  • Arduino Fio
  • Arduino Mega
  • Arduino Due
  • ESP8266 (On the Arduino IDE)
  • ATTiny85

Installation

Option 1
  • Click on the 'Download zip' below.
  • Unzip the archive and rename resulting folder to 'SPIFlash'
  • Move the folder to your libraries folder (~/sketches/libraries)
Option 2
  • Open the Arduino IDE.
  • Go to Sketch > Include Library > Manage libraries.
  • Search for SPIFlash.
  • Install the latest version.

Change log

v2.5.0

Bugs Squashed:
  • Errorchecking on writeByteArray() and writeCharArray() was broken in 2.4.0 and is fixed now.
  • Previous versions (< 2.5.0) suffered from the inability to write datasets that spanned page boundaries. This has now been fixed (Ref. Enhancements section below)
Deletions
  • flash.writePage() & flash.readPage() have been retired as they can be duplicated - more effectively - by other functions. Refer to pageDiag() in Diagnostics.ino to see how the same results can be obtained by using flash.writeByteArray() & flash.readByteArray().
Enhancements & Optimizations:
  • Added support for SPI Transactions.
  • Added an upgrade for Arduino Due users to read and write large arrays of data at very high speeds - previously reading 60kb of data would take ~108ms - it now takes ~525uS. In this mode, the time between consecutive reads has been reduced to <12ms (needs more work!).
  • Completely re-written writeByteArray() and writeCharArray() functions. They no longer breakdown when writing arrays that span multiple pages.
  • All functions that write more than 1 byte of data now take into account page boundaries when writing across pages. In previous versions writing across a page boundary would cause the remainder of the data to wrap around to the beginning of the page. Now the data is written seamlessly from one page over to the next.
  • Calling flash.begin() now instantiates the SPI bus. Comms with other SPI slaves do not need to call SPI.begin() if flash.begin() has already been called first in the user's code.
  • Sped up _beginSPI(). Code in _beginSPI() instantiates the SPI bus if another SPI comms library has shut it down.
  • Added function allowing setting SPI clock speeds - call the function flash.setClock(uint32_t clockSpeed); straight after begin();.
  • Made _beginSPI() & _nextByte() shorter and faster.
  • Replaced all calls to SPI.transfer() with xfer() to make the code more human readable and to enable simplicity when switching platforms.
  • Added the ability to change Chip Erase wait times depending on the chip (supported chips only).
  • Don't need to #include <SPI.h> in user code anymore. Just #include<SPIFlash.h> will do. Examples are now updated.
  • Now supports & uses SPI.transfer(*buf, count) along with the standard SPI.transfer(), speeding up the read/write of anything larger than an byte (AVR Boards only)
  • Reduces the program storage space in the uC's flash (AVR Boards)