Ryo Od / Mbed 2 deprecated Nucleo_rtos_SPI_Master_Test

Dependencies:   mbed-rtos mbed st7565LCD

Revision:
5:915a9d45c969
Parent:
4:c2b67c69d048
Child:
6:66955ebd56dd
diff -r c2b67c69d048 -r 915a9d45c969 main.cpp
--- a/main.cpp	Tue Oct 04 01:26:14 2016 +0000
+++ b/main.cpp	Tue Oct 04 04:58:19 2016 +0000
@@ -2,7 +2,8 @@
 #include "rtos.h"
 #include "st7565LCD.h"
 
-#define SPI_SPEED   (10000000)
+#define SPI_SPEED       (4000000)
+#define SPI_DUMMY_DATA  (0x55)
 
 BusIn Switches(PA_0, PA_1, PA_4, PB_0, PC_1, PC_0);
 
@@ -26,6 +27,12 @@
 {
     printf("\r\n\nNucleo rtos SPI Master Test..\r\n");
     
+    #if DEVICE_SPI_ASYNCH
+    printf("DEVICE_SPI_ASYNCH: defined\r\n");
+    #else
+    printf("DEVICE_SPI_ASYNCH: not defined\r\n");
+    #endif
+    
     // Setup LCD
     
     gLCD.begin(0x10);
@@ -52,23 +59,21 @@
     Thread::wait(1000);
     //gLCD.clear();
     
+    uint8_t count = 0;
     for (;;) {
-        uint8_t sendVal = ~Switches.read();
-        
-        if (prevSendVal != sendVal || isStepChanged) {
-            SpiMCs = 0;
-            uint8_t receivedVal = SpiM.write(sendVal);
-            SpiMCs = 1;
-            
-            prevSendVal = sendVal;
-            
-            if (isStepChanged) {
-                char lineBuffer[20];
-                sprintf(lineBuffer, "Step: %02d", receivedVal);
-                gLCD.drawstring(0, 0, lineBuffer);
-                gLCD.display();
-                isStepChanged = false;
-            }
+        SpiMCs = 0;
+        uint8_t receivedVal = SpiM.write(count);
+        SpiMCs = 1;
+        count++;
+        if (isStepChanged) {
+            char lineBuffer[20];
+            sprintf(lineBuffer, "Step: %02d", receivedVal);
+            gLCD.drawstring(0, 0, lineBuffer);
+            gLCD.display();
+            isStepChanged = false;
+
         }
+        //Thread::wait(1);
+        wait_us(100);
     }
 }