forked library from davervw/SWSPI
Dependents: 11u35_usbLocalFilesystem
Fork of SWSPI by
Diff: SWSPI.cpp
- Revision:
- 3:8c6310f2038f
- Parent:
- 2:457a920a1223
diff -r 457a920a1223 -r 8c6310f2038f SWSPI.cpp --- a/SWSPI.cpp Fri Mar 04 10:33:56 2016 +0000 +++ b/SWSPI.cpp Thu Jul 07 01:45:53 2016 +0000 @@ -24,10 +24,13 @@ SWSPI::SWSPI(PinName mosi_pin, PinName miso_pin, PinName sclk_pin):_fast(false) { - mosi = new DigitalOut(mosi_pin); - miso = new DigitalIn(miso_pin); - sclk = new DigitalOut(sclk_pin); - format(8); + mosi = new DigitalInOut(mosi_pin); + miso = new DigitalInOut(miso_pin); + sclk = new DigitalInOut(sclk_pin); + mosi->output(); + miso->input(); + sclk->output(); + format(8,0); frequency(); } @@ -58,6 +61,9 @@ int SWSPI::write(int value) { + mosi->output(); + miso->input(); + sclk->output(); int read = 0; if (_fast) { read = fast_write(value); @@ -84,6 +90,9 @@ wait_us(1000000/freq/2); } } + mosi->input(); + miso->input(); + sclk->input(); return read; }