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.
Diff: mmSPI.cpp
- Revision:
- 4:aa1fe8707bef
- Parent:
- 3:de99451ab3c0
- Child:
- 5:b14dcaae260e
--- a/mmSPI.cpp Wed Aug 14 10:45:33 2013 +0000
+++ b/mmSPI.cpp Wed Aug 14 14:47:12 2013 +0000
@@ -31,6 +31,15 @@
pSCLK = new DigitalOut(mmSPI_SCLK); // SPI SCLK pin object.
if (!pSCLK) error("\n\r mmSPI::allocations : FATAL malloc error for pSCLK. \n\r");
}
+//----------------------------------------------//------------------------------
+ void mmSPI::setSPIfrequency(float fFreq) // set SPI clock frequency.
+ {
+ fSPIfreq = fFreq; // promote to object scope.
+ if (fSPIfreq < .05) // don't get near divide-by-zero.
+ error("\n\r mmSPI::setSPIfrequency : FATAL SPI frequency set too low. \n\r");
+ fSPIquarterP = (1 / fSPIfreq) / 4; // figure quarter-cycle period.
+ }
+
//----------------------------------------------//------------------------------
char mmSPI::transceive_byte(char cSend) // send/receive a byte.
{