航空研究会
/
Scarlet_relay_V4
割り込み付きjevois実装版
Fork of Scarlet_relay_V2 by
main.cpp
- Committer:
- taknokolat
- Date:
- 2018-09-22
- Revision:
- 3:92c039aed84a
- Parent:
- 2:f975d9cb584d
- Child:
- 4:c08f2e993acc
File content as of revision 3:92c039aed84a:
#include "mbed.h" //#include "Serial.h" 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() { 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)); } } int main() { // シリアル通信受信の割り込みイベント登録 pc.attach(ISR_Serial_Rx, Serial::RxIrq); while (1) { // メイン処理 //NVIC_DisableIRQ(USART2_IRQn); //usbSerial.printf("TUAT\r\n"); //NVIC_EnableIRQ(USART2_IRQn); // wait(1.0); } }