Winbond W25Q32 SPI library. Tested on Winbond W74M32 embedded on Hani-IoT. Based on https://os.mbed.com/users/perezalvarezhi/code/W25Q80BV/
Diff: W25Q32.cpp
- Revision:
- 1:d3928deefb53
- Parent:
- 0:cc8118fdcc22
--- a/W25Q32.cpp Wed Jan 08 11:13:52 2020 +0100 +++ b/W25Q32.cpp Wed Jan 08 11:17:24 2020 +0100 @@ -4,7 +4,7 @@ } -int W25Q80BV::getMID() +int W25Q32::getMID() { int ID = 0; chipEnable(); @@ -18,7 +18,7 @@ return ID; } -int W25Q80BV::readByte(int addr) +int W25Q32::readByte(int addr) { chipEnable(); this->writeSPI(READ_DATA); @@ -30,7 +30,7 @@ return response; } -int W25Q80BV::readByte(int a2, int a1, int a0) +int W25Q32::readByte(int a2, int a1, int a0) { chipEnable(); this->writeSPI(READ_DATA); @@ -41,7 +41,7 @@ chipDisable(); return response; } -void W25Q80BV::readStream(int addr, char* buf, int count) +void W25Q32::readStream(int addr, char* buf, int count) { if (count < 1) { return; @@ -60,7 +60,7 @@ chipDisable(); } -void W25Q80BV::writeByte(int addr, int data) +void W25Q32::writeByte(int addr, int data) { writeEnable(); chipEnable(); @@ -74,7 +74,7 @@ thread_sleep_for(WAIT_TIME); } -void W25Q80BV::writeByte(int a2, int a1, int a0, int data) +void W25Q32::writeByte(int a2, int a1, int a0, int data) { writeEnable(); chipEnable(); @@ -88,7 +88,7 @@ thread_sleep_for(WAIT_TIME); } -void W25Q80BV::writeStream(int addr, char* buf, int count) { +void W25Q32::writeStream(int addr, char* buf, int count) { if (count < 1) { return; } @@ -109,7 +109,7 @@ thread_sleep_for(WAIT_TIME); } -void W25Q80BV::chipErase() +void W25Q32::chipErase() { writeEnable(); chipEnable(); @@ -119,32 +119,32 @@ thread_sleep_for(WAIT_TIME); } -void W25Q80BV::writeEnable() +void W25Q32::writeEnable() { chipEnable(); this->writeSPI(WRITE_ENABLE); chipDisable(); } -void W25Q80BV::writeDisable() +void W25Q32::writeDisable() { chipEnable(); this->writeSPI(WRITE_DISABLE); chipDisable(); } -void W25Q80BV::chipEnable() +void W25Q32::chipEnable() { _cs = 0; } -void W25Q80BV::chipDisable() +void W25Q32::chipDisable() { _cs = 1; } // Sends and receives 1 byte of SPI data MSB endianness -int W25Q80BV::writeSPI(int data){ +int W25Q32::writeSPI(int data){ int i; int aux = 0; int aux2 = 0;