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.
Fork of SWSPI by
Revision 3:8c19911bdb58, committed 2015-05-08
- Comitter:
- lionello
- Date:
- Fri May 08 08:29:50 2015 +0000
- Parent:
- 2:eafe3ec5fbf8
- Commit message:
- Use wait_us instead of wait(float)
Changed in this revision
| SWSPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SWSPI.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
--- a/SWSPI.h Fri May 08 08:23:58 2015 +0000
+++ b/SWSPI.h Fri May 08 08:29:50 2015 +0000
@@ -55,7 +55,7 @@
int8_t bits;
int8_t polarity; // idle clock value
int8_t phase; // 0=sample on leading (first) clock edge, 1=trailing (second)
- float delay_s;
+ unsigned delay_us;
public:
/** Create SWSPI object
