ENPRA_Foot / Mbed 2 deprecated Nucleo_spi_slave

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Keith_N
Date:
Mon Nov 19 05:26:48 2018 +0000
Commit message:
spi_slave

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 19 05:26:48 2018 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+
+SPISlave device(PB_5,PB_4,PB_3,PA_4); // mosi, miso, sclk, ssel
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+
+int main()
+{
+    device.format(8,0);
+    device.frequency(1000000);
+    uint8_t hbyte = 7;
+    uint8_t lbyte = 208;
+
+    int counter = 0;
+
+    while(1) {        
+        if(device.receive()) {
+            
+            int val = device.read();
+            pc.printf("received1: %d, ",val);
+            device.reply(0xFF);
+
+            int val2 = device.read();
+            pc.printf("received2: %d, ",val2);
+            device.reply(hbyte);         // Make this the next reply
+
+            int val3 = device.read();
+            pc.printf("receive3: %d, ",val3);
+            pc.printf("count: %d\r\n",counter);
+            device.reply(lbyte);         // Make this the next reply
+
+            counter = counter+1;
+        }
+        wait(0.01);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 19 05:26:48 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file