Ryo Od / Mbed 2 deprecated Nucleo_rtos_SPISlave_16bit_Test

Dependencies:   mbed-rtos mbed

Fork of Nucleo_rtos_SPISlave_Test by Ryo Od

Revision:
3:e35c6a9ad906
Parent:
2:46e25b11a043
Child:
4:3617af415d4c
--- a/main.cpp	Sat Oct 01 12:33:07 2016 +0000
+++ b/main.cpp	Tue Oct 04 04:58:34 2016 +0000
@@ -2,7 +2,7 @@
 #include "rtos.h"
 #include "SPISlave.h"
 
-#define SPI_SPEED   (10000000)
+#define SPI_SPEED   (4000000)
 
 BusOut Leds(PA_10, PB_3, PB_5, PB_4, PB_10, PA_8);
 //DigitalOut StepChangePin(PC_7);
@@ -41,13 +41,20 @@
 
     // RtosTimer
     RtosTimer stepTimer(stepUp, osTimerPeriodic, (void *)0);
-    stepTimer.start(250);   // BPM:60
+    stepTimer.start(500);   // BPM:30
     
     SpiS.reply(0);
+    uint8_t prevVal = 0;
+    uint8_t errCount = 0;
     while(1) {
         if(SpiS.receive()) {
-            int v = SpiS.read();   // Read byte from master
-            Leds.write(v);
+            uint8_t val = SpiS.read();   // Read byte from master
+            prevVal++;
+            if (val != prevVal) {
+                errCount++;
+                Leds.write(errCount);
+            }
+            prevVal = val;
             SpiS.reply(step % 16);
         }
     }