Motor Control board Slave control

Dependencies:   mbed

Revision:
0:673453dbcc7a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 29 16:05:05 2017 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+//DigitalOut myled(LED1);
+
+SPISlave device(PB_5,PB_4, PB_3, PA_4); // mosi, miso, sclk, ssel
+Serial pc(SERIAL_TX, SERIAL_RX);
+ 
+ int main() {
+    pc.baud(115200);
+    pc.printf("The F303K8 is working \n\r");
+    char v = 0;
+    device.reply(0x00);              // Prime SPI with first reply
+    device.format(8,3);
+    device.frequency(1000000);
+     while(1) {
+         //pc.printf("Slave is about to read");
+
+         if(device.receive()) {
+             
+            v = device.read();   // Read byte from master
+                // Add one to it, modulo 256
+             pc.printf("Slave recieved byte %c \n\r",v);
+             //device.reply(v);         // Make this the next reply
+         }
+     }
+ }
\ No newline at end of file