First Commit

Dependencies:   mbed Crypto_light mbed-rtos

Spin it 2 win it

Revision:
19:526fd700e1b3
Parent:
18:05e5d280a082
Child:
20:a435105305fe
--- a/main.cpp	Tue Mar 20 15:00:09 2018 +0000
+++ b/main.cpp	Tue Mar 20 15:10:08 2018 +0000
@@ -123,7 +123,11 @@
 }
 
 
-
+void photointerrupter_isr()
+{
+    int8_t intState = readRotorState();
+    motorOut((intState-orState+lead+6)%6, torque); //+6 to make sure the remainder is positive
+}
 
 Thread decodeT;
 
@@ -152,6 +156,7 @@
             putMessage(MSG_NEW_KEY, newKey);
         } else if (sscanf(s, "T%u", &torque_)) {
             torque = torque_;
+            photointerrupter_isr(); //Give it a kick
             putMessage(MSG_TORQUE, torque);
         //ERROR
         } else
@@ -238,11 +243,6 @@
     return readRotorState();
 }
 
-void photointerrupter_isr()
-{
-    int8_t intState = readRotorState();
-    motorOut((intState-orState+lead+6)%6, torque); //+6 to make sure the remainder is positive
-}
 
 
 //Main
@@ -277,8 +277,8 @@
 
     //Calling the ISR once starts the motor movement
     photointerrupter_isr();
-    
-    
+
+
 
     SHA256 sha256;
 
@@ -315,7 +315,3 @@
         hashcount++;
     }
 }
-
-
-// K12345678\r
-// K12345678