航空研究会
/
Scarlet_relay_V5
同時通信確認版
Fork of Scarlet_relay_V4 by
main.cpp@3:92c039aed84a, 2018-09-22 (annotated)
- Committer:
- taknokolat
- Date:
- Sat Sep 22 06:55:34 2018 +0000
- Revision:
- 3:92c039aed84a
- Parent:
- 2:f975d9cb584d
- Child:
- 4:c08f2e993acc
a;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TUATBM | 0:1f2bac0f6ab8 | 1 | #include "mbed.h" |
taknokolat | 2:f975d9cb584d | 2 | //#include "Serial.h" |
TUATBM | 1:e257c3c3f659 | 3 | |
taknokolat | 3:92c039aed84a | 4 | RawSerial pc(PA_2,PA_3,115200); |
taknokolat | 3:92c039aed84a | 5 | //RawSerial pc(PB_6,PB_7,115200); |
TUATBM | 1:e257c3c3f659 | 6 | //Serial MySerial1(PA_2,PA_3); |
TUATBM | 0:1f2bac0f6ab8 | 7 | |
TUATBM | 1:e257c3c3f659 | 8 | |
taknokolat | 3:92c039aed84a | 9 | char g_landingcommand; |
TUATBM | 1:e257c3c3f659 | 10 | |
TUATBM | 0:1f2bac0f6ab8 | 11 | |
TUATBM | 0:1f2bac0f6ab8 | 12 | void ISR_Serial_Rx() |
TUATBM | 0:1f2bac0f6ab8 | 13 | { |
taknokolat | 3:92c039aed84a | 14 | static char SFbuf[16]; |
taknokolat | 3:92c039aed84a | 15 | static int bufcounter=0; |
taknokolat | 3:92c039aed84a | 16 | |
taknokolat | 3:92c039aed84a | 17 | |
taknokolat | 3:92c039aed84a | 18 | SFbuf[bufcounter] = pc.getc(); |
taknokolat | 3:92c039aed84a | 19 | |
taknokolat | 3:92c039aed84a | 20 | |
taknokolat | 3:92c039aed84a | 21 | |
taknokolat | 3:92c039aed84a | 22 | if(SFbuf[0]=='S'&&bufcounter<5) bufcounter++; |
taknokolat | 3:92c039aed84a | 23 | |
taknokolat | 3:92c039aed84a | 24 | if(bufcounter==5 && SFbuf[4]=='F'){ |
taknokolat | 3:92c039aed84a | 25 | g_landingcommand = SFbuf[1]; |
taknokolat | 3:92c039aed84a | 26 | pc.printf("S"); |
taknokolat | 3:92c039aed84a | 27 | pc.printf("%c",g_landingcommand); |
taknokolat | 3:92c039aed84a | 28 | pc.printf("A"); |
taknokolat | 3:92c039aed84a | 29 | pc.printf("A"); |
taknokolat | 3:92c039aed84a | 30 | pc.printf("F"); |
taknokolat | 3:92c039aed84a | 31 | wait_ms(31); |
taknokolat | 3:92c039aed84a | 32 | bufcounter = 0; |
taknokolat | 3:92c039aed84a | 33 | memset(SFbuf, 0, strlen(SFbuf)); |
taknokolat | 3:92c039aed84a | 34 | } |
taknokolat | 3:92c039aed84a | 35 | else if(bufcounter>=5 ){ |
taknokolat | 3:92c039aed84a | 36 | //pc.printf("Communication Falsed.\r\n"); |
taknokolat | 3:92c039aed84a | 37 | bufcounter = 0; |
taknokolat | 3:92c039aed84a | 38 | memset(SFbuf, 0, strlen(SFbuf)); |
taknokolat | 3:92c039aed84a | 39 | } |
taknokolat | 3:92c039aed84a | 40 | |
taknokolat | 3:92c039aed84a | 41 | } |
TUATBM | 1:e257c3c3f659 | 42 | |
TUATBM | 0:1f2bac0f6ab8 | 43 | |
TUATBM | 0:1f2bac0f6ab8 | 44 | int main() |
TUATBM | 0:1f2bac0f6ab8 | 45 | { |
taknokolat | 3:92c039aed84a | 46 | |
TUATBM | 0:1f2bac0f6ab8 | 47 | // シリアル通信受信の割り込みイベント登録 |
taknokolat | 2:f975d9cb584d | 48 | pc.attach(ISR_Serial_Rx, Serial::RxIrq); |
TUATBM | 0:1f2bac0f6ab8 | 49 | |
TUATBM | 0:1f2bac0f6ab8 | 50 | while (1) { |
TUATBM | 0:1f2bac0f6ab8 | 51 | // メイン処理 |
taknokolat | 2:f975d9cb584d | 52 | //NVIC_DisableIRQ(USART2_IRQn); |
taknokolat | 2:f975d9cb584d | 53 | //usbSerial.printf("TUAT\r\n"); |
taknokolat | 2:f975d9cb584d | 54 | //NVIC_EnableIRQ(USART2_IRQn); |
taknokolat | 2:f975d9cb584d | 55 | // wait(1.0); |
TUATBM | 0:1f2bac0f6ab8 | 56 | |
TUATBM | 0:1f2bac0f6ab8 | 57 | } |
TUATBM | 0:1f2bac0f6ab8 | 58 | |
TUATBM | 0:1f2bac0f6ab8 | 59 | } |