Software SPI allows non-standard SPI pins to be used for interfacing with SPI devices
Fork of SWSPI by
Revision 1:9e0c0217646d, committed 2015-05-08
- Comitter:
- lionello
- Date:
- Fri May 08 08:05:29 2015 +0000
- Parent:
- 0:6a500a08c7fd
- Child:
- 2:eafe3ec5fbf8
- Commit message:
- Made miso pin optional (accept NC)
Changed in this revision
SWSPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SWSPI.cpp Tue Feb 04 06:54:01 2014 +0000 +++ b/SWSPI.cpp Fri May 08 08:05:29 2015 +0000 @@ -23,10 +23,11 @@ #include <mbed.h> #include "SWSPI.h" -SWSPI::SWSPI(PinName mosi_pin, PinName miso_pin, PinName sclk_pin) +SWSPI::SWSPI(PinName mosi_pin, PinName miso_pin, PinName sclk_pin) : miso(NULL) { mosi = new DigitalOut(mosi_pin); - miso = new DigitalIn(miso_pin); + if (miso_pin!= NC) + miso = new DigitalIn(miso_pin); sclk = new DigitalOut(sclk_pin); format(8); frequency(); @@ -62,7 +63,7 @@ if (phase == 0) { - if (miso->read()) + if (miso && miso->read()) read |= (1 << bit); } @@ -72,7 +73,7 @@ if (phase == 1) { - if (miso->read()) + if (miso && miso->read()) read |= (1 << bit); }