割り込み付きjevois実装版

Dependencies:   mbed mbed

Fork of Scarlet_relay_V2 by 航空研究会

Files at this revision

API Documentation at this revision

Comitter:
taknokolat
Date:
Sat Sep 22 08:56:53 2018 +0000
Parent:
3:92c039aed84a
Commit message:
a

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 92c039aed84a -r c08f2e993acc main.cpp
--- a/main.cpp	Sat Sep 22 06:55:34 2018 +0000
+++ b/main.cpp	Sat Sep 22 08:56:53 2018 +0000
@@ -2,18 +2,18 @@
 //#include "Serial.h"
 
 RawSerial pc(PA_2,PA_3,115200);
-//RawSerial pc(PB_6,PB_7,115200);
+RawSerial pc2(PB_6,PB_7,115200);
 //Serial MySerial1(PA_2,PA_3);
 
 
- char g_landingcommand;
+
 
  
 void ISR_Serial_Rx()
 {
        static char SFbuf[16];
         static int bufcounter=0;
-        
+        char g_landingcommand;
         
             SFbuf[bufcounter] = pc.getc();    
         
@@ -40,18 +40,54 @@
            
 }
 
+
+void ISR_Serial_Rx_jevois()
+{
+       NVIC_DisableIRQ(USART2_IRQn);
+       static char SFbuf2[16];
+       static int bufcounter2=0;
+       char g_landingcommand2; 
+        
+            SFbuf2[bufcounter2] = pc2.getc();    
+        
+        
+        
+        if(SFbuf2[0]=='S'&&bufcounter2<5) bufcounter2++;
+            
+        if(bufcounter2==5 && SFbuf2[4]=='F'){
+            g_landingcommand2 = SFbuf2[1];
+            pc.printf("S");
+            pc.printf("%c",g_landingcommand2);
+            pc.printf("A");
+            pc.printf("A");
+            pc.printf("F");
+            wait_ms(31);
+            bufcounter2 = 0;
+            memset(SFbuf2, 0, strlen(SFbuf2));
+         }
+            else if(bufcounter2>=5 ){
+                //pc.printf("Communication Falsed.\r\n");
+                bufcounter2 = 0;
+                memset(SFbuf2, 0, strlen(SFbuf2));
+            } 
+            NVIC_EnableIRQ(USART2_IRQn);
+           
+}
  
 int main()
 {
      
     // シリアル通信受信の割り込みイベント登録
     pc.attach(ISR_Serial_Rx, Serial::RxIrq);
+    pc2.attach(ISR_Serial_Rx_jevois, Serial::RxIrq);
+    
+    NVIC_SetPriority(USART1_IRQn,0);
+    NVIC_SetPriority(USART2_IRQn,1);
  
     while (1) { 
-        // メイン処理
-        //NVIC_DisableIRQ(USART2_IRQn);
-        //usbSerial.printf("TUAT\r\n");
-        //NVIC_EnableIRQ(USART2_IRQn);
+        NVIC_SetPriority(USART1_IRQn,0);
+        NVIC_SetPriority(USART2_IRQn,1);
+       
        // wait(1.0);
  
         }