Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SerialFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class SerialFlashChip
static void write(uint32_t addr, const void *buf, uint32_t len);
static void eraseAll();
static void eraseBlock(uint32_t addr);

static void reset();

static SerialFlashFile open(const char *filename);
static bool create(const char *filename, uint32_t length, uint32_t align = 0);
static bool createErasable(const char *filename, uint32_t length) {
Expand Down
36 changes: 36 additions & 0 deletions SerialFlashChip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,42 @@ bool SerialFlashChip::begin(uint8_t pin)

// chips tested: https://github.com/PaulStoffregen/SerialFlash/pull/12#issuecomment-169596992
//
/*
7.2.43 Enable Reset (66h) and Reset (99h)
Because of the small package and the limitation on the number of pins, the W25Q64FV provide a
software Reset instruction instead of a dedicated RESET pin. Once the Reset instruction is accepted, any
on-going internal operations will be terminated and the device will return to its default power-on state and
lose all the current volatile settings, such as Volatile Status Register bits, Write Enable Latch (WEL)
status, Program/Erase Suspend status, Read parameter setting (P7-P0), Continuous Read Mode bit
setting (M7-M0) and Wrap Bit setting (W6-W4).
“Enable Reset (66h)” and “Reset (99h)” instructions can be issued in either SPI mode or QPI mode. To
avoid accidental reset, both instructions must be issued in sequence. Any other commands other than
“Reset (99h)” after the “Enable Reset (66h)” command will disable the “Reset Enable” state. A new
sequence of “Enable Reset (66h)” and “Reset (99h)” is needed to reset the device. Once the Reset
command is accepted by the device, the device will take approximately tRST=30us to reset. During this
period, no command will be accepted.
Data corruption may happen if there is an on-going or suspended internal Erase or Program operation
when Reset command sequence is accepted by the device. It is recommended to check the BUSY bit and
the SUS bit in Status Register before issuing the Reset command sequence.
*/
void SerialFlashChip::reset()
{
if (busy) wait();
busy = 1;
SPIPORT.beginTransaction(SPICONFIG);
CSASSERT();
SPIPORT.transfer(0x66); // Enable reset command
CSRELEASE();

// SPIPORT.beginTransaction(SPICONFIG);
CSASSERT();
SPIPORT.transfer(0x99); // Reset command
CSRELEASE();
delayMicroseconds(30);
busy = 0;
}


void SerialFlashChip::sleep()
{
if (busy) wait();
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ready KEYWORD2
create KEYWORD2
createWritable KEYWORD2
getAddress KEYWORD2
reset KEYWORD2
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SerialFlash
version=0.5
version=0.6
author=Paul Stoffregen
maintainer=Paul Stoffregen
sentence=Access SPI Serial Flash memory with filesystem-like functions
Expand Down