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: Embedded_RTOS_Project
Fork of mmSPI by
Revision 7:b3e8b537d5c2, committed 2013-08-14
- Comitter:
- gatedClock
- Date:
- Wed Aug 14 15:34:10 2013 +0000
- Parent:
- 6:b480fc4e87e5
- Child:
- 8:e2d8bbc3e659
- Commit message:
- void mmSPI::transceive_vector(char *cReceive, char *cSend, char cNumBytes)
Changed in this revision
| mmSPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mmSPI.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/mmSPI.cpp Wed Aug 14 15:19:24 2013 +0000
+++ b/mmSPI.cpp Wed Aug 14 15:34:10 2013 +0000
@@ -43,10 +43,11 @@
// we're not going for speed, so lets go for good setup / hold.
// send/receive a byte over SPI.
+ // MSB out/in first.
void mmSPI::transceive_byte(char *cReceive, char *cSend)
{
*cReceive = 0; // clear receive byte.
- for (cLoop01 = 7; cLoop01 >= 0; cLoop01++)// loop for 8 bits in the byte.
+ for (cLoop01 = 7; cLoop01 >= 0; cLoop01--)// loop for 8 bits in the byte.
{
*pSCLK = 0; // SPI clock negedge.
wait(fSPIquarterP); // until middle of clock low.
@@ -59,6 +60,15 @@
}
}
//----------------------------------------------//------------------------------
+ // transceive a character array.
+ // limit is 256 characters.
+ // MSB out/in first.
+ void mmSPI::transceive_vector(char *cReceive, char *cSend, char cNumBytes)
+ {
+ for (cLoop02 = (cNumBytes - 1); cLoop02 >= 0; cLoop02--)
+ transceive_byte(&(cReceive[cLoop02]), &(cSend[cLoop02]));
+ }
+//----------------------------------------------//------------------------------
@@ -68,3 +78,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
--- a/mmSPI.h Wed Aug 14 15:19:24 2013 +0000
+++ b/mmSPI.h Wed Aug 14 15:34:10 2013 +0000
@@ -31,6 +31,9 @@
// byte transceive.
void transceive_byte(char *cReceive, char *cSend);
+
+ // byte-array transceive.
+ void transceive_vector(char *cReceive, char *cSend, char cNumBytes);
private:
DigitalOut * pMOSI; // SPI pin.
@@ -39,6 +42,7 @@
float fSPIfreq; // SPI clock frequency.
float fSPIquarterP; // SPI quarter period.
char cLoop01; // loop index.
+ char cLoop02; // loop index.
