航空研究会
/
Scarlet_relay_V4
割り込み付きjevois実装版
Fork of Scarlet_relay_V2 by
Diff: main.cpp
- Revision:
- 3:92c039aed84a
- Parent:
- 2:f975d9cb584d
- Child:
- 4:c08f2e993acc
--- a/main.cpp Tue Sep 18 02:20:23 2018 +0000 +++ b/main.cpp Sat Sep 22 06:55:34 2018 +0000 @@ -1,36 +1,49 @@ #include "mbed.h" //#include "Serial.h" -RawSerial pc(PA_2,PA_3,57600); -//RawSerial uart1(PB_6,PB_7,57600); +RawSerial pc(PA_2,PA_3,115200); +//RawSerial pc(PB_6,PB_7,115200); //Serial MySerial1(PA_2,PA_3); - + char g_landingcommand; void ISR_Serial_Rx() { - - - // シリアルの受信処理 - - char data=pc.getc(); - - + static char SFbuf[16]; + static int bufcounter=0; + + + SFbuf[bufcounter] = pc.getc(); + + + + if(SFbuf[0]=='S'&&bufcounter<5) bufcounter++; + + if(bufcounter==5 && SFbuf[4]=='F'){ + g_landingcommand = SFbuf[1]; + pc.printf("S"); + pc.printf("%c",g_landingcommand); + pc.printf("A"); + pc.printf("A"); + pc.printf("F"); + wait_ms(31); + bufcounter = 0; + memset(SFbuf, 0, strlen(SFbuf)); + } + else if(bufcounter>=5 ){ + //pc.printf("Communication Falsed.\r\n"); + bufcounter = 0; + memset(SFbuf, 0, strlen(SFbuf)); + } + +} - - // メイン処理 - pc.printf("%c",data); - - - - -} int main() { - + // シリアル通信受信の割り込みイベント登録 pc.attach(ISR_Serial_Rx, Serial::RxIrq);