
test
Fork of SPI_master_mdot by
Diff: main.cpp
- Revision:
- 0:bd27ff0337e4
- Child:
- 1:d34b1023e89b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 10 05:19:39 2016 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" + +SPI spimaster(SPI1_MOSI, SPI1_MISO, SPI1_SCK); +DigitalOut cs(SPI1_CS); + +int main() +{ + int response; + // 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 + spimaster.format(8,0); + spimaster.frequency(1000000); + while(true) + { + // Select the device by seting chip select low + cs = 0; + + // Send a dummy byte to receive response from the slave + response = spimaster.write(0x00); + printf("\r\nSlave response = 0x%X", response); + + // Deselect the device + cs = 1; + wait(1); + } +} \ No newline at end of file