割り込みテスト用

Dependencies:   HCSR04_2 MPU6050_2 mbed SDFileSystem3

Fork of Autoflight2018_27 by 航空研究会

Files at this revision

API Documentation at this revision

Comitter:
taknokolat
Date:
Thu Sep 20 04:20:19 2018 +0000
Parent:
22:438bedf24707
Commit message:
a

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Sep 19 06:37:31 2018 +0000
+++ b/main.cpp	Thu Sep 20 04:20:19 2018 +0000
@@ -18,7 +18,7 @@
 #include "pid.h"
 
 #define DEBUG_SEMIAUTO 0
-#define DEBUG_PRINT_INLOOP 1
+#define DEBUG_PRINT_INLOOP 0
 
 #define KP_ELE 15.0  //2.0
 #define KI_ELE 0.0
@@ -334,8 +334,8 @@
     
     NVIC_SetPriority(USART1_IRQn,0);
     NVIC_SetPriority(EXTI0_IRQn,1);
-    NVIC_SetPriority(TIM5_IRQn,2);
-    NVIC_SetPriority(EXTI9_5_IRQn,3);
+    NVIC_SetPriority(TIM5_IRQn,3);
+    NVIC_SetPriority(EXTI9_5_IRQn,4);
     DisplayClock();
     t.start();
     
@@ -354,7 +354,7 @@
     }
     
      pc.attach(getSF_Serial, Serial::RxIrq);
-     NVIC_SetPriority(USART2_IRQn,4);
+     NVIC_SetPriority(USART2_IRQn,2);
     
     FirstROLL = nowAngle[ROLL];
     FirstPITCH = nowAngle[PITCH];
@@ -373,18 +373,26 @@
 
 void loop(){
     static float targetAngle[3] = {0.0, 0.0, 0.0}, controlValue[2] = {0.0, 0.0};
-
+    pc.printf("0\r\n");
     SensingMPU();
+    pc.printf("1\r\n");
     NVIC_DisableIRQ(USART2_IRQn);
     UpdateTargetAngle(targetAngle);
+    pc.printf("2\r\n ");
     //Rotate(targetAngle, 30.0);
     CalculateControlValue(targetAngle, controlValue);
+    pc.printf("3\r\n");
     NVIC_DisableIRQ(USART1_IRQn);
     UpdateAutoPWM(controlValue);
+    pc.printf("4\r\n");
     NVIC_EnableIRQ(USART1_IRQn);
     NVIC_EnableIRQ(USART2_IRQn);
+    pc.printf("5\r\n");
     wait_ms(23);
-    pc.printf("%c",g_landingcommand);
+    pc.printf("6\r\n");
+    //NVIC_DisableIRQ(USART2_IRQn);
+    //pc.printf("%c",g_landingcommand);
+    //NVIC_EnableIRQ(USART2_IRQn);
 #if DEBUG_PRINT_INLOOP
     //Sbusprintf();
     DebugPrint();
@@ -1033,6 +1041,9 @@
 
 
 void getSF_Serial(){
+    NVIC_DisableIRQ(USART1_IRQn);
+    NVIC_DisableIRQ(EXTI0_IRQn);
+    NVIC_DisableIRQ(TIM5_IRQn);
     
         static char SFbuf[16];
         static int bufcounter=0;
@@ -1048,7 +1059,7 @@
             
         if(bufcounter==5 && SFbuf[4]=='F'){
             g_landingcommand = SFbuf[1];
-            wait_ms(20);
+            //wait_ms(20);
             if(g_landingcommand=='Y')g_SerialTargetYAW = ConvertByteintoFloat(SFbuf[2], SFbuf[3]);
             bufcounter = 0;
             memset(SFbuf, 0, strlen(SFbuf));
@@ -1058,7 +1069,9 @@
                 pc.printf("Communication Falsed.\r\n");
                 bufcounter = 0;
             }
-            
+            NVIC_EnableIRQ(TIM5_IRQn);
+            NVIC_EnableIRQ(EXTI0_IRQn);
+           NVIC_EnableIRQ(USART1_IRQn); 
     }
     
 float ConvertByteintoFloat(char high, char low){