SPI library used to communicate with an altera development board attached to four zigbee-header pins.

Revision:
3:de99451ab3c0
Parent:
2:bebcf53b72dc
Child:
4:aa1fe8707bef
--- a/mmSPI.cpp	Wed Aug 14 10:30:30 2013 +0000
+++ b/mmSPI.cpp	Wed Aug 14 10:45:33 2013 +0000
@@ -10,13 +10,27 @@
 //==============================================//==============================
     mmSPI::mmSPI()                              // constructor.
     {
-      pSCLK = new DigitalOut(p29);
+      allocations();                            // object allocations.
     }
 //----------------------------------------------//------------------------------    
     mmSPI::~mmSPI()                             // destructor.
     {
-
-    }  
+      if (pMOSI) {delete pMOSI; pMOSI = NULL;}  // delete allocation.
+      if (pMISO) {delete pMISO; pMISO = NULL;}  // delete allocation.
+      if (pSCLK) {delete pSCLK; pSCLK = NULL;}  // delete allocation.
+    } 
+//----------------------------------------------//------------------------------
+    void mmSPI::allocations(void)               // object allocations.
+    {
+      pMOSI = new DigitalOut(mmSPI_MOSI);       // SPI MOSI pin object.
+      if (!pMOSI) error("\n\r mmSPI::allocations : FATAL malloc error for pMOSI. \n\r"); 
+      
+      pMISO = new DigitalOut(mmSPI_MISO);      // SPI MISO pin object.
+      if (!pMISO) error("\n\r mmSPI::allocations : FATAL malloc error for pMISO. \n\r"); 
+    
+      pSCLK = new DigitalOut(mmSPI_SCLK);       // SPI SCLK pin object.
+      if (!pSCLK) error("\n\r mmSPI::allocations : FATAL malloc error for pSCLK. \n\r"); 
+    } 
 //----------------------------------------------//------------------------------
     char mmSPI::transceive_byte(char cSend)     // send/receive a byte.
     {