瀏覽代碼

Add sleep & wakeup (thanks rocketscream)

main
PaulStoffregen 9 年之前
父節點
當前提交
1ce2f5d753
共有 2 個檔案被更改,包括 19 行新增0 行删除
  1. +2
    -0
      SerialFlash.h
  2. +17
    -0
      SerialFlashChip.cpp

+ 2
- 0
SerialFlash.h 查看文件

@@ -39,6 +39,8 @@ public:
static bool begin();
static uint32_t capacity(const uint8_t *id);
static uint32_t blockSize();
static void sleep();
static void wakeup();
static void readID(uint8_t *buf);
static void read(uint32_t addr, void *buf, uint32_t len);
static bool ready();

+ 17
- 0
SerialFlashChip.cpp 查看文件

@@ -383,6 +383,23 @@ bool SerialFlashChip::begin()
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)
{
if (busy) wait();

Loading…
取消
儲存