Ryo Od / Mbed 2 deprecated Nucleo_rtos_SPI_Master_Test

Dependencies:   mbed-rtos mbed st7565LCD

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Thu Sep 29 07:46:45 2016 +0000
Parent:
1:74e13cd94576
Child:
3:2b2c6c0e9f1d
Commit message:
some update

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Sep 29 07:41:01 2016 +0000
+++ b/main.cpp	Thu Sep 29 07:46:45 2016 +0000
@@ -10,28 +10,13 @@
 DigitalOut SpiMCs(PB_6);
 
 InterruptIn stepChangeInterrupt(PC_7);
-//DigitalOut myled(PA_10);
 
 volatile bool isStepChanged = false;
 uint8_t prevSendVal = 0x00;
 
-//float delay = 1.0f;
-
 void setChangeStep()
 {
     isStepChanged = true;
-    /*
-    static uint8_t f = 0x0f;
-    
-    Leds.write(f);
-    f = ~f & 0x0f;
-    */
-    /*
-    if (delay == 1.0)
-        delay = 0.2; // 200 ms
-    else
-        delay = 1.0; // 1 sec
-    */
 }
 
 int main()
@@ -65,19 +50,18 @@
     
     for (;;) {
         uint8_t sendVal = ~Switches.read();
-        static uint8_t receivedVal;
         
-        //if (prevSendVal != sendVal) {
+        if (prevSendVal != sendVal || isStepChanged) {
             SpiMCs = 0;
-            receivedVal = SpiM.write(sendVal);
+            uint8_t receivedVal = SpiM.write(sendVal);
             SpiMCs = 1;
             
             prevSendVal = sendVal;
-        //}
-        
-        if (isStepChanged) {
-            Leds.write(receivedVal & 0x0f);
-            isStepChanged = false;
+            
+            if (isStepChanged) {
+                Leds.write(receivedVal & 0x0f);
+                isStepChanged = false;
+            }
         }
     }
 }