Winbond W25Q80BV SPI library
Diff: W25Q80BV.cpp
- Revision:
- 1:72b556f51896
- Parent:
- 0:6f374c3ed666
- Child:
- 2:e8dc659cf54e
--- a/W25Q80BV.cpp Wed Jan 29 02:05:38 2014 +0000 +++ b/W25Q80BV.cpp Thu Jan 30 00:51:50 2014 +0000 @@ -113,7 +113,7 @@ } -//ENABLE/DISABLE (private functions) +//Private Functions void W25Q80BV::writeEnable() { chipEnable(); this->writeSPI(WE_INST); @@ -131,22 +131,21 @@ _cs = 1; } //Sends and receives 1 byte of SPI data MSB endianness -int writeSPI(int data){ - +int W25Q80BV::writeSPI(int data){ int aux =0,aux2=0,i=0,read=0; //aux=data; for(i=0;i<8;i++){ _sclk = 0; //output aux = data&0x80; - aux = aux>>7; + aux >>= 7; _mosi = aux; - data = data>>1; + data <<= 1; //input - read = read<<1; + read <<= 1; aux2 = _miso; - read = read|aux2; + read |= aux2; + _sclk = 1; } - read = read>1; //This might not be needed return read; } \ No newline at end of file