SDの設定が反映されるように修正

Dependencies:   mbed MPU6050_2 HMC5883L_2 SDFileSystem3

Revision:
2:f30666d7838b
Parent:
1:290e621741fd
Child:
3:c18342e4fddd
diff -r 290e621741fd -r f30666d7838b main.cpp
--- a/main.cpp	Sat Dec 22 10:41:25 2018 +0000
+++ b/main.cpp	Mon Dec 24 07:47:22 2018 +0000
@@ -28,10 +28,10 @@
 PwmOut servoR(PC_6);
 PwmOut servoL(PC_7);
 
-RawSerial pc(PA_2,PA_3,115200);
-RawSerial pc2(PB_6,PB_7,115200);
+RawSerial pc(PA_2,PA_3,115200); //uart2
+RawSerial pc2(PB_6,PB_7,115200); //uart1
 
-char g_landingcommand='X';
+char g_landingcommand='N';
 
 void MoveCansat(char g_landingcommand);
 
@@ -52,52 +52,52 @@
 
 void MoveCansat(char g_landingcommand)
 {
-    NVIC_DisableIRQ(USART1_IRQn);
+    //NVIC_DisableIRQ(USART1_IRQn);
     NVIC_DisableIRQ(USART2_IRQn);
     switch(g_landingcommand){
-        case 'N': //MOVE_NEUTRAL
-            NVIC_EnableIRQ(USART1_IRQn);
-            NVIC_EnableIRQ(USART2_IRQn); 
+        case 'N': //MOVE_NEUTRAL 
             servoR.pulsewidth_us(servo_NEUTRAL_R);
             servoL.pulsewidth_us(servo_NEUTRAL_L);
+            //NVIC_EnableIRQ(USART1_IRQn);
+            NVIC_EnableIRQ(USART2_IRQn);
             break;
             
-        case 'F': //MOVE_FORWARD
-            NVIC_EnableIRQ(USART1_IRQn);
-            NVIC_EnableIRQ(USART2_IRQn); 
+        case 'Y': //MOVE_FORWARD
             servoR.pulsewidth_us(servo_FORWARD_R);
             servoL.pulsewidth_us(servo_FORWARD_L);
+            //NVIC_EnableIRQ(USART1_IRQn);
+            NVIC_EnableIRQ(USART2_IRQn); 
             break;
             
         case 'L': //MOVE_LEFT 
-            NVIC_EnableIRQ(USART1_IRQn);
-            NVIC_EnableIRQ(USART2_IRQn); 
             servoR.pulsewidth_us(servo_slow_FORWARD_R);
             servoL.pulsewidth_us(servo_slow_back_L);
+            //NVIC_EnableIRQ(USART1_IRQn);
+            NVIC_EnableIRQ(USART2_IRQn); 
             
-        case 'R': //MOVE_RIGHT 
-            NVIC_EnableIRQ(USART1_IRQn);
-            NVIC_EnableIRQ(USART2_IRQn); 
+        case 'R': //MOVE_RIGHT  
             servoR.pulsewidth_us(servo_slow_back_R);
             servoL.pulsewidth_us(servo_slow_FORWARD_L);
+            //NVIC_EnableIRQ(USART1_IRQn);
+            NVIC_EnableIRQ(USART2_IRQn); 
             break;
             
         case 'B': //MOVE_BACK 
-            NVIC_EnableIRQ(USART1_IRQn);
-            NVIC_EnableIRQ(USART2_IRQn); 
             servoR.pulsewidth_us(servo_back_R);
             servoL.pulsewidth_us(servo_back_L);
+            //NVIC_EnableIRQ(USART1_IRQn);
+            NVIC_EnableIRQ(USART2_IRQn); 
             break;
             
         case 'G': //GOAL_FORWARD
-            NVIC_EnableIRQ(USART1_IRQn);
-            NVIC_EnableIRQ(USART2_IRQn); 
             servoR.pulsewidth_us(servo_slow_FORWARD_R);
             servoL.pulsewidth_us(servo_slow_FORWARD_L);
+            //NVIC_EnableIRQ(USART1_IRQn);
+            NVIC_EnableIRQ(USART2_IRQn); 
             break;
             
         default :
-            NVIC_EnableIRQ(USART1_IRQn);
+            //NVIC_EnableIRQ(USART1_IRQn);
             NVIC_EnableIRQ(USART2_IRQn);  
             break;
      
@@ -131,6 +131,7 @@
         if(bufcounter==5 && SFbuf[4]=='F'){
                 
             g_landingcommand = SFbuf[1];
+            wait_ms(31);//信号が速すぎることによる割り込み防止
             //pc.printf("%c",g_landingcommand);
             //wait_ms(20);
             //if(g_landingcommand=='Y')g_SerialTargetYAW = ConvertByteintoFloat(SFbuf[2], SFbuf[3]);
@@ -153,7 +154,8 @@
 
 
 void getSF_Serial_pi(){
-
+    
+    NVIC_DisableIRQ(USART2_IRQn);
 
     static char SFbuf[16]={'Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q','Q'};
     
@@ -178,6 +180,7 @@
         if(bufcounter==5 && SFbuf[4]=='F'){
                 
             g_landingcommand = SFbuf[1];
+            wait_ms(31);//信号が速すぎることによる割り込み防止
             //pc.printf("%c",g_landingcommand);
             //wait_ms(20);
             //if(g_landingcommand=='Y')g_SerialTargetYAW = ConvertByteintoFloat(SFbuf[2], SFbuf[3]);
@@ -194,6 +197,8 @@
             NVIC_ClearPendingIRQ(USART2_IRQn);
         }
     }
+    
+    NVIC_EnableIRQ(USART2_IRQn);
                     
 
 }