Ryo Od / Mbed 2 deprecated Nucleo_rtos_SPISlave_16bit_Test

Dependencies:   mbed-rtos mbed

Fork of Nucleo_rtos_SPISlave_Test by Ryo Od

Revision:
4:3617af415d4c
Parent:
3:e35c6a9ad906
--- a/main.cpp	Tue Oct 04 04:58:34 2016 +0000
+++ b/main.cpp	Tue Oct 04 06:43:09 2016 +0000
@@ -3,6 +3,7 @@
 #include "SPISlave.h"
 
 #define SPI_SPEED   (4000000)
+#define SPI_HEADER  (0x55)
 
 BusOut Leds(PA_10, PB_3, PB_5, PB_4, PB_10, PA_8);
 //DigitalOut StepChangePin(PC_7);
@@ -36,7 +37,7 @@
     }
 
     // Setup SPISlave
-    SpiS.format(8, 0);
+    SpiS.format(16, 0);
     SpiS.frequency(SPI_SPEED);
 
     // RtosTimer
@@ -48,13 +49,13 @@
     uint8_t errCount = 0;
     while(1) {
         if(SpiS.receive()) {
-            uint8_t val = SpiS.read();   // Read byte from master
+            uint16_t val = SpiS.read();
             prevVal++;
-            if (val != prevVal) {
+            if ((val & 0xff00) != (SPI_HEADER << 8) || (val & 0xff) != prevVal) {
                 errCount++;
                 Leds.write(errCount);
             }
-            prevVal = val;
+            prevVal = val & 0xff;
             SpiS.reply(step % 16);
         }
     }