GifuRobo B term

Dependencies:   FastPWM cal_PID mbed omuni

Fork of omuni_speed_pid by shinji sawai

Revision:
8:956a76b98da0
Parent:
7:5cdd805ca8a3
Child:
9:bf6d20813364
diff -r 5cdd805ca8a3 -r 956a76b98da0 main.cpp
--- a/main.cpp	Tue Sep 19 02:39:07 2017 +0000
+++ b/main.cpp	Tue Sep 19 03:19:28 2017 +0000
@@ -44,6 +44,7 @@
 bool comTimeout_state = true;
 
 bool ems = false;
+bool recovery = false;
 
 bool arm = false;
 bool spear = false;
@@ -114,6 +115,9 @@
 
 comBuf_t comBuf;
 
+void reset(){
+    NVIC_SystemReset();
+}
 
 int grayDiffer2bit(int gray, int origin){
     
@@ -198,7 +202,12 @@
     
     int lift_nearest_num = 0;
     
-    ems = buf->EMO != 0;
+    if(buf->EMO != 0){
+        ems = true;
+    }
+    else if(ems == true){
+        reset();
+    }
     
     speed_x = omuni_speed_max * getJoy7bit(buf->joyLX) / 64.0f;
     speed_y = omuni_speed_max * getJoy7bit(buf->joyLY) / 64.0f;
@@ -322,10 +331,8 @@
     else{
         soundEnd = true;
     }
-    
 }
 
-
 void comTimeout_intr(){
     
     if(comTimeout_count >= comTimeout_ms){
@@ -559,6 +566,7 @@
     drive_motor(EMO_Addr, 0);
     
     while(1);
+    
 }