Browse Source

Add sleep & wakeup (thanks rocketscream)

main
PaulStoffregen 9 years ago
parent
commit
1ce2f5d753
2 changed files with 19 additions and 0 deletions
  1. +2
    -0
      SerialFlash.h
  2. +17
    -0
      SerialFlashChip.cpp

+ 2
- 0
SerialFlash.h View File

static bool begin(); static bool begin();
static uint32_t capacity(const uint8_t *id); static uint32_t capacity(const uint8_t *id);
static uint32_t blockSize(); static uint32_t blockSize();
static void sleep();
static void wakeup();
static void readID(uint8_t *buf); static void readID(uint8_t *buf);
static void read(uint32_t addr, void *buf, uint32_t len); static void read(uint32_t addr, void *buf, uint32_t len);
static bool ready(); static bool ready();

+ 17
- 0
SerialFlashChip.cpp View File

return true; return true;
} }


void SerialFlashChip::sleep()
{
if (busy) wait();
SPI.beginTransaction(SPICONFIG);
CSASSERT();
SPI.transfer(0xB9); // Deep power down command
CSRELEASE();
}

void SerialFlashChip::wakeup()
{
SPI.beginTransaction(SPICONFIG);
CSASSERT();
SPI.transfer(0xAB); // Wake up from deep power down command
CSRELEASE();
}

void SerialFlashChip::readID(uint8_t *buf) void SerialFlashChip::readID(uint8_t *buf)
{ {
if (busy) wait(); if (busy) wait();

Loading…
Cancel
Save