![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
FINAL PROJECT isn't it
Fork of ELEC351 by
SPI.cpp
- Committer:
- thomasmorris
- Date:
- 2018-08-15
- Revision:
- 57:aba1296e51b1
- Parent:
- 56:bc5345bc6650
File content as of revision 57:aba1296e51b1:
#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);} pc.printf("Received data = %d\n", SPI_RX_DATA); Thread::wait(1000); */ }