航空研究会
/
Scarlet_relay_V4
割り込み付きjevois実装版
Fork of Scarlet_relay_V2 by
main.cpp@1:e257c3c3f659, 2018-09-10 (annotated)
- Committer:
- TUATBM
- Date:
- Mon Sep 10 02:57:01 2018 +0000
- Revision:
- 1:e257c3c3f659
- Parent:
- 0:1f2bac0f6ab8
- Child:
- 2:f975d9cb584d
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TUATBM | 0:1f2bac0f6ab8 | 1 | #include "mbed.h" |
TUATBM | 0:1f2bac0f6ab8 | 2 | #include "Serial.h" |
TUATBM | 0:1f2bac0f6ab8 | 3 | |
TUATBM | 0:1f2bac0f6ab8 | 4 | /*送信*/ |
TUATBM | 1:e257c3c3f659 | 5 | |
TUATBM | 1:e257c3c3f659 | 6 | |
TUATBM | 1:e257c3c3f659 | 7 | Serial usbSerial(PA_9, PA_10,115200); |
TUATBM | 1:e257c3c3f659 | 8 | Serial g_Serial1(USBTX,USBRX,115200); |
TUATBM | 0:1f2bac0f6ab8 | 9 | |
TUATBM | 1:e257c3c3f659 | 10 | //void ISR_Serial_Rx() |
TUATBM | 1:e257c3c3f659 | 11 | //{ |
TUATBM | 0:1f2bac0f6ab8 | 12 | // シリアルの受信処理 |
TUATBM | 1:e257c3c3f659 | 13 | // char data = usbSerial.getc(); |
TUATBM | 1:e257c3c3f659 | 14 | //} |
TUATBM | 0:1f2bac0f6ab8 | 15 | |
TUATBM | 1:e257c3c3f659 | 16 | //void ISR_Serial_Tx() |
TUATBM | 1:e257c3c3f659 | 17 | //{ |
TUATBM | 0:1f2bac0f6ab8 | 18 | // シリアルのs送信処理 |
TUATBM | 1:e257c3c3f659 | 19 | // usbSerial.attach(NULL, Serial::TxIrq); |
TUATBM | 1:e257c3c3f659 | 20 | //} |
TUATBM | 0:1f2bac0f6ab8 | 21 | |
TUATBM | 0:1f2bac0f6ab8 | 22 | int main() |
TUATBM | 0:1f2bac0f6ab8 | 23 | { |
TUATBM | 0:1f2bac0f6ab8 | 24 | // シリアル通信の速度設定 |
TUATBM | 1:e257c3c3f659 | 25 | usbSerial.baud(115200); |
TUATBM | 0:1f2bac0f6ab8 | 26 | |
TUATBM | 0:1f2bac0f6ab8 | 27 | // シリアル通信受信の割り込みイベント登録 |
TUATBM | 1:e257c3c3f659 | 28 | // usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq); |
TUATBM | 0:1f2bac0f6ab8 | 29 | |
TUATBM | 0:1f2bac0f6ab8 | 30 | // シリアル通信のデータ送信 |
TUATBM | 1:e257c3c3f659 | 31 | // usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq); |
TUATBM | 0:1f2bac0f6ab8 | 32 | |
TUATBM | 0:1f2bac0f6ab8 | 33 | |
TUATBM | 0:1f2bac0f6ab8 | 34 | |
TUATBM | 0:1f2bac0f6ab8 | 35 | while (1) { |
TUATBM | 0:1f2bac0f6ab8 | 36 | // メイン処理 |
TUATBM | 1:e257c3c3f659 | 37 | wait(10.0); |
TUATBM | 1:e257c3c3f659 | 38 | g_Serial1.printf("a\r\n"); |
TUATBM | 1:e257c3c3f659 | 39 | usbSerial.putc('C'); |
TUATBM | 1:e257c3c3f659 | 40 | wait(20.0); |
TUATBM | 1:e257c3c3f659 | 41 | |
TUATBM | 1:e257c3c3f659 | 42 | |
TUATBM | 0:1f2bac0f6ab8 | 43 | } |
TUATBM | 0:1f2bac0f6ab8 | 44 | } |
TUATBM | 1:e257c3c3f659 | 45 | |
TUATBM | 0:1f2bac0f6ab8 | 46 | |
TUATBM | 0:1f2bac0f6ab8 | 47 | |
TUATBM | 0:1f2bac0f6ab8 | 48 | /*受信*/ |
TUATBM | 1:e257c3c3f659 | 49 | /* |
TUATBM | 1:e257c3c3f659 | 50 | Serial usbSerial(PA_2,PA_3); |
TUATBM | 1:e257c3c3f659 | 51 | Serial usbSerial2(PB_6,PB_7); |
TUATBM | 1:e257c3c3f659 | 52 | //Serial MySerial1(PA_2,PA_3); |
TUATBM | 0:1f2bac0f6ab8 | 53 | |
TUATBM | 1:e257c3c3f659 | 54 | |
TUATBM | 1:e257c3c3f659 | 55 | |
TUATBM | 1:e257c3c3f659 | 56 | |
TUATBM | 0:1f2bac0f6ab8 | 57 | |
TUATBM | 0:1f2bac0f6ab8 | 58 | void ISR_Serial_Rx() |
TUATBM | 0:1f2bac0f6ab8 | 59 | { |
TUATBM | 1:e257c3c3f659 | 60 | |
TUATBM | 1:e257c3c3f659 | 61 | |
TUATBM | 0:1f2bac0f6ab8 | 62 | // シリアルの受信処理 |
TUATBM | 1:e257c3c3f659 | 63 | |
TUATBM | 0:1f2bac0f6ab8 | 64 | char data = usbSerial.getc(); |
TUATBM | 0:1f2bac0f6ab8 | 65 | |
TUATBM | 1:e257c3c3f659 | 66 | |
TUATBM | 1:e257c3c3f659 | 67 | usbSerial.printf("%c\r\n",data); |
TUATBM | 1:e257c3c3f659 | 68 | //printf("Hello world!\r\n"); |
TUATBM | 1:e257c3c3f659 | 69 | |
TUATBM | 1:e257c3c3f659 | 70 | |
TUATBM | 1:e257c3c3f659 | 71 | |
TUATBM | 1:e257c3c3f659 | 72 | // シリアル通信受信の割り込みイベント登録 |
TUATBM | 1:e257c3c3f659 | 73 | //usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq); |
TUATBM | 1:e257c3c3f659 | 74 | |
TUATBM | 1:e257c3c3f659 | 75 | // シリアル通信のデータ送信 |
TUATBM | 1:e257c3c3f659 | 76 | //usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq); |
TUATBM | 1:e257c3c3f659 | 77 | |
TUATBM | 1:e257c3c3f659 | 78 | |
TUATBM | 1:e257c3c3f659 | 79 | |
TUATBM | 1:e257c3c3f659 | 80 | // メイン処理 |
TUATBM | 1:e257c3c3f659 | 81 | usbSerial.putc('3'); |
TUATBM | 1:e257c3c3f659 | 82 | |
TUATBM | 1:e257c3c3f659 | 83 | |
TUATBM | 0:1f2bac0f6ab8 | 84 | |
TUATBM | 0:1f2bac0f6ab8 | 85 | |
TUATBM | 0:1f2bac0f6ab8 | 86 | } |
TUATBM | 0:1f2bac0f6ab8 | 87 | |
TUATBM | 0:1f2bac0f6ab8 | 88 | int main() |
TUATBM | 0:1f2bac0f6ab8 | 89 | { |
TUATBM | 0:1f2bac0f6ab8 | 90 | // シリアル通信の速度設定 |
TUATBM | 1:e257c3c3f659 | 91 | usbSerial.baud(115200); |
TUATBM | 1:e257c3c3f659 | 92 | usbSerial2.baud(115200); |
TUATBM | 0:1f2bac0f6ab8 | 93 | |
TUATBM | 0:1f2bac0f6ab8 | 94 | // シリアル通信受信の割り込みイベント登録 |
TUATBM | 0:1f2bac0f6ab8 | 95 | usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq); |
TUATBM | 0:1f2bac0f6ab8 | 96 | |
TUATBM | 0:1f2bac0f6ab8 | 97 | while (1) { |
TUATBM | 0:1f2bac0f6ab8 | 98 | // メイン処理 |
TUATBM | 1:e257c3c3f659 | 99 | NVIC_DisableIRQ(USART2_IRQn); |
TUATBM | 1:e257c3c3f659 | 100 | usbSerial.printf("TUAT\r\n"); |
TUATBM | 1:e257c3c3f659 | 101 | NVIC_EnableIRQ(USART2_IRQn); |
TUATBM | 0:1f2bac0f6ab8 | 102 | wait(1.0); |
TUATBM | 0:1f2bac0f6ab8 | 103 | |
TUATBM | 0:1f2bac0f6ab8 | 104 | } |
TUATBM | 0:1f2bac0f6ab8 | 105 | |
TUATBM | 0:1f2bac0f6ab8 | 106 | } |
TUATBM | 1:e257c3c3f659 | 107 | */ |