Software SPI allows non-standard SPI pins to be used for interfacing with SPI devices
Fork of SWSPI by
Diff: SWSPI.cpp
- Revision:
- 3:8c19911bdb58
- Parent:
- 2:eafe3ec5fbf8
diff -r eafe3ec5fbf8 -r 8c19911bdb58 SWSPI.cpp --- a/SWSPI.cpp Fri May 08 08:23:58 2015 +0000 +++ b/SWSPI.cpp Fri May 08 08:29:50 2015 +0000 @@ -50,7 +50,7 @@ void SWSPI::frequency(int hz) { // TODO: need wait_ns taking int - this->delay_s = 0.5f/hz; + this->delay_us = 500000/hz; } int SWSPI::write(int value) @@ -63,22 +63,22 @@ if (phase == 0) { if (miso && miso->read()) - read |= (1 << bit); + read |= bit; } sclk.write(!polarity); - wait(delay_s); + if (delay_us) wait_us(delay_us); if (phase == 1) { if (miso && miso->read()) - read |= (1 << bit); + read |= bit; } sclk.write(polarity); - wait(delay_s); + if (delay_us) wait_us(delay_us); } return read;