割り込み付きjevois実装版

Dependencies:   mbed mbed

Fork of Scarlet_relay_V2 by 航空研究会

Committer:
TUATBM
Date:
Tue Aug 28 09:31:55 2018 +0000
Revision:
0:1f2bac0f6ab8
Child:
1:e257c3c3f659
s

Who changed what in which revision?

UserRevisionLine numberNew 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 0:1f2bac0f6ab8 5 /*
TUATBM 0:1f2bac0f6ab8 6 Serial usbSerial(PA_9, PA_10);
TUATBM 0:1f2bac0f6ab8 7
TUATBM 0:1f2bac0f6ab8 8 void ISR_Serial_Rx()
TUATBM 0:1f2bac0f6ab8 9 {
TUATBM 0:1f2bac0f6ab8 10 // シリアルの受信処理
TUATBM 0:1f2bac0f6ab8 11 char data = usbSerial.getc();
TUATBM 0:1f2bac0f6ab8 12 }
TUATBM 0:1f2bac0f6ab8 13
TUATBM 0:1f2bac0f6ab8 14 void ISR_Serial_Tx()
TUATBM 0:1f2bac0f6ab8 15 {
TUATBM 0:1f2bac0f6ab8 16 // シリアルのs送信処理
TUATBM 0:1f2bac0f6ab8 17 usbSerial.attach(NULL, Serial::TxIrq);
TUATBM 0:1f2bac0f6ab8 18 }
TUATBM 0:1f2bac0f6ab8 19
TUATBM 0:1f2bac0f6ab8 20 int main()
TUATBM 0:1f2bac0f6ab8 21 {
TUATBM 0:1f2bac0f6ab8 22 // シリアル通信の速度設定
TUATBM 0:1f2bac0f6ab8 23 usbSerial.baud(9600);
TUATBM 0:1f2bac0f6ab8 24
TUATBM 0:1f2bac0f6ab8 25 // シリアル通信受信の割り込みイベント登録
TUATBM 0:1f2bac0f6ab8 26 usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
TUATBM 0:1f2bac0f6ab8 27
TUATBM 0:1f2bac0f6ab8 28 // シリアル通信のデータ送信
TUATBM 0:1f2bac0f6ab8 29 usbSerial.attach(ISR_Serial_Tx, Serial::TxIrq);
TUATBM 0:1f2bac0f6ab8 30
TUATBM 0:1f2bac0f6ab8 31
TUATBM 0:1f2bac0f6ab8 32
TUATBM 0:1f2bac0f6ab8 33 while (1) {
TUATBM 0:1f2bac0f6ab8 34 // メイン処理
TUATBM 0:1f2bac0f6ab8 35 usbSerial.putc('2');
TUATBM 0:1f2bac0f6ab8 36 wait(3.0);
TUATBM 0:1f2bac0f6ab8 37 printf("a\r\n");
TUATBM 0:1f2bac0f6ab8 38 }
TUATBM 0:1f2bac0f6ab8 39 }
TUATBM 0:1f2bac0f6ab8 40 */
TUATBM 0:1f2bac0f6ab8 41
TUATBM 0:1f2bac0f6ab8 42
TUATBM 0:1f2bac0f6ab8 43 /*受信*/
TUATBM 0:1f2bac0f6ab8 44
TUATBM 0:1f2bac0f6ab8 45 Serial usbSerial(PA_9,PA_10);
TUATBM 0:1f2bac0f6ab8 46 Serial MySerial1(USBTX,USBRX);
TUATBM 0:1f2bac0f6ab8 47
TUATBM 0:1f2bac0f6ab8 48 void ISR_Serial_Rx()
TUATBM 0:1f2bac0f6ab8 49 {
TUATBM 0:1f2bac0f6ab8 50 // シリアルの受信処理
TUATBM 0:1f2bac0f6ab8 51 char data = usbSerial.getc();
TUATBM 0:1f2bac0f6ab8 52
TUATBM 0:1f2bac0f6ab8 53 printf("%c",data);
TUATBM 0:1f2bac0f6ab8 54 printf("Hello world!\r\n");
TUATBM 0:1f2bac0f6ab8 55
TUATBM 0:1f2bac0f6ab8 56
TUATBM 0:1f2bac0f6ab8 57 }
TUATBM 0:1f2bac0f6ab8 58
TUATBM 0:1f2bac0f6ab8 59 int main()
TUATBM 0:1f2bac0f6ab8 60 {
TUATBM 0:1f2bac0f6ab8 61 // シリアル通信の速度設定
TUATBM 0:1f2bac0f6ab8 62 usbSerial.baud(9600);
TUATBM 0:1f2bac0f6ab8 63
TUATBM 0:1f2bac0f6ab8 64 // シリアル通信受信の割り込みイベント登録
TUATBM 0:1f2bac0f6ab8 65 usbSerial.attach(ISR_Serial_Rx, Serial::RxIrq);
TUATBM 0:1f2bac0f6ab8 66
TUATBM 0:1f2bac0f6ab8 67 while (1) {
TUATBM 0:1f2bac0f6ab8 68 // メイン処理
TUATBM 0:1f2bac0f6ab8 69 printf("NOKOLAT\r\n");
TUATBM 0:1f2bac0f6ab8 70 wait(1.0);
TUATBM 0:1f2bac0f6ab8 71
TUATBM 0:1f2bac0f6ab8 72 }
TUATBM 0:1f2bac0f6ab8 73
TUATBM 0:1f2bac0f6ab8 74 }