This is an involuntary fork, created because the repository would not update mmSPI. SPI library used to communicate with an altera development board attached to four zigbee-header pins.

Dependents:   Embedded_RTOS_Project

Fork of mmSPI by Mike Moore

Revision:
5:b14dcaae260e
Parent:
4:aa1fe8707bef
Child:
6:b480fc4e87e5
diff -r aa1fe8707bef -r b14dcaae260e mmSPI.cpp
--- a/mmSPI.cpp	Wed Aug 14 14:47:12 2013 +0000
+++ b/mmSPI.cpp	Wed Aug 14 15:13:05 2013 +0000
@@ -41,11 +41,31 @@
     }
     
 //----------------------------------------------//------------------------------
-    char mmSPI::transceive_byte(char cSend)     // send/receive a byte.
+//  we're not going for speed, so lets go for good setup / hold.
+    void mmSPI::transceive_byte(void)           // send/receive a byte.
     {
-      *pSCLK = 1;
-    
-    
-    
+      cReceive = 0;                             // clear receive 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.
+        *pMOSI = (cSend >> cLoop01) & 1;        // assert MOSI.
+        wait(fSPIquarterP);                     // MOSI setup time
+        *pSCLK = 1;                             // SPI clock posedge.
+        wait(fSPIquarterP);                     // MISO setup time.
+        cReceive = cReceive | (*pMISO << cLoop01);
+        wait(fSPIquarterP);                     // finish-out cycle.
+      }
     }
-//----------------------------------------------//------------------------------
\ No newline at end of file
+//----------------------------------------------//------------------------------
+
+
+
+
+
+
+
+
+
+
+