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:
17:b81c0c1f312f
Parent:
16:0e422fd263c6
Child:
18:4a29cad91540
--- a/mmSPI.cpp	Mon Aug 19 16:26:29 2013 +0000
+++ b/mmSPI.cpp	Mon Aug 19 18:26:39 2013 +0000
@@ -255,8 +255,54 @@
       pcSend[7] = 0x02;
       pcSend[1] = ((cRegister & 0x07) << 2) | 0xA0;
       pcSend[0] = cValue & 0xFF;
+ 
+      transceive_vector2(pcReceive, pcSend, 8);
+ 
+      pcSend[7] = 0x00;
+      pcSend[6] = 0x00;
+      pcSend[5] = 0x00;
+      pcSend[4] = 0x00;
+      pcSend[3] = 0x00;
+      pcSend[2] = 0x00;
+      pcSend[1] = 0x00;
+      pcSend[0] = 0x00;
+    }
+//----------------------------------------------//------------------------------
+                                                // returns the content of
+                                                // a CPU register.
+    char mmSPI::read_register(char cRegister, char * pcReceive, char * pcSend)
+    { 
+      int dLoop;                                // send all 0.
+      for (dLoop = 0; dLoop < 8; dLoop++) pcSend = 0x00;    
       
- //     transceive_vector(pcReceive, pcSend, 8);
+                                                
+      transceive_vector2(pcReceive, pcSend, 8); // snap & scan-out reg contents.
+      
+      return (pcReceive[cRegister]);            // return the particular reg value.
+    }
+//----------------------------------------------//------------------------------
+
+
+    void mmSPI::write_pulse(char * pcReceive, char * pcSend)
+    {     
+      pcSend[7] = 0x02;                         // write-enable high.
+      pcSend[1] = 0x02;
+      pcSend[0] = 0x00;
+      transceive_vector2(pcReceive, pcSend, 8);
+      
+      pcSend[7] = 0x02;                         // write-enable low.
+      pcSend[1] = 0x00;
+      pcSend[0] = 0x00;
+      transceive_vector2(pcReceive, pcSend, 8);
+ 
+      pcSend[7] = 0x00;
+      pcSend[6] = 0x00;
+      pcSend[5] = 0x00;
+      pcSend[4] = 0x00;
+      pcSend[3] = 0x00;
+      pcSend[2] = 0x00;
+      pcSend[1] = 0x00;
+      pcSend[0] = 0x00;
     }
 //----------------------------------------------//------------------------------
 
@@ -273,6 +319,3 @@
 
 
 
-
-
-