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

mmSPI.h

Committer:
gatedClock
Date:
2013-08-14
Revision:
7:b3e8b537d5c2
Parent:
6:b480fc4e87e5
Child:
8:e2d8bbc3e659

File content as of revision 7:b3e8b537d5c2:

#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.
//---defines------------------------------------//------------------------------
    #define mmSPI_MOSI p9                       // SPI interface pin.
    #define mmSPI_MISO p10                      // SPI interface pin.
    #define mmSPI_SCLK p30                      // SPI interface pin.
    
    

/*----------------------------------------------//------------------------------  
------------------------------------------------//----------------------------*/

//==============================================//==============================
    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);
      private:
      
      DigitalOut * pMOSI;                       // SPI pin.
      DigitalOut * pMISO;                       // SPI pin.
      DigitalOut * pSCLK;                       // SPI pin.
      float        fSPIfreq;                    // SPI clock   frequency.
      float        fSPIquarterP;                // SPI quarter period.
      char         cLoop01;                     // loop index.
      char         cLoop02;                     // loop index.
      
      

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