Program for testing simple spi on FPGA

Dependencies:   mbed

Fork of SPI_HelloWorld_Mbed by mbed official

Revision:
1:cfd8aef8d053
Parent:
0:466ad3f38b6b
Child:
2:8b87ec0dce1b
--- a/main.cpp	Tue Feb 12 17:25:49 2013 +0000
+++ b/main.cpp	Fri Sep 07 00:28:02 2018 +0000
@@ -1,27 +1,22 @@
 #include "mbed.h"
  
-SPI spi(p5, p6, p7); // mosi, miso, sclk
-DigitalOut cs(p8);
+SPI spi(D11, D12, D13); // mosi, miso, sclk
+DigitalOut cs(D10);
  
-int main() {
-    // Chip must be deselected
+int main() 
+{    
     cs = 1;
+    uint8_t val = 0;
 
     // Setup the spi for 8 bit data, high steady state clock,
     // second edge capture, with a 1MHz clock rate
     spi.format(8,3);
     spi.frequency(1000000);
  
-    // Select the device by seting chip select low
-    cs = 0;
- 
-    // 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;
+    while (1) {
+        wait(0.5);
+        cs = 0;
+        spi.write(val++);
+        cs = 1;
+    }
 }
\ No newline at end of file