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

mmSPI.h

Committer:
gatedClock
Date:
2013-08-19
Revision:
16:0e422fd263c6
Parent:
15:d6cc57c4e23d
Child:
17:b81c0c1f312f

File content as of revision 16:0e422fd263c6:

#ifndef mmSPI_H                                 // include guard.
#define mmSPI_H                                 // include guard.
/*----------------------------------------------//------------------------------
    student   : m-moore
    class     : external SPI interface
    directory : mmSPI
    file      : mmSPI.h
----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.
    #define mmSPI_SCLK p9                       // SPI interface pin.
    #define mmCPU_CLK  p10                      // soft CPU system clock.
    
 
/*----------------------------------------------//------------------------------  
------------------------------------------------//----------------------------*/

//==============================================//==============================
    class mmSPI
    {
      public:
             mmSPI();                           // constructor.
            ~mmSPI();                           // destructor.
        void allocations();                     // object allocations.
        void setSPIfrequency(float);            // set SPI clock frequency.

                                                // byte transceive.
        void transceive_byte(char *cReceive, char *cSend);
        
                                                // byte-array transceive.
        void transceive_vector(char *cReceive, char *cSend, char cNumBytes);
        
         void transceive_vector2(char *cReceive, char *cSend, int cNumBytes);
        
        void test_toggle_cpu_clock();           // cpu clock toggle test.
        
        void force_write(char, char, char);     // force write.  act as IR.
        void force_read(char);
        
        void write_register(char, char, char *, char *);

      private:
      
      DigitalOut * pMOSI;                       // SPI pin.
      DigitalOut * pMISO;                       // SPI pin.
      DigitalOut * pSCLK;                       // SPI pin.
      DigitalOut * pCPUclk;                     // soft cpu clock.
      float        fSPIfreq;                    // SPI clock   frequency.
      float        fSPIquarterP;                // SPI quarter period.
      int          dLoop01;                     // loop index.
      int          dLoop02;                     // loop index.
      
      

    };
//----------------------------------------------//------------------------------
#endif                                          // include guard.