Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 11u35_usbLocalFilesystem
Fork of SWSPI by
Diff: SWSPI.cpp
- Revision:
- 3:8c6310f2038f
- Parent:
- 2:457a920a1223
--- 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;
}
