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

Revision:
32:5a5d9525c6c4
Parent:
31:ea7b25e494b5
Child:
34:d5553509f31a
--- a/mmSPI.h	Sun Aug 25 20:12:32 2013 +0000
+++ b/mmSPI.h	Mon Aug 26 22:39:44 2013 +0000
@@ -2,15 +2,16 @@
 #define mmSPI_H                                 // include guard.
 /*----------------------------------------------//------------------------------
     student   : m-moore
-    class     : external SPI interface
+    email     : gated.clock@gmail.com
+    class     : usb device drivers
     directory : mmSPI
     file      : mmSPI.h
+    date      : september 3, 2013.
 ----description---------------------------------//------------------------------    
 ----notes---------------------------------------//------------------------------ 
     1. the SPI interface pins are routed to the zigbee header.
 ------------------------------------------------//----------------------------*/
     #include "mbed.h"                           // standard mbed.org class.
-    #include "C12832_lcd.h"                     // LCD.
 //---defines------------------------------------//------------------------------
     #define mmSPI_MOSI p29                      // SPI interface pin.
     #define mmSPI_MISO p30                      // SPI interface pin.
@@ -23,41 +24,48 @@
     class mmSPI
     {
       public:
-             mmSPI();                           // constructor.
-            ~mmSPI();                           // destructor.
-        void allocations();                     // object allocations.
-        void setSPIfrequency (float);           // initializations.
-        void setSendBuffer   (char * pcSendBuffer);
-        void setReceiveBuffer(char * pcReceiveBuffer);
-        void setNumberOfBytes(int    dNumberOfBytes);
+                      mmSPI();                  // constructor.
+                     ~mmSPI();                  // destructor.
+        void          allocations();            // object allocations.       
+        
+        void          setSPIfrequency (float);  // initializations.
+        void          setSendBuffer   (char * pcSendBuffer);
+        void          setReceiveBuffer(char * pcReceiveBuffer);
+        void          setNumberOfBytes(int    dNumberOfBytes);
 
                                                 // SPI transceive loop.
-        void transceive_vector(char cPreCPU, char cPreSPI, char cScan, char cPostCPU);
+        void          transceive_vector(char cPreCPU, char cPreSPI, char cScan, char cPostCPU);       
         
                                                 // write/read CPU registers.     
-        void write_register(char cRegister, char cValue);
-        char read_register (char cRegister);
+        void          write_register(char cRegister, char cValue);
+        char          read_register (char cRegister);
+        
                                                 // write/read CPU main-memory.
-        void         write_memory(char cHData, char cLdata, char cAddress);
-        unsigned int read_memory (char cAddress);
+        void          write_memory(char cHData, char cLdata, char cAddress);
+        unsigned int  read_memory (char cAddress);
+        
+        void          step();                   // step the CPU.
         
-        void step();                            // step the CPU.
+        void          clear_transmit_vector();  // fill with 0.
         
-        void clear_transmit_vector();           // fill with 0.
+        unsigned long SPIClockCount();          // return SPI clock count.
+        unsigned long CPUClockCount();          // return CPU clock count.      
         
       private:
       
-      DigitalOut * pMOSI;                       // SPI pin.
-      DigitalOut * pMISO;                       // SPI pin.
-      DigitalOut * pSCLK;                       // SPI pin.
-      DigitalOut * pCPUclk;                     // soft cpu clock.
-      char       * pcSend;                      // SPI transmit vector.
-      char       * pcReceive;                   // SPI receive  vector.
-      float        fSPIfreq;                    // SPI clock   frequency.
-      float        fSPIquarterP;                // SPI quarter period.
-      int          dNumBytes;                   // number of SPI bytes.
-      int          dLoop01;                     // loop index.
-      int          dLoop02;                     // loop index.
+      DigitalOut  * pMOSI;                      // SPI pin.
+      DigitalOut  * pMISO;                      // SPI pin.
+      DigitalOut  * pSCLK;                      // SPI pin.
+      DigitalOut  * pCPUclk;                    // soft cpu clock.
+      char        * pcSend;                     // SPI transmit vector.
+      char        * pcReceive;                  // SPI receive  vector.
+      float         fSPIfreq;                   // SPI clock   frequency.
+      float         fSPIquarterP;               // SPI quarter period.
+      int           dNumBytes;                  // number of SPI bytes.
+      int           dLoop01;                    // loop index.
+      int           dLoop02;                    // loop index.
+      unsigned long ulSPIclkCount;              // SPI clock count.
+      unsigned long ulCPUclkCount;              // CPU clock count.
     };
 //----------------------------------------------//------------------------------
 #endif                                          // include guard.
\ No newline at end of file