For Master of SPI Communication between two LPC1768

Dependencies:   mbed

Revision:
0:382b3838a100
diff -r 000000000000 -r 382b3838a100 spi_master.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spi_master.cpp	Sat Jan 02 09:02:40 2021 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+SPI to_eps(p5,p6,p7);
+DigitalOut cs(p8);
+
+Serial pc(USBTX,USBRX);
+
+#define DTIME 0.1
+
+int main()
+{
+    pc.printf("--Hi,this is cdh(master).\r\n");
+    cs = 1;
+
+    to_eps.format(8,3);
+    to_eps.frequency(1000000);
+    int cmd = 0;
+
+    while(1) {
+        char c = pc.getc();
+        pc.printf("count: %d, ",cmd);
+
+        cs=0;
+        int dummy = to_eps.write(cmd); // send command
+        int rdata = to_eps.write(0x00);        
+        cs=1;
+        
+        pc.printf("dummy: %d, ",dummy);
+        pc.printf("rdata: %d\r\n",rdata);
+        
+        cmd++;
+    }
+}