For Master of SPI Communication between two LPC1768

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
taiga_prelude
Date:
Sat Jan 02 09:02:40 2021 +0000
Commit message:
1st upload

Changed in this revision

mbed.bld Show annotated file Show diff for this revision Revisions of this file
spi_master.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 382b3838a100 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jan 02 09:02:40 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
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++;
+    }
+}