Ishwar anjana
/
spi_comm
spi_comm
Fork of spi_comm by
main.cpp
- Committer:
- Ishwar_Anjana
- Date:
- 2017-12-25
- Revision:
- 1:5a737795f89c
- Parent:
- 0:ff086cd5333c
File content as of revision 1:5a737795f89c:
#include "mbed.h" #include "SPI.h" SPI spi(D11, D12, D13); // mosi, miso, sclk DigitalOut cs(D9); char hello[14] = "Hello World \n"; int main() { // Chip must be deselected cs = 1; // Setup the spi for 8 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate spi.format(8,0); spi.frequency(1000000); // Select the device by seting chip select low // Send 0x8f, the command to read the WHOAMI register //spi.write(0x8F); // Send a dummy byte to receive the contents of the WHOAMI register while(1){ cs = 0; for(int i=0; i<14; i++){ spi.write(hello[i]); } wait(2); cs = 1; wait(1); } // Deselect the device }