Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
SPI.cpp
- Committer:
- thomasmorris
- Date:
- 2018-07-16
- Revision:
- 56:bc5345bc6650
- Parent:
- 53:71f59e195f06
- Child:
- 57:aba1296e51b1
File content as of revision 56:bc5345bc6650:
#include "SPI.hpp" //File for SPI communication int SPI_RX_DATA = 0; 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; } void SPI_INTERFACE_SERIAL() { //pc.printf("SPI Test \n"); Thread::wait(1000); cs= 0; SPI_RX_DATA = spi.write(0xF0); wait_us(3); cs= 1; colour_data = SPI_RX_DATA; if(Log_Value == 1){pc.printf("Received data = %d\n", SPI_RX_DATA);} Thread::wait(1000); }