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

mmSPI.h

Committer:
gatedClock
Date:
2013-08-20
Revision:
23:dbd89a56716d
Parent:
22:7524dee5c753
Child:
24:d3b8c68f41f2

File content as of revision 23:dbd89a56716d:

#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.

                                                // SPI transceive loop.
        void transceive_vector();
        

                                
        void write_register(char cRegister, char cValue);
        char read_register(char cRegister);

        void write_memory(char cHData, char cLdata, char cAddress);
        unsigned int read_memory(char cAddress);
        
        void setSendBuffer(char * pcSendBuffer);
        void setReceiveBuffer(char * pcReceiveBuffer);
        void setNumberOfBytes(int dNumberOfBytes);

      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.
    };
//----------------------------------------------//------------------------------
#endif                                          // include guard.