Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

SPI.cpp

Committer:
thomasmorris
Date:
2018-05-07
Revision:
53:71f59e195f06
Child:
56:bc5345bc6650

File content as of revision 53:71f59e195f06:

#include "SPI.hpp"
//File for SPI communication



void SPI_INIT()
{
    
    
    /*
    MOSI = Blue
    MISO = White
    SCLK = Yellow
    Slave Select = Green
    
    */

 
    // Chip must be deselected
    cs = 1; //Active Low

    // Setup the spi for 8 bit data, high steady state clock,
    // second edge capture, with a 1MHz clock rate
    spi.format(16,0); // 8 Data bits phase 0 polarity 0
    spi.frequency(1000000);//Output clock frequency 1Mhz
 
    // Select the device by seting chip select low
    //cs = 0;//This is active after spi is set up
 
    // Send 0x8f, the command to read the WHOAMI register
    //spi.write(0x8F);
 
    // Send a dummy byte to receive the contents of the WHOAMI register
    //int whoami = spi.write(0x00);
    //printf("WHOAMI register = 0x%X\n", whoami);
    // Deselect the device
    //cs = 1;
}